@hbmodsofc/baileys 1.5.2 → 1.7.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/WAProto/index.js +19671 -152026
- package/lib/Defaults/index.d.ts +12 -8
- package/lib/Defaults/index.js +90 -124
- package/lib/Signal/Group/group_cipher.d.ts +0 -1
- package/lib/Signal/Group/group_cipher.js +28 -39
- package/lib/Signal/Group/sender-chain-key.d.ts +1 -1
- package/lib/Signal/Group/sender-chain-key.js +9 -2
- package/lib/Signal/Group/sender-key-distribution-message.js +3 -3
- package/lib/Signal/Group/sender-key-message.js +3 -3
- package/lib/Signal/Group/sender-key-state.d.ts +4 -4
- package/lib/Signal/Group/sender-key-state.js +47 -16
- package/lib/Signal/libsignal.d.ts +7 -3
- package/lib/Signal/libsignal.js +224 -39
- package/lib/Signal/lid-mapping.d.ts +26 -0
- package/lib/Signal/lid-mapping.js +146 -0
- package/lib/Socket/Client/index.d.ts +2 -3
- package/lib/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/{abstract-socket-client.d.ts → types.d.ts} +1 -3
- package/lib/Socket/Client/{web-socket-client.d.ts → websocket.d.ts} +1 -1
- package/lib/Socket/Client/{web-socket-client.js → websocket.js} +10 -16
- package/lib/Socket/business.d.ts +94 -78
- package/lib/Socket/business.js +130 -11
- package/lib/Socket/chats.d.ts +63 -233
- package/lib/Socket/chats.js +234 -184
- package/lib/Socket/communities.d.ts +232 -0
- package/lib/Socket/communities.js +402 -0
- package/lib/Socket/groups.d.ts +62 -41
- package/lib/Socket/groups.js +76 -64
- package/lib/Socket/index.d.ts +129 -83
- package/lib/Socket/index.js +13 -6
- package/lib/Socket/messages-recv.d.ts +59 -48
- package/lib/Socket/messages-recv.js +516 -371
- package/lib/Socket/messages-send.d.ts +86 -67
- package/lib/Socket/messages-send.js +1091 -1
- package/lib/Socket/mex.d.ts +2 -0
- package/lib/Socket/mex.js +45 -0
- package/lib/Socket/newsletter.d.ts +76 -64
- package/lib/Socket/newsletter.js +184 -1
- package/lib/Socket/socket.d.ts +19 -13
- package/lib/Socket/socket.js +805 -1
- package/lib/Types/Auth.d.ts +4 -10
- package/lib/Types/Bussines.d.ts +24 -0
- package/lib/Types/Bussines.js +2 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +29 -9
- package/lib/Types/Chat.js +7 -1
- package/lib/Types/Contact.d.ts +5 -1
- package/lib/Types/Events.d.ts +55 -14
- package/lib/Types/GroupMetadata.d.ts +15 -5
- package/lib/Types/Label.d.ts +11 -0
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +75 -49
- package/lib/Types/Message.js +10 -7
- package/lib/Types/Newsletter.d.ts +129 -98
- package/lib/Types/Newsletter.js +33 -38
- package/lib/Types/Product.d.ts +1 -1
- package/lib/Types/Signal.d.ts +29 -1
- package/lib/Types/Socket.d.ts +48 -22
- package/lib/Types/State.d.ts +13 -2
- package/lib/Types/State.js +12 -0
- package/lib/Types/USync.d.ts +1 -1
- package/lib/Types/index.d.ts +10 -3
- package/lib/Types/index.js +2 -2
- package/lib/Utils/auth-utils.d.ts +3 -3
- package/lib/Utils/auth-utils.js +378 -102
- package/lib/Utils/baileys-event-stream.js +1 -1
- package/lib/Utils/business.d.ts +2 -2
- package/lib/Utils/business.js +19 -13
- package/lib/Utils/chat-utils.d.ts +21 -22
- package/lib/Utils/chat-utils.js +201 -154
- package/lib/Utils/crypto.d.ts +18 -19
- package/lib/Utils/crypto.js +78 -37
- package/lib/Utils/decode-wa-message.d.ts +34 -7
- package/lib/Utils/decode-wa-message.js +138 -66
- package/lib/Utils/event-buffer.d.ts +6 -8
- package/lib/Utils/event-buffer.js +81 -43
- package/lib/Utils/generics.d.ts +27 -27
- package/lib/Utils/generics.js +128 -133
- package/lib/Utils/history.d.ts +9 -5
- package/lib/Utils/history.js +17 -23
- package/lib/Utils/index.d.ts +2 -0
- package/lib/Utils/index.js +2 -0
- package/lib/Utils/lidToJid-test.d.ts +11 -0
- package/lib/Utils/lidToJid-test.js +27 -0
- package/lib/Utils/link-preview.d.ts +4 -4
- package/lib/Utils/link-preview.js +40 -12
- package/lib/Utils/logger.d.ts +11 -3
- package/lib/Utils/lt-hash.d.ts +8 -8
- package/lib/Utils/lt-hash.js +23 -24
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/make-mutex.js +3 -2
- package/lib/Utils/message-retry-manager.d.ts +81 -0
- package/lib/Utils/message-retry-manager.js +152 -0
- package/lib/Utils/messages-media.d.ts +37 -41
- package/lib/Utils/messages-media.js +252 -368
- package/lib/Utils/messages.d.ts +13 -15
- package/lib/Utils/messages.js +274 -261
- package/lib/Utils/noise-handler.d.ts +13 -15
- package/lib/Utils/noise-handler.js +20 -26
- package/lib/Utils/process-message.d.ts +9 -8
- package/lib/Utils/process-message.js +157 -93
- package/lib/Utils/signal.d.ts +6 -5
- package/lib/Utils/signal.js +37 -29
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -2
- package/lib/Utils/use-multi-file-auth-state.js +12 -7
- package/lib/Utils/validate-connection.d.ts +5 -6
- package/lib/Utils/validate-connection.js +39 -97
- package/lib/WABinary/constants.d.ts +24 -27
- package/lib/WABinary/constants.js +1276 -13
- package/lib/WABinary/decode.d.ts +3 -4
- package/lib/WABinary/decode.js +28 -14
- package/lib/WABinary/encode.d.ts +1 -2
- package/lib/WABinary/encode.js +134 -147
- package/lib/WABinary/generic-utils.d.ts +4 -7
- package/lib/WABinary/generic-utils.js +40 -125
- package/lib/WABinary/jid-utils.d.ts +13 -8
- package/lib/WABinary/jid-utils.js +27 -16
- package/lib/WAM/BinaryInfo.d.ts +2 -11
- package/lib/WAM/constants.d.ts +3 -2
- package/lib/WAM/constants.js +2252 -2359
- package/lib/WAM/encode.d.ts +1 -2
- package/lib/WAM/encode.js +8 -11
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +3 -4
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +5 -5
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +5 -6
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +2 -2
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +1 -1
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +4 -3
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +11 -3
- package/lib/WAUSync/USyncQuery.d.ts +2 -2
- package/lib/WAUSync/USyncQuery.js +19 -15
- package/lib/WAUSync/USyncUser.d.ts +5 -5
- package/lib/WAUSync/index.d.ts +1 -1
- package/lib/WAUSync/index.js +1 -1
- package/package.json +102 -102
- package/lib/Defaults/baileys-version.json +0 -3
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Signal/Group/queue-job.d.ts +0 -1
- package/lib/Signal/Group/queue-job.js +0 -57
- package/lib/Socket/Client/mobile-socket-client.d.ts +0 -13
- package/lib/Socket/Client/mobile-socket-client.js +0 -65
- package/lib/Socket/hbmods.d.ts +0 -253
- package/lib/Socket/hbmods.js +0 -1
- package/lib/Socket/registration.d.ts +0 -267
- package/lib/Socket/registration.js +0 -166
- package/lib/Socket/usync.d.ts +0 -36
- package/lib/Socket/usync.js +0 -70
- /package/lib/Socket/Client/{abstract-socket-client.js → types.js} +0 -0
package/lib/Socket/business.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
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("
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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").
|
|
31
|
-
|
|
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,
|
|
66
|
-
newsletterDemote: (jid: string,
|
|
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: "
|
|
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
|
|
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
|
-
|
|
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" | "
|
|
95
|
-
groupMemberAddMode: (jid: string, mode: "
|
|
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 |
|
|
107
|
+
mutex<T>(code: () => Promise<T> | T): Promise<T>;
|
|
102
108
|
};
|
|
103
|
-
upsertMessage: (msg: import("../Types").
|
|
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
|
|
106
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer
|
|
107
|
-
profilePictureUrl: (jid: string, type?: "
|
|
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: (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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").
|
|
133
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyGroupAddValue) => Promise<void>;
|
|
129
134
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
130
|
-
getBusinessProfile: (jid: string) => Promise<
|
|
131
|
-
resyncAppState: (collections: readonly ("
|
|
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?:
|
|
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
|
|
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:
|
|
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[],
|
|
148
|
-
flush(
|
|
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").
|
|
165
|
+
signalRepository: import("../Types").SignalRepositoryWithLIDStore;
|
|
156
166
|
user: import("../Types").Contact | undefined;
|
|
157
167
|
generateMessageTag: () => string;
|
|
158
|
-
query: (node: BinaryNode, timeoutMs?: number
|
|
159
|
-
waitForMessage: <
|
|
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
|
|
173
|
+
logout: (msg?: string) => Promise<void>;
|
|
164
174
|
end: (error: Error | undefined) => void;
|
|
165
|
-
onUnexpectedError: (err: Error | import("@hapi/boom").Boom
|
|
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
|
|
170
|
-
sendWAMBuffer: (wamBuffer: Buffer) => Promise<
|
|
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
|
};
|
package/lib/Socket/business.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
185
|
+
smax_id: '35'
|
|
70
186
|
},
|
|
71
187
|
content: [
|
|
72
188
|
{
|
|
73
189
|
tag: 'collections',
|
|
74
190
|
attrs: {
|
|
75
|
-
|
|
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
|
-
|
|
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: +(
|
|
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;
|