whatsapp-web.js 1.18.0-alpha.1 → 1.18.0
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 +4 -7
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
|
@@ -51,6 +51,7 @@ exports.ExposeStore = (moduleRaidStr) => {
|
|
|
51
51
|
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
|
52
52
|
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
|
53
53
|
window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
|
|
54
|
+
window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
|
|
54
55
|
window.Store.StickerTools = {
|
|
55
56
|
...window.mR.findModule('toWebpSticker')[0],
|
|
56
57
|
...window.mR.findModule('addWebpMetadata')[0]
|
|
@@ -227,11 +228,7 @@ exports.LoadUtils = () => {
|
|
|
227
228
|
const extraOptions = options.extraOptions || {};
|
|
228
229
|
delete options.extraOptions;
|
|
229
230
|
|
|
230
|
-
const
|
|
231
|
-
ephemeralDuration: chat.isEphemeralSettingOn() ? chat.getEphemeralSetting() : undefined,
|
|
232
|
-
ephemeralSettingTimestamp: chat.getEphemeralSettingTimestamp() || undefined,
|
|
233
|
-
disappearingModeInitiator: chat.getDisappearingModeInitiator() || undefined,
|
|
234
|
-
};
|
|
231
|
+
const ephemeralFields = window.Store.EphemeralFields.getEphemeralFields(chat);
|
|
235
232
|
|
|
236
233
|
const message = {
|
|
237
234
|
...options,
|
|
@@ -245,7 +242,7 @@ exports.LoadUtils = () => {
|
|
|
245
242
|
t: parseInt(new Date().getTime() / 1000),
|
|
246
243
|
isNewMsg: true,
|
|
247
244
|
type: 'chat',
|
|
248
|
-
...
|
|
245
|
+
...ephemeralFields,
|
|
249
246
|
...locationOptions,
|
|
250
247
|
...attOptions,
|
|
251
248
|
...quotedMsgOptions,
|
|
@@ -366,7 +363,7 @@ exports.LoadUtils = () => {
|
|
|
366
363
|
|
|
367
364
|
msg.isEphemeral = message.isEphemeral;
|
|
368
365
|
msg.isStatusV3 = message.isStatusV3;
|
|
369
|
-
msg.links = (message.
|
|
366
|
+
msg.links = (message.getRawLinks()).map(link => ({
|
|
370
367
|
link: link.href,
|
|
371
368
|
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
|
|
372
369
|
}));
|