gifted-baileys 1.5.6 → 1.5.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/README.md +9 -0
- package/WAProto/WAProto.proto +969 -88
- package/WAProto/index.d.ts +13199 -1260
- package/WAProto/index.js +124901 -74525
- package/lib/Defaults/baileys-version.json +3 -0
- package/lib/Defaults/index.d.ts +284 -0
- package/{src → lib}/Defaults/index.js +7 -14
- package/lib/Signal/libsignal.d.ts +3 -0
- package/lib/Signal/libsignal.js +161 -0
- package/lib/Socket/Client/abstract-socket-client.d.ts +15 -0
- package/lib/Socket/Client/index.d.ts +2 -0
- package/{src → lib}/Socket/Client/index.js +2 -3
- package/lib/Socket/Client/mobile-socket-client.d.ts +12 -0
- package/lib/Socket/Client/mobile-socket-client.js +65 -0
- package/lib/Socket/Client/types.d.ts +17 -0
- package/lib/Socket/Client/types.js +13 -0
- package/lib/Socket/Client/websocket.d.ts +12 -0
- package/lib/Socket/Client/websocket.js +62 -0
- package/lib/Socket/business.d.ts +170 -0
- package/{src → lib}/Socket/business.js +28 -33
- package/lib/Socket/chats.d.ts +81 -0
- package/{src → lib}/Socket/chats.js +174 -176
- package/lib/Socket/groups.d.ts +115 -0
- package/{src → lib}/Socket/groups.js +80 -68
- package/lib/Socket/index.d.ts +172 -0
- package/{src → lib}/Socket/index.js +4 -1
- package/lib/Socket/messages-recv.d.ts +158 -0
- package/{src → lib}/Socket/messages-recv.js +378 -211
- package/lib/Socket/messages-send.d.ts +155 -0
- package/{src → lib}/Socket/messages-send.js +452 -177
- package/lib/Socket/newsletter.d.ts +132 -0
- package/{src → lib}/Socket/newsletter.js +107 -98
- package/lib/Socket/registration.d.ts +264 -0
- package/{src → lib}/Socket/registration.js +56 -48
- package/lib/Socket/socket.d.ts +44 -0
- package/{src → lib}/Socket/socket.js +77 -77
- package/lib/Socket/usync.d.ts +37 -0
- package/lib/Socket/usync.js +70 -0
- package/lib/Store/index.d.ts +3 -0
- package/lib/Store/make-cache-manager-store.d.ts +14 -0
- package/{src → lib}/Store/make-cache-manager-store.js +25 -34
- package/lib/Store/make-in-memory-store.d.ts +118 -0
- package/{src → lib}/Store/make-in-memory-store.js +36 -32
- package/lib/Store/make-ordered-dictionary.d.ts +13 -0
- package/lib/Store/object-repository.d.ts +10 -0
- package/{src → lib}/Store/object-repository.js +1 -1
- package/lib/Types/Auth.d.ts +109 -0
- package/lib/Types/Call.d.ts +13 -0
- package/lib/Types/Chat.d.ts +107 -0
- package/{src/Types/Contact.ts → lib/Types/Contact.d.ts} +8 -9
- package/lib/Types/Events.d.ts +172 -0
- package/lib/Types/GroupMetadata.d.ts +56 -0
- package/lib/Types/Label.d.ts +46 -0
- package/{src/Types/LabelAssociation.ts → lib/Types/LabelAssociation.d.ts} +16 -22
- package/lib/Types/Message.d.ts +433 -0
- package/lib/Types/Newsletter.d.ts +92 -0
- package/lib/Types/Product.d.ts +78 -0
- package/lib/Types/Signal.d.ts +57 -0
- package/{src/Types/Socket.ts → lib/Types/Socket.d.ts} +61 -68
- package/lib/Types/State.d.ts +27 -0
- package/lib/Types/USync.d.ts +25 -0
- package/lib/Types/index.d.ts +66 -0
- package/lib/Utils/auth-utils.d.ts +18 -0
- package/{src → lib}/Utils/auth-utils.js +73 -90
- package/lib/Utils/baileys-event-stream.d.ts +16 -0
- package/lib/Utils/baileys-event-stream.js +63 -0
- package/lib/Utils/business.d.ts +22 -0
- package/{src → lib}/Utils/business.js +15 -43
- package/lib/Utils/chat-utils.d.ts +70 -0
- package/{src → lib}/Utils/chat-utils.js +87 -94
- package/lib/Utils/crypto.d.ts +40 -0
- package/{src → lib}/Utils/crypto.js +4 -2
- package/lib/Utils/decode-wa-message.d.ts +36 -0
- package/lib/Utils/decode-wa-message.js +226 -0
- package/lib/Utils/event-buffer.d.ts +35 -0
- package/{src → lib}/Utils/event-buffer.js +4 -13
- package/lib/Utils/generics.d.ts +88 -0
- package/{src → lib}/Utils/generics.js +67 -86
- package/lib/Utils/history.d.ts +19 -0
- package/{src → lib}/Utils/history.js +13 -39
- package/lib/Utils/index.d.ts +17 -0
- package/lib/Utils/link-preview.d.ts +21 -0
- package/{src → lib}/Utils/link-preview.js +17 -54
- package/lib/Utils/logger.d.ts +2 -0
- package/lib/Utils/lt-hash.d.ts +12 -0
- package/lib/Utils/make-mutex.d.ts +7 -0
- package/{src → lib}/Utils/make-mutex.js +4 -13
- package/lib/Utils/messages-media.d.ts +113 -0
- package/{src → lib}/Utils/messages-media.js +193 -255
- package/lib/Utils/messages.d.ts +77 -0
- package/{src → lib}/Utils/messages.js +588 -118
- package/lib/Utils/noise-handler.d.ts +20 -0
- package/lib/Utils/process-message.d.ts +41 -0
- package/{src → lib}/Utils/process-message.js +27 -30
- package/lib/Utils/signal.d.ts +33 -0
- package/{src → lib}/Utils/signal.js +25 -42
- package/lib/Utils/use-multi-file-auth-state.d.ts +12 -0
- package/{src → lib}/Utils/use-multi-file-auth-state.js +27 -28
- package/lib/Utils/validate-connection.d.ts +11 -0
- package/{src → lib}/Utils/validate-connection.js +40 -9
- package/lib/WABinary/constants.d.ts +27 -0
- package/lib/WABinary/decode.d.ts +6 -0
- package/lib/WABinary/encode.d.ts +2 -0
- package/{src → lib}/WABinary/encode.js +16 -10
- package/lib/WABinary/generic-utils.d.ts +14 -0
- package/lib/WABinary/index.d.ts +5 -0
- package/lib/WABinary/jid-utils.d.ts +31 -0
- package/lib/WABinary/types.d.ts +18 -0
- package/lib/WABinary/types.js +2 -0
- package/lib/WAM/BinaryInfo.d.ts +8 -0
- package/lib/WAM/constants.d.ts +38 -0
- package/lib/WAM/encode.d.ts +2 -0
- package/lib/WAM/index.d.ts +3 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.d.ts +9 -0
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +32 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.d.ts +22 -0
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +57 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +30 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.d.ts +12 -0
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +42 -0
- package/lib/WAUSync/Protocols/index.d.ts +4 -0
- package/lib/WAUSync/Protocols/index.js +20 -0
- package/lib/WAUSync/USyncQuery.d.ts +26 -0
- package/lib/WAUSync/USyncQuery.js +79 -0
- package/lib/WAUSync/USyncUser.d.ts +10 -0
- package/lib/WAUSync/USyncUser.js +22 -0
- package/lib/WAUSync/index.d.ts +3 -0
- package/lib/WAUSync/index.js +19 -0
- package/{src → lib}/index.js +1 -0
- package/package.json +26 -8
- package/LICENSE +0 -21
- package/src/Defaults/baileys-version.json +0 -3
- package/src/Defaults/index.ts +0 -131
- package/src/README.md +0 -1
- package/src/Signal/libsignal.js +0 -180
- package/src/Signal/libsignal.ts +0 -141
- package/src/Socket/Client/abstract-socket-client.ts +0 -19
- package/src/Socket/Client/index.ts +0 -3
- package/src/Socket/Client/mobile-socket-client.js +0 -78
- package/src/Socket/Client/mobile-socket-client.ts +0 -66
- package/src/Socket/Client/web-socket-client.js +0 -75
- package/src/Socket/Client/web-socket-client.ts +0 -57
- package/src/Socket/business.ts +0 -281
- package/src/Socket/chats.ts +0 -1030
- package/src/Socket/groups.ts +0 -356
- package/src/Socket/index.ts +0 -13
- package/src/Socket/messages-recv.ts +0 -985
- package/src/Socket/messages-send.ts +0 -871
- package/src/Socket/newsletter.ts +0 -282
- package/src/Socket/registration.ts +0 -250
- package/src/Socket/socket.ts +0 -777
- package/src/Store/index.ts +0 -3
- package/src/Store/make-cache-manager-store.ts +0 -100
- package/src/Store/make-in-memory-store.ts +0 -475
- package/src/Store/make-ordered-dictionary.ts +0 -86
- package/src/Store/object-repository.ts +0 -32
- package/src/Tests/test.app-state-sync.js +0 -204
- package/src/Tests/test.app-state-sync.ts +0 -207
- package/src/Tests/test.event-buffer.js +0 -270
- package/src/Tests/test.event-buffer.ts +0 -319
- package/src/Tests/test.key-store.js +0 -76
- package/src/Tests/test.key-store.ts +0 -92
- package/src/Tests/test.libsignal.js +0 -141
- package/src/Tests/test.libsignal.ts +0 -186
- package/src/Tests/test.media-download.js +0 -93
- package/src/Tests/test.media-download.ts +0 -76
- package/src/Tests/test.messages.js +0 -33
- package/src/Tests/test.messages.ts +0 -37
- package/src/Tests/utils.js +0 -34
- package/src/Tests/utils.ts +0 -36
- package/src/Types/Auth.ts +0 -113
- package/src/Types/Call.ts +0 -15
- package/src/Types/Chat.ts +0 -106
- package/src/Types/Events.ts +0 -93
- package/src/Types/GroupMetadata.ts +0 -53
- package/src/Types/Label.ts +0 -36
- package/src/Types/Message.ts +0 -288
- package/src/Types/Newsletter.ts +0 -98
- package/src/Types/Product.ts +0 -85
- package/src/Types/Signal.ts +0 -68
- package/src/Types/State.ts +0 -29
- package/src/Types/index.ts +0 -59
- package/src/Utils/auth-utils.ts +0 -222
- package/src/Utils/baileys-event-stream.js +0 -92
- package/src/Utils/baileys-event-stream.ts +0 -66
- package/src/Utils/business.ts +0 -275
- package/src/Utils/chat-utils.ts +0 -860
- package/src/Utils/crypto.ts +0 -131
- package/src/Utils/decode-wa-message.js +0 -211
- package/src/Utils/decode-wa-message.ts +0 -228
- package/src/Utils/event-buffer.ts +0 -613
- package/src/Utils/generics.ts +0 -434
- package/src/Utils/history.ts +0 -112
- package/src/Utils/index.ts +0 -17
- package/src/Utils/link-preview.ts +0 -122
- package/src/Utils/logger.ts +0 -3
- package/src/Utils/lt-hash.ts +0 -61
- package/src/Utils/make-mutex.ts +0 -44
- package/src/Utils/messages-media.ts +0 -847
- package/src/Utils/messages.ts +0 -956
- package/src/Utils/noise-handler.ts +0 -197
- package/src/Utils/process-message.ts +0 -414
- package/src/Utils/signal.ts +0 -177
- package/src/Utils/use-multi-file-auth-state.ts +0 -90
- package/src/Utils/validate-connection.ts +0 -238
- package/src/WABinary/constants.ts +0 -42
- package/src/WABinary/decode.ts +0 -265
- package/src/WABinary/encode.ts +0 -236
- package/src/WABinary/generic-utils.ts +0 -121
- package/src/WABinary/index.ts +0 -5
- package/src/WABinary/jid-utils.ts +0 -68
- package/src/WABinary/types.ts +0 -17
- package/src/WAM/BinaryInfo.ts +0 -12
- package/src/WAM/constants.ts +0 -15382
- package/src/WAM/encode.ts +0 -174
- package/src/WAM/index.ts +0 -3
- package/src/gifted +0 -1
- package/src/index.ts +0 -13
- /package/{src → lib}/Defaults/phonenumber-mcc.json +0 -0
- /package/{src → lib}/Socket/Client/abstract-socket-client.js +0 -0
- /package/{src → lib}/Store/index.js +0 -0
- /package/{src → lib}/Store/make-ordered-dictionary.js +0 -0
- /package/{src → lib}/Types/Auth.js +0 -0
- /package/{src → lib}/Types/Call.js +0 -0
- /package/{src → lib}/Types/Chat.js +0 -0
- /package/{src → lib}/Types/Contact.js +0 -0
- /package/{src → lib}/Types/Events.js +0 -0
- /package/{src → lib}/Types/GroupMetadata.js +0 -0
- /package/{src → lib}/Types/Label.js +0 -0
- /package/{src → lib}/Types/LabelAssociation.js +0 -0
- /package/{src → lib}/Types/Message.js +0 -0
- /package/{src → lib}/Types/Newsletter.js +0 -0
- /package/{src → lib}/Types/Product.js +0 -0
- /package/{src → lib}/Types/Signal.js +0 -0
- /package/{src → lib}/Types/Socket.js +0 -0
- /package/{src → lib}/Types/State.js +0 -0
- /package/{src/WABinary/types.js → lib/Types/USync.js} +0 -0
- /package/{src → lib}/Types/index.js +0 -0
- /package/{src → lib}/Utils/index.js +0 -0
- /package/{src → lib}/Utils/logger.js +0 -0
- /package/{src → lib}/Utils/lt-hash.js +0 -0
- /package/{src → lib}/Utils/noise-handler.js +0 -0
- /package/{src → lib}/WABinary/constants.js +0 -0
- /package/{src → lib}/WABinary/decode.js +0 -0
- /package/{src → lib}/WABinary/generic-utils.js +0 -0
- /package/{src → lib}/WABinary/index.js +0 -0
- /package/{src → lib}/WABinary/jid-utils.js +0 -0
- /package/{src → lib}/WAM/BinaryInfo.js +0 -0
- /package/{src → lib}/WAM/constants.js +0 -0
- /package/{src → lib}/WAM/encode.js +0 -0
- /package/{src → lib}/WAM/index.js +0 -0
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -21,25 +12,26 @@ const Utils_1 = require("../Utils");
|
|
|
21
12
|
const make_mutex_1 = require("../Utils/make-mutex");
|
|
22
13
|
const process_message_1 = __importDefault(require("../Utils/process-message"));
|
|
23
14
|
const WABinary_1 = require("../WABinary");
|
|
24
|
-
const
|
|
15
|
+
const WAUSync_1 = require("../WAUSync");
|
|
16
|
+
const usync_1 = require("./usync");
|
|
25
17
|
const MAX_SYNC_ATTEMPTS = 2;
|
|
26
18
|
const makeChatsSocket = (config) => {
|
|
27
19
|
const { logger, markOnlineOnConnect, fireInitQueries, appStateMacVerification, shouldIgnoreJid, shouldSyncHistoryMessage, } = config;
|
|
28
|
-
const sock = (0,
|
|
29
|
-
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError
|
|
20
|
+
const sock = (0, usync_1.makeUSyncSocket)(config);
|
|
21
|
+
const { ev, ws, authState, generateMessageTag, sendNode, query, onUnexpectedError } = sock;
|
|
30
22
|
let privacySettings;
|
|
31
23
|
let needToFlushWithAppStateSync = false;
|
|
32
24
|
let pendingAppStateSync = false;
|
|
33
25
|
/** this mutex ensures that the notifications (receipts, messages etc.) are processed in order */
|
|
34
26
|
const processingMutex = (0, make_mutex_1.makeMutex)();
|
|
35
27
|
/** helper function to fetch the given app state sync key */
|
|
36
|
-
const getAppStateSyncKey = (keyId) =>
|
|
37
|
-
const { [keyId]: key } =
|
|
28
|
+
const getAppStateSyncKey = async (keyId) => {
|
|
29
|
+
const { [keyId]: key } = await authState.keys.get('app-state-sync-key', [keyId]);
|
|
38
30
|
return key;
|
|
39
|
-
}
|
|
40
|
-
const fetchPrivacySettings =
|
|
31
|
+
};
|
|
32
|
+
const fetchPrivacySettings = async (force = false) => {
|
|
41
33
|
if (!privacySettings || force) {
|
|
42
|
-
const { content } =
|
|
34
|
+
const { content } = await query({
|
|
43
35
|
tag: 'iq',
|
|
44
36
|
attrs: {
|
|
45
37
|
xmlns: 'privacy',
|
|
@@ -53,10 +45,10 @@ const makeChatsSocket = (config) => {
|
|
|
53
45
|
privacySettings = (0, WABinary_1.reduceBinaryNodeToDictionary)(content === null || content === void 0 ? void 0 : content[0], 'category');
|
|
54
46
|
}
|
|
55
47
|
return privacySettings;
|
|
56
|
-
}
|
|
48
|
+
};
|
|
57
49
|
/** helper function to run a privacy IQ query */
|
|
58
|
-
const privacyQuery = (name, value) =>
|
|
59
|
-
|
|
50
|
+
const privacyQuery = async (name, value) => {
|
|
51
|
+
await query({
|
|
60
52
|
tag: 'iq',
|
|
61
53
|
attrs: {
|
|
62
54
|
xmlns: 'privacy',
|
|
@@ -74,27 +66,27 @@ const makeChatsSocket = (config) => {
|
|
|
74
66
|
]
|
|
75
67
|
}]
|
|
76
68
|
});
|
|
77
|
-
}
|
|
78
|
-
const updateLastSeenPrivacy = (value) =>
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
const updateOnlinePrivacy = (value) =>
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
const updateProfilePicturePrivacy = (value) =>
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
const updateStatusPrivacy = (value) =>
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
const updateReadReceiptsPrivacy = (value) =>
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
const updateGroupsAddPrivacy = (value) =>
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
const updateDefaultDisappearingMode = (duration) =>
|
|
97
|
-
|
|
69
|
+
};
|
|
70
|
+
const updateLastSeenPrivacy = async (value) => {
|
|
71
|
+
await privacyQuery('last', value);
|
|
72
|
+
};
|
|
73
|
+
const updateOnlinePrivacy = async (value) => {
|
|
74
|
+
await privacyQuery('online', value);
|
|
75
|
+
};
|
|
76
|
+
const updateProfilePicturePrivacy = async (value) => {
|
|
77
|
+
await privacyQuery('profile', value);
|
|
78
|
+
};
|
|
79
|
+
const updateStatusPrivacy = async (value) => {
|
|
80
|
+
await privacyQuery('status', value);
|
|
81
|
+
};
|
|
82
|
+
const updateReadReceiptsPrivacy = async (value) => {
|
|
83
|
+
await privacyQuery('readreceipts', value);
|
|
84
|
+
};
|
|
85
|
+
const updateGroupsAddPrivacy = async (value) => {
|
|
86
|
+
await privacyQuery('groupadd', value);
|
|
87
|
+
};
|
|
88
|
+
const updateDefaultDisappearingMode = async (duration) => {
|
|
89
|
+
await query({
|
|
98
90
|
tag: 'iq',
|
|
99
91
|
attrs: {
|
|
100
92
|
xmlns: 'disappearing_mode',
|
|
@@ -108,10 +100,10 @@ const makeChatsSocket = (config) => {
|
|
|
108
100
|
}
|
|
109
101
|
}]
|
|
110
102
|
});
|
|
111
|
-
}
|
|
103
|
+
};
|
|
112
104
|
/** helper function to run a generic IQ query */
|
|
113
|
-
const interactiveQuery = (userNodes, queryNode) =>
|
|
114
|
-
const result =
|
|
105
|
+
const interactiveQuery = async (userNodes, queryNode) => {
|
|
106
|
+
const result = await query({
|
|
115
107
|
tag: 'iq',
|
|
116
108
|
attrs: {
|
|
117
109
|
to: WABinary_1.S_WHATSAPP_NET,
|
|
@@ -147,40 +139,58 @@ const makeChatsSocket = (config) => {
|
|
|
147
139
|
const listNode = (0, WABinary_1.getBinaryNodeChild)(usyncNode, 'list');
|
|
148
140
|
const users = (0, WABinary_1.getBinaryNodeChildren)(listNode, 'user');
|
|
149
141
|
return users;
|
|
150
|
-
}
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
// insures only 1 + is there
|
|
155
|
-
const content = `+${jid.replace('+', '')}`;
|
|
156
|
-
return {
|
|
142
|
+
};
|
|
143
|
+
const fetchUserLid = async (jid) => {
|
|
144
|
+
const [result] = await interactiveQuery([
|
|
145
|
+
{
|
|
157
146
|
tag: 'user',
|
|
158
|
-
attrs: {}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}],
|
|
164
|
-
};
|
|
147
|
+
attrs: { jid }
|
|
148
|
+
}
|
|
149
|
+
], {
|
|
150
|
+
tag: 'lid',
|
|
151
|
+
attrs: {}
|
|
165
152
|
});
|
|
166
|
-
const results = yield interactiveQuery(list, query);
|
|
167
|
-
return results.map(user => {
|
|
168
|
-
const contact = (0, WABinary_1.getBinaryNodeChild)(user, 'contact');
|
|
169
|
-
return { exists: (contact === null || contact === void 0 ? void 0 : contact.attrs.type) === 'in', jid: user.attrs.jid };
|
|
170
|
-
}).filter(item => item.exists);
|
|
171
|
-
});
|
|
172
|
-
const fetchStatus = (jid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
-
const [result] = yield interactiveQuery([{ tag: 'user', attrs: { jid } }], { tag: 'status', attrs: {} });
|
|
174
153
|
if (result) {
|
|
175
|
-
const
|
|
176
|
-
return
|
|
177
|
-
status: status === null || status === void 0 ? void 0 : status.content.toString(),
|
|
178
|
-
setAt: new Date(+((status === null || status === void 0 ? void 0 : status.attrs.t) || 0) * 1000)
|
|
179
|
-
};
|
|
154
|
+
const lid = (0, WABinary_1.getBinaryNodeChild)(result, 'lid');
|
|
155
|
+
return lid.attrs.val;
|
|
180
156
|
}
|
|
181
|
-
}
|
|
157
|
+
};
|
|
158
|
+
const onWhatsApp = async (...jids) => {
|
|
159
|
+
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
160
|
+
.withContactProtocol();
|
|
161
|
+
for (const jid of jids) {
|
|
162
|
+
const phone = `+${jid.replace('+', '').split('@')[0].split(':')[0]}`;
|
|
163
|
+
usyncQuery.withUser(new WAUSync_1.USyncUser().withPhone(phone));
|
|
164
|
+
}
|
|
165
|
+
const results = await sock.executeUSyncQuery(usyncQuery);
|
|
166
|
+
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;
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
const fetchDisappearingDuration = async (...jids) => {
|
|
182
|
+
const usyncQuery = new WAUSync_1.USyncQuery()
|
|
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);
|
|
188
|
+
if (result) {
|
|
189
|
+
return result.list;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
182
192
|
/** update the profile picture for yourself or a group */
|
|
183
|
-
const updateProfilePicture = (jid, content) =>
|
|
193
|
+
const updateProfilePicture = async (jid, content) => {
|
|
184
194
|
let targetJid;
|
|
185
195
|
if (!jid) {
|
|
186
196
|
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
@@ -188,8 +198,8 @@ const makeChatsSocket = (config) => {
|
|
|
188
198
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
189
199
|
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
190
200
|
}
|
|
191
|
-
const { img } =
|
|
192
|
-
|
|
201
|
+
const { img } = await (0, Utils_1.generateProfilePicture)(content);
|
|
202
|
+
await query({
|
|
193
203
|
tag: 'iq',
|
|
194
204
|
attrs: {
|
|
195
205
|
target: targetJid,
|
|
@@ -205,9 +215,9 @@ const makeChatsSocket = (config) => {
|
|
|
205
215
|
}
|
|
206
216
|
]
|
|
207
217
|
});
|
|
208
|
-
}
|
|
218
|
+
};
|
|
209
219
|
/** remove the profile picture for yourself or a group */
|
|
210
|
-
const removeProfilePicture = (jid) =>
|
|
220
|
+
const removeProfilePicture = async (jid) => {
|
|
211
221
|
let targetJid;
|
|
212
222
|
if (!jid) {
|
|
213
223
|
throw new boom_1.Boom('Illegal no-jid profile update. Please specify either your ID or the ID of the chat you wish to update');
|
|
@@ -215,7 +225,7 @@ const makeChatsSocket = (config) => {
|
|
|
215
225
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
216
226
|
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
217
227
|
}
|
|
218
|
-
|
|
228
|
+
await query({
|
|
219
229
|
tag: 'iq',
|
|
220
230
|
attrs: {
|
|
221
231
|
target: targetJid,
|
|
@@ -224,10 +234,10 @@ const makeChatsSocket = (config) => {
|
|
|
224
234
|
xmlns: 'w:profile:picture'
|
|
225
235
|
}
|
|
226
236
|
});
|
|
227
|
-
}
|
|
237
|
+
};
|
|
228
238
|
/** update the profile status for yourself */
|
|
229
|
-
const updateProfileStatus = (status) =>
|
|
230
|
-
|
|
239
|
+
const updateProfileStatus = async (status) => {
|
|
240
|
+
await query({
|
|
231
241
|
tag: 'iq',
|
|
232
242
|
attrs: {
|
|
233
243
|
to: WABinary_1.S_WHATSAPP_NET,
|
|
@@ -242,12 +252,12 @@ const makeChatsSocket = (config) => {
|
|
|
242
252
|
}
|
|
243
253
|
]
|
|
244
254
|
});
|
|
245
|
-
}
|
|
246
|
-
const updateProfileName = (name) =>
|
|
247
|
-
|
|
248
|
-
}
|
|
249
|
-
const fetchBlocklist = () =>
|
|
250
|
-
const result =
|
|
255
|
+
};
|
|
256
|
+
const updateProfileName = async (name) => {
|
|
257
|
+
await chatModify({ pushNameSetting: name }, '');
|
|
258
|
+
};
|
|
259
|
+
const fetchBlocklist = async () => {
|
|
260
|
+
const result = await query({
|
|
251
261
|
tag: 'iq',
|
|
252
262
|
attrs: {
|
|
253
263
|
xmlns: 'blocklist',
|
|
@@ -258,9 +268,9 @@ const makeChatsSocket = (config) => {
|
|
|
258
268
|
const listNode = (0, WABinary_1.getBinaryNodeChild)(result, 'list');
|
|
259
269
|
return (0, WABinary_1.getBinaryNodeChildren)(listNode, 'item')
|
|
260
270
|
.map(n => n.attrs.jid);
|
|
261
|
-
}
|
|
262
|
-
const updateBlockStatus = (jid, action) =>
|
|
263
|
-
|
|
271
|
+
};
|
|
272
|
+
const updateBlockStatus = async (jid, action) => {
|
|
273
|
+
await query({
|
|
264
274
|
tag: 'iq',
|
|
265
275
|
attrs: {
|
|
266
276
|
xmlns: 'blocklist',
|
|
@@ -277,10 +287,10 @@ const makeChatsSocket = (config) => {
|
|
|
277
287
|
}
|
|
278
288
|
]
|
|
279
289
|
});
|
|
280
|
-
}
|
|
281
|
-
const getBusinessProfile = (jid) =>
|
|
290
|
+
};
|
|
291
|
+
const getBusinessProfile = async (jid) => {
|
|
282
292
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
283
|
-
const results =
|
|
293
|
+
const results = await query({
|
|
284
294
|
tag: 'iq',
|
|
285
295
|
attrs: {
|
|
286
296
|
to: 's.whatsapp.net',
|
|
@@ -322,10 +332,10 @@ const makeChatsSocket = (config) => {
|
|
|
322
332
|
}
|
|
323
333
|
};
|
|
324
334
|
}
|
|
325
|
-
}
|
|
326
|
-
const cleanDirtyBits = (type, fromTimestamp) =>
|
|
335
|
+
};
|
|
336
|
+
const cleanDirtyBits = async (type, fromTimestamp) => {
|
|
327
337
|
logger.info({ fromTimestamp }, 'clean dirty bits ' + type);
|
|
328
|
-
|
|
338
|
+
await sendNode({
|
|
329
339
|
tag: 'iq',
|
|
330
340
|
attrs: {
|
|
331
341
|
to: WABinary_1.S_WHATSAPP_NET,
|
|
@@ -336,11 +346,14 @@ const makeChatsSocket = (config) => {
|
|
|
336
346
|
content: [
|
|
337
347
|
{
|
|
338
348
|
tag: 'clean',
|
|
339
|
-
attrs:
|
|
349
|
+
attrs: {
|
|
350
|
+
type,
|
|
351
|
+
...(fromTimestamp ? { timestamp: fromTimestamp.toString() } : null),
|
|
352
|
+
}
|
|
340
353
|
}
|
|
341
354
|
]
|
|
342
355
|
});
|
|
343
|
-
}
|
|
356
|
+
};
|
|
344
357
|
const newAppStateChunkHandler = (isInitialSync) => {
|
|
345
358
|
return {
|
|
346
359
|
onMutation(mutation) {
|
|
@@ -348,12 +361,12 @@ const makeChatsSocket = (config) => {
|
|
|
348
361
|
}
|
|
349
362
|
};
|
|
350
363
|
};
|
|
351
|
-
const resyncAppState = ev.createBufferedFunction((collections, isInitialSync) =>
|
|
364
|
+
const resyncAppState = ev.createBufferedFunction(async (collections, isInitialSync) => {
|
|
352
365
|
// we use this to determine which events to fire
|
|
353
366
|
// otherwise when we resync from scratch -- all notifications will fire
|
|
354
367
|
const initialVersionMap = {};
|
|
355
368
|
const globalMutationMap = {};
|
|
356
|
-
|
|
369
|
+
await authState.keys.transaction(async () => {
|
|
357
370
|
var _a;
|
|
358
371
|
const collectionsToHandle = new Set(collections);
|
|
359
372
|
// in case something goes wrong -- ensure we don't enter a loop that cannot be exited from
|
|
@@ -365,7 +378,7 @@ const makeChatsSocket = (config) => {
|
|
|
365
378
|
const states = {};
|
|
366
379
|
const nodes = [];
|
|
367
380
|
for (const name of collectionsToHandle) {
|
|
368
|
-
const result =
|
|
381
|
+
const result = await authState.keys.get('app-state-sync-version', [name]);
|
|
369
382
|
let state = result[name];
|
|
370
383
|
if (state) {
|
|
371
384
|
if (typeof initialVersionMap[name] === 'undefined') {
|
|
@@ -387,7 +400,7 @@ const makeChatsSocket = (config) => {
|
|
|
387
400
|
}
|
|
388
401
|
});
|
|
389
402
|
}
|
|
390
|
-
const result =
|
|
403
|
+
const result = await query({
|
|
391
404
|
tag: 'iq',
|
|
392
405
|
attrs: {
|
|
393
406
|
to: WABinary_1.S_WHATSAPP_NET,
|
|
@@ -403,24 +416,24 @@ const makeChatsSocket = (config) => {
|
|
|
403
416
|
]
|
|
404
417
|
});
|
|
405
418
|
// extract from binary node
|
|
406
|
-
const decoded =
|
|
419
|
+
const decoded = await (0, Utils_1.extractSyncdPatches)(result, config === null || config === void 0 ? void 0 : config.options);
|
|
407
420
|
for (const key in decoded) {
|
|
408
421
|
const name = key;
|
|
409
422
|
const { patches, hasMorePatches, snapshot } = decoded[name];
|
|
410
423
|
try {
|
|
411
424
|
if (snapshot) {
|
|
412
|
-
const { state: newState, mutationMap } =
|
|
425
|
+
const { state: newState, mutationMap } = await (0, Utils_1.decodeSyncdSnapshot)(name, snapshot, getAppStateSyncKey, initialVersionMap[name], appStateMacVerification.snapshot);
|
|
413
426
|
states[name] = newState;
|
|
414
427
|
Object.assign(globalMutationMap, mutationMap);
|
|
415
428
|
logger.info(`restored state of ${name} from snapshot to v${newState.version} with mutations`);
|
|
416
|
-
|
|
429
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
417
430
|
[name]: newState
|
|
418
431
|
} });
|
|
419
432
|
}
|
|
420
433
|
// only process if there are syncd patches
|
|
421
434
|
if (patches.length) {
|
|
422
|
-
const { state: newState, mutationMap } =
|
|
423
|
-
|
|
435
|
+
const { state: newState, mutationMap } = await (0, Utils_1.decodePatches)(name, patches, states[name], getAppStateSyncKey, config.options, initialVersionMap[name], logger, appStateMacVerification.patch);
|
|
436
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
424
437
|
[name]: newState
|
|
425
438
|
} });
|
|
426
439
|
logger.info(`synced ${name} to v${newState.version}`);
|
|
@@ -441,7 +454,7 @@ const makeChatsSocket = (config) => {
|
|
|
441
454
|
((_a = error.output) === null || _a === void 0 ? void 0 : _a.statusCode) === 404 ||
|
|
442
455
|
error.name === 'TypeError';
|
|
443
456
|
logger.info({ name, error: error.stack }, `failed to sync state from version${isIrrecoverableError ? '' : ', removing and trying from scratch'}`);
|
|
444
|
-
|
|
457
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
445
458
|
[name]: null
|
|
446
459
|
} });
|
|
447
460
|
// increment number of retries
|
|
@@ -453,36 +466,18 @@ const makeChatsSocket = (config) => {
|
|
|
453
466
|
}
|
|
454
467
|
}
|
|
455
468
|
}
|
|
456
|
-
})
|
|
469
|
+
});
|
|
457
470
|
const { onMutation } = newAppStateChunkHandler(isInitialSync);
|
|
458
471
|
for (const key in globalMutationMap) {
|
|
459
472
|
onMutation(globalMutationMap[key]);
|
|
460
473
|
}
|
|
461
|
-
})
|
|
474
|
+
});
|
|
462
475
|
/**
|
|
463
476
|
* fetch the profile picture of a user/group
|
|
464
477
|
* type = "preview" for a low res picture
|
|
465
478
|
* type = "image for the high res picture"
|
|
466
479
|
*/
|
|
467
|
-
const
|
|
468
|
-
var _a;
|
|
469
|
-
jid = (0, WABinary_1.jidNormalizedUser)(jid);
|
|
470
|
-
const result = yield query({
|
|
471
|
-
tag: 'iq',
|
|
472
|
-
attrs: {
|
|
473
|
-
target: jid,
|
|
474
|
-
to: WABinary_1.S_WHATSAPP_NET,
|
|
475
|
-
type: 'get',
|
|
476
|
-
xmlns: 'w:profile:picture'
|
|
477
|
-
},
|
|
478
|
-
content: [
|
|
479
|
-
{ tag: 'picture', attrs: { type, query: 'url' } }
|
|
480
|
-
]
|
|
481
|
-
}, timeoutMs);
|
|
482
|
-
const child = (0, WABinary_1.getBinaryNodeChild)(result, 'picture');
|
|
483
|
-
return (_a = child === null || child === void 0 ? void 0 : child.attrs) === null || _a === void 0 ? void 0 : _a.url;
|
|
484
|
-
});
|
|
485
|
-
const sendPresenceUpdate = (type, toJid) => __awaiter(void 0, void 0, void 0, function* () {
|
|
480
|
+
const sendPresenceUpdate = async (type, toJid) => {
|
|
486
481
|
const me = authState.creds.me;
|
|
487
482
|
if (type === 'available' || type === 'unavailable') {
|
|
488
483
|
if (!me.name) {
|
|
@@ -490,7 +485,7 @@ const makeChatsSocket = (config) => {
|
|
|
490
485
|
return;
|
|
491
486
|
}
|
|
492
487
|
ev.emit('connection.update', { isOnline: type === 'available' });
|
|
493
|
-
|
|
488
|
+
await sendNode({
|
|
494
489
|
tag: 'presence',
|
|
495
490
|
attrs: {
|
|
496
491
|
name: me.name,
|
|
@@ -499,7 +494,7 @@ const makeChatsSocket = (config) => {
|
|
|
499
494
|
});
|
|
500
495
|
}
|
|
501
496
|
else {
|
|
502
|
-
|
|
497
|
+
await sendNode({
|
|
503
498
|
tag: 'chatstate',
|
|
504
499
|
attrs: {
|
|
505
500
|
from: me.id,
|
|
@@ -513,7 +508,7 @@ const makeChatsSocket = (config) => {
|
|
|
513
508
|
]
|
|
514
509
|
});
|
|
515
510
|
}
|
|
516
|
-
}
|
|
511
|
+
};
|
|
517
512
|
/**
|
|
518
513
|
* @param toJid the jid to subscribe to
|
|
519
514
|
* @param tcToken token for subscription, use if present
|
|
@@ -569,7 +564,7 @@ const makeChatsSocket = (config) => {
|
|
|
569
564
|
} });
|
|
570
565
|
}
|
|
571
566
|
};
|
|
572
|
-
const appPatch = (patchCreate) =>
|
|
567
|
+
const appPatch = async (patchCreate) => {
|
|
573
568
|
const name = patchCreate.type;
|
|
574
569
|
const myAppStateKeyId = authState.creds.myAppStateKeyId;
|
|
575
570
|
if (!myAppStateKeyId) {
|
|
@@ -577,13 +572,13 @@ const makeChatsSocket = (config) => {
|
|
|
577
572
|
}
|
|
578
573
|
let initial;
|
|
579
574
|
let encodeResult;
|
|
580
|
-
|
|
581
|
-
|
|
575
|
+
await processingMutex.mutex(async () => {
|
|
576
|
+
await authState.keys.transaction(async () => {
|
|
582
577
|
logger.debug({ patch: patchCreate }, 'applying app patch');
|
|
583
|
-
|
|
584
|
-
const { [name]: currentSyncVersion } =
|
|
578
|
+
await resyncAppState([name], false);
|
|
579
|
+
const { [name]: currentSyncVersion } = await authState.keys.get('app-state-sync-version', [name]);
|
|
585
580
|
initial = currentSyncVersion || (0, Utils_1.newLTHashState)();
|
|
586
|
-
encodeResult =
|
|
581
|
+
encodeResult = await (0, Utils_1.encodeSyncdPatch)(patchCreate, myAppStateKeyId, initial, getAppStateSyncKey);
|
|
587
582
|
const { patch, state } = encodeResult;
|
|
588
583
|
const node = {
|
|
589
584
|
tag: 'iq',
|
|
@@ -616,24 +611,24 @@ const makeChatsSocket = (config) => {
|
|
|
616
611
|
}
|
|
617
612
|
]
|
|
618
613
|
};
|
|
619
|
-
|
|
620
|
-
|
|
614
|
+
await query(node);
|
|
615
|
+
await authState.keys.set({ 'app-state-sync-version': {
|
|
621
616
|
[name]: state
|
|
622
617
|
} });
|
|
623
|
-
})
|
|
624
|
-
})
|
|
618
|
+
});
|
|
619
|
+
});
|
|
625
620
|
if (config.emitOwnEvents) {
|
|
626
621
|
const { onMutation } = newAppStateChunkHandler(false);
|
|
627
|
-
const { mutationMap } =
|
|
622
|
+
const { mutationMap } = await (0, Utils_1.decodePatches)(name, [{ ...encodeResult.patch, version: { version: encodeResult.state.version }, }], initial, getAppStateSyncKey, config.options, undefined, logger);
|
|
628
623
|
for (const key in mutationMap) {
|
|
629
624
|
onMutation(mutationMap[key]);
|
|
630
625
|
}
|
|
631
626
|
}
|
|
632
|
-
}
|
|
627
|
+
};
|
|
633
628
|
/** sending non-abt props may fix QR scan fail if server expects */
|
|
634
|
-
const fetchProps = () =>
|
|
629
|
+
const fetchProps = async () => {
|
|
635
630
|
var _a, _b;
|
|
636
|
-
const resultNode =
|
|
631
|
+
const resultNode = await query({
|
|
637
632
|
tag: 'iq',
|
|
638
633
|
attrs: {
|
|
639
634
|
to: WABinary_1.S_WHATSAPP_NET,
|
|
@@ -659,7 +654,7 @@ const makeChatsSocket = (config) => {
|
|
|
659
654
|
}
|
|
660
655
|
logger.debug('fetched props');
|
|
661
656
|
return props;
|
|
662
|
-
}
|
|
657
|
+
};
|
|
663
658
|
/**
|
|
664
659
|
* modify a chat -- mark unread, read etc.
|
|
665
660
|
* lastMessages must be sorted in reverse chronologically
|
|
@@ -726,14 +721,14 @@ const makeChatsSocket = (config) => {
|
|
|
726
721
|
* queries need to be fired on connection open
|
|
727
722
|
* help ensure parity with WA Web
|
|
728
723
|
* */
|
|
729
|
-
const executeInitQueries = () =>
|
|
730
|
-
|
|
724
|
+
const executeInitQueries = async () => {
|
|
725
|
+
await Promise.all([
|
|
731
726
|
fetchProps(),
|
|
732
727
|
fetchBlocklist(),
|
|
733
728
|
fetchPrivacySettings(),
|
|
734
729
|
]);
|
|
735
|
-
}
|
|
736
|
-
const upsertMessage = ev.createBufferedFunction((msg, type) =>
|
|
730
|
+
};
|
|
731
|
+
const upsertMessage = ev.createBufferedFunction(async (msg, type) => {
|
|
737
732
|
var _a, _b, _c;
|
|
738
733
|
ev.emit('messages.upsert', { messages: [msg], type });
|
|
739
734
|
if (!!msg.pushName) {
|
|
@@ -744,7 +739,7 @@ const makeChatsSocket = (config) => {
|
|
|
744
739
|
}
|
|
745
740
|
// update our pushname too
|
|
746
741
|
if (msg.key.fromMe && msg.pushName && ((_a = authState.creds.me) === null || _a === void 0 ? void 0 : _a.name) !== msg.pushName) {
|
|
747
|
-
ev.emit('creds.update', { me:
|
|
742
|
+
ev.emit('creds.update', { me: { ...authState.creds.me, name: msg.pushName } });
|
|
748
743
|
}
|
|
749
744
|
}
|
|
750
745
|
const historyMsg = (0, Utils_1.getHistoryMsg)(msg.message);
|
|
@@ -756,14 +751,14 @@ const makeChatsSocket = (config) => {
|
|
|
756
751
|
logger.warn('skipping app state sync, as myAppStateKeyId is not set');
|
|
757
752
|
pendingAppStateSync = true;
|
|
758
753
|
}
|
|
759
|
-
|
|
760
|
-
(() =>
|
|
754
|
+
await Promise.all([
|
|
755
|
+
(async () => {
|
|
761
756
|
if (historyMsg &&
|
|
762
757
|
authState.creds.myAppStateKeyId) {
|
|
763
758
|
pendingAppStateSync = false;
|
|
764
|
-
|
|
759
|
+
await doAppStateSync();
|
|
765
760
|
}
|
|
766
|
-
})
|
|
761
|
+
})(),
|
|
767
762
|
(0, process_message_1.default)(msg, {
|
|
768
763
|
shouldProcessHistoryMsg,
|
|
769
764
|
ev,
|
|
@@ -776,27 +771,25 @@ const makeChatsSocket = (config) => {
|
|
|
776
771
|
]);
|
|
777
772
|
if (((_c = (_b = msg.message) === null || _b === void 0 ? void 0 : _b.protocolMessage) === null || _c === void 0 ? void 0 : _c.appStateSyncKeyShare) &&
|
|
778
773
|
pendingAppStateSync) {
|
|
779
|
-
|
|
774
|
+
await doAppStateSync();
|
|
780
775
|
pendingAppStateSync = false;
|
|
781
776
|
}
|
|
782
|
-
function doAppStateSync() {
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
ev.flush();
|
|
792
|
-
}
|
|
777
|
+
async function doAppStateSync() {
|
|
778
|
+
if (!authState.creds.accountSyncCounter) {
|
|
779
|
+
logger.info('doing initial app state sync');
|
|
780
|
+
await resyncAppState(Types_1.ALL_WA_PATCH_NAMES, true);
|
|
781
|
+
const accountSyncCounter = (authState.creds.accountSyncCounter || 0) + 1;
|
|
782
|
+
ev.emit('creds.update', { accountSyncCounter });
|
|
783
|
+
if (needToFlushWithAppStateSync) {
|
|
784
|
+
logger.debug('flushing with app state sync');
|
|
785
|
+
ev.flush();
|
|
793
786
|
}
|
|
794
|
-
}
|
|
787
|
+
}
|
|
795
788
|
}
|
|
796
|
-
})
|
|
789
|
+
});
|
|
797
790
|
ws.on('CB:presence', handlePresenceUpdate);
|
|
798
791
|
ws.on('CB:chatstate', handlePresenceUpdate);
|
|
799
|
-
ws.on('CB:ib,,dirty', (node) =>
|
|
792
|
+
ws.on('CB:ib,,dirty', async (node) => {
|
|
800
793
|
const { attrs } = (0, WABinary_1.getBinaryNodeChild)(node, 'dirty');
|
|
801
794
|
const type = attrs.type;
|
|
802
795
|
switch (type) {
|
|
@@ -804,7 +797,7 @@ const makeChatsSocket = (config) => {
|
|
|
804
797
|
if (attrs.timestamp) {
|
|
805
798
|
let { lastAccountSyncTimestamp } = authState.creds;
|
|
806
799
|
if (lastAccountSyncTimestamp) {
|
|
807
|
-
|
|
800
|
+
await cleanDirtyBits('account_sync', lastAccountSyncTimestamp);
|
|
808
801
|
}
|
|
809
802
|
lastAccountSyncTimestamp = +attrs.timestamp;
|
|
810
803
|
ev.emit('creds.update', { lastAccountSyncTimestamp });
|
|
@@ -817,7 +810,7 @@ const makeChatsSocket = (config) => {
|
|
|
817
810
|
logger.info({ node }, 'received unknown sync');
|
|
818
811
|
break;
|
|
819
812
|
}
|
|
820
|
-
})
|
|
813
|
+
});
|
|
821
814
|
ev.on('connection.update', ({ connection, receivedPendingNotifications }) => {
|
|
822
815
|
var _a;
|
|
823
816
|
if (connection === 'open') {
|
|
@@ -838,16 +831,20 @@ const makeChatsSocket = (config) => {
|
|
|
838
831
|
}
|
|
839
832
|
}
|
|
840
833
|
});
|
|
841
|
-
return
|
|
834
|
+
return {
|
|
835
|
+
...sock,
|
|
836
|
+
interactiveQuery,
|
|
837
|
+
processingMutex,
|
|
842
838
|
fetchPrivacySettings,
|
|
843
839
|
upsertMessage,
|
|
844
840
|
appPatch,
|
|
841
|
+
fetchUserLid,
|
|
845
842
|
sendPresenceUpdate,
|
|
846
843
|
presenceSubscribe,
|
|
847
|
-
profilePictureUrl,
|
|
848
844
|
onWhatsApp,
|
|
849
845
|
fetchBlocklist,
|
|
850
846
|
fetchStatus,
|
|
847
|
+
fetchDisappearingDuration,
|
|
851
848
|
updateProfilePicture,
|
|
852
849
|
removeProfilePicture,
|
|
853
850
|
updateProfileStatus,
|
|
@@ -868,6 +865,7 @@ const makeChatsSocket = (config) => {
|
|
|
868
865
|
removeChatLabel,
|
|
869
866
|
addMessageLabel,
|
|
870
867
|
removeMessageLabel,
|
|
871
|
-
star
|
|
868
|
+
star
|
|
869
|
+
};
|
|
872
870
|
};
|
|
873
871
|
exports.makeChatsSocket = makeChatsSocket;
|