@hbmodsofc/baileys 1.5.2 → 1.7.6

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 (156) hide show
  1. package/LICENSE +1 -1
  2. package/WAProto/index.js +19671 -152026
  3. package/engine-requirements.js +4 -4
  4. package/lib/Defaults/index.d.ts +12 -8
  5. package/lib/Defaults/index.js +90 -124
  6. package/lib/Signal/Group/group_cipher.d.ts +0 -1
  7. package/lib/Signal/Group/group_cipher.js +28 -39
  8. package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
  9. package/lib/Signal/Group/sender-chain-key.js +9 -2
  10. package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
  11. package/lib/Signal/Group/sender-key-message.js +3 -3
  12. package/lib/Signal/Group/sender-key-state.d.ts +4 -4
  13. package/lib/Signal/Group/sender-key-state.js +47 -16
  14. package/lib/Signal/libsignal.d.ts +7 -3
  15. package/lib/Signal/libsignal.js +224 -39
  16. package/lib/Signal/lid-mapping.d.ts +26 -0
  17. package/lib/Signal/lid-mapping.js +146 -0
  18. package/lib/Socket/Client/index.d.ts +2 -3
  19. package/lib/Socket/Client/index.js +2 -3
  20. package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
  21. package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
  22. package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
  23. package/lib/Socket/business.d.ts +94 -78
  24. package/lib/Socket/business.js +130 -11
  25. package/lib/Socket/chats.d.ts +63 -233
  26. package/lib/Socket/chats.js +234 -184
  27. package/lib/Socket/communities.d.ts +232 -0
  28. package/lib/Socket/communities.js +402 -0
  29. package/lib/Socket/groups.d.ts +62 -41
  30. package/lib/Socket/groups.js +76 -64
  31. package/lib/Socket/index.d.ts +129 -83
  32. package/lib/Socket/index.js +13 -6
  33. package/lib/Socket/messages-recv.d.ts +59 -48
  34. package/lib/Socket/messages-recv.js +516 -371
  35. package/lib/Socket/messages-send.d.ts +86 -67
  36. package/lib/Socket/messages-send.js +1091 -1
  37. package/lib/Socket/mex.d.ts +2 -0
  38. package/lib/Socket/mex.js +45 -0
  39. package/lib/Socket/newsletter.d.ts +76 -64
  40. package/lib/Socket/newsletter.js +184 -1
  41. package/lib/Socket/socket.d.ts +19 -13
  42. package/lib/Socket/socket.js +805 -1
  43. package/lib/Types/Auth.d.ts +4 -10
  44. package/lib/Types/Bussines.d.ts +24 -0
  45. package/lib/Types/Bussines.js +2 -0
  46. package/lib/Types/Call.d.ts +1 -1
  47. package/lib/Types/Chat.d.ts +29 -9
  48. package/lib/Types/Chat.js +7 -1
  49. package/lib/Types/Contact.d.ts +5 -1
  50. package/lib/Types/Events.d.ts +55 -14
  51. package/lib/Types/GroupMetadata.d.ts +15 -5
  52. package/lib/Types/Label.d.ts +11 -0
  53. package/lib/Types/Label.js +1 -1
  54. package/lib/Types/LabelAssociation.js +1 -1
  55. package/lib/Types/Message.d.ts +75 -49
  56. package/lib/Types/Message.js +10 -7
  57. package/lib/Types/Newsletter.d.ts +129 -98
  58. package/lib/Types/Newsletter.js +33 -38
  59. package/lib/Types/Product.d.ts +1 -1
  60. package/lib/Types/Signal.d.ts +29 -1
  61. package/lib/Types/Socket.d.ts +48 -22
  62. package/lib/Types/State.d.ts +13 -2
  63. package/lib/Types/State.js +12 -0
  64. package/lib/Types/USync.d.ts +1 -1
  65. package/lib/Types/index.d.ts +10 -3
  66. package/lib/Types/index.js +2 -2
  67. package/lib/Utils/auth-utils.d.ts +3 -3
  68. package/lib/Utils/auth-utils.js +378 -102
  69. package/lib/Utils/baileys-event-stream.js +1 -1
  70. package/lib/Utils/business.d.ts +2 -2
  71. package/lib/Utils/business.js +19 -13
  72. package/lib/Utils/chat-utils.d.ts +21 -22
  73. package/lib/Utils/chat-utils.js +201 -154
  74. package/lib/Utils/crypto.d.ts +18 -19
  75. package/lib/Utils/crypto.js +78 -37
  76. package/lib/Utils/decode-wa-message.d.ts +34 -7
  77. package/lib/Utils/decode-wa-message.js +138 -66
  78. package/lib/Utils/event-buffer.d.ts +6 -8
  79. package/lib/Utils/event-buffer.js +81 -43
  80. package/lib/Utils/generics.d.ts +27 -27
  81. package/lib/Utils/generics.js +128 -133
  82. package/lib/Utils/history.d.ts +9 -5
  83. package/lib/Utils/history.js +17 -23
  84. package/lib/Utils/index.d.ts +2 -0
  85. package/lib/Utils/index.js +2 -0
  86. package/lib/Utils/lidToJid-test.d.ts +11 -0
  87. package/lib/Utils/lidToJid-test.js +27 -0
  88. package/lib/Utils/link-preview.d.ts +4 -4
  89. package/lib/Utils/link-preview.js +40 -12
  90. package/lib/Utils/logger.d.ts +11 -3
  91. package/lib/Utils/lt-hash.d.ts +8 -8
  92. package/lib/Utils/lt-hash.js +23 -24
  93. package/lib/Utils/make-mutex.d.ts +2 -2
  94. package/lib/Utils/make-mutex.js +3 -2
  95. package/lib/Utils/message-retry-manager.d.ts +81 -0
  96. package/lib/Utils/message-retry-manager.js +152 -0
  97. package/lib/Utils/messages-media.d.ts +37 -41
  98. package/lib/Utils/messages-media.js +252 -368
  99. package/lib/Utils/messages.d.ts +13 -15
  100. package/lib/Utils/messages.js +274 -261
  101. package/lib/Utils/noise-handler.d.ts +13 -15
  102. package/lib/Utils/noise-handler.js +20 -26
  103. package/lib/Utils/process-message.d.ts +9 -8
  104. package/lib/Utils/process-message.js +157 -93
  105. package/lib/Utils/signal.d.ts +6 -5
  106. package/lib/Utils/signal.js +37 -29
  107. package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
  108. package/lib/Utils/use-multi-file-auth-state.js +12 -7
  109. package/lib/Utils/validate-connection.d.ts +5 -6
  110. package/lib/Utils/validate-connection.js +39 -97
  111. package/lib/WABinary/constants.d.ts +24 -27
  112. package/lib/WABinary/constants.js +1276 -13
  113. package/lib/WABinary/decode.d.ts +3 -4
  114. package/lib/WABinary/decode.js +28 -14
  115. package/lib/WABinary/encode.d.ts +1 -2
  116. package/lib/WABinary/encode.js +134 -147
  117. package/lib/WABinary/generic-utils.d.ts +4 -7
  118. package/lib/WABinary/generic-utils.js +40 -125
  119. package/lib/WABinary/jid-utils.d.ts +13 -8
  120. package/lib/WABinary/jid-utils.js +27 -16
  121. package/lib/WAM/BinaryInfo.d.ts +2 -11
  122. package/lib/WAM/constants.d.ts +3 -2
  123. package/lib/WAM/constants.js +2252 -2359
  124. package/lib/WAM/encode.d.ts +1 -2
  125. package/lib/WAM/encode.js +8 -11
  126. package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
  127. package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
  128. package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
  129. package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
  130. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
  131. package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
  132. package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
  133. package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
  134. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
  135. package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
  136. package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
  137. package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
  138. package/lib/WAUSync/USyncQuery.d.ts +2 -2
  139. package/lib/WAUSync/USyncQuery.js +19 -15
  140. package/lib/WAUSync/USyncUser.d.ts +5 -5
  141. package/lib/WAUSync/index.d.ts +1 -1
  142. package/lib/WAUSync/index.js +1 -1
  143. package/package.json +102 -102
  144. package/lib/Defaults/baileys-version.json +0 -3
  145. package/lib/Defaults/phonenumber-mcc.json +0 -223
  146. package/lib/Signal/Group/queue-job.d.ts +0 -1
  147. package/lib/Signal/Group/queue-job.js +0 -57
  148. package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
  149. package/lib/Socket/Client/mobile-socket-client.js +0 -65
  150. package/lib/Socket/hbmods.d.ts +0 -253
  151. package/lib/Socket/hbmods.js +0 -1
  152. package/lib/Socket/registration.d.ts +0 -267
  153. package/lib/Socket/registration.js +0 -166
  154. package/lib/Socket/usync.d.ts +0 -36
  155. package/lib/Socket/usync.js +0 -70
  156. /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
