whatsapp-web.js 1.18.0-alpha.1 → 1.18.1
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 +1 -1
- package/index.d.ts +5 -5
- package/package.json +1 -1
- package/src/Client.js +7 -1
- package/src/authStrategies/RemoteAuth.js +2 -2
- package/src/structures/Message.js +3 -3
- package/src/util/Injected.js +17 -9
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765) ](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
|
2
2
|
|
|
3
3
|
# whatsapp-web.js
|
|
4
4
|
A WhatsApp API client that connects through the WhatsApp Web browser app
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { EventEmitter } from 'events'
|
|
3
3
|
import { RequestInit } from 'node-fetch'
|
|
4
|
-
import puppeteer from 'puppeteer'
|
|
4
|
+
import * as puppeteer from 'puppeteer'
|
|
5
5
|
|
|
6
6
|
declare namespace WAWebJS {
|
|
7
7
|
|
|
@@ -399,10 +399,10 @@ declare namespace WAWebJS {
|
|
|
399
399
|
* Remote store interface
|
|
400
400
|
*/
|
|
401
401
|
export interface Store {
|
|
402
|
-
sessionExists: ({session: string}) => Promise<boolean> | boolean,
|
|
403
|
-
delete: ({session: string}) => Promise<any> | any,
|
|
404
|
-
save: ({session: string}) => Promise<any> | any,
|
|
405
|
-
extract: ({session: string, path: string}) => Promise<any> | any,
|
|
402
|
+
sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
|
|
403
|
+
delete: (options: { session: string }) => Promise<any> | any,
|
|
404
|
+
save: (options: { session: string }) => Promise<any> | any,
|
|
405
|
+
extract: (options: { session: string, path: string }) => Promise<any> | any,
|
|
406
406
|
}
|
|
407
407
|
|
|
408
408
|
/**
|
package/package.json
CHANGED
package/src/Client.js
CHANGED
|
@@ -989,7 +989,13 @@ class Client extends EventEmitter {
|
|
|
989
989
|
*/
|
|
990
990
|
async getCommonGroups(contactId) {
|
|
991
991
|
const commonGroups = await this.pupPage.evaluate(async (contactId) => {
|
|
992
|
-
|
|
992
|
+
let contact = window.Store.Contact.get(contactId);
|
|
993
|
+
if (!contact) {
|
|
994
|
+
const wid = window.Store.WidFactory.createUserWid(contactId);
|
|
995
|
+
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
|
|
996
|
+
contact = new chatConstructor({id: wid});
|
|
997
|
+
}
|
|
998
|
+
|
|
993
999
|
if (contact.commonGroups) {
|
|
994
1000
|
return contact.commonGroups.serialize();
|
|
995
1001
|
}
|
|
@@ -178,9 +178,9 @@ class RemoteAuth extends BaseAuthStrategy {
|
|
|
178
178
|
await fs.promises.rm(dirElement, {
|
|
179
179
|
recursive: true,
|
|
180
180
|
force: true
|
|
181
|
-
});
|
|
181
|
+
}).catch(() => {});
|
|
182
182
|
} else {
|
|
183
|
-
await fs.promises.unlink(dirElement);
|
|
183
|
+
await fs.promises.unlink(dirElement).catch(() => {});
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -430,14 +430,14 @@ class Message extends Base {
|
|
|
430
430
|
|
|
431
431
|
/**
|
|
432
432
|
* Deletes a message from the chat
|
|
433
|
-
* @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat.
|
|
433
|
+
* @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.
|
|
434
434
|
*/
|
|
435
435
|
async delete(everyone) {
|
|
436
436
|
await this.client.pupPage.evaluate((msgId, everyone) => {
|
|
437
437
|
let msg = window.Store.Msg.get(msgId);
|
|
438
438
|
|
|
439
|
-
if (everyone && msg.
|
|
440
|
-
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], {type: 'Sender'});
|
|
439
|
+
if (everyone && msg._canRevoke()) {
|
|
440
|
+
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' });
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
package/src/util/Injected.js
CHANGED
|
@@ -13,7 +13,6 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
13
13
|
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
|
14
14
|
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
|
15
15
|
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
|
16
|
-
window.Store.MDBackend = window.mR.findModule('isMDBackend')[0].isMDBackend();
|
|
17
16
|
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].LegacyPhoneFeatures;
|
|
18
17
|
window.Store.GroupMetadata = window.mR.findModule((module) => module.default && module.default.handlePendingInvite)[0].default;
|
|
19
18
|
window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0];
|
|
@@ -39,7 +38,6 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
39
38
|
window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
|
|
40
39
|
window.Store.Validators = window.mR.findModule('findLinks')[0];
|
|
41
40
|
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
|
42
|
-
window.Store.Wap = window.mR.findModule('queryLinkPreview')[0].default;
|
|
43
41
|
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
|
44
42
|
window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
|
|
45
43
|
window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
|
|
@@ -51,6 +49,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
51
49
|
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
|
52
50
|
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
|
53
51
|
window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
|
|
52
|
+
window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
|
|
54
53
|
window.Store.StickerTools = {
|
|
55
54
|
...window.mR.findModule('toWebpSticker')[0],
|
|
56
55
|
...window.mR.findModule('addWebpMetadata')[0]
|
|
@@ -70,6 +69,19 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
70
69
|
});
|
|
71
70
|
};
|
|
72
71
|
}
|
|
72
|
+
|
|
73
|
+
// TODO remove these once everybody has been updated to WWebJS with legacy sessions removed
|
|
74
|
+
const _linkPreview = window.mR.findModule('queryLinkPreview');
|
|
75
|
+
if (_linkPreview && _linkPreview[0] && _linkPreview[0].default) {
|
|
76
|
+
window.Store.Wap = _linkPreview[0].default;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const _isMDBackend = window.mR.findModule('isMDBackend');
|
|
80
|
+
if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
|
|
81
|
+
window.Store.MDBackend = _isMDBackend[0].isMDBackend();
|
|
82
|
+
} else {
|
|
83
|
+
window.Store.MDBackend = true;
|
|
84
|
+
}
|
|
73
85
|
};
|
|
74
86
|
|
|
75
87
|
exports.LoadUtils = () => {
|
|
@@ -227,11 +239,7 @@ exports.LoadUtils = () => {
|
|
|
227
239
|
const extraOptions = options.extraOptions || {};
|
|
228
240
|
delete options.extraOptions;
|
|
229
241
|
|
|
230
|
-
const
|
|
231
|
-
ephemeralDuration: chat.isEphemeralSettingOn() ? chat.getEphemeralSetting() : undefined,
|
|
232
|
-
ephemeralSettingTimestamp: chat.getEphemeralSettingTimestamp() || undefined,
|
|
233
|
-
disappearingModeInitiator: chat.getDisappearingModeInitiator() || undefined,
|
|
234
|
-
};
|
|
242
|
+
const ephemeralFields = window.Store.EphemeralFields.getEphemeralFields(chat);
|
|
235
243
|
|
|
236
244
|
const message = {
|
|
237
245
|
...options,
|
|
@@ -245,7 +253,7 @@ exports.LoadUtils = () => {
|
|
|
245
253
|
t: parseInt(new Date().getTime() / 1000),
|
|
246
254
|
isNewMsg: true,
|
|
247
255
|
type: 'chat',
|
|
248
|
-
...
|
|
256
|
+
...ephemeralFields,
|
|
249
257
|
...locationOptions,
|
|
250
258
|
...attOptions,
|
|
251
259
|
...quotedMsgOptions,
|
|
@@ -366,7 +374,7 @@ exports.LoadUtils = () => {
|
|
|
366
374
|
|
|
367
375
|
msg.isEphemeral = message.isEphemeral;
|
|
368
376
|
msg.isStatusV3 = message.isStatusV3;
|
|
369
|
-
msg.links = (message.
|
|
377
|
+
msg.links = (message.getRawLinks()).map(link => ({
|
|
370
378
|
link: link.href,
|
|
371
379
|
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
|
|
372
380
|
}));
|