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 CHANGED
@@ -1,4 +1,4 @@
1
- [![npm](https://img.shields.io/npm/v/whatsapp-web.js.svg)](https://www.npmjs.com/package/whatsapp-web.js) [![Depfu](https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg)](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765) ![WhatsApp_Web 2.2224.8](https://img.shields.io/badge/WhatsApp_Web-2.2224.8-brightgreen.svg) [![Discord Chat](https://img.shields.io/discord/698610475432411196.svg?logo=discord)](https://discord.gg/H7DqQs4)
1
+ [![npm](https://img.shields.io/npm/v/whatsapp-web.js.svg)](https://www.npmjs.com/package/whatsapp-web.js) [![Depfu](https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg)](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765) ![WhatsApp_Web 2.2240.7](https://img.shields.io/badge/WhatsApp_Web-2.2240.7-brightgreen.svg) [![Discord Chat](https://img.shields.io/discord/698610475432411196.svg?logo=discord)](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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "whatsapp-web.js",
3
- "version": "1.18.0-alpha.1",
3
+ "version": "1.18.0",
4
4
  "description": "Library for interacting with the WhatsApp Web API ",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
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
- const contact = window.Store.Contact.get(contactId);
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.id.fromMe && msg._canRevoke()) {
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);
@@ -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 ephemeralSettings = {
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
- ...ephemeralSettings,
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.getLinks()).map(link => ({
366
+ msg.links = (message.getRawLinks()).map(link => ({
370
367
  link: link.href,
371
368
  isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
372
369
  }));