@@ -1,8 +1,8 @@
1
- /// <reference types="node" />
2
- import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
3
- import { BinaryNode } from '../WABinary';
1
+ import type { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig, WAMediaUpload } from '../Types';
2
+ import type { UpdateBussinesProfileProps } from '../Types/Bussines';
3
+ import { type BinaryNode } from '../WABinary';
4
4
  export declare const makeBusinessSocket: (config: SocketConfig) => {
5
- logger: import("pino").Logger<import("pino").LoggerOptions>;
5
+ logger: import("../Utils/logger").ILogger;
6
6
  getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
7
7
  getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
8
8
  products: import("../Types").Product[];
@@ -16,58 +16,59 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
16
16
  deleted: number;
17
17
  }>;
18
18
  productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
19
- sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
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>;
20
23
  sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
21
- offerCall: (toJid: string, isVideo?: boolean) => Promise<{
22
- id: string;
23
- to: string;
24
- }>;
25
24
  rejectCall: (callId: string, callFrom: string) => Promise<void>;
26
- getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
25
+ fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | Long) => Promise<string>;
26
+ requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
27
+ messageRetryManager: import("../Utils").MessageRetryManager | null;
28
+ getPrivacyTokens: (jids: string[]) => Promise<any>;
27
29
  assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
