chore: mark version v1.20.0

This commit is contained in:
Pedro S Lopez 2023-05-19 23:58:10 -04:00
commit 915763a8d0
60 changed files with 4356 additions and 3441 deletions

View file

@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta name="generator" content="JSDoc 3.6.11">
<meta charset="utf-8">
<title>whatsapp-web.js 1.19.5 &raquo; Source: Client.js</title>
<title>whatsapp-web.js 1.20.0 &raquo; Source: Client.js</title>
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css">
<link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css">
@ -15,7 +15,7 @@
<nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar">
<div id="jsdoc-navbar-container">
<div id="jsdoc-navbar-content">
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>19.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>20.<wbr>0</a>
</div>
</div>
</nav>
@ -41,7 +41,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } &#x3D; require(&#x27;./ut
const { ExposeStore, LoadUtils } &#x3D; require(&#x27;./util/Injected&#x27;);
const ChatFactory &#x3D; require(&#x27;./factories/ChatFactory&#x27;);
const ContactFactory &#x3D; require(&#x27;./factories/ContactFactory&#x27;);
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } &#x3D; require(&#x27;./structures&#x27;);
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction, Chat } &#x3D; require(&#x27;./structures&#x27;);
const LegacySessionAuth &#x3D; require(&#x27;./authStrategies/LegacySessionAuth&#x27;);
const NoAuth &#x3D; require(&#x27;./authStrategies/NoAuth&#x27;);
@ -60,6 +60,7 @@ const NoAuth &#x3D; require(&#x27;./authStrategies/NoAuth&#x27;);
* @param {string} options.userAgent - User agent to use in puppeteer
* @param {string} options.ffmpegPath - Ffmpeg path to use when formating videos to webp while sending stickers
* @param {boolean} options.bypassCSP - Sets bypassing of page&#x27;s Content-Security-Policy.
* @param {object} options.proxyAuthentication - Proxy Authentication object.
*
* @fires Client#qr
* @fires Client#authenticated
@ -76,6 +77,8 @@ const NoAuth &#x3D; require(&#x27;./authStrategies/NoAuth&#x27;);
* @fires Client#group_update
* @fires Client#disconnected
* @fires Client#change_state
* @fires Client#contact_changed
* @fires Client#group_admin_changed
*/
class Client extends EventEmitter {
constructor(options &#x3D; {}) {
@ -131,6 +134,10 @@ class Client extends EventEmitter {
browser &#x3D; await puppeteer.launch({...puppeteerOpts, args: browserArgs});
page &#x3D; (await browser.pages())[0];
}
if (this.options.proxyAuthentication !&#x3D;&#x3D; undefined) {
await page.authenticate(this.options.proxyAuthentication);
}
await page.setUserAgent(this.options.userAgent);
if (this.options.bypassCSP) await page.setBypassCSP(true);
@ -348,6 +355,13 @@ class Client extends EventEmitter {
* @param {GroupNotification} notification GroupNotification with more information about the action
*/
this.emit(Events.GROUP_LEAVE, notification);
} else if (msg.subtype &#x3D;&#x3D;&#x3D; &#x27;promote&#x27; || msg.subtype &#x3D;&#x3D;&#x3D; &#x27;demote&#x27;) {
/**
* Emitted when a current user is promoted to an admin or demoted to a regular user.
* @event Client#group_admin_changed
* @param {GroupNotification} notification GroupNotification with more information about the action
*/
this.emit(Events.GROUP_ADMIN_CHANGED, notification);
} else {
/**
* Emitted when group settings are updated, such as subject, description or picture.
@ -407,6 +421,36 @@ class Client extends EventEmitter {
last_message &#x3D; msg;
}
/**
* The event notification that is received when one of
* the group participants changes thier phone number.
*/
const isParticipant &#x3D; msg.type &#x3D;&#x3D;&#x3D; &#x27;gp2&#x27; &amp;amp;&amp;amp; msg.subtype &#x3D;&#x3D;&#x3D; &#x27;modify&#x27;;
/**
* The event notification that is received when one of
* the contacts changes thier phone number.
*/
const isContact &#x3D; msg.type &#x3D;&#x3D;&#x3D; &#x27;notification_template&#x27; &amp;amp;&amp;amp; msg.subtype &#x3D;&#x3D;&#x3D; &#x27;change_number&#x27;;
if (isParticipant || isContact) {
/** {@link GroupNotification} object does not provide enough information about this event, so a {@link Message} object is used. */
const message &#x3D; new Message(this, msg);
const newId &#x3D; isParticipant ? msg.recipients[0] : msg.to;
const oldId &#x3D; isParticipant ? msg.author : msg.templateParams.find(id &#x3D;&gt; id !&#x3D;&#x3D; newId);
/**
* Emitted when a contact or a group participant changes their phone number.
* @event Client#contact_changed
* @param {Message} message Message with more information about the event.
* @param {String} oldId The user&#x27;s id (an old one) who changed their phone number
* and who triggered the notification.
* @param {String} newId The user&#x27;s new id after the change.
* @param {Boolean} isContact Indicates if a contact or a group participant changed their phone number.
*/
this.emit(Events.CONTACT_CHANGED, message, oldId, newId, isContact);
}
});
await page.exposeFunction(&#x27;onRemoveMessageEvent&#x27;, (msg) &#x3D;&gt; {
@ -438,6 +482,15 @@ class Client extends EventEmitter {
});
await page.exposeFunction(&#x27;onChatUnreadCountEvent&#x27;, async (data) &#x3D;&gt;{
const chat &#x3D; await this.getChatById(data.id);
/**
* Emitted when the chat unread count changes
*/
this.emit(Events.UNREAD_COUNT, chat);
});
await page.exposeFunction(&#x27;onMessageMediaUploadedEvent&#x27;, (msg) &#x3D;&gt; {
const message &#x3D; new Message(this, msg);
@ -538,6 +591,26 @@ class Client extends EventEmitter {
}
});
await page.exposeFunction(&#x27;onRemoveChatEvent&#x27;, (chat) &#x3D;&gt; {
/**
* Emitted when a chat is removed
* @event Client#chat_removed
* @param {Chat} chat
*/
this.emit(Events.CHAT_REMOVED, new Chat(this, chat));
});
await page.exposeFunction(&#x27;onArchiveChatEvent&#x27;, (chat, currState, prevState) &#x3D;&gt; {
/**
* Emitted when a chat is archived/unarchived
* @event Client#chat_archived
* @param {Chat} chat
* @param {boolean} currState
* @param {boolean} prevState
*/
this.emit(Events.CHAT_ARCHIVED, new Chat(this, chat), currState, prevState);
});
await page.evaluate(() &#x3D;&gt; {
window.Store.Msg.on(&#x27;change&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on(&#x27;change:type&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
@ -547,6 +620,8 @@ class Client extends EventEmitter {
window.Store.AppState.on(&#x27;change:state&#x27;, (_AppState, state) &#x3D;&gt; { window.onAppStateChangedEvent(state); });
window.Store.Conn.on(&#x27;change:battery&#x27;, (state) &#x3D;&gt; { window.onBatteryStateChangedEvent(state); });
window.Store.Call.on(&#x27;add&#x27;, (call) &#x3D;&gt; { window.onIncomingCall(call); });
window.Store.Chat.on(&#x27;remove&#x27;, async (chat) &#x3D;&gt; { window.onRemoveChatEvent(await window.WWebJS.getChatModel(chat)); });
window.Store.Chat.on(&#x27;change:archive&#x27;, async (chat, currState, prevState) &#x3D;&gt; { window.onArchiveChatEvent(await window.WWebJS.getChatModel(chat), currState, prevState); });
window.Store.Msg.on(&#x27;add&#x27;, (msg) &#x3D;&gt; {
if (msg.isNewMsg) {
if(msg.type &#x3D;&#x3D;&#x3D; &#x27;ciphertext&#x27;) {
@ -557,7 +632,8 @@ class Client extends EventEmitter {
}
}
});
window.Store.Chat.on(&#x27;change:unreadCount&#x27;, (chat) &#x3D;&gt; {window.onChatUnreadCountEvent(chat);});
{
const module &#x3D; window.Store.createOrUpdateReactionsModule;
const ogMethod &#x3D; module.createOrUpdateReactions;
@ -1209,6 +1285,31 @@ class Client extends EventEmitter {
return blockedContacts.map(contact &#x3D;&gt; ContactFactory.create(this.client, contact));
}
/**
* Sets the current user&#x27;s profile picture.
* @param {MessageMedia} media
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the picture was properly updated.
*/
async setProfilePicture(media) {
const success &#x3D; await this.pupPage.evaluate((chatid, media) &#x3D;&gt; {
return window.WWebJS.setPicture(chatid, media);
}, this.info.wid._serialized, media);
return success;
}
/**
* Deletes the current user&#x27;s profile picture.
* @returns {Promise&amp;lt;boolean&gt;} Returns true if the picture was properly deleted.
*/
async deleteProfilePicture() {
const success &#x3D; await this.pupPage.evaluate((chatid) &#x3D;&gt; {
return window.WWebJS.deletePicture(chatid);
}, this.info.wid._serialized);
return success;
}
}
module.exports &#x3D; Client;
@ -1222,7 +1323,7 @@ module.exports &#x3D; Client;
<footer id="jsdoc-footer" class="jsdoc-footer">
<div id="jsdoc-footer-container">
<p>
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on March 18, 2023.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on May 19, 2023.
</p>
</div>
</footer>