@queenanya/baileys 7.4.7 → 7.4.13
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 +26 -26
- package/WAProto/index.js +97194 -67957
- package/lib/Defaults/baileys-version.json +1 -1
- package/lib/Defaults/index.d.ts +231 -1
- package/lib/Defaults/index.js +23 -11
- package/lib/Defaults/phonenumber-mcc.json +223 -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 +13 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -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 +22 -29
- package/lib/Socket/chats.d.ts +3 -14
- package/lib/Socket/chats.js +48 -76
- package/lib/Socket/groups.d.ts +4 -21
- package/lib/Socket/groups.js +1 -12
- package/lib/Socket/index.d.ts +32 -37
- package/lib/Socket/index.js +2 -2
- package/lib/Socket/messages-recv.d.ts +22 -28
- package/lib/Socket/messages-recv.js +180 -291
- package/lib/Socket/messages-send.d.ts +13 -23
- package/lib/Socket/messages-send.js +76 -110
- package/lib/Socket/newsletter.d.ts +7 -17
- package/lib/Socket/newsletter.js +54 -67
- package/lib/Socket/registration.d.ts +267 -0
- package/lib/Socket/registration.js +166 -0
- package/lib/Socket/socket.d.ts +1 -3
- package/lib/Socket/socket.js +17 -15
- package/lib/Store/make-cache-manager-store.d.ts +1 -2
- package/lib/Store/make-in-memory-store.js +11 -13
- package/lib/Store/make-ordered-dictionary.js +2 -2
- package/lib/Types/Auth.d.ts +6 -1
- package/lib/Types/Call.d.ts +1 -1
- package/lib/Types/Chat.d.ts +7 -12
- package/lib/Types/Contact.d.ts +1 -1
- package/lib/Types/Events.d.ts +2 -44
- package/lib/Types/GroupMetadata.d.ts +1 -3
- package/lib/Types/Label.d.ts +0 -11
- package/lib/Types/Message.d.ts +30 -37
- package/lib/Types/Newsletter.d.ts +13 -0
- package/lib/Types/Newsletter.js +15 -1
- package/lib/Types/Socket.d.ts +3 -10
- package/lib/Types/index.d.ts +0 -8
- package/lib/Utils/auth-utils.js +7 -1
- package/lib/Utils/chat-utils.d.ts +4 -5
- package/lib/Utils/chat-utils.js +20 -41
- package/lib/Utils/crypto.d.ts +1 -2
- package/lib/Utils/crypto.js +2 -4
- package/lib/Utils/decode-wa-message.d.ts +0 -1
- package/lib/Utils/decode-wa-message.js +14 -34
- package/lib/Utils/event-buffer.js +8 -14
- package/lib/Utils/generics.d.ts +13 -37
- package/lib/Utils/generics.js +18 -102
- package/lib/Utils/history.d.ts +2 -6
- package/lib/Utils/history.js +0 -3
- package/lib/Utils/index.d.ts +0 -1
- package/lib/Utils/index.js +0 -1
- package/lib/Utils/link-preview.js +1 -24
- package/lib/Utils/logger.d.ts +3 -1
- package/lib/Utils/make-mutex.js +0 -1
- package/lib/Utils/messages-media.d.ts +2 -3
- package/lib/Utils/messages-media.js +32 -17
- package/lib/Utils/messages.d.ts +0 -1
- package/lib/Utils/messages.js +72 -67
- package/lib/Utils/noise-handler.d.ts +3 -3
- package/lib/Utils/noise-handler.js +12 -7
- package/lib/Utils/process-message.d.ts +2 -3
- package/lib/Utils/process-message.js +21 -55
- package/lib/Utils/signal.js +16 -23
- package/lib/Utils/use-multi-file-auth-state.js +3 -17
- package/lib/Utils/validate-connection.d.ts +1 -0
- package/lib/Utils/validate-connection.js +44 -10
- package/lib/WABinary/constants.js +5 -5
- package/lib/WABinary/decode.d.ts +2 -3
- package/lib/WABinary/decode.js +4 -6
- package/lib/WABinary/encode.d.ts +2 -1
- package/lib/WABinary/encode.js +6 -8
- package/lib/WABinary/generic-utils.d.ts +0 -1
- package/lib/WABinary/jid-utils.d.ts +3 -3
- package/lib/WABinary/jid-utils.js +5 -5
- package/lib/WAM/BinaryInfo.d.ts +2 -3
- package/lib/WAM/constants.d.ts +2 -3
- package/lib/WAM/encode.d.ts +0 -1
- package/lib/WAM/encode.js +2 -2
- package/package.json +37 -39
- /package/lib/Socket/Client/{types.d.ts → abstract-socket-client.d.ts} +0 -0
- /package/lib/Socket/Client/{types.js → abstract-socket-client.js} +0 -0
package/lib/Socket/business.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
/// <reference types="long" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
1
|
/// <reference types="node" />
|
|
4
2
|
import { GetCatalogOptions, ProductCreate, ProductUpdate, SocketConfig } from '../Types';
|
|
5
3
|
import { BinaryNode } from '../WABinary';
|
|
6
4
|
export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
7
|
-
logger: import("pino").Logger<
|
|
5
|
+
logger: import("pino").Logger<import("pino").LoggerOptions>;
|
|
8
6
|
getOrderDetails: (orderId: string, tokenBase64: string) => Promise<import("../Types").OrderDetails>;
|
|
9
7
|
getCatalog: ({ jid, limit, cursor }: GetCatalogOptions) => Promise<{
|
|
10
8
|
products: import("../Types").Product[];
|
|
@@ -20,28 +18,32 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
20
18
|
productUpdate: (productId: string, update: ProductUpdate) => Promise<import("../Types").Product>;
|
|
21
19
|
sendMessageAck: ({ tag, attrs, content }: BinaryNode) => Promise<void>;
|
|
22
20
|
sendRetryRequest: (node: BinaryNode, forceIncludeKeys?: boolean) => Promise<void>;
|
|
21
|
+
offerCall: (toJid: string, isVideo?: boolean) => Promise<{
|
|
22
|
+
id: string;
|
|
23
|
+
to: string;
|
|
24
|
+
}>;
|
|
23
25
|
rejectCall: (callId: string, callFrom: string) => Promise<void>;
|
|
24
|
-
fetchMessageHistory: (count: number, oldestMsgKey: import("../Types").WAMessageKey, oldestMsgTimestamp: number | import("long").Long) => Promise<string>;
|
|
25
|
-
requestPlaceholderResend: (messageKey: import("../Types").WAMessageKey) => Promise<string | undefined>;
|
|
26
26
|
getPrivacyTokens: (jids: string[]) => Promise<BinaryNode>;
|
|
27
27
|
assertSessions: (jids: string[], force: boolean) => Promise<boolean>;
|
|
28
|
-
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache,
|
|
28
|
+
relayMessage: (jid: string, message: import("../Types").WAProto.IMessage, { messageId: msgId, participant, additionalAttributes, additionalNodes, useUserDevicesCache, cachedGroupMetadata, statusJidList }: import("../Types").MessageRelayOptions) => Promise<string>;
|
|
29
29
|
sendReceipt: (jid: string, participant: string | undefined, messageIds: string[], type: import("../Types").MessageReceiptType) => Promise<void>;
|
|
30
|
-
sendReceipts: (keys: import("../Types").
|
|
31
|
-
|
|
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
35
|
refreshMediaConn: (forceGet?: boolean) => Promise<import("../Types").MediaConnInfo>;
|
|
33
|
-
|
|
34
|
-
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
35
|
-
[_: string]: string;
|
|
36
|
-
}>;
|
|
37
|
-
sendPeerDataOperationMessage: (pdoMessage: import("../Types").WAProto.Message.IPeerDataOperationRequestMessage) => Promise<string>;
|
|
36
|
+
getUSyncDevices: (jids: string[], useCache: boolean, ignoreZeroDevices: boolean) => Promise<import("../WABinary").JidWithDevice[]>;
|
|
38
37
|
createParticipantNodes: (jids: string[], message: import("../Types").WAProto.IMessage, extraAttrs?: {
|
|
39
38
|
[key: string]: string;
|
|
40
39
|
} | undefined) => Promise<{
|
|
41
40
|
nodes: BinaryNode[];
|
|
42
41
|
shouldIncludeDeviceIdentity: boolean;
|
|
43
42
|
}>;
|
|
44
|
-
|
|
43
|
+
waUploadToServer: import("../Types").WAMediaUploadFunction;
|
|
44
|
+
fetchPrivacySettings: (force?: boolean) => Promise<{
|
|
45
|
+
[_: string]: string;
|
|
46
|
+
}>;
|
|
45
47
|
updateMediaMessage: (message: import("../Types").WAProto.IWebMessageInfo) => Promise<import("../Types").WAProto.IWebMessageInfo>;
|
|
46
48
|
sendMessage: (jid: string, content: import("../Types").AnyMessageContent, options?: import("../Types").MiscMessageGenerationOptions) => Promise<import("../Types").WAProto.WebMessageInfo | undefined>;
|
|
47
49
|
subscribeNewsletterUpdates: (jid: string) => Promise<{
|
|
@@ -56,13 +58,14 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
56
58
|
newsletterFollow: (jid: string) => Promise<void>;
|
|
57
59
|
newsletterUnmute: (jid: string) => Promise<void>;
|
|
58
60
|
newsletterMute: (jid: string) => Promise<void>;
|
|
59
|
-
|
|
61
|
+
newsletterAction: (jid: string, type: "mute" | "follow" | "unfollow" | "unmute") => Promise<void>;
|
|
62
|
+
newsletterCreate: (name: string, description: string, reaction_codes: string) => Promise<import("../Types").NewsletterMetadata>;
|
|
60
63
|
newsletterMetadata: (type: "invite" | "jid", key: string, role?: import("../Types").NewsletterViewRole | undefined) => Promise<import("../Types").NewsletterMetadata>;
|
|
61
64
|
newsletterAdminCount: (jid: string) => Promise<number>;
|
|
62
65
|
newsletterChangeOwner: (jid: string, user: string) => Promise<void>;
|
|
63
66
|
newsletterDemote: (jid: string, user: string) => Promise<void>;
|
|
64
67
|
newsletterDelete: (jid: string) => Promise<void>;
|
|
65
|
-
newsletterReactMessage: (jid: string,
|
|
68
|
+
newsletterReactMessage: (jid: string, serverId: string, code?: string | undefined) => Promise<void>;
|
|
66
69
|
newsletterFetchMessages: (type: "invite" | "jid", key: string, count: number, after?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
67
70
|
newsletterFetchUpdates: (jid: string, count: number, after?: number | undefined, since?: number | undefined) => Promise<import("../Types").NewsletterFetchedUpdate[]>;
|
|
68
71
|
groupMetadata: (jid: string) => Promise<import("../Types").GroupMetadata>;
|
|
@@ -85,8 +88,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
85
88
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
86
89
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
87
90
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
88
|
-
|
|
89
|
-
groupAcceptInviteV4: (key: string | import("../Types").WAMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
91
|
+
groupAcceptInviteV4: (key: string | import("../Types").WAProto.IMessageKey, inviteMessage: import("../Types").WAProto.Message.IGroupInviteMessage) => Promise<string>;
|
|
90
92
|
groupGetInviteInfo: (code: string) => Promise<import("../Types").GroupMetadata>;
|
|
91
93
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
92
94
|
groupSettingUpdate: (jid: string, setting: "announcement" | "locked" | "not_announcement" | "unlocked") => Promise<void>;
|
|
@@ -108,35 +110,26 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
108
110
|
jid: string;
|
|
109
111
|
}[]>;
|
|
110
112
|
fetchBlocklist: () => Promise<string[]>;
|
|
111
|
-
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
112
|
-
user: string;
|
|
113
|
-
duration: number;
|
|
114
|
-
setAt: Date;
|
|
115
|
-
}[]>;
|
|
116
113
|
fetchStatus: (jid: string) => Promise<{
|
|
117
114
|
status: string | undefined;
|
|
118
115
|
setAt: Date;
|
|
119
116
|
} | undefined>;
|
|
120
117
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
121
|
-
updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
|
|
122
|
-
updateProfilePictureFull2: (jid: any, content: any) => Promise<void>;
|
|
123
118
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
124
119
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
125
120
|
updateProfileName: (name: string) => Promise<void>;
|
|
126
121
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
127
|
-
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
128
122
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
129
123
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
130
124
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
131
125
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
132
126
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
133
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
127
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
134
128
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
135
129
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
136
130
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
137
131
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
138
132
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
139
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
140
133
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
141
134
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
142
135
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -146,7 +139,7 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
146
139
|
fromMe?: boolean | undefined;
|
|
147
140
|
}[], star: boolean) => Promise<void>;
|
|
148
141
|
type: "md";
|
|
149
|
-
ws:
|
|
142
|
+
ws: any;
|
|
150
143
|
ev: import("../Types").BaileysEventEmitter & {
|
|
151
144
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
152
145
|
buffer(): void;
|
package/lib/Socket/chats.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { Boom } from '@hapi/boom';
|
|
4
3
|
import { proto } from '../../WAProto';
|
|
5
|
-
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence,
|
|
6
|
-
import { LabelActionBody } from '../Types/Label';
|
|
4
|
+
import { ChatModification, MessageUpsertType, SocketConfig, WABusinessProfile, WAMediaUpload, WAPatchCreate, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '../Types';
|
|
7
5
|
import { BinaryNode } from '../WABinary';
|
|
8
6
|
export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
9
7
|
processingMutex: {
|
|
@@ -22,35 +20,26 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
22
20
|
jid: string;
|
|
23
21
|
}[]>;
|
|
24
22
|
fetchBlocklist: () => Promise<string[]>;
|
|
25
|
-
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
26
|
-
user: string;
|
|
27
|
-
duration: number;
|
|
28
|
-
setAt: Date;
|
|
29
|
-
}[]>;
|
|
30
23
|
fetchStatus: (jid: string) => Promise<{
|
|
31
24
|
status: string | undefined;
|
|
32
25
|
setAt: Date;
|
|
33
26
|
} | undefined>;
|
|
34
27
|
updateProfilePicture: (jid: string, content: WAMediaUpload) => Promise<void>;
|
|
35
|
-
updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
|
|
36
|
-
updateProfilePictureFull2: (jid: any, content: any) => Promise<void>;
|
|
37
28
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
38
29
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
39
30
|
updateProfileName: (name: string) => Promise<void>;
|
|
40
31
|
updateBlockStatus: (jid: string, action: 'block' | 'unblock') => Promise<void>;
|
|
41
|
-
updateCallPrivacy: (value: WAPrivacyCallValue) => Promise<void>;
|
|
42
32
|
updateLastSeenPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
43
33
|
updateOnlinePrivacy: (value: WAPrivacyOnlineValue) => Promise<void>;
|
|
44
34
|
updateProfilePicturePrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
45
35
|
updateStatusPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
46
36
|
updateReadReceiptsPrivacy: (value: WAReadReceiptsValue) => Promise<void>;
|
|
47
|
-
updateGroupsAddPrivacy: (value:
|
|
37
|
+
updateGroupsAddPrivacy: (value: WAPrivacyValue) => Promise<void>;
|
|
48
38
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
49
39
|
getBusinessProfile: (jid: string) => Promise<WABusinessProfile | void>;
|
|
50
40
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
51
41
|
chatModify: (mod: ChatModification, jid: string) => Promise<void>;
|
|
52
42
|
cleanDirtyBits: (type: 'account_sync' | 'groups', fromTimestamp?: number | string) => Promise<void>;
|
|
53
|
-
addLabel: (jid: string, labels: LabelActionBody) => Promise<void>;
|
|
54
43
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
55
44
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
56
45
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -60,7 +49,7 @@ export declare const makeChatsSocket: (config: SocketConfig) => {
|
|
|
60
49
|
fromMe?: boolean;
|
|
61
50
|
}[], star: boolean) => Promise<void>;
|
|
62
51
|
type: "md";
|
|
63
|
-
ws:
|
|
52
|
+
ws: any;
|
|
64
53
|
ev: import("../Types").BaileysEventEmitter & {
|
|
65
54
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
66
55
|
buffer(): void;
|
package/lib/Socket/chats.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.makeChatsSocket = void 0;
|
|
7
7
|
const boom_1 = require("@hapi/boom");
|
|
8
|
-
const node_cache_1 = __importDefault(require("node-cache"));
|
|
9
8
|
const WAProto_1 = require("../../WAProto");
|
|
10
9
|
const Defaults_1 = require("../Defaults");
|
|
11
10
|
const Types_1 = require("../Types");
|
|
@@ -24,13 +23,6 @@ const makeChatsSocket = (config) => {
|
|
|
24
23
|
let pendingAppStateSync = false;
|
|
25
24
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
26
25
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
27
|
-
const placeholderResendCache = config.placeholderResendCache || new node_cache_1.default({
|
|
28
|
-
stdTTL: Defaults_1.DEFAULT_CACHE_TTLS.MSG_RETRY,
|
|
29
|
-
useClones: false
|
|
30
|
-
});
|
|
31
|
-
if (!config.placeholderResendCache) {
|
|
32
|
-
config.placeholderResendCache = placeholderResendCache;
|
|
33
|
-
}
|
|
34
26
|
/** helper function to fetch the given app state sync key */
|
|
35
27
|
const getAppStateSyncKey = async (keyId) => {
|
|
36
28
|
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
@@ -74,9 +66,6 @@ const makeChatsSocket = (config) => {
|
|
|
74
66
|
}]
|
|
75
67
|
});
|
|
76
68
|
};
|
|
77
|
-
const updateCallPrivacy = async (value) => {
|
|
78
|
-
await privacyQuery('calladd', value);
|
|
79
|
-
};
|
|
80
69
|
const updateLastSeenPrivacy = async (value) => {
|
|
81
70
|
await privacyQuery('last', value);
|
|
82
71
|
};
|
|
@@ -181,19 +170,6 @@ const makeChatsSocket = (config) => {
|
|
|
181
170
|
};
|
|
182
171
|
}
|
|
183
172
|
};
|
|
184
|
-
/** Fetching The Disappearing Duration of a specific chats by their jids*/
|
|
185
|
-
const fetchDisappearingDuration = async (...jids) => {
|
|
186
|
-
const list = jids.map((jid) => ({ tag: 'user', attrs: { jid } }));
|
|
187
|
-
const results = await interactiveQuery(list, { tag: 'disappearing_mode', attrs: {} });
|
|
188
|
-
return results.map(item => {
|
|
189
|
-
const result = (0, WABinary_1.getBinaryNodeChild)(item, 'disappearing_mode');
|
|
190
|
-
return {
|
|
191
|
-
user: item.attrs.jid,
|
|
192
|
-
duration: parseInt(result === null || result === void 0 ? void 0 : result.attrs.duration),
|
|
193
|
-
setAt: new Date(+((result === null || result === void 0 ? void 0 : result.attrs.t) || 0) * 1000)
|
|
194
|
-
};
|
|
195
|
-
});
|
|
196
|
-
};
|
|
197
173
|
/** update the profile picture for yourself or a group */
|
|
198
174
|
const updateProfilePicture = async (jid, content) => {
|
|
199
175
|
let targetJid;
|
|
@@ -373,9 +349,9 @@ const makeChatsSocket = (config) => {
|
|
|
373
349
|
const email = (0, WABinary_1.getBinaryNodeChild)(profiles, 'email');
|
|
374
350
|
const category = (0, WABinary_1.getBinaryNodeChild)((0, WABinary_1.getBinaryNodeChild)(profiles, 'categories'), 'category');
|
|
375
351
|
const businessHours = (0, WABinary_1.getBinaryNodeChild)(profiles, 'business_hours');
|
|
376
|
-
const businessHoursConfig = businessHours
|
|
377
|
-
|
|
378
|
-
|
|
352
|
+
const businessHoursConfig = businessHours ?
|
|
353
|
+
(0, WABinary_1.getBinaryNodeChildren)(businessHours, 'business_hours_config') :
|
|
354
|
+
undefined;
|
|
379
355
|
const websiteStr = (_a = website === null || website === void 0 ? void 0 : website.content) === null || _a === void 0 ? void 0 : _a.toString();
|
|
380
356
|
return {
|
|
381
357
|
wid: (_b = profiles.attrs) === null || _b === void 0 ? void 0 : _b.jid,
|
|
@@ -484,12 +460,16 @@ const makeChatsSocket = (config) => {
|
|
|
484
460
|
states[name] = newState;
|
|
485
461
|
Object.assign(globalMutationMap, mutationMap);
|
|
486
462
|
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
|
|
487
|
-
await authState.keys.set({ 'app-state-sync-version': {
|
|
463
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
464
|
+
[name]: newState
|
|
465
|
+
} });
|
|
488
466
|
}
|
|
489
467
|
// only process if there are syncd patches
|
|
490
468
|
if (patches.length) {
|
|
491
469
|
const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
|
|
492
|
-
await authState.keys.set({ 'app-state-sync-version': {
|
|
470
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
471
|
+
[name]: newState
|
|
472
|
+
} });
|
|
493
473
|
logger.info(`synced ${name} to v${newState.version}`);
|
|
494
474
|
initialVersionMap[name] = newState.version;
|
|
495
475
|
Object.assign(globalMutationMap, mutationMap);
|
|
@@ -504,11 +484,13 @@ const makeChatsSocket = (config) => {
|
|
|
504
484
|
catch (error) {
|
|
505
485
|
// if retry attempts overshoot
|
|
506
486
|
// or key not found
|
|
507
|
-
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS
|
|
508
|
-
|
|
509
|
-
|
|
487
|
+
const isIrrecoverableError = attemptsMap[name] >= MAX_SYNC_ATTEMPTS ||
|
|
488
|
+
((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404 ||
|
|
489
|
+
error.name === 'TypeError';
|
|
510
490
|
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
|
|
511
|
-
await authState.keys.set({ 'app-state-sync-version': {
|
|
491
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
492
|
+
[name]: null
|
|
493
|
+
} });
|
|
512
494
|
// increment number of retries
|
|
513
495
|
attemptsMap[name] = (attemptsMap[name] || 0) + 1;
|
|
514
496
|
if (isIrrecoverableError) {
|
|
@@ -590,15 +572,15 @@ const makeChatsSocket = (config) => {
|
|
|
590
572
|
id: generateMessageTag(),
|
|
591
573
|
type: 'subscribe'
|
|
592
574
|
},
|
|
593
|
-
content: tcToken
|
|
594
|
-
|
|
575
|
+
content: tcToken ?
|
|
576
|
+
[
|
|
595
577
|
{
|
|
596
578
|
tag: 'tctoken',
|
|
597
579
|
attrs: {},
|
|
598
580
|
content: tcToken
|
|
599
581
|
}
|
|
600
|
-
]
|
|
601
|
-
|
|
582
|
+
] :
|
|
583
|
+
undefined
|
|
602
584
|
}));
|
|
603
585
|
const handlePresenceUpdate = ({ tag, attrs, content }) => {
|
|
604
586
|
var _a;
|
|
@@ -629,7 +611,9 @@ const makeChatsSocket = (config) => {
|
|
|
629
611
|
logger.error({ tag, attrs, content }, 'recv invalid presence node');
|
|
630
612
|
}
|
|
631
613
|
if (presence) {
|
|
632
|
-
ev.emit('presence.update', { id: jid, presences: {
|
|
614
|
+
ev.emit('presence.update', { id: jid, presences: {
|
|
615
|
+
[participant]: presence
|
|
616
|
+
} });
|
|
633
617
|
}
|
|
634
618
|
};
|
|
635
619
|
const appPatch = async (patchCreate) => {
|
|
@@ -680,7 +664,9 @@ const makeChatsSocket = (config) => {
|
|
|
680
664
|
]
|
|
681
665
|
};
|
|
682
666
|
await query(node);
|
|
683
|
-
await authState.keys.set({ 'app-state-sync-version': {
|
|
667
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
668
|
+
[name]: state
|
|
669
|
+
} });
|
|
684
670
|
});
|
|
685
671
|
});
|
|
686
672
|
if (config.emitOwnEvents) {
|
|
@@ -693,7 +679,7 @@ const makeChatsSocket = (config) => {
|
|
|
693
679
|
};
|
|
694
680
|
/** sending non-abt props may fix QR scan fail if server expects */
|
|
695
681
|
const fetchProps = async () => {
|
|
696
|
-
var _a, _b
|
|
682
|
+
var _a, _b;
|
|
697
683
|
const resultNode = await query({
|
|
698
684
|
tag: 'iq',
|
|
699
685
|
attrs: {
|
|
@@ -702,19 +688,20 @@ const makeChatsSocket = (config) => {
|
|
|
702
688
|
type: 'get',
|
|
703
689
|
},
|
|
704
690
|
content: [
|
|
705
|
-
{
|
|
691
|
+
{
|
|
692
|
+
tag: 'props',
|
|
693
|
+
attrs: {
|
|
706
694
|
protocol: '2',
|
|
707
695
|
hash: ((_a = authState === null || authState === void 0 ? void 0 : authState.creds) === null || _a === void 0 ? void 0 : _a.lastPropHash) || ''
|
|
708
|
-
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
709
698
|
]
|
|
710
699
|
});
|
|
711
700
|
const propsNode = (0, WABinary_1.getBinaryNodeChild)(resultNode, 'props');
|
|
712
701
|
let props = {};
|
|
713
702
|
if (propsNode) {
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
ev.emit('creds.update', authState.creds);
|
|
717
|
-
}
|
|
703
|
+
authState.creds.lastPropHash = (_b = propsNode === null || propsNode === void 0 ? void 0 : propsNode.attrs) === null || _b === void 0 ? void 0 : _b.hash;
|
|
704
|
+
ev.emit('creds.update', authState.creds);
|
|
718
705
|
props = (0, WABinary_1.reduceBinaryNodeToDictionary)(propsNode, 'prop');
|
|
719
706
|
}
|
|
720
707
|
logger.debug('fetched props');
|
|
@@ -724,7 +711,7 @@ const makeChatsSocket = (config) => {
|
|
|
724
711
|
* modify a chat -- mark unread, read etc.
|
|
725
712
|
* lastMessages must be sorted in reverse chronologically
|
|
726
713
|
* requires the last messages till the last message received; required for archive & unread
|
|
727
|
-
|
|
714
|
+
*/
|
|
728
715
|
const chatModify = (mod, jid) => {
|
|
729
716
|
const patch = (0, Utils_1.chatModificationToAppPatch)(mod, jid);
|
|
730
717
|
return appPatch(patch);
|
|
@@ -740,16 +727,6 @@ const makeChatsSocket = (config) => {
|
|
|
740
727
|
}
|
|
741
728
|
}, jid);
|
|
742
729
|
};
|
|
743
|
-
/**
|
|
744
|
-
* Adds label
|
|
745
|
-
*/
|
|
746
|
-
const addLabel = (jid, labels) => {
|
|
747
|
-
return chatModify({
|
|
748
|
-
addLabel: {
|
|
749
|
-
...labels
|
|
750
|
-
}
|
|
751
|
-
}, jid);
|
|
752
|
-
};
|
|
753
730
|
/**
|
|
754
731
|
* Adds label for the chats
|
|
755
732
|
*/
|
|
@@ -818,25 +795,24 @@ const makeChatsSocket = (config) => {
|
|
|
818
795
|
}
|
|
819
796
|
}
|
|
820
797
|
const historyMsg = (0, Utils_1.getHistoryMsg)(msg.message);
|
|
821
|
-
const shouldProcessHistoryMsg = historyMsg
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
798
|
+
const shouldProcessHistoryMsg = historyMsg ?
|
|
799
|
+
(shouldSyncHistoryMessage(historyMsg) &&
|
|
800
|
+
Defaults_1.PROCESSABLE_HISTORY_TYPES.includes(historyMsg.syncType)) :
|
|
801
|
+
false;
|
|
825
802
|
if (historyMsg && !authState.creds.myAppStateKeyId) {
|
|
826
803
|
logger.warn('skipping app state sync, as myAppStateKeyId is not set');
|
|
827
804
|
pendingAppStateSync = true;
|
|
828
805
|
}
|
|
829
806
|
await Promise.all([
|
|
830
807
|
(async () => {
|
|
831
|
-
if (historyMsg
|
|
832
|
-
|
|
808
|
+
if (historyMsg &&
|
|
809
|
+
authState.creds.myAppStateKeyId) {
|
|
833
810
|
pendingAppStateSync = false;
|
|
834
811
|
await doAppStateSync();
|
|
835
812
|
}
|
|
836
813
|
})(),
|
|
837
814
|
(0, process_message_1.default)(msg, {
|
|
838
815
|
shouldProcessHistoryMsg,
|
|
839
|
-
placeholderResendCache,
|
|
840
816
|
ev,
|
|
841
817
|
creds: authState.creds,
|
|
842
818
|
keyStore: authState.keys,
|
|
@@ -845,8 +821,8 @@ const makeChatsSocket = (config) => {
|
|
|
845
821
|
getMessage: config.getMessage,
|
|
846
822
|
})
|
|
847
823
|
]);
|
|
848
|
-
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare)
|
|
849
|
-
|
|
824
|
+
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare) &&
|
|
825
|
+
pendingAppStateSync) {
|
|
850
826
|
await doAppStateSync();
|
|
851
827
|
pendingAppStateSync = false;
|
|
852
828
|
}
|
|
@@ -897,13 +873,14 @@ const makeChatsSocket = (config) => {
|
|
|
897
873
|
sendPresenceUpdate(markOnlineOnConnect ? 'available' : 'unavailable')
|
|
898
874
|
.catch(error => onUnexpectedError(error, 'presence update requests'));
|
|
899
875
|
}
|
|
900
|
-
if (receivedPendingNotifications
|
|
876
|
+
if (receivedPendingNotifications) {
|
|
877
|
+
// if we don't have the app state key
|
|
901
878
|
// we keep buffering events until we finally have
|
|
902
879
|
// the key and can sync the messages
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
880
|
+
if (!((_a = authState.creds) === null || _a === void 0 ? void 0 : _a.myAppStateKeyId) && !config.mobile) {
|
|
881
|
+
ev.buffer();
|
|
882
|
+
needToFlushWithAppStateSync = true;
|
|
883
|
+
}
|
|
907
884
|
}
|
|
908
885
|
});
|
|
909
886
|
return {
|
|
@@ -917,16 +894,12 @@ const makeChatsSocket = (config) => {
|
|
|
917
894
|
profilePictureUrl,
|
|
918
895
|
onWhatsApp,
|
|
919
896
|
fetchBlocklist,
|
|
920
|
-
fetchDisappearingDuration,
|
|
921
897
|
fetchStatus,
|
|
922
898
|
updateProfilePicture,
|
|
923
|
-
updateProfilePictureFull,
|
|
924
|
-
updateProfilePictureFull2,
|
|
925
899
|
removeProfilePicture,
|
|
926
900
|
updateProfileStatus,
|
|
927
901
|
updateProfileName,
|
|
928
902
|
updateBlockStatus,
|
|
929
|
-
updateCallPrivacy,
|
|
930
903
|
updateLastSeenPrivacy,
|
|
931
904
|
updateOnlinePrivacy,
|
|
932
905
|
updateProfilePicturePrivacy,
|
|
@@ -938,7 +911,6 @@ const makeChatsSocket = (config) => {
|
|
|
938
911
|
resyncAppState,
|
|
939
912
|
chatModify,
|
|
940
913
|
cleanDirtyBits,
|
|
941
|
-
addLabel,
|
|
942
914
|
addChatLabel,
|
|
943
915
|
removeChatLabel,
|
|
944
916
|
addMessageLabel,
|
package/lib/Socket/groups.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
2
|
import { proto } from '../../WAProto';
|
|
4
|
-
import { GroupMetadata, ParticipantAction, SocketConfig
|
|
3
|
+
import { GroupMetadata, ParticipantAction, SocketConfig } from '../Types';
|
|
5
4
|
import { BinaryNode } from '../WABinary';
|
|
6
5
|
export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
7
6
|
groupMetadata: (jid: string) => Promise<GroupMetadata>;
|
|
@@ -24,19 +23,12 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
24
23
|
groupInviteCode: (jid: string) => Promise<string | undefined>;
|
|
25
24
|
groupRevokeInvite: (jid: string) => Promise<string | undefined>;
|
|
26
25
|
groupAcceptInvite: (code: string) => Promise<string | undefined>;
|
|
27
|
-
/**
|
|
28
|
-
* revoke a v4 invite for someone
|
|
29
|
-
* @param groupJid group jid
|
|
30
|
-
* @param invitedJid jid of person you invited
|
|
31
|
-
* @returns true if successful
|
|
32
|
-
*/
|
|
33
|
-
groupRevokeInviteV4: (groupJid: string, invitedJid: string) => Promise<boolean>;
|
|
34
26
|
/**
|
|
35
27
|
* accept a GroupInviteMessage
|
|
36
28
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
37
29
|
* @param inviteMessage the message to accept
|
|
38
30
|
*/
|
|
39
|
-
groupAcceptInviteV4: (key: string |
|
|
31
|
+
groupAcceptInviteV4: (key: string | proto.IMessageKey, inviteMessage: proto.Message.IGroupInviteMessage) => Promise<string>;
|
|
40
32
|
groupGetInviteInfo: (code: string) => Promise<GroupMetadata>;
|
|
41
33
|
groupToggleEphemeral: (jid: string, ephemeralExpiration: number) => Promise<void>;
|
|
42
34
|
groupSettingUpdate: (jid: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked') => Promise<void>;
|
|
@@ -61,35 +53,26 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
61
53
|
jid: string;
|
|
62
54
|
}[]>;
|
|
63
55
|
fetchBlocklist: () => Promise<string[]>;
|
|
64
|
-
fetchDisappearingDuration: (...jids: string[]) => Promise<{
|
|
65
|
-
user: string;
|
|
66
|
-
duration: number;
|
|
67
|
-
setAt: Date;
|
|
68
|
-
}[]>;
|
|
69
56
|
fetchStatus: (jid: string) => Promise<{
|
|
70
57
|
status: string | undefined;
|
|
71
58
|
setAt: Date;
|
|
72
59
|
} | undefined>;
|
|
73
60
|
updateProfilePicture: (jid: string, content: import("../Types").WAMediaUpload) => Promise<void>;
|
|
74
|
-
updateProfilePictureFull: (jid: any, content: any) => Promise<void>;
|
|
75
|
-
updateProfilePictureFull2: (jid: any, content: any) => Promise<void>;
|
|
76
61
|
removeProfilePicture: (jid: string) => Promise<void>;
|
|
77
62
|
updateProfileStatus: (status: string) => Promise<void>;
|
|
78
63
|
updateProfileName: (name: string) => Promise<void>;
|
|
79
64
|
updateBlockStatus: (jid: string, action: "block" | "unblock") => Promise<void>;
|
|
80
|
-
updateCallPrivacy: (value: import("../Types").WAPrivacyCallValue) => Promise<void>;
|
|
81
65
|
updateLastSeenPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
82
66
|
updateOnlinePrivacy: (value: import("../Types").WAPrivacyOnlineValue) => Promise<void>;
|
|
83
67
|
updateProfilePicturePrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
84
68
|
updateStatusPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
85
69
|
updateReadReceiptsPrivacy: (value: import("../Types").WAReadReceiptsValue) => Promise<void>;
|
|
86
|
-
updateGroupsAddPrivacy: (value: import("../Types").
|
|
70
|
+
updateGroupsAddPrivacy: (value: import("../Types").WAPrivacyValue) => Promise<void>;
|
|
87
71
|
updateDefaultDisappearingMode: (duration: number) => Promise<void>;
|
|
88
72
|
getBusinessProfile: (jid: string) => Promise<void | import("../Types").WABusinessProfile>;
|
|
89
73
|
resyncAppState: (collections: readonly ("critical_block" | "critical_unblock_low" | "regular_high" | "regular_low" | "regular")[], isInitialSync: boolean) => Promise<void>;
|
|
90
74
|
chatModify: (mod: import("../Types").ChatModification, jid: string) => Promise<void>;
|
|
91
75
|
cleanDirtyBits: (type: "account_sync" | "groups", fromTimestamp?: string | number | undefined) => Promise<void>;
|
|
92
|
-
addLabel: (jid: string, labels: import("../Types/Label").LabelActionBody) => Promise<void>;
|
|
93
76
|
addChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
94
77
|
removeChatLabel: (jid: string, labelId: string) => Promise<void>;
|
|
95
78
|
addMessageLabel: (jid: string, messageId: string, labelId: string) => Promise<void>;
|
|
@@ -99,7 +82,7 @@ export declare const makeGroupsSocket: (config: SocketConfig) => {
|
|
|
99
82
|
fromMe?: boolean | undefined;
|
|
100
83
|
}[], star: boolean) => Promise<void>;
|
|
101
84
|
type: "md";
|
|
102
|
-
ws:
|
|
85
|
+
ws: any;
|
|
103
86
|
ev: import("../Types").BaileysEventEmitter & {
|
|
104
87
|
process(handler: (events: Partial<import("../Types").BaileysEventMap>) => void | Promise<void>): () => void;
|
|
105
88
|
buffer(): void;
|
package/lib/Socket/groups.js
CHANGED
|
@@ -187,23 +187,12 @@ const makeGroupsSocket = (config) => {
|
|
|
187
187
|
const result = (0, WABinary_1.getBinaryNodeChild)(results, 'group');
|
|
188
188
|
return result === null || result === void 0 ? void 0 : result.attrs.jid;
|
|
189
189
|
},
|
|
190
|
-
/**
|
|
191
|
-
* revoke a v4 invite for someone
|
|
192
|
-
* @param groupJid group jid
|
|
193
|
-
* @param invitedJid jid of person you invited
|
|
194
|
-
* @returns true if successful
|
|
195
|
-
*/
|
|
196
|
-
groupRevokeInviteV4: async (groupJid, invitedJid) => {
|
|
197
|
-
const result = await groupQuery(groupJid, 'set', [{ tag: 'revoke', attrs: {}, content: [{ tag: 'participant', attrs: { jid: invitedJid } }] }]);
|
|
198
|
-
return !!result;
|
|
199
|
-
},
|
|
200
190
|
/**
|
|
201
191
|
* accept a GroupInviteMessage
|
|
202
192
|
* @param key the key of the invite message, or optionally only provide the jid of the person who sent the invite
|
|
203
193
|
* @param inviteMessage the message to accept
|
|
204
194
|
*/
|
|
205
195
|
groupAcceptInviteV4: ev.createBufferedFunction(async (key, inviteMessage) => {
|
|
206
|
-
var _a;
|
|
207
196
|
key = typeof key === 'string' ? { remoteJid: key } : key;
|
|
208
197
|
const results = await groupQuery(inviteMessage.groupJid, 'set', [{
|
|
209
198
|
tag: 'accept',
|
|
@@ -235,7 +224,7 @@ const makeGroupsSocket = (config) => {
|
|
|
235
224
|
await upsertMessage({
|
|
236
225
|
key: {
|
|
237
226
|
remoteJid: inviteMessage.groupJid,
|
|
238
|
-
id: (0, Utils_1.
|
|
227
|
+
id: (0, Utils_1.generateMessageID)(),
|
|
239
228
|
fromMe: false,
|
|
240
229
|
participant: key.remoteJid,
|
|
241
230
|
},
|