naya-flore 4.7.1 → 4.7.3
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/README.md +0 -104
- package/WAProto/WAProto.proto +89 -1195
- package/WAProto/index.d.ts +1256 -13195
- package/WAProto/index.js +11405 -32544
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +0 -231
- package/lib/Defaults/index.js +102 -92
- package/lib/Defaults/phonenumber-mcc.json +221 -221
- package/lib/Signal/libsignal.js +9 -18
- package/lib/Socket/Client/abstract-socket-client.d.ts +2 -0
- package/lib/Socket/Client/index.d.ts +3 -2
- package/lib/Socket/Client/index.js +3 -2
- package/lib/Socket/Client/mobile-socket-client.d.ts +1 -0
- package/lib/Socket/Client/{websocket.d.ts → web-socket-client.d.ts} +1 -1
- package/lib/Socket/Client/{websocket.js → web-socket-client.js} +2 -2
- package/lib/Socket/business.d.ts +43 -42
- package/lib/Socket/chats.d.ts +8 -9
- package/lib/Socket/chats.js +34 -41
- package/lib/Socket/groups.d.ts +7 -7
- package/lib/Socket/groups.js +4 -2
- package/lib/Socket/index.d.ts +52 -51
- package/lib/Socket/messages-recv.d.ts +42 -41
- package/lib/Socket/messages-recv.js +127 -190
- package/lib/Socket/messages-send.d.ts +9 -16
- package/lib/Socket/messages-send.js +316 -467
- package/lib/Socket/newsletter.d.ts +28 -26
- package/lib/Socket/newsletter.js +3 -3
- package/lib/Socket/registration.d.ts +52 -49
- package/lib/Socket/registration.js +7 -7
- package/lib/Socket/socket.d.ts +0 -1
- package/lib/Socket/socket.js +23 -49
- package/lib/Socket/usync.d.ts +10 -11
- package/lib/Store/index.d.ts +2 -2
- package/lib/Store/index.js +2 -2
- package/lib/Store/make-cache-manager-store.d.ts +0 -1
- package/lib/Store/make-in-memory-store.js +1 -5
- package/lib/Store/make-ordered-dictionary.d.ts +1 -1
- package/lib/Types/Auth.d.ts +1 -0
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -12
- package/lib/Types/Events.d.ts +2 -17
- package/lib/Types/GroupMetadata.d.ts +2 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Label.js +1 -1
- package/lib/Types/LabelAssociation.js +1 -1
- package/lib/Types/Message.d.ts +10 -170
- package/lib/Types/Newsletter.js +3 -3
- package/lib/Types/Socket.d.ts +4 -7
- package/lib/Types/index.d.ts +0 -9
- package/lib/Types/index.js +1 -1
- package/lib/Utils/auth-utils.js +3 -3
- package/lib/Utils/business.d.ts +1 -1
- package/lib/Utils/business.js +2 -2
- package/lib/Utils/chat-utils.d.ts +12 -11
- package/lib/Utils/chat-utils.js +26 -42
- package/lib/Utils/crypto.d.ts +16 -15
- package/lib/Utils/crypto.js +23 -35
- package/lib/Utils/decode-wa-message.d.ts +0 -17
- package/lib/Utils/decode-wa-message.js +15 -43
- package/lib/Utils/generics.d.ts +17 -13
- package/lib/Utils/generics.js +15 -25
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +6 -4
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/make-mutex.d.ts +2 -2
- package/lib/Utils/messages-media.d.ts +28 -25
- package/lib/Utils/messages-media.js +47 -38
- package/lib/Utils/messages.js +41 -454
- package/lib/Utils/noise-handler.d.ts +5 -4
- package/lib/Utils/process-message.js +2 -2
- package/lib/Utils/signal.d.ts +1 -2
- package/lib/Utils/signal.js +19 -11
- package/lib/Utils/use-multi-file-auth-state.d.ts +1 -0
- package/lib/Utils/use-multi-file-auth-state.js +3 -11
- package/lib/Utils/validate-connection.d.ts +1 -1
- package/lib/Utils/validate-connection.js +1 -1
- package/lib/WABinary/decode.d.ts +2 -1
- package/lib/WABinary/decode.js +7 -17
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +17 -33
- package/lib/WABinary/generic-utils.d.ts +3 -2
- package/lib/WABinary/generic-utils.js +2 -2
- package/lib/WABinary/jid-utils.d.ts +1 -1
- package/lib/WAM/BinaryInfo.d.ts +11 -2
- package/lib/WAM/encode.d.ts +2 -1
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +3 -3
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.d.ts +25 -0
- package/lib/WAUSync/Protocols/UsyncBotProfileProtocol.js +53 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.d.ts +8 -0
- package/lib/WAUSync/Protocols/UsyncLIDProtocol.js +24 -0
- package/lib/WAUSync/USyncQuery.d.ts +2 -0
- package/lib/WAUSync/USyncQuery.js +10 -0
- package/lib/WAUSync/USyncUser.d.ts +2 -0
- package/lib/WAUSync/USyncUser.js +4 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/package.json +19 -32
- package/lib/Socket/Client/types.d.ts +0 -17
- package/lib/Socket/Client/types.js +0 -13
package/lib/Socket/business.d.ts
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
2
3
|
import { BinaryNode } from '../WABinary';
|
3
4
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
4
|
-
logger: Logger
|
5
|
+
logger: import("pino").Logger<import("pino").LoggerOptions>;
|
5
6
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
6
7
|
getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
|
7
8
|
products: import("../Types").Product[];
|
8
|
-
nextPageCursor:
|
9
|
+
nextPageCursor: string | undefined;
|
9
10
|
}>;
|
10
11
|
getCollections: (jid?: string, limit?: number) => Promise<{
|
11
12
|
collections: import("../Types").CatalogCollection[];
|
@@ -15,26 +16,27 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
15
16
|
deleted: number;
|
16
17
|
}>;
|
17
18
|
productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
|
18
|
-
sendMessageAck: ({ tag, attrs, content }: BinaryNode
|
19
|
+
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
19
20
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
20
21
|
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
21
|
-
id:
|
22
|
+
id: string;
|
22
23
|
to: string;
|
23
24
|
}>;
|
24
25
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
25
|
-
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number) => Promise<string>;
|
26
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
27
26
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
28
27
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
29
28
|
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
30
29
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
31
|
-
sendReceipts: (keys: import("../Types").
|
32
|
-
getButtonArgs: (message: import("../Types").WAProto.IMessage) =>
|
33
|
-
|
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>;
|
34
35
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
35
36
|
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
36
|
-
|
37
|
-
|
37
|
+
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
38
|
+
[key: string]: string;
|
39
|
+
} | undefined) => Promise<{
|
38
40
|
nodes: BinaryNode[];
|
39
41
|
shouldIncludeDeviceIdentity: boolean;
|
40
42
|
}>;
|
@@ -43,14 +45,12 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
43
45
|
[_: string]: string;
|
44
46
|
}>;
|
45
47
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
46
|
-
sendStatusMentions: (content: import("../Types").AnyMessageContent, jids?: string[]) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
47
|
-
sendAlbumMessage: (jid: string, medias: import("../Types").Media[], options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo>;
|
48
48
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
49
49
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
50
50
|
duration: string;
|
51
51
|
}>;
|
52
52
|
newsletterReactionMode: (jid: string, mode: import("../Types").NewsletterReactionMode) => Promise<void>;
|
53
|
-
newsletterUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
53
|
+
newsletterUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
54
54
|
newsletterUpdateName: (jid: string, name: string) => Promise<void>;
|
55
55
|
newsletterUpdatePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
56
56
|
newsletterRemovePicture: (jid: string) => Promise<void>;
|
@@ -58,16 +58,16 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
58
58
|
newsletterFollow: (jid: string) => Promise<void>;
|
59
59
|
newsletterUnmute: (jid: string) => Promise<void>;
|
60
60
|
newsletterMute: (jid: string) => Promise<void>;
|
61
|
-
newsletterAction: (jid: string, type: "
|
62
|
-
newsletterCreate: (name: string, description: string) => Promise<import("../Types").NewsletterMetadata>;
|
63
|
-
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole) => Promise<import("../Types").NewsletterMetadata>;
|
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>;
|
64
64
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
65
65
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
66
66
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
67
67
|
newsletterDelete: (jid: string) => Promise<void>;
|
68
|
-
newsletterReactMessage: (jid: string, serverId: string, code?: string) => Promise<void>;
|
69
|
-
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
70
|
-
newsletterFetchUpdates: (jid: string, count: number, after?: number, since?: number) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
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
71
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
72
72
|
groupCreate: (subject: string, participants: string[]) => Promise<import("../Types").GroupMetadata>;
|
73
73
|
groupLeave: (id: string) => Promise<void>;
|
@@ -75,7 +75,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
75
75
|
groupRequestParticipantsList: (jid: string) => Promise<{
|
76
76
|
[key: string]: string;
|
77
77
|
}[]>;
|
78
|
-
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "
|
78
|
+
groupRequestParticipantsUpdate: (jid: string, participants: string[], action: "reject" | "approve") => Promise<{
|
79
79
|
status: string;
|
80
80
|
jid: string;
|
81
81
|
}[]>;
|
@@ -84,31 +84,32 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
84
84
|
jid: string;
|
85
85
|
content: BinaryNode;
|
86
86
|
}[]>;
|
87
|
-
groupUpdateDescription: (jid: string, description?: string) => Promise<void>;
|
87
|
+
groupUpdateDescription: (jid: string, description?: string | undefined) => Promise<void>;
|
88
88
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
89
89
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
90
90
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
91
91
|
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
92
92
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
93
93
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
94
|
-
groupSettingUpdate: (jid: string, setting: "announcement" | "
|
95
|
-
groupMemberAddMode: (jid: string, mode: "
|
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
96
|
groupJoinApprovalMode: (jid: string, mode: "on" | "off") => Promise<void>;
|
97
97
|
groupFetchAllParticipating: () => Promise<{
|
98
98
|
[_: string]: import("../Types").GroupMetadata;
|
99
99
|
}>;
|
100
100
|
processingMutex: {
|
101
|
-
mutex<T>(code: () =>
|
101
|
+
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
102
102
|
};
|
103
103
|
upsertMessage: (msg: import("../Types").WAProto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
104
104
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
105
|
-
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string) => Promise<void>;
|
106
|
-
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
107
|
-
profilePictureUrl: (jid: string, type?: "
|
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
108
|
onWhatsApp: (...jids: string[]) => Promise<{
|
109
|
-
exists: boolean;
|
110
109
|
jid: string;
|
111
|
-
|
110
|
+
exists: unknown;
|
111
|
+
lid: unknown;
|
112
|
+
}[] | undefined>;
|
112
113
|
fetchBlocklist: () => Promise<string[]>;
|
113
114
|
fetchStatus: (jid: string) => Promise<{
|
114
115
|
status: string | undefined;
|
@@ -126,25 +127,25 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
126
127
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
127
128
|
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
128
129
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
129
|
-
getBusinessProfile: (jid: string) => Promise<import("../Types").WABusinessProfile
|
130
|
+
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
130
131
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
131
132
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
132
|
-
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: number |
|
133
|
+
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
133
134
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
134
135
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
135
136
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
136
137
|
removeMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
137
138
|
star: (jid: string, messages: {
|
138
139
|
id: string;
|
139
|
-
fromMe?: boolean;
|
140
|
+
fromMe?: boolean | undefined;
|
140
141
|
}[], star: boolean) => Promise<void>;
|
141
142
|
type: "md";
|
142
143
|
ws: any;
|
143
144
|
ev: import("../Types").BaileysEventEmitter & {
|
144
|
-
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): (
|
145
|
+
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
145
146
|
buffer(): void;
|
146
|
-
createBufferedFunction<A extends any[],
|
147
|
-
flush(force?: boolean): boolean;
|
147
|
+
createBufferedFunction<A extends any[], T_1>(work: (...args: A) => Promise<T_1>): (...args: A) => Promise<T_1>;
|
148
|
+
flush(force?: boolean | undefined): boolean;
|
148
149
|
isBuffering(): boolean;
|
149
150
|
};
|
150
151
|
authState: {
|
@@ -154,17 +155,17 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
154
155
|
signalRepository: import("../Types").SignalRepository;
|
155
156
|
user: import("../Types").Contact | undefined;
|
156
157
|
generateMessageTag: () => string;
|
157
|
-
query: (node: BinaryNode, timeoutMs?: number) => Promise<BinaryNode>;
|
158
|
-
waitForMessage: <
|
158
|
+
query: (node: BinaryNode, timeoutMs?: number | undefined) => Promise<BinaryNode>;
|
159
|
+
waitForMessage: <T_2>(msgId: string, timeoutMs?: number | undefined) => Promise<T_2>;
|
159
160
|
waitForSocketOpen: () => Promise<void>;
|
160
161
|
sendRawMessage: (data: Uint8Array | Buffer) => Promise<void>;
|
161
162
|
sendNode: (frame: BinaryNode) => Promise<void>;
|
162
|
-
logout: (msg?: string) => Promise<void>;
|
163
|
+
logout: (msg?: string | undefined) => Promise<void>;
|
163
164
|
end: (error: Error | undefined) => void;
|
164
|
-
onUnexpectedError: (err: Error | Boom
|
165
|
+
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
165
166
|
uploadPreKeys: (count?: number) => Promise<void>;
|
166
167
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
167
|
-
requestPairingCode: (phoneNumber: string
|
168
|
-
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number) => Promise<void>;
|
168
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
169
|
+
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
169
170
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
170
171
|
};
|
package/lib/Socket/chats.d.ts
CHANGED
@@ -3,9 +3,7 @@ import { Boom } from '@hapi/boom';
|
|
3
3
|
import { proto } from '../../WAProto';
|
4
4
|
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
5
5
|
import { BinaryNode } from '../WABinary';
|
6
|
-
import { USyncQuery } from '../WAUSync';
|
7
6
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
8
|
-
interactiveQuery: (userNodes: BinaryNode[], queryNode: BinaryNode) => Promise<BinaryNode[]>;
|
9
7
|
processingMutex: {
|
10
8
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
11
9
|
};
|
@@ -14,16 +12,18 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
14
12
|
}>;
|
15
13
|
upsertMessage: (msg: proto.IWebMessageInfo, type: MessageUpsertType) => Promise<void>;
|
16
14
|
appPatch: (patchCreate: WAPatchCreate) => Promise<void>;
|
17
|
-
fetchUserLid: (jid: string) => Promise<string | undefined>;
|
18
15
|
sendPresenceUpdate: (type: WAPresence, toJid?: string) => Promise<void>;
|
19
16
|
presenceSubscribe: (toJid: string, tcToken?: Buffer) => Promise<void>;
|
17
|
+
profilePictureUrl: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | undefined>;
|
20
18
|
onWhatsApp: (...jids: string[]) => Promise<{
|
19
|
+
exists: boolean;
|
21
20
|
jid: string;
|
22
|
-
|
23
|
-
}[] | undefined>;
|
21
|
+
}[]>;
|
24
22
|
fetchBlocklist: () => Promise<string[]>;
|
25
|
-
fetchStatus: (
|
26
|
-
|
23
|
+
fetchStatus: (jid: string) => Promise<{
|
24
|
+
status: string | undefined;
|
25
|
+
setAt: Date;
|
26
|
+
} | undefined>;
|
27
27
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
28
28
|
removeProfilePicture: (jid: string) => Promise<void>;
|
29
29
|
updateProfileStatus: (status: string) => Promise<void>;
|
@@ -48,7 +48,6 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
48
48
|
id: string;
|
49
49
|
fromMe?: boolean;
|
50
50
|
}[], star: boolean) => Promise<void>;
|
51
|
-
executeUSyncQuery: (usyncQuery: USyncQuery) => Promise<import("../WAUSync").USyncQueryResult | undefined>;
|
52
51
|
type: "md";
|
53
52
|
ws: any;
|
54
53
|
ev: import("../Types").BaileysEventEmitter & {
|
@@ -75,7 +74,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
75
74
|
onUnexpectedError: (err: Error | Boom<any>, msg: string) => void;
|
76
75
|
uploadPreKeys: (count?: number) => Promise<void>;
|
77
76
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
78
|
-
requestPairingCode: (phoneNumber: string
|
77
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
79
78
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
80
79
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
81
80
|
};
|
package/lib/Socket/chats.js
CHANGED
@@ -12,13 +12,14 @@ const Utils_1 = require("../Utils");
|
|
12
12
|
const make_mutex_1 = require("../Utils/make-mutex");
|
13
13
|
const process_message_1 = __importDefault(require("../Utils/process-message"));
|
14
14
|
const WABinary_1 = require("../WABinary");
|
15
|
+
const socket_1 = require("./socket");
|
15
16
|
const WAUSync_1 = require("../WAUSync");
|
16
17
|
const usync_1 = require("./usync");
|
17
18
|
const MAX_SYNC_ATTEMPTS = 2;
|
18
19
|
const makeChatsSocket = (config) => {
|
19
20
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config;
|
20
21
|
const sock = (0, usync_1.makeUSyncSocket)(config);
|
21
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError } = sock;
|
22
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError, } = sock;
|
22
23
|
let privacySettings;
|
23
24
|
let needToFlushWithAppStateSync = false;
|
24
25
|
let pendingAppStateSync = false;
|
@@ -140,53 +141,27 @@ const makeChatsSocket = (config) => {
|
|
140
141
|
const users = (0, WABinary_1.getBinaryNodeChildren)(listNode, 'user');
|
141
142
|
return users;
|
142
143
|
};
|
143
|
-
const fetchUserLid = async (jid) => {
|
144
|
-
const [result] = await interactiveQuery([
|
145
|
-
{
|
146
|
-
tag: 'user',
|
147
|
-
attrs: { jid }
|
148
|
-
}
|
149
|
-
], {
|
150
|
-
tag: 'lid',
|
151
|
-
attrs: {}
|
152
|
-
});
|
153
|
-
if (result) {
|
154
|
-
const lid = (0, WABinary_1.getBinaryNodeChild)(result, 'lid');
|
155
|
-
return lid.attrs.val;
|
156
|
-
}
|
157
|
-
};
|
158
144
|
const onWhatsApp = async (...jids) => {
|
159
145
|
const usyncQuery = new WAUSync_1.USyncQuery()
|
160
|
-
.withContactProtocol()
|
146
|
+
.withContactProtocol()
|
147
|
+
.withLIDProtocol();
|
161
148
|
for (const jid of jids) {
|
162
149
|
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
|
163
150
|
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
|
164
151
|
}
|
165
152
|
const results = await sock.executeUSyncQuery(usyncQuery);
|
166
153
|
if (results) {
|
167
|
-
return results.list.filter((a) => !!a.contact).map(({ contact, id }) => ({ jid: id, exists: contact }));
|
168
|
-
}
|
169
|
-
};
|
170
|
-
const fetchStatus = async (...jids) => {
|
171
|
-
const usyncQuery = new WAUSync_1.USyncQuery()
|
172
|
-
.withStatusProtocol();
|
173
|
-
for (const jid of jids) {
|
174
|
-
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
|
175
|
-
}
|
176
|
-
const result = await sock.executeUSyncQuery(usyncQuery);
|
177
|
-
if (result) {
|
178
|
-
return result.list;
|
154
|
+
return results.list.filter((a) => !!a.contact).map(({ contact, id, lid }) => ({ jid: id, exists: contact, lid }));
|
179
155
|
}
|
180
156
|
};
|
181
|
-
const
|
182
|
-
const
|
183
|
-
.withDisappearingModeProtocol();
|
184
|
-
for (const jid of jids) {
|
185
|
-
usyncQuery.withUser(new WAUSync_1.USyncUser().withId(jid));
|
186
|
-
}
|
187
|
-
const result = await sock.executeUSyncQuery(usyncQuery);
|
157
|
+
const fetchStatus = async (jid) => {
|
158
|
+
const [result] = await interactiveQuery([{ tag: 'user', attrs: { jid } }], { tag: 'status', attrs: {} });
|
188
159
|
if (result) {
|
189
|
-
|
160
|
+
const status = (0, WABinary_1.getBinaryNodeChild)(result, 'status');
|
161
|
+
return {
|
162
|
+
status: status === null || status === void 0 ? void 0 : status.content.toString(),
|
163
|
+
setAt: new Date(+((status === null || status === void 0 ? void 0 : status.attrs.t) || 0) * 1000)
|
164
|
+
};
|
190
165
|
}
|
191
166
|
};
|
192
167
|
/** update the profile picture for yourself or a group */
|
@@ -477,6 +452,24 @@ const makeChatsSocket = (config) => {
|
|
477
452
|
* type = "preview" for a low res picture
|
478
453
|
* type = "image for the high res picture"
|
479
454
|
*/
|
455
|
+
const profilePictureUrl = async (jid, type = 'preview', timeoutMs) => {
|
456
|
+
var _a;
|
457
|
+
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
458
|
+
const result = await query({
|
459
|
+
tag: 'iq',
|
460
|
+
attrs: {
|
461
|
+
target: jid,
|
462
|
+
to: WABinary_1.S_WHATSAPP_NET,
|
463
|
+
type: 'get',
|
464
|
+
xmlns: 'w:profile:picture'
|
465
|
+
},
|
466
|
+
content: [
|
467
|
+
{ tag: 'picture', attrs: { type, query: 'url' } }
|
468
|
+
]
|
469
|
+
}, timeoutMs);
|
470
|
+
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
|
471
|
+
return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
|
472
|
+
};
|
480
473
|
const sendPresenceUpdate = async (type, toJid) => {
|
481
474
|
const me = authState.creds.me;
|
482
475
|
if (type === 'available' || type === 'unavailable') {
|
@@ -494,10 +487,12 @@ const makeChatsSocket = (config) => {
|
|
494
487
|
});
|
495
488
|
}
|
496
489
|
else {
|
490
|
+
const { server } = (0, WABinary_1.jidDecode)(toJid);
|
491
|
+
const isLid = server === 'lid';
|
497
492
|
await sendNode({
|
498
493
|
tag: 'chatstate',
|
499
494
|
attrs: {
|
500
|
-
from: me.id,
|
495
|
+
from: isLid ? me.lid : me.id,
|
501
496
|
to: toJid,
|
502
497
|
},
|
503
498
|
content: [
|
@@ -833,18 +828,16 @@ const makeChatsSocket = (config) => {
|
|
833
828
|
});
|
834
829
|
return {
|
835
830
|
...sock,
|
836
|
-
interactiveQuery,
|
837
831
|
processingMutex,
|
838
832
|
fetchPrivacySettings,
|
839
833
|
upsertMessage,
|
840
834
|
appPatch,
|
841
|
-
fetchUserLid,
|
842
835
|
sendPresenceUpdate,
|
843
836
|
presenceSubscribe,
|
837
|
+
profilePictureUrl,
|
844
838
|
onWhatsApp,
|
845
839
|
fetchBlocklist,
|
846
840
|
fetchStatus,
|
847
|
-
fetchDisappearingDuration,
|
848
841
|
updateProfilePicture,
|
849
842
|
removeProfilePicture,
|
850
843
|
updateProfileStatus,
|
package/lib/Socket/groups.d.ts
CHANGED
@@ -3,7 +3,6 @@ import { proto } from '../../WAProto';
|
|
3
3
|
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
4
4
|
import { BinaryNode } from '../WABinary';
|
5
5
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
6
|
-
groupQuery: (jid: string, type: 'get' | 'set', content: BinaryNode[]) => Promise<BinaryNode>;
|
7
6
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
8
7
|
groupCreate: (subject: string, participants: string[]) => Promise<GroupMetadata>;
|
9
8
|
groupLeave: (id: string) => Promise<void>;
|
@@ -38,7 +37,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
38
37
|
groupFetchAllParticipating: () => Promise<{
|
39
38
|
[_: string]: GroupMetadata;
|
40
39
|
}>;
|
41
|
-
interactiveQuery: (userNodes: BinaryNode[], queryNode: BinaryNode) => Promise<BinaryNode[]>;
|
42
40
|
processingMutex: {
|
43
41
|
mutex<T>(code: () => T | Promise<T>): Promise<T>;
|
44
42
|
};
|
@@ -47,16 +45,19 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
47
45
|
}>;
|
48
46
|
upsertMessage: (msg: proto.IWebMessageInfo, type: import("../Types").MessageUpsertType) => Promise<void>;
|
49
47
|
appPatch: (patchCreate: import("../Types").WAPatchCreate) => Promise<void>;
|
50
|
-
fetchUserLid: (jid: string) => Promise<string | undefined>;
|
51
48
|
sendPresenceUpdate: (type: import("../Types").WAPresence, toJid?: string | undefined) => Promise<void>;
|
52
49
|
presenceSubscribe: (toJid: string, tcToken?: Buffer | undefined) => Promise<void>;
|
50
|
+
profilePictureUrl: (jid: string, type?: "image" | "preview", timeoutMs?: number | undefined) => Promise<string | undefined>;
|
53
51
|
onWhatsApp: (...jids: string[]) => Promise<{
|
54
52
|
jid: string;
|
55
53
|
exists: unknown;
|
54
|
+
lid: unknown;
|
56
55
|
}[] | undefined>;
|
57
56
|
fetchBlocklist: () => Promise<string[]>;
|
58
|
-
fetchStatus: (
|
59
|
-
|
57
|
+
fetchStatus: (jid: string) => Promise<{
|
58
|
+
status: string | undefined;
|
59
|
+
setAt: Date;
|
60
|
+
} | undefined>;
|
60
61
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
61
62
|
removeProfilePicture: (jid: string) => Promise<void>;
|
62
63
|
updateProfileStatus: (status: string) => Promise<void>;
|
@@ -81,7 +82,6 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
81
82
|
id: string;
|
82
83
|
fromMe?: boolean | undefined;
|
83
84
|
}[], star: boolean) => Promise<void>;
|
84
|
-
executeUSyncQuery: (usyncQuery: import("../index").USyncQuery) => Promise<import("../index").USyncQueryResult | undefined>;
|
85
85
|
type: "md";
|
86
86
|
ws: any;
|
87
87
|
ev: import("../Types").BaileysEventEmitter & {
|
@@ -108,7 +108,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
108
108
|
onUnexpectedError: (err: Error | import("@hapi/boom").Boom<any>, msg: string) => void;
|
109
109
|
uploadPreKeys: (count?: number) => Promise<void>;
|
110
110
|
uploadPreKeysToServerIfRequired: () => Promise<void>;
|
111
|
-
requestPairingCode: (phoneNumber: string
|
111
|
+
requestPairingCode: (phoneNumber: string) => Promise<string>;
|
112
112
|
waitForConnectionUpdate: (check: (u: Partial<import("../Types").ConnectionState>) => boolean | undefined, timeoutMs?: number | undefined) => Promise<void>;
|
113
113
|
sendWAMBuffer: (wamBuffer: Buffer) => Promise<BinaryNode>;
|
114
114
|
};
|
package/lib/Socket/groups.js
CHANGED
@@ -6,6 +6,7 @@ const Types_1 = require("../Types");
|
|
6
6
|
const Utils_1 = require("../Utils");
|
7
7
|
const WABinary_1 = require("../WABinary");
|
8
8
|
const chats_1 = require("./chats");
|
9
|
+
const WAUSync_1 = require("../WAUSync");
|
9
10
|
const makeGroupsSocket = (config) => {
|
10
11
|
const sock = (0, chats_1.makeChatsSocket)(config);
|
11
12
|
const { authState, ev, query, upsertMessage } = sock;
|
@@ -67,7 +68,6 @@ const makeGroupsSocket = (config) => {
|
|
67
68
|
});
|
68
69
|
return {
|
69
70
|
...sock,
|
70
|
-
groupQuery,
|
71
71
|
groupMetadata,
|
72
72
|
groupCreate: async (subject, participants) => {
|
73
73
|
const key = (0, Utils_1.generateMessageID)();
|
@@ -294,10 +294,12 @@ const extractGroupMetadata = (result) => {
|
|
294
294
|
participants: (0, WABinary_1.getBinaryNodeChildren)(group, 'participant').map(({ attrs }) => {
|
295
295
|
return {
|
296
296
|
id: attrs.jid,
|
297
|
+
jid: (0, WABinary_1.isJidUser)(attrs.jid) ? attrs.jid : (0, WABinary_1.jidNormalizedUser)(attrs.phone_number),
|
298
|
+
lid: (0, WABinary_1.isLidUser)(attrs.jid) ? attrs.jid : attrs.lid,
|
297
299
|
admin: (attrs.type || null),
|
298
300
|
};
|
299
301
|
}),
|
300
|
-
ephemeralDuration: eph ? +eph :
|
302
|
+
ephemeralDuration: eph ? +eph : undefined
|
301
303
|
};
|
302
304
|
return metadata;
|
303
305
|
};
|