28
- relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
30
+ relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, useCachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
29
31
  sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
30
- sendReceipts: (keys: import("../Types").WAProto.IMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
31
- getButtonArgs: (message: import("../Types").WAProto.IMessage) => {
32
- [key: string]: string;
33
- };
34
- readMessages: (keys: import("../Types").WAProto.IMessageKey[]) => Promise<void>;
32
+ sendReceipts: (keys: import("../Types").WAMessageKey[], type: import("../Types").MessageReceiptType) => Promise<void>;
33
+ readMessages: (keys: import("../Types").WAMessageKey[]) => Promise<void>;
35
34
  refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
36
- getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
37
- createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
38
- [key: string]: string;
39
- } | undefined) => Promise<{
40
- nodes: BinaryNode[];
41
- shouldIncludeDeviceIdentity: boolean;
42
- }>;
43
35
  waUploadToServer: import("../Types").WAMediaUploadFunction;
44
36
  fetchPrivacySettings: (force?: boolean) => Promise<{
45
37
  [_: string]: string;
46
38
  }>;
39
+ sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
40
+ createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: BinaryNode["attrs"], dsmMessage?: import("../Types").WAProto.IMessage) => Promise<{
41
+ nodes: BinaryNode[];
42
+ shouldIncludeDeviceIdentity: boolean;
43
+ }>;
44
+ getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<(import("../WABinary").JidWithDevice & {
45
+ wireJid: string;
46
+ })[]>;
47
47
  updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
48
48
  sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
49
+ newsletterCreate: (name: string, description?: string) => Promise<import("../Types").NewsletterMetadata>;
50
+ newsletterUpdate: (jid: string, updates: import("../Types").NewsletterUpdate) => Promise<unknown>;
51
+ newsletterSubscribers: (jid: string) => Promise<{
52
+ subscribers: number;
53
+ }>;
54
+ newsletterMetadata: (type: "invite" | "jid", key: string) => Promise<import("../Types").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>;
49
65
  subscribeNewsletterUpdates: (jid: string) => Promise<{
50
66
  duration: string;
51
- }>;
52
- newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
53
- newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
54
- newsletterUpdateName: (jid: string, name: string) => Promise<void>;
55
- newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
56
- newsletterRemovePicture: (jid: string) => Promise<void>;
57
- newsletterUnfollow: (jid: string) => Promise<void>;
58
- newsletterFollow: (jid: string) => Promise<void>;
59
- newsletterUnmute: (jid: string) => Promise<void>;
60
- newsletterMute: (jid: string) => Promise<void>;
61
- newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
62
- newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
63
- newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
67
+ } | null>;
64
68
  newsletterAdminCount: (jid: string) => Promise<number>;
65
- newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
66
- newsletterDemote: (jid: string, user: string) => Promise<void>;
69
+ newsletterChangeOwner: (jid: string, newOwnerJid: string) => Promise<void>;
70
+ newsletterDemote: (jid: string, userJid: string) => Promise<void>;
67
71
  newsletterDelete: (jid: string) => Promise<void>;
68
- newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
69
- newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
70
- newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
71
72
  groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
72
73
  groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
73
74
  groupLeave: (id: string) => Promise<void>;
@@ -75,7 +76,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
75
76
  groupRequestParticipantsList: (jid: string) => Promise<{
76
77
  [key: string]: string;
77
78
  }[]>;
78
- groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
79
+ groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "approve" | "reject") => Promise<{
79
80
  status: string;
80
81
  jid: string;
81
82
  }[]>;
@@ -84,88 +85,103 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
84
85
  jid: string;
85
86
  content: BinaryNode;
86
87
  }[]>;
87
- groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
88
+ groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
88
89
  groupInviteCode: (jid: string) => Promise<string | undefined>;
89
90
  groupRevokeInvite: (jid: string) => Promise<string | undefined>;
90
91
  groupAcceptInvite: (code: string) => Promise<string | undefined>;
91
- groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
92
+ groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
93
+ groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<any>;
92
94
  groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
93
95
  groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
94
- groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
95
- groupMemberAddMode: (jid: string, mode: "all_member_add" | "admin_add") => 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>;
96
98
  groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
97
99
  groupFetchAllParticipating: () => Promise<{
98
100
  [_: string]: import("../Types").GroupMetadata;
99
101
  }>;
102
+ createCallLink: (type: "audio" | "video", event?: {
103
+ startTime: number;
104
+ }, timeoutMs?: number) => Promise<string | undefined>;
105
+ getBotListV2: () => Promise<import("../Types").BotListInfo[]>;
100
106
  processingMutex: {
101
- mutex<T>(code: () => T | Promise<T>): Promise<T>;
107
+ mutex<T>(code: () => Promise<T> | T): Promise<T>;
102
108
  };
103
- upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
109
+ upsertMessage: (msg: import("../Types").WAMessage, type: import("../Types").MessageUpsertType) => Promise<void>;
104
110
  appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
105
- sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
106
- presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
107
- profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
108
- onWhatsApp: (...jids: string[]) => Promise<{
109
- jid: string;
110
- exists: unknown;
111
- lid: unknown;
112
- }[] | undefined>;
111
+ sendPresenceUpdate: (type: import("../Types").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>;
113
114
  fetchBlocklist: () => Promise<string[]>;
114
- fetchStatus: (jid: string) => Promise<{
115
- status: string | undefined;
116
- setAt: Date;
117
- } | undefined>;
118
- updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
115
+ fetchStatus: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
116
+ fetchDisappearingDuration: (...jids: string[]) => Promise<import("..").USyncQueryResultList[] | undefined>;
117
+ updateProfilePicture: (jid: string, content: WAMediaUpload, dimensions?: {
118
+ width: number;
119
+ height: number;
120
+ }) => Promise<void>;
119
121
  removeProfilePicture: (jid: string) => Promise<void>;
120
122
  updateProfileStatus: (status: string) => Promise<void>;
121
123
  updateProfileName: (name: string) => Promise<void>;
122
124
  updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
125
+ updateDisableLinkPreviewsPrivacy: (isPreviewsDisabled: boolean) => Promise<void>;
126
+ updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
127
+ updateMessagesPrivacy: (value: import("../Types").WAPrivacyMessagesValue) => Promise<void>;
123
128
  updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
124
129
  updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
125
130
  updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
126
131
  updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
127
132
  updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
128
- updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
133
+ updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
129
134
  updateDefaultDisappearingMode: (duration: number) => Promise<void>;
130
- getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
131
- resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
135
+ getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile | void>;
136
+ resyncAppState: (collections: readonly ("critical_unblock_low" | "regular_high" | "regular_low" | "critical_block" | "regular")[], isInitialSync: boolean) => Promise<void>;
132
137
  chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
133
- cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
138
+ cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number | string) => Promise<void>;
139
+ addOrEditContact: (jid: string, contact: import("../Types").WAProto.SyncActionValue.IContactAction) => Promise<void>;
140
+ removeContact: (jid: string) => Promise<void>;
141
+ addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
134
142
  addChatLabel: (jid: string, labelId: string) => Promise<void>;
135
143
  removeChatLabel: (jid: string, labelId: string) => Promise<void>;
136
144
  addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
137
145
  removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
138
146
  star: (jid: string, messages: {
139
147
  id: string;
140
- fromMe?: boolean | undefined;
148
+ fromMe?: boolean;
141
149
  }[], star: boolean) => Promise<void>;
150
+ addOrEditQuickReply: (quickReply: import("../Types/Bussines").QuickReplyAction) => Promise<void>;
151
+ removeQuickReply: (timestamp: string) => Promise<void>;
142
152
  type: "md";
143
- ws: any;
153
+ ws: import("./Client").WebSocketClient;
144
154
  ev: import("../Types").BaileysEventEmitter & {
145
155
  process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
146
156
  buffer(): void;
147
- createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
148
- flush(force?: boolean | undefined): boolean;
157
+ createBufferedFunction<A extends any[], T>(work: (...args: A) => Promise<T>): (...args: A) => Promise<T>;
158
+ flush(): boolean;
149
159
  isBuffering(): boolean;
150
160
  };
151
161
  authState: {
152
162
  creds: import("../Types").AuthenticationCreds;
153
163
  keys: import("../Types").SignalKeyStoreWithTransaction;
154
164
  };
155
- signalRepository: import("../Types").SignalRepository;
165
+ signalRepository: import("../Types").SignalRepositoryWithLIDStore;
156
166
  user: import("../Types").Contact | undefined;
157
167
  generateMessageTag: () => string;
158
- query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
159
- waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
168
+ query: (node: BinaryNode, timeoutMs?: number) => Promise<any>;
169
+ waitForMessage: <T>(msgId: string, timeoutMs?: number | undefined) => Promise<T | undefined>;
160
170
  waitForSocketOpen: () => Promise<void>;
161
171
  sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
162
172
  sendNode: (frame: BinaryNode) => Promise<void>;
163
- logout: (msg?: string | undefined) => Promise<void>;
173
+ logout: (msg?: string) => Promise<void>;
164
174
  end: (error: Error | undefined) => void;
165
- onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
166
- uploadPreKeys: (count?: number) => Promise<void>;
175
+ onUnexpectedError: (err: Error | import("@hapi/boom").Boom, msg: string) => void;
176
+ uploadPreKeys: (count?: number, retryCount?: number) => Promise<void>;
167
177
  uploadPreKeysToServerIfRequired: () => Promise<void>;
168
- requestPairingCode: (phoneNumber: string) => Promise<string>;
169
- waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
170
- sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
178
+ requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
179
+ waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => Promise<boolean | undefined>, timeoutMs?: number) => Promise<void>;
180
+ sendWAMBuffer: (wamBuffer: Buffer) => Promise<any>;
181
+ executeUSyncQuery: (usyncQuery: import("..").USyncQuery) => Promise<import("..").USyncQueryResult | undefined>;
182
+ onWhatsApp: (...jids: string[]) => Promise<{
183
+ jid: string;
184
+ exists: boolean;
185
+ lid: string;
186
+ }[] | undefined>;
171
187
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeBusinessSocket = void 0;
4
+ const Utils_1 = require("../Utils");
4
5
  const business_1 = require("../Utils/business");
5
6
  const WABinary_1 = require("../WABinary");
6
7
  const generic_utils_1 = require("../WABinary/generic-utils");
@@ -8,9 +9,125 @@ const messages_recv_1 = require("./messages-recv");
8
9
  const makeBusinessSocket = (config) => {
9
10
  const sock = (0, messages_recv_1.makeMessagesRecvSocket)(config);
10
11
  const { authState, query, waUploadToServer } = sock;
12
+ const updateBussinesProfile = async (args) => {
13
+ const node = [];
14
+ const simpleFields = ['address', 'email', 'description'];
15
+ node.push(...simpleFields
16
+ .filter(key => args[key])
17
+ .map(key => ({
18
+ tag: key,
19
+ attrs: {},
20
+ content: args[key]
21
+ })));
22
+ if (args.websites) {
23
+ node.push(...args.websites.map(website => ({
24
+ tag: 'website',
25
+ attrs: {},
26
+ content: website
27
+ })));
28
+ }
29
+ if (args.hours) {
30
+ node.push({
31
+ tag: 'business_hours',
32
+ attrs: { timezone: args.hours.timezone },
33
+ content: args.hours.days.map(config => {
34
+ const base = {
35
+ tag: 'business_hours_config',
36
+ attrs: { day_of_week: config.day, mode: config.mode }
37
+ };
38
+ if (config.mode === 'specific_hours') {
39
+ return {
40
+ ...base,
41
+ attrs: {
42
+ ...base.attrs,
43
+ open_time: config.openTimeInMinutes,
44
+ close_time: config.closeTimeInMinutes
45
+ }
46
+ };
47
+ }
48
+ return base;
49
+ })
50
+ });
51
+ }
52
+ const result = await query({
53
+ tag: 'iq',
54
+ attrs: {
55
+ to: WABinary_1.S_WHATSAPP_NET,
56
+ type: 'set',
57
+ xmlns: 'w:biz'
58
+ },
59
+ content: [
60
+ {
61
+ tag: 'business_profile',
62
+ attrs: {
63
+ v: '3',
64
+ mutation_type: 'delta'
65
+ },
66
+ content: node
67
+ }
68
+ ]
69
+ });
70
+ return result;
71
+ };
72
+ const updateCoverPhoto = async (photo) => {
73
+ const { fileSha256, filePath } = await (0, Utils_1.getRawMediaUploadData)(photo, 'biz-cover-photo');
74
+ const fileSha256B64 = fileSha256.toString('base64');
75
+ const { meta_hmac, fbid, ts } = await waUploadToServer(filePath, {
76
+ fileEncSha256B64: fileSha256B64,
77
+ mediaType: 'biz-cover-photo'
78
+ });
79
+ await query({
80
+ tag: 'iq',
81
+ attrs: {
82
+ to: WABinary_1.S_WHATSAPP_NET,
83
+ type: 'set',
84
+ xmlns: 'w:biz'
85
+ },
86
+ content: [
87
+ {
88
+ tag: 'business_profile',
89
+ attrs: {
90
+ v: '3',
91
+ mutation_type: 'delta'
92
+ },
93
+ content: [
94
+ {
95
+ tag: 'cover_photo',
96
+ attrs: { id: String(fbid), op: 'update', token: meta_hmac, ts: String(ts) }
97
+ }
98
+ ]
99
+ }
100
+ ]
101
+ });
102
+ return fbid;
103
+ };
104
+ const removeCoverPhoto = async (id) => {
105
+ return await query({
106
+ tag: 'iq',
107
+ attrs: {
108
+ to: WABinary_1.S_WHATSAPP_NET,
109
+ type: 'set',
110
+ xmlns: 'w:biz'
111
+ },
112
+ content: [
113
+ {
114
+ tag: 'business_profile',
115
+ attrs: {
116
+ v: '3',
117
+ mutation_type: 'delta'
118
+ },
119
+ content: [
120
+ {
121
+ tag: 'cover_photo',
122
+ attrs: { op: 'delete', id }
123
+ }
124
+ ]
125
+ }
126
+ ]
127
+ });
128
+ };
11
129
  const getCatalog = async ({ jid, limit, cursor }) => {
12
- var _a;
13
- jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
130
+ jid = jid || authState.creds.me?.id;
14
131
  jid = (0, WABinary_1.jidNormalizedUser)(jid);
15
132
  const queryParamNodes = [
16
133
  {
@@ -27,7 +144,7 @@ const makeBusinessSocket = (config) => {
27
144
  tag: 'height',
28
145
  attrs: {},
29
146
  content: Buffer.from('100')
30
- },
147
+ }
31
148
  ];
32
149
  if (cursor) {
33
150
  queryParamNodes.push({
@@ -48,7 +165,7 @@ const makeBusinessSocket = (config) => {
48
165
  tag: 'product_catalog',
49
166
  attrs: {
50
167
  jid,
51
- 'allow_shop_source': 'true'
168
+ allow_shop_source: 'true'
52
169
  },
53
170
  content: queryParamNodes
54
171
  }
@@ -57,8 +174,7 @@ const makeBusinessSocket = (config) => {
57
174
  return (0, business_1.parseCatalogNode)(result);
58
175
  };
59
176
  const getCollections = async (jid, limit = 51) => {
60
- var _a;
61
- jid = jid || ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.id);
177
+ jid = jid || authState.creds.me?.id;
62
178
  jid = (0, WABinary_1.jidNormalizedUser)(jid);
63
179
  const result = await query({
64
180
  tag: 'iq',
@@ -66,13 +182,13 @@ const makeBusinessSocket = (config) => {
66
182
  to: WABinary_1.S_WHATSAPP_NET,
67
183
  type: 'get',
68
184
  xmlns: 'w:biz:catalog',
69
- 'smax_id': '35'
185
+ smax_id: '35'
70
186
  },
71
187
  content: [
72
188
  {
73
189
  tag: 'collections',
74
190
  attrs: {
75
- 'biz_jid': jid,
191
+ biz_jid: jid
76
192
  },
77
193
  content: [
78
194
  {
@@ -108,7 +224,7 @@ const makeBusinessSocket = (config) => {
108
224
  to: WABinary_1.S_WHATSAPP_NET,
109
225
  type: 'get',
110
226
  xmlns: 'fb:thrift_iq',
111
- 'smax_id': '5'
227
+ smax_id: '5'
112
228
  },
113
229
  content: [
114
230
  {
@@ -243,7 +359,7 @@ const makeBusinessSocket = (config) => {
243
359
  });
244
360
  const productCatalogDelNode = (0, generic_utils_1.getBinaryNodeChild)(result, 'product_catalog_delete');
245
361
  return {
246
- deleted: +((productCatalogDelNode === null || productCatalogDelNode === void 0 ? void 0 : productCatalogDelNode.attrs.deleted_count) || 0)
362
+ deleted: +(productCatalogDelNode?.attrs.deleted_count || 0)
247
363
  };
248
364
  };
249
365
  return {
@@ -254,7 +370,10 @@ const makeBusinessSocket = (config) => {
254
370
  getCollections,
255
371
  productCreate,
256
372
  productDelete,
257
- productUpdate
373
+ productUpdate,
374
+ updateBussinesProfile,
375
+ updateCoverPhoto,
376
+ removeCoverPhoto
258
377
  };
259
378
  };
260
379
  exports.makeBusinessSocket = makeBusinessSocket;