Compare commits

...

72 Commits

Author SHA1 Message Date
Rajeh Taher
308ab9826c Merge branch 'main' into message-by-id 2021-09-21 21:07:26 +03:00
tuyuribr
b60029ed09 feat: Send buttons and Lists (#756) 2021-09-14 00:06:05 +03:00
tuyuribr
ab415ff9be feat: Include payment info (#684) 2021-09-13 23:58:39 +03:00
Rajeh Taher
6cf9c2a0f3 Merge branch 'main' into message-by-id 2021-09-02 18:43:27 +03:00
Pedro Lopez
7beeff4901 chore: mark version 1.14.1 2021-09-01 09:19:28 -04:00
Pedro Lopez
022c87f3c7 optionally patch _find function if it's not found 2021-09-01 09:18:34 -04:00
Pedro Lopez
e527fe74fd fix: patch find function to get chats 2021-09-01 09:16:12 -04:00
Rajeh Taher
60761399ca ESLint fix 2021-08-28 00:45:40 +03:00
Rajeh Taher
7a8e922696 Added Tests 2021-08-28 00:43:29 +03:00
Pedro Lopez
841719ff4c feat: get message by id 2021-08-21 03:56:42 -04:00
Pedro S. Lopez
7597608f9d Update README.md 2021-08-02 00:49:03 -04:00
Pedro Lopez
be018e651d update .npmignore 2021-08-02 00:07:52 -04:00
Pedro Lopez
64189d2d67 chore: mark version v1.14.0 2021-08-01 23:59:56 -04:00
Pedro Lopez
38e31a07cf Update package.json and readme for node 12 support 2021-08-01 23:57:21 -04:00
Pedro Lopez
40cec51956 fix: node v12 support 2021-08-01 23:56:27 -04:00
Pedro S. Lopez
d9ccb6f276 fix: correctly resolve media that hasn't been downloaded (#763)
* fix: correctly abort if media does not exist

* catch 404s

* dont throw for media that cant be fetched
2021-08-01 23:29:06 -04:00
github-actions[bot]
628b6e4d49 Update supported WhatsApp Web version to v2.2126.14 (#806)
Co-authored-by: pedroslopez <pedroslopez@users.noreply.github.com>
2021-08-01 23:13:07 -04:00
Pedro S. Lopez
8e56aef3ce fix: more stable latest version check (#805) 2021-08-01 23:04:02 -04:00
Wictor Nogueira
cd774bef17 feat: Add MessageMedia.fromUrl method (#769) 2021-07-31 16:36:11 +03:00
Pedro S. Lopez
9c2592e164 chore: temporarily stop update action from auto running 2021-07-20 14:51:58 -04:00
Pedro S. Lopez
ae6d61bda9 fix: correctly serialize messages with replyButtons 2021-07-19 22:23:06 -04:00
Pedro S. Lopez
98acd2312d delete gh branch automatically when closing update PR 2021-07-19 19:46:24 -04:00
Pedro Lopez
62c7c15f44 chore: update links 2021-07-19 00:19:40 -04:00
Pedro Lopez
e12c53f6ce chore: specify minimum required node version 2021-07-19 00:11:57 -04:00
Pedro S. Lopez
811008da4b Delete CNAME 2021-07-18 23:37:45 -04:00
Pedro S. Lopez
863284c9d1 Create CNAME 2021-07-18 23:37:21 -04:00
Pedro S. Lopez
ec95483518 Create CNAME 2021-07-18 23:36:02 -04:00
Pedro S. Lopez
ff2eb95751 Change WA Web update PR branch name 2021-07-18 22:57:18 -04:00
dependabot[bot]
1b5e9d2392 chore(deps-dev): bump mocha from 8.4.0 to 9.0.2 (#776)
Bumps [mocha](https://github.com/mochajs/mocha) from 8.4.0 to 9.0.2.
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v8.4.0...v9.0.2)

---
updated-dependencies:
- dependency-name: mocha
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-18 22:55:06 -04:00
Pedro Lopez
340e9764fe Publish gh-pages site (branch name change) 2021-07-18 22:43:07 -04:00
Rajeh Taher
084525ddfa Add Operating System information for bug reports. (#725)
* 📄 Add Operating System information for bug reports.

* 🐛 Forgot Line Break
2021-07-17 22:04:44 -04:00
github-actions[bot]
3398501ee6 Update supported WhatsApp Web version to v2.2126.11 (#766)
Co-authored-by: pedroslopez <pedroslopez@users.noreply.github.com>
Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-07-17 00:07:38 -04:00
tuyuribr
cdede835af Include Calls (#720)
* Get Call module

* The call event

* Update onCall index.d.ts
2021-07-17 00:05:53 -04:00
Pedro S. Lopez
449d0f01d8 Trim current version string 2021-07-16 03:19:58 -04:00
Pedro S. Lopez
4ed9312eb7 Update update.yml 2021-07-16 03:09:54 -04:00
Pedro S. Lopez
76deaad2fd Update update.yml 2021-07-16 03:05:18 -04:00
Pedro S. Lopez
284903dce4 Update README.md 2021-07-16 02:53:39 -04:00
Pedro S. Lopez
a03cc41d22 Add tests and detect WhatsApp Web updates (#686)
* test setup, add initializer tests

* test sending messages

* add script to check latest version

* add github action

* use env vars

* configure environment with .env file

* add test for sticker name and author

* add DownloadManager model

* test chats and contacts

* test for number utility functions

* throw error if no remote id has been set

* Update .version
2021-07-16 02:50:05 -04:00
ApeironTsuka
04d2308bbc Update node-webpmux 2.x syntax to 3.x (support upstream breaking change) (#762)
Co-authored-by: Apeiron <apeiron@none>
2021-07-15 22:50:54 -04:00
Pedro S. Lopez
dc9b7e5f3d Update minimum moduleRaid version to 5.0.2
close #741
2021-07-14 22:42:21 -04:00
dependabot[bot]
cc7a729223 chore(deps): bump puppeteer from 5.5.0 to 10.1.0 (#750)
Bumps [puppeteer](https://github.com/puppeteer/puppeteer) from 5.5.0 to 10.1.0.
- [Release notes](https://github.com/puppeteer/puppeteer/releases)
- [Changelog](https://github.com/puppeteer/puppeteer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/puppeteer/puppeteer/compare/v5.5.0...v10.1.0)

---
updated-dependencies:
- dependency-name: puppeteer
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-14 18:39:24 -04:00
dependabot[bot]
2ec46f674a chore(deps): bump sharp from 0.26.3 to 0.28.3 (#751)
Bumps [sharp](https://github.com/lovell/sharp) from 0.26.3 to 0.28.3.
- [Release notes](https://github.com/lovell/sharp/releases)
- [Changelog](https://github.com/lovell/sharp/blob/master/docs/changelog.md)
- [Commits](https://github.com/lovell/sharp/compare/v0.26.3...v0.28.3)

---
updated-dependencies:
- dependency-name: sharp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-14 18:35:59 -04:00
dependabot[bot]
22993fc23d chore(deps): bump node-webpmux from 2.0.3 to 3.0.0 (#749)
Bumps [node-webpmux](https://github.com/ApeironTsuka/node-webpmux) from 2.0.3 to 3.0.0.
- [Release notes](https://github.com/ApeironTsuka/node-webpmux/releases)
- [Commits](https://github.com/ApeironTsuka/node-webpmux/commits)

---
updated-dependencies:
- dependency-name: node-webpmux
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-07-14 18:33:36 -04:00
Edson Tégila
cd52075447 Add the option to use "browserWSEndpoint" (#727)
* Update Client.js

* Update package.json

* Update package.json

* 🚨🔥 Fixed ESLint and removed old code.

* Update README.md

* Update README.md

* Update Client.js

* chore(deps): bump sharp from 0.26.3 to 0.28.3

Bumps [sharp](https://github.com/lovell/sharp) from 0.26.3 to 0.28.3.
- [Release notes](https://github.com/lovell/sharp/releases)
- [Changelog](https://github.com/lovell/sharp/blob/master/docs/changelog.md)
- [Commits](https://github.com/lovell/sharp/compare/v0.26.3...v0.28.3)

---
updated-dependencies:
- dependency-name: sharp
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update package.json

* Update README.md

* Update example.js

* Update README.md

Co-authored-by: Rajeh Taher <52720753+PurpShell@users.noreply.github.com>
Co-authored-by: Rajeh Taher <rajeh@reforward.tk>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Aliyss Snow <33941859+Aliyss@users.noreply.github.com>
2021-07-13 10:27:00 -07:00
Rajeh Taher
54a07fa22f feat: Add support to suspicious links (#642) 2021-07-12 11:03:11 -07:00
Pedro S. Lopez
1d49f74ab4 Update dependabot.yml 2021-07-11 21:29:58 -04:00
Pedro S. Lopez
ea4dfb17f3 Create dependabot.yml 2021-07-11 21:28:39 -04:00
stefanfuchs
efa6cf98d2 fix: location class type (#718) 2021-07-12 00:54:32 +00:00
Giancarlo Rocha
9d715735ed feat: message forwarding score (#716) 2021-07-11 20:52:54 -04:00
Pedro Lopez
4afff38713 Fix download media (v1.13.2) 2021-07-09 03:08:52 -04:00
Pedro Lopez
b13dea0339 chore: mark version v1.13.1 2021-07-09 02:39:13 -04:00
Pedro S. Lopez
0ef6061d7e Fix downloading media for WhatsApp Web v2.2126.10 (#735)
* fix downloadMedia

* return a boolean for hasMedia
2021-07-09 02:38:31 -04:00
Pedro Lopez
0465507009 chore: mark version v1.13.0 2021-07-09 01:22:08 -04:00
Pedro Lopez
2fd96e76b9 update readme to indicate node 14 is required 2021-07-09 01:18:09 -04:00
Pedro Lopez
caab11cfe4 bump minimum required moduleraid version 2021-07-09 01:14:07 -04:00
Pedro S. Lopez
ebba1b9ab9 Update lint.yml 2021-06-05 19:02:08 -04:00
JoseHM8A
cdc00e934d feat: acceptGroupV4Invite (#677)
* Added option client.acceptGroupV4Invite()

* Update Client.js

* Update index.d.ts

Added a description to the inviteV4 object

Renamed "invite" by "inviteV4"

* Update Client.js

* Update Message.js

renamed "invite" to "inviteV4"

* Update Client.js

* Added message.acceptGroupV4Invite method

* Update index.d.ts

acceptGroupV4Invite

* better typings, refactor some names

Co-authored-by: Pedro Lopez <pedroslopez@me.com>
2021-06-05 17:10:47 -04:00
Pedro S. Lopez
795570a697 chore: update eslint and ecmaVersion (#680) 2021-06-02 23:39:01 -04:00
Pedro S. Lopez
0465742ffb chore: update lint action (#679)
* update lint action

* fix script path

* ignore docs

* update names
2021-06-02 23:17:28 -04:00
Ricardo Araújo Paes
38976558f5 feat(dev): add argument bypassCSP to use in pupperter (#635) 2021-06-01 22:05:44 -04:00
Wictor Nogueira
b895437458 add searchMessages method (#586)
* add searchMessages method

* fix typing

* fix typing

* remove unused statement

Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-06-01 21:54:27 -04:00
tuyuribr
0a061f982c feat: Add from which device the message was sent (#648)
* Add from which device the message was sent.

Use the message Id for fingerprint the device that was being use when the message was sent

* To single quotes

Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-05-31 21:03:23 -04:00
Aliyss Snow
63d11d3f84 feat: disable / enable WA Web features (#543)
* Added Features and Enabling/Disabling of Features within WhatsappWeb

* remove feature commands from example

Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
Co-authored-by: Pedro Lopez <pedroslopez@me.com>
2021-05-31 20:58:55 -04:00
renjop
5177a257cf feat: Get Orders and Products (#612)
* - Get products and orders

* - Get products and orders

* - Eslint fixes

* - Eslint fixes

* allow downloading media for products

* products and orders work on normal accounts

Co-authored-by: Renato Jop <renato.jop@consystec-corp.com>
Co-authored-by: Pedro Lopez <pedroslopez@me.com>
Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-05-31 20:46:43 -04:00
Wictor Nogueira
f506c171c1 add extra option to MessageSendOptions (#600)
Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-05-31 19:24:30 -04:00
tuyuribr
64e2cc48fc feat: openChatWindow can open new chats (#592)
Open the chat window even if you never chatted with the chatId

Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-05-31 19:21:57 -04:00
Wictor Nogueira
6c66ab2bef Add sendVideoAsGif option (#578)
* Add sendVideoAsGif option

* fix typo

Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
2021-05-31 19:18:10 -04:00
Rajeh Taher
efc7018f9a Add support for sticker Name and author (#527)
* Added Sticker author and sticker name support

This patch of Client.js includes support for sticker metadata

* Docs: stickerName and stickerAuthor in MessageOpts

* Hotfix_Sticker_Feature

fixes a bug

* Update global.html

* updated

* fixed comma

* Fixed duplicate code

* Fixing eslint

* Fixing eslint again

* eslint....

* fixing problem with eslint.

* move sticker exif data filling to Utils.formatToWebpSticker() function

* Update Client.js

* Added temporary stuff

* eslint

* Update Util.js

* eslint bad :D

* eslint

* polish work with files

* fix error and TODOs

* clean up code to match with repo code style

* update typescript params

* Update src/util/Util.js

camel Case

Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>

* Update Util.js

*  webp-converter  node-webpmux

* Update Util.js

*  Use node-webpmux

*  node-webpmux  node-webpmux-commonjs

* ✏️ Fixed require mode

* :heavy_plus_sign:node-webpmux  node-webpmux-commonjs

* ⬆️ Node-webpmux update changes

* 🚨 removing try/catch

* 🚨 complier warnings

* 🧐 stupid mistakes

* ⬆️ Upgrade required version

* 🐛 creating a buffer the right way

* 🐛 linting and simplification

* 🐛 unsimplification

* 🚨 eslint loves singlequotes

*  Added emojis / categories in metadata

* 🏷️ TypeScript Declarations

*  Sticker Categories in sendMessage

* 🏷️ Improved TS declarations

* fix stickerCategories type

* fix: don't set name/author if not defined

Co-authored-by: Marcelo Carvalho <mpirescarvalho17@gmail.com>
Co-authored-by: Pedro S. Lopez <pslamoros@hotmail.com>
Co-authored-by: Pedro S. Lopez <pedroslopez@me.com>
2021-05-31 19:13:30 -04:00
Pedro Lopez
5991b28b88 update supported whatsapp web ver to v2.2114.8 2021-04-20 23:02:33 -04:00
Pedro Lopez
2894832b00 chore: mark version v1.12.6 2021-04-20 22:59:35 -04:00
Pedro Lopez
6cece4a006 fix: emit disconnected event on page navigation
This also addresses an issue due to a change in behavior from WhatsApp Web when the session is logged out from the device.
2021-04-20 20:02:22 -04:00
Pedro Lopez
f1e2f32988 fix: click correct element on manual qr code refresh 2021-04-20 19:39:13 -04:00
76 changed files with 4496 additions and 402 deletions

2
.env.example Normal file
View File

@@ -0,0 +1,2 @@
WWEBJS_TEST_SESSION_PATH=test_session.json
WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us

View File

@@ -5,14 +5,16 @@
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"extends": ["eslint:recommended", "plugin:mocha/recommended"],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
"ecmaVersion": 2020
},
"plugins": ["mocha"],
"ignorePatterns": ["docs"],
"rules": {
"indent": [
"error",

View File

@@ -34,5 +34,8 @@ If applicable, add code snippets to help explain your problem.
- npm or yarn version (`npm -v`):
- whatsapp-web.js version:
**Other**
- Operating system (the one running node) [Linux / MacOS / Windows]:
- Operating system version (ex. Windows 10):
### Additional context
Add any other context about the problem here.

7
.github/dependabot.yml vendored Normal file
View File

@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
open-pull-requests-limit: 10
schedule:
interval: "monthly"

View File

@@ -6,19 +6,15 @@ on:
jobs:
eslint:
name: eslint
name: ESLint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install node v12
uses: actions/setup-node@v1
- uses: actions/checkout@v2
- name: Install node v14
uses: actions/setup-node@v2
with:
node-version: 12
- name: npm install
node-version: '14'
- name: Install dependencies
run: npm install
- name: eslint
uses: icrawl/action-eslint@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
job-name: eslint
- name: Run ESLint
run: ./node_modules/.bin/eslint .

39
.github/workflows/update.yml vendored Normal file
View File

@@ -0,0 +1,39 @@
name: Update
on:
schedule:
- cron: "0/15 * * * *"
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./tools/version-checker
steps:
- uses: actions/checkout@v2
- name: Install node v16
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install dependencies
run: npm install
- name: Run Updater
run: ./update-version
- name: Store WA Version
run: echo WA_VERSION=`cat ./.version` >> $GITHUB_ENV
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
branch: auto-wa-web-update/patch
delete-branch: true
commit-message: Update supported WhatsApp Web version to v${{ env.WA_VERSION }}
title: Update WhatsApp Web Version (${{ env.WA_VERSION }})
body: |
A new version of WhatsApp Web has been detected!
Tests should be run against this new version before merging.
labels: WhatsApp Change
reviewers: pedroslopez

View File

@@ -12,3 +12,6 @@ yarn-debug.log*
yarn-error.log*
*session.json
.env
tools/
tests/

View File

@@ -1,4 +1,4 @@
[![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.2106.5](https://img.shields.io/badge/WhatsApp_Web-2.2106.5-brightgreen.svg) [![Discord Chat](https://img.shields.io/discord/698610475432411196.svg?logo=discord)](https://discord.gg/H7DqQs4)
[![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.2126.14](https://img.shields.io/badge/WhatsApp_Web-2.2126.14-brightgreen.svg) [![Discord Chat](https://img.shields.io/discord/698610475432411196.svg?logo=discord)](https://discord.gg/H7DqQs4)
# whatsapp-web.js
A WhatsApp API client that connects through the WhatsApp Web browser app
@@ -11,12 +11,13 @@ It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocke
The module is now available on npm! `npm i whatsapp-web.js`
Please note that Node v10.18.1+ is required due to Puppeteer.
Please note that Node v12+ is required.
## Example usage
```js
const { Client } = require('whatsapp-web.js');
const client = new Client();
client.on('qr', (qr) => {
@@ -39,6 +40,39 @@ client.initialize();
Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js) for another example with more use cases.
## Remote Access
You could also connect to any previously existing browser instance:
```js
const client = new Client({
puppeteer: {
browserWSEndpoint: `ws://localhost:3000`
}
});
```
### Docker
1) Installing a browser using browserless:
```
docker run \
--rm \
-p 3000:3000 \
-e "MAX_CONCURRENT_SESSIONS=1" \
browserless/chrome:latest
```
Reference: https://docs.browserless.io/docs/docker-quickstart.html
### Remote Debugging
2) Running a browser with websocket remote debugging enabled:
> chrome.exe --remote-debugging-port=9222
After that check the following webpage and check http://127.0.0.1:9220/json and get the **webSocketDebuggerUrl**
## Supported features
| Feature | Status |
@@ -46,7 +80,7 @@ Take a look at [example.js](https://github.com/pedroslopez/whatsapp-web.js/blob/
| Send messages | ✅ |
| Receive messages | ✅ |
| Send media (images/audio/documents) | ✅ |
| Send media (video) | ✅ [(requires google chrome)](https://waguide.pedroslopez.me/features/handling-attachments#caveat-for-sending-videos-and-gifs) |
| Send media (video) | ✅ [(requires google chrome)](https://guide.wwebjs.dev/features/handling-attachments#caveat-for-sending-videos-and-gifs) |
| Send stickers | ✅ |
| Receive media (images/audio/video/documents) | ✅ |
| Send contact cards | ✅ |
@@ -71,9 +105,10 @@ Something missing? Make an issue and let us know!
## Links
* [Reference](https://pedroslopez.me/whatsapp-web.js)
* [Guide](https://waguide.pedroslopez.me/) _(work in progress)_
* [Reference](https://docs.wwebjs.dev/)
* [Guide](https://guide.wwebjs.dev/) _(work in progress)_
* [GitHub](https://github.com/pedroslopez/whatsapp-web.js)
* [npm](https://npmjs.org/package/whatsapp-web.js)
## Contributing

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Base</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Base</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -50,7 +50,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: BusinessContact</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: BusinessContact</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -290,7 +290,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

1
docs/CNAME Normal file
View File

@@ -0,0 +1 @@
docs.wwebjs.dev

159
docs/Call.html Normal file
View File

@@ -0,0 +1,159 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Class: Call</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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-main" role="main">
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Call</span></h1>
<p class="source-link">Source: <a href="structures_Call.js.html#source-line-9">structures/<wbr>Call.<wbr>js:9</a></p>
<div class="symbol-classdesc">
<p>Represents a Call on WhatsApp</p>
</div>
<dl class="dl-compact">
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Properties</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Call.html#canHandleLocally">canHandleLocally</a></dt>
<dd>
</dd>
<dt><a href="Call.html#from">from</a></dt>
<dd>
</dd>
<dt><a href="Call.html#fromMe">fromMe</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Call.html#id">id</a></dt>
<dd>
</dd>
<dt><a href="Call.html#isGroup">isGroup</a></dt>
<dd>
</dd>
<dt><a href="Call.html#isVideo">isVideo</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Call.html#participants">participants</a></dt>
<dd>
</dd>
<dt><a href="Call.html#timestamp">timestamp</a></dt>
<dd>
</dd>
<dt><a href="Call.html#webClientShouldHandle">webClientShouldHandle</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<h2 id="Call">new&nbsp;<span class="symbol-name">Call</span><span class="signature"><span class="signature-params">()</span></span></h2>
<dl class="dl-compact">
<dt>Extends</dt>
<dd><a href="Base.html">Base</a></dd>
</dl>
</section>
<section>
<h2>Properties</h2>
<section>
<h3 id="canHandleLocally"><span class="symbol-name">canHandleLocally</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Indicates if the call can be handled in waweb</p>
<dl class="dl-compact">
</dl>
<h3 id="from"><span class="symbol-name">from</span><small class="property-type">
&nbsp;string</small></h3>
<p>From</p>
<dl class="dl-compact">
</dl>
<h3 id="fromMe"><span class="symbol-name">fromMe</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Indicates if the call was sent by the current user</p>
<dl class="dl-compact">
</dl>
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
&nbsp;string</small></h3>
<p>Call ID</p>
<dl class="dl-compact">
</dl>
<h3 id="isGroup"><span class="symbol-name">isGroup</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Is Group</p>
<dl class="dl-compact">
</dl>
<h3 id="isVideo"><span class="symbol-name">isVideo</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Is video</p>
<dl class="dl-compact">
</dl>
<h3 id="participants"><span class="symbol-name">participants</span><small class="property-type">
&nbsp;object</small></h3>
<p>Object with participants</p>
<dl class="dl-compact">
</dl>
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
&nbsp;number</small></h3>
<p>Unix timestamp for when the call was created</p>
<dl class="dl-compact">
</dl>
<h3 id="webClientShouldHandle"><span class="symbol-name">webClientShouldHandle</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Indicates if the call Should be handled in waweb</p>
<dl class="dl-compact">
</dl>
</section>
</section>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Chat</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Chat</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -224,8 +224,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing Boolean</code> 
<p>result</p>
<p><code>Promise containing Boolean</code> <p>result</p>
</p>
</dd>
</dl>
@@ -240,8 +239,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing Boolean</code> 
<p>result</p>
<p><code>Promise containing Boolean</code> <p>result</p>
</p>
</dd>
</dl>
@@ -374,8 +372,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
</p>
</dd>
</dl>
@@ -426,8 +423,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="Message.html">Message</a></code> 
<p>Message that was just sent</p>
<p><code>Promise containing <a href="Message.html">Message</a></code> <p>Message that was just sent</p>
</p>
</dd>
</dl>
@@ -437,8 +433,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing Boolean</code> 
<p>result</p>
<p><code>Promise containing Boolean</code> <p>result</p>
</p>
</dd>
</dl>
@@ -468,8 +463,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>New pin state</p>
<p><code>Promise containing boolean</code> <p>New pin state</p>
</p>
</dd>
</dl>
@@ -483,7 +477,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Client</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Client</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -26,7 +26,7 @@
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Client</span></h1>
<p class="source-link">Source: <a href="Client.js.html#source-line-51">Client.<wbr>js:51</a></p>
<p class="source-link">Source: <a href="Client.js.html#source-line-52">Client.<wbr>js:52</a></p>
<div class="symbol-classdesc">
<p>Starting point for interacting with the WhatsApp Web API</p>
</div>
@@ -55,6 +55,9 @@
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Client.html#acceptGroupV4Invite">acceptGroupV4Invite(inviteV4)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#acceptInvite">acceptInvite(inviteCode)</a></dt>
<dd>
</dd>
@@ -125,14 +128,17 @@
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
<dd>
</dd>
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
<dt><a href="Client.html#resetState">resetState()</a></dt>
<dd>
</dd>
<dt><a href="Client.html#resetState">resetState()</a></dt>
<dt><a href="Client.html#searchMessages">searchMessages(query[, options])</a></dt>
<dd>
</dd>
<dt><a href="Client.html#sendMessage">sendMessage(chatId, content[, options])</a></dt>
@@ -196,6 +202,9 @@
<dt><a href="Client.html#event:group_update">group_update</a></dt>
<dd>
</dd>
<dt><a href="Client.html#event:incoming_call">incoming_call</a></dt>
<dd>
</dd>
<dt><a href="Client.html#event:media_uploaded">media_uploaded</a></dt>
<dd>
</dd>
@@ -205,13 +214,13 @@
<dt><a href="Client.html#event:message_ack">message_ack</a></dt>
<dd>
</dd>
<dt><a href="Client.html#event:message_create">message_create</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Client.html#event:message_create">message_create</a></dt>
<dd>
</dd>
<dt><a href="Client.html#event:message_revoke_everyone">message_revoke_everyone</a></dt>
<dd>
</dd>
@@ -458,6 +467,20 @@
<p>Ffmpeg path to use when formating videos to webp while sending stickers</p>
</td>
</tr>
<tr>
<td>
<p>bypassCSP</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Sets bypassing of page's Content-Security-Policy.</p>
</td>
</tr>
</tbody>
</table>
</td>
@@ -498,6 +521,44 @@
</section>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="acceptGroupV4Invite"><span class="symbol-name">acceptGroupV4Invite</span><span class="signature"><span class="signature-params">(inviteV4)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing Object</span></span></h3>
<p>Accepts a private invitation to join a group</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>inviteV4</p>
</td>
<td>
<p>object</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Invite V4 Info</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing Object</code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="acceptInvite"><span class="symbol-name">acceptInvite</span><span class="signature"><span class="signature-params">(inviteCode)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing string</span></span></h3>
<p>Accepts an invitation to join a group</p>
@@ -533,8 +594,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing string</code> 
<p>Id of the joined Chat</p>
<p><code>Promise containing string</code> <p>Id of the joined Chat</p>
</p>
</dd>
</dl>
@@ -596,18 +656,15 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Object</code> 
<p>createRes</p>
<p><code>Object</code> <p>createRes</p>
</p>
</dd>
<dd>
<p><code>string</code> 
<p>createRes.gid - ID for the group that was just created</p>
<p><code>string</code> <p>createRes.gid - ID for the group that was just created</p>
</p>
</dd>
<dd>
<p><code>Object with string properties</code> 
<p>createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.</p>
<p><code>Object with string properties</code> <p>createRes.missingParticipants - participants that were not added to the group. Keys represent the ID for participant that was not added and its value is a status code that represents the reason why participant could not be added. This is usually 403 if the user's privacy settings don't allow you to add them to groups.</p>
</p>
</dd>
</dl>
@@ -816,8 +873,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing object</code> 
<p>Invite information</p>
<p><code>Promise containing object</code> <p>Invite information</p>
</p>
</dd>
</dl>
@@ -1098,8 +1154,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>New pin state. Could be false if the max number of pinned chats was reached.</p>
<p><code>Promise containing boolean</code> <p>New pin state. Could be false if the max number of pinned chats was reached.</p>
</p>
</dd>
</dl>
@@ -1109,6 +1164,108 @@
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="searchMessages"><span class="symbol-name">searchMessages</span><span class="signature"><span class="signature-params">(query[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing Array of <a href="Message.html">Message</a></span></span></h3>
<p>Searches for messages</p>
<section>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>query</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>options</p>
</td>
<td>
<p>Object</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Values in <code>options</code> have the following properties:</p>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>page</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>limit</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>chatId</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing Array of <a href="Message.html">Message</a></code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="sendMessage"><span class="symbol-name">sendMessage</span><span class="signature"><span class="signature-params">(chatId, content[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Send a message to a specific chatId</p>
<section>
@@ -1169,8 +1326,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="Message.html">Message</a></code> 
<p>Message that was just sent</p>
<p><code>Promise containing <a href="Message.html">Message</a></code> <p>Message that was just sent</p>
</p>
</dd>
</dl>
@@ -1213,8 +1369,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>result</p>
<p><code>Promise containing boolean</code> <p>result</p>
</p>
</dd>
</dl>
@@ -1336,8 +1491,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>New pin state</p>
<p><code>Promise containing boolean</code> <p>New pin state</p>
</p>
</dd>
</dl>
@@ -1599,13 +1753,13 @@
<p>reason</p>
</td>
<td>
<p><a href="global.html#WAState">WAState</a></p>
<p>(<a href="global.html#WAState">WAState</a> or "NAVIGATION")</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>state that caused the disconnect</p>
<p>reason that caused the disconnect</p>
</td>
</tr>
</tbody>
@@ -1712,6 +1866,163 @@
</section>
<dl class="dl-compact">
</dl>
<h3 id="event:incoming_call"><span class="symbol-name">incoming_call</span></h3>
<p>Emitted when a call is received</p>
<section>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>call</p>
</td>
<td>
<p>object</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Values in <code>call</code> have the following properties:</p>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>id</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Call id</p>
</td>
</tr>
<tr>
<td>
<p>peerJid</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Who called</p>
</td>
</tr>
<tr>
<td>
<p>isVideo</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>if is video</p>
</td>
</tr>
<tr>
<td>
<p>isGroup</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>if is group</p>
</td>
</tr>
<tr>
<td>
<p>canHandleLocally</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>if we can handle in waweb</p>
</td>
</tr>
<tr>
<td>
<p>outgoing</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>if is outgoing</p>
</td>
</tr>
<tr>
<td>
<p>webClientShouldHandle</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>If Waweb should handle</p>
</td>
</tr>
<tr>
<td>
<p>participants</p>
</td>
<td>
<p>object</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>Participants</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<h3 id="event:media_uploaded"><span class="symbol-name">media_uploaded</span></h3>
<p>Emitted when media has been uploaded for a message sent by the client.</p>
<section>
@@ -1987,7 +2298,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: Client.js</title>
<title>whatsapp-web.js 1.14.1 &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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -42,7 +42,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 } &#x3D; require(&#x27;./structures&#x27;);
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call } &#x3D; require(&#x27;./structures&#x27;);
/**
* Starting point for interacting with the WhatsApp Web API
* @extends {EventEmitter}
@@ -61,6 +61,7 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
* @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.
*
* @fires Client#qr
* @fires Client#authenticated
@@ -95,8 +96,16 @@ class Client extends EventEmitter {
* Sets up events and requirements, kicks off authentication request
*/
async initialize() {
const browser &#x3D; await puppeteer.launch(this.options.puppeteer);
const page &#x3D; (await browser.pages())[0];
let [browser, page] &#x3D; [null, null];
if(this.options.puppeteer &amp;amp;&amp;amp; this.options.puppeteer.browserWSEndpoint) {
browser &#x3D; await puppeteer.connect(this.options.puppeteer);
page &#x3D; await browser.newPage();
} else {
browser &#x3D; await puppeteer.launch(this.options.puppeteer);
page &#x3D; (await browser.pages())[0];
}
page.setUserAgent(this.options.userAgent);
this.pupBrowser &#x3D; browser;
@@ -113,6 +122,10 @@ class Client extends EventEmitter {
}, this.options.session);
}
if(this.options.bypassCSP) {
await page.setBypassCSP(true);
}
await page.goto(WhatsWebURL, {
waitUntil: &#x27;load&#x27;,
timeout: 0,
@@ -147,18 +160,18 @@ class Client extends EventEmitter {
} else {
const getQrCode &#x3D; async () &#x3D;&gt; {
// Check if retry button is present
var QR_RETRY_SELECTOR &#x3D; &#x27;div[data-ref] &gt; span &gt; div&#x27;;
var QR_RETRY_SELECTOR &#x3D; &#x27;div[data-ref] &gt; span &gt; button&#x27;;
var qrRetry &#x3D; await page.$(QR_RETRY_SELECTOR);
if (qrRetry) {
await qrRetry.click();
}
// Wait for QR Code
const QR_CANVAS_SELECTOR &#x3D; &#x27;canvas&#x27;;
await page.waitForSelector(QR_CANVAS_SELECTOR, { timeout: this.options.qrTimeoutMs });
const qrImgData &#x3D; await page.$eval(QR_CANVAS_SELECTOR, canvas &#x3D;&gt; [].slice.call(canvas.getContext(&#x27;2d&#x27;).getImageData(0, 0, 264, 264).data));
const qr &#x3D; jsQR(qrImgData, 264, 264).data;
/**
* Emitted when the QR code is received
* @event Client#qr
@@ -366,7 +379,7 @@ class Client extends EventEmitter {
/**
* Emitted when the client has been disconnected
* @event Client#disconnected
* @param {WAState} reason state that caused the disconnect
* @param {WAState|&quot;NAVIGATION&quot;} reason reason that caused the disconnect
*/
this.emit(Events.DISCONNECTED, state);
this.destroy();
@@ -388,6 +401,24 @@ class Client extends EventEmitter {
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
});
await page.exposeFunction(&#x27;onIncomingCall&#x27;, (call) &#x3D;&gt; {
/**
* Emitted when a call is received
* @event Client#incoming_call
* @param {object} call
* @param {number} call.id - Call id
* @param {string} call.peerJid - Who called
* @param {boolean} call.isVideo - if is video
* @param {boolean} call.isGroup - if is group
* @param {boolean} call.canHandleLocally - if we can handle in waweb
* @param {boolean} call.outgoing - if is outgoing
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
* @param {object} call.participants - Participants
*/
const cll &#x3D; new Call(this,call);
this.emit(Events.INCOMING_CALL, cll);
});
await page.evaluate(() &#x3D;&gt; {
window.Store.Msg.on(&#x27;add&#x27;, (msg) &#x3D;&gt; { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on(&#x27;change&#x27;, (msg) &#x3D;&gt; { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
@@ -397,6 +428,7 @@ class Client extends EventEmitter {
window.Store.Msg.on(&#x27;remove&#x27;, (msg) &#x3D;&gt; { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
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); });
});
/**
@@ -404,6 +436,13 @@ class Client extends EventEmitter {
* @event Client#ready
*/
this.emit(Events.READY);
// Disconnect when navigating away
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
this.pupPage.on(&#x27;framenavigated&#x27;, async () &#x3D;&gt; {
this.emit(Events.DISCONNECTED, &#x27;NAVIGATION&#x27;);
await this.destroy();
});
}
/**
@@ -454,6 +493,7 @@ class Client extends EventEmitter {
* @typedef {Object} MessageSendOptions
* @property {boolean} [linkPreview&#x3D;true] - Show links preview
* @property {boolean} [sendAudioAsVoice&#x3D;false] - Send audio as voice message
* @property {boolean} [sendVideoAsGif&#x3D;false] - Send video as gif
* @property {boolean} [sendMediaAsSticker&#x3D;false] - Send media as a sticker
* @property {boolean} [sendMediaAsDocument&#x3D;false] - Send media as a document
* @property {boolean} [parseVCards&#x3D;true] - Automatically parse vCards and send them as contacts
@@ -461,6 +501,9 @@ class Client extends EventEmitter {
* @property {string} [quotedMessageId] - Id of the message that is being quoted (or replied to)
* @property {Contact[]} [mentions] - Contacts that are being mentioned in the message
* @property {boolean} [sendSeen&#x3D;true] - Mark the conversation as seen after sending the message
* @property {string} [stickerAuthor&#x3D;undefined] - Sets the author of the sticker, (if sendMediaAsSticker is true).
* @property {string} [stickerName&#x3D;undefined] - Sets the name of the sticker, (if sendMediaAsSticker is true).
* @property {string[]} [stickerCategories&#x3D;undefined] - Sets the categories of the sticker, (if sendMediaAsSticker is true). Provide emoji char array, can be null.
* @property {MessageMedia} [media] - Media to be sent
*/
@@ -476,12 +519,14 @@ class Client extends EventEmitter {
let internalOptions &#x3D; {
linkPreview: options.linkPreview &#x3D;&#x3D;&#x3D; false ? undefined : true,
sendAudioAsVoice: options.sendAudioAsVoice,
sendVideoAsGif: options.sendVideoAsGif,
sendMediaAsSticker: options.sendMediaAsSticker,
sendMediaAsDocument: options.sendMediaAsDocument,
caption: options.caption,
quotedMessageId: options.quotedMessageId,
parseVCards: options.parseVCards &#x3D;&#x3D;&#x3D; false ? false : true,
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact &#x3D;&gt; contact.id._serialized) : []
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact &#x3D;&gt; contact.id._serialized) : [],
...options.extra
};
const sendSeen &#x3D; typeof options.sendSeen &#x3D;&#x3D;&#x3D; &#x27;undefined&#x27; ? true : options.sendSeen;
@@ -505,7 +550,12 @@ class Client extends EventEmitter {
}
if (internalOptions.sendMediaAsSticker &amp;amp;&amp;amp; internalOptions.attachment) {
internalOptions.attachment &#x3D; await Util.formatToWebpSticker(internalOptions.attachment);
internalOptions.attachment &#x3D;
await Util.formatToWebpSticker(internalOptions.attachment, {
name: options.stickerName,
author: options.stickerAuthor,
categories: options.stickerCategories
});
}
const newMessage &#x3D; await this.pupPage.evaluate(async (chatId, message, options, sendSeen) &#x3D;&gt; {
@@ -523,6 +573,24 @@ class Client extends EventEmitter {
return new Message(this, newMessage);
}
/**
* Searches for messages
* @param {string} query
* @param {Object} [options]
* @param {number} [options.page]
* @param {number} [options.limit]
* @param {string} [options.chatId]
* @returns {Promise&amp;lt;Message[]&gt;}
*/
async searchMessages(query, options &#x3D; {}) {
const messages &#x3D; await this.pupPage.evaluate(async (query, page, count, remote) &#x3D;&gt; {
const { messages } &#x3D; await window.Store.Msg.search(query, page, count, remote);
return messages.map(msg &#x3D;&gt; window.WWebJS.getMessageModel(msg));
}, query, options.page, options.limit, options.chatId);
return messages.map(msg &#x3D;&gt; new Message(this, msg));
}
/**
* Get all current chat instances
* @returns {Promise&amp;lt;Array&amp;lt;Chat&gt;&gt;}
@@ -597,6 +665,20 @@ class Client extends EventEmitter {
return chatId._serialized;
}
/**
* Accepts a private invitation to join a group
* @param {object} inviteV4 Invite V4 Info
* @returns {Promise&amp;lt;Object&gt;}
*/
async acceptGroupV4Invite(inviteInfo) {
if(!inviteInfo.inviteCode) throw &#x27;Invalid invite code, try passing the message.inviteV4 object&#x27;;
if (inviteInfo.inviteCodeExp &#x3D;&#x3D; 0) throw &#x27;Expired invite code&#x27;;
return await this.pupPage.evaluate(async inviteInfo &#x3D;&gt; {
let { groupId, fromId, inviteCode, inviteCodeExp, toId } &#x3D; inviteInfo;
return await window.Store.Wap.acceptGroupV4Invite(groupId, fromId, inviteCode, String(inviteCodeExp), toId);
}, inviteInfo);
}
/**
* Sets the current user&#x27;s status message
* @param {string} status New status message
@@ -893,7 +975,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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: ClientInfo</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: ClientInfo</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -213,18 +213,15 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>object</code> 
<p>batteryStatus</p>
<p><code>object</code> <p>batteryStatus</p>
</p>
</dd>
<dd>
<p><code>number</code> 
<p>batteryStatus.battery - The current battery percentage</p>
<p><code>number</code> <p>batteryStatus.battery - The current battery percentage</p>
</p>
</dd>
<dd>
<p><code>boolean</code> 
<p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
<p><code>boolean</code> <p>batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)</p>
</p>
</dd>
</dl>
@@ -238,7 +235,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Contact</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Contact</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -257,7 +257,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: GroupChat</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: GroupChat</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -405,8 +405,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing {status: number}</code> 
<p>Object with status code indicating if the operation was successful</p>
<p><code>Promise containing {status: number}</code> <p>Object with status code indicating if the operation was successful</p>
</p>
</dd>
</dl>
@@ -491,8 +490,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing string</code> 
<p>Group's invite code</p>
<p><code>Promise containing string</code> <p>Group's invite code</p>
</p>
</dd>
</dl>
@@ -602,8 +600,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing {status: number}</code> 
<p>Object with status code indicating if the operation was successful</p>
<p><code>Promise containing {status: number}</code> <p>Object with status code indicating if the operation was successful</p>
</p>
</dd>
</dl>
@@ -803,8 +800,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
</p>
</dd>
</dl>
@@ -844,8 +840,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing boolean</code> 
<p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
<p><code>Promise containing boolean</code> <p>Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.</p>
</p>
</dd>
</dl>
@@ -921,7 +916,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: GroupNotification</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: GroupNotification</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -233,7 +233,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: InterfaceController</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: InterfaceController</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -39,16 +39,28 @@
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="InterfaceController.html#checkFeatureStatus">checkFeatureStatus(feature)</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#closeRightDrawer">closeRightDrawer()</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#openChatDrawer">openChatDrawer(chatId)</a></dt>
<dt><a href="InterfaceController.html#disableFeatures">disableFeatures(features)</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#enableFeatures">enableFeatures(features)</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="InterfaceController.html#getFeatures">getFeatures()</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#openChatDrawer">openChatDrawer(chatId)</a></dt>
<dd>
</dd>
<dt><a href="InterfaceController.html#openChatSearch">openChatSearch(chatId)</a></dt>
<dd>
</dd>
@@ -78,12 +90,119 @@
<section>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="checkFeatureStatus"><span class="symbol-name">checkFeatureStatus</span><span class="signature"><span class="signature-params">(feature)</span></span></h3>
<p>Check if Feature is enabled</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>feature</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>status to check</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="closeRightDrawer"><span class="symbol-name">closeRightDrawer</span><span class="signature"><span class="signature-params">()</span></span></h3>
<p>Closes the Right Drawer</p>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="disableFeatures"><span class="symbol-name">disableFeatures</span><span class="signature"><span class="signature-params">(features)</span></span></h3>
<p>Disable Features</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>features</p>
</td>
<td>
<p>Array of string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>to be disabled</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="enableFeatures"><span class="symbol-name">enableFeatures</span><span class="signature"><span class="signature-params">(features)</span></span></h3>
<p>Enable Features</p>
<section>
<h4>Parameter</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>features</p>
</td>
<td>
<p>Array of string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>to be enabled</p>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getFeatures"><span class="symbol-name">getFeatures</span><span class="signature"><span class="signature-params">()</span></span></h3>
<p>Get all Features</p>
<dl class="dl-compact">
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="openChatDrawer"><span class="symbol-name">openChatDrawer</span><span class="signature"><span class="signature-params">(chatId)</span></span></h3>
<p>Opens the Chat Drawer</p>
<section>
@@ -263,7 +382,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Label</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Label</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -163,7 +163,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Location</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Location</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -149,7 +149,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Message</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Message</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -26,7 +26,7 @@
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Message</span></h1>
<p class="source-link">Source: <a href="structures_Message.js.html#source-line-12">structures/<wbr>Message.<wbr>js:12</a></p>
<p class="source-link">Source: <a href="structures_Message.js.html#source-line-13">structures/<wbr>Message.<wbr>js:13</a></p>
<div class="symbol-classdesc">
<p>Represents a Message on WhatsApp</p>
</div>
@@ -51,6 +51,12 @@
<dt><a href="Message.html#broadcast">broadcast</a></dt>
<dd>
</dd>
<dt><a href="Message.html#deviceType">deviceType</a></dt>
<dd>
</dd>
<dt><a href="Message.html#forwardingScore">forwardingScore</a></dt>
<dd>
</dd>
<dt><a href="Message.html#from">from</a></dt>
<dd>
</dd>
@@ -70,6 +76,9 @@
<dt><a href="Message.html#id">id</a></dt>
<dd>
</dd>
<dt><a href="Message.html#inviteV4">inviteV4</a></dt>
<dd>
</dd>
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
<dd>
</dd>
@@ -85,14 +94,17 @@
<dt><a href="Message.html#location">location</a></dt>
<dd>
</dd>
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Message.html#mediaKey">mediaKey</a></dt>
<dt><a href="Message.html#mentionedIds">mentionedIds</a></dt>
<dd>
</dd>
<dt><a href="Message.html#mentionedIds">mentionedIds</a></dt>
<dt><a href="Message.html#orderId">orderId</a></dt>
<dd>
</dd>
<dt><a href="Message.html#timestamp">timestamp</a></dt>
@@ -101,6 +113,9 @@
<dt><a href="Message.html#to">to</a></dt>
<dd>
</dd>
<dt><a href="Message.html#token">token</a></dt>
<dd>
</dd>
<dt><a href="Message.html#type">type</a></dt>
<dd>
</dd>
@@ -116,6 +131,9 @@
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Message.html#acceptGroupV4Invite">acceptGroupV4Invite()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#delete">delete(everyone)</a></dt>
<dd>
</dd>
@@ -141,6 +159,9 @@
<dt><a href="Message.html#getMentions">getMentions()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#getOrder">getOrder()</a></dt>
<dd>
</dd>
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
<dd>
</dd>
@@ -192,6 +213,17 @@
<p>Indicates if the message was a broadcast</p>
<dl class="dl-compact">
</dl>
<h3 id="deviceType"><span class="symbol-name">deviceType</span><small class="property-type">
&nbsp;string</small></h3>
<p>String that represents from which device type the message was sent</p>
<dl class="dl-compact">
</dl>
<h3 id="forwardingScore"><span class="symbol-name">forwardingScore</span><small class="property-type">
&nbsp;number</small></h3>
<p>Indicates how many times the message was forwarded.</p>
<p>The maximum value is 127.</p>
<dl class="dl-compact">
</dl>
<h3 id="from"><span class="symbol-name">from</span><small class="property-type">
&nbsp;string</small></h3>
<p>ID for the Chat that this message was sent to, except if the message was sent by the current user.</p>
@@ -217,6 +249,11 @@
<p>ID that represents the message</p>
<dl class="dl-compact">
</dl>
<h3 id="inviteV4"><span class="symbol-name">inviteV4</span><small class="property-type">
&nbsp;object</small></h3>
<p>Group Invite Data</p>
<dl class="dl-compact">
</dl>
<h3 id="isForwarded"><span class="symbol-name">isForwarded</span><small class="property-type">
&nbsp;boolean</small></h3>
<p>Indicates if the message was forwarded</p>
@@ -233,7 +270,7 @@
<dl class="dl-compact">
</dl>
<h3 id="links"><span class="symbol-name">links</span><small class="property-type">
&nbsp;Array of string</small></h3>
&nbsp;Array of {link: string, isSuspicious: boolean}</small></h3>
<p>Links included in the message.</p>
<dl class="dl-compact">
</dl>
@@ -252,6 +289,11 @@
<p>Indicates the mentions in the message body.</p>
<dl class="dl-compact">
</dl>
<h3 id="orderId"><span class="symbol-name">orderId</span><small class="property-type">
&nbsp;string</small></h3>
<p>Order ID for message type ORDER</p>
<dl class="dl-compact">
</dl>
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
&nbsp;number</small></h3>
<p>Unix timestamp for when the message was created</p>
@@ -264,6 +306,11 @@
If the message is sent by another user, it will be the ID for the current user.</p>
<dl class="dl-compact">
</dl>
<h3 id="token"><span class="symbol-name">token</span><small class="property-type">
&nbsp;string</small></h3>
<p>Order Token for message type ORDER</p>
<dl class="dl-compact">
</dl>
<h3 id="type"><span class="symbol-name">type</span><small class="property-type">
&nbsp;<a href="global.html#MessageTypes">MessageTypes</a></small></h3>
<p>Message type</p>
@@ -277,6 +324,15 @@
</section>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="acceptGroupV4Invite"><span class="symbol-name">acceptGroupV4Invite</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing Object</span></span></h3>
<p>Accept Group V4 Invite</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing Object</code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="delete"><span class="symbol-name">delete</span><span class="signature"><span class="signature-params">(everyone)</span></span></h3>
<p>Deletes a message from the chat</p>
@@ -394,6 +450,15 @@
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getOrder"><span class="symbol-name">getOrder</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Order.html">Order</a></span></span></h3>
<p>Gets the order associated with a given message</p>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="Order.html">Order</a></code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
<h3 id="getQuotedMessage"><span class="symbol-name">getQuotedMessage</span><span class="signature"><span class="signature-params">()</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
<p>Returns the quoted message, if any</p>
<dl class="dl-compact">
@@ -487,7 +552,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: MessageMedia</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: MessageMedia</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -26,7 +26,7 @@
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">MessageMedia</span></h1>
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-13">structures/<wbr>MessageMedia.<wbr>js:13</a></p>
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-15">structures/<wbr>MessageMedia.<wbr>js:15</a></p>
<div class="symbol-classdesc">
<p>Media attached to a message</p>
</div>
@@ -61,7 +61,7 @@
</div>
</div>
<div class="summary-callout">
<h2 class="summary-callout-heading">Method</h2>
<h2 class="summary-callout-heading">Methods</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
@@ -71,6 +71,11 @@
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="MessageMedia.html#.fromUrl">fromUrl(url[, options])</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
</div>
@@ -159,7 +164,7 @@
<dl class="dl-compact">
</dl>
</section>
<h2>Method</h2>
<h2>Methods</h2>
<section>
<div class="symbol-detail-labels"><span class="label label-static">static</span></div>
<h3 id=".fromFilePath"><span class="symbol-name">fromFilePath</span><span class="signature"><span class="signature-params">(filePath)</span>&nbsp;&rarr; <span class="signature-returns"> <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
@@ -198,6 +203,123 @@
<p><code><a href="MessageMedia.html">MessageMedia</a></code> </p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span>&nbsp;<span class="label label-static">static</span></div>
<h3 id=".fromUrl"><span class="symbol-name">fromUrl</span><span class="signature"><span class="signature-params">(url[, options])</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
<p>Creates a MessageMedia instance from a URL</p>
<section>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>url</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>options</p>
</td>
<td>
<p>Object</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Values in <code>options</code> have the following properties:</p>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>unsafeMime</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Defaults to <code>false</code>.</p>
</td>
</tr>
<tr>
<td>
<p>client</p>
</td>
<td>
<p>object</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>reqOptions</p>
</td>
<td>
<p>object</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>reqOptions.size</p>
</td>
<td>
<p>number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Defaults to <code>0</code>.</p>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> </p>
</dd>
</dl>
</section>
</section>
</div>
@@ -208,7 +330,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

117
docs/Order.html Normal file
View File

@@ -0,0 +1,117 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Class: Order</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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-main" role="main">
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Order</span></h1>
<p class="source-link">Source: <a href="structures_Order.js.html#source-line-10">structures/<wbr>Order.<wbr>js:10</a></p>
<div class="symbol-classdesc">
<p>Represents a Order on WhatsApp</p>
</div>
<dl class="dl-compact">
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Properties</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Order.html#createdAt">createdAt</a></dt>
<dd>
</dd>
<dt><a href="Order.html#currency">currency</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Order.html#subtotal">subtotal</a></dt>
<dd>
</dd>
<dt><a href="Order.html#total">total</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
</div>
</div>
</div>
</section>
<section>
<h2 id="Order">new&nbsp;<span class="symbol-name">Order</span><span class="signature"><span class="signature-params">()</span></span></h2>
<dl class="dl-compact">
<dt>Extends</dt>
<dd><a href="Base.html">Base</a></dd>
</dl>
</section>
<section>
<h2>Properties</h2>
<section>
<h3 id="createdAt"><span class="symbol-name">createdAt</span><small class="property-type">
&nbsp;number</small></h3>
<p>Order Created At</p>
<dl class="dl-compact">
</dl>
<h3 id="currency"><span class="symbol-name">currency</span><small class="property-type">
&nbsp;string</small></h3>
<p>Order Currency</p>
<dl class="dl-compact">
</dl>
<h3 id="subtotal"><span class="symbol-name">subtotal</span><small class="property-type">
&nbsp;string</small></h3>
<p>Order Subtotal</p>
<dl class="dl-compact">
</dl>
<h3 id="total"><span class="symbol-name">total</span><small class="property-type">
&nbsp;string</small></h3>
<p>Order Total</p>
<dl class="dl-compact">
</dl>
</section>
</section>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: PrivateChat</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: PrivateChat</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -519,7 +519,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: PrivateContact</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: PrivateContact</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -283,7 +283,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

142
docs/Product.html Normal file
View File

@@ -0,0 +1,142 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Class: Product</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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-main" role="main">
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Product</span></h1>
<p class="source-link">Source: <a href="structures_Product.js.html#source-line-10">structures/<wbr>Product.<wbr>js:10</a></p>
<div class="symbol-classdesc">
<p>Represents a Product on WhatsAppBusiness</p>
</div>
<dl class="dl-compact">
</dl>
</header>
<section id="summary">
<div class="summary-callout">
<h2 class="summary-callout-heading">Properties</h2>
<div class="summary-content">
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Product.html#currency">currency</a></dt>
<dd>
</dd>
<dt><a href="Product.html#data">data</a></dt>
<dd>
</dd>
<dt><a href="Product.html#id">id</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Product.html#name">name</a></dt>
<dd>
</dd>
<dt><a href="Product.html#price">price</a></dt>
<dd>
</dd>
<dt><a href="Product.html#quantity">quantity</a></dt>
<dd>
</dd>
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="Product.html#thumbnailUrl">thumbnailUrl</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<h2 id="Product">new&nbsp;<span class="symbol-name">Product</span><span class="signature"><span class="signature-params">()</span></span></h2>
<dl class="dl-compact">
<dt>Extends</dt>
<dd><a href="Base.html">Base</a></dd>
</dl>
</section>
<section>
<h2>Properties</h2>
<section>
<h3 id="currency"><span class="symbol-name">currency</span><small class="property-type">
&nbsp;string</small></h3>
<p>Currency</p>
<dl class="dl-compact">
</dl>
<h3 id="data"><span class="symbol-name">data</span></h3>
<p>Product metadata</p>
<dl class="dl-compact">
</dl>
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
&nbsp;string</small></h3>
<p>Product ID</p>
<dl class="dl-compact">
</dl>
<h3 id="name"><span class="symbol-name">name</span><small class="property-type">
&nbsp;string</small></h3>
<p>Product Name</p>
<dl class="dl-compact">
</dl>
<h3 id="price"><span class="symbol-name">price</span><small class="property-type">
&nbsp;string</small></h3>
<p>Price</p>
<dl class="dl-compact">
</dl>
<h3 id="quantity"><span class="symbol-name">quantity</span><small class="property-type">
&nbsp;number</small></h3>
<p>Product Quantity</p>
<dl class="dl-compact">
</dl>
<h3 id="thumbnailUrl"><span class="symbol-name">thumbnailUrl</span><small class="property-type">
&nbsp;string</small></h3>
<p>Product Thumbnail</p>
<dl class="dl-compact">
</dl>
</section>
</section>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Class: Util</title>
<title>whatsapp-web.js 1.14.1 &raquo; Class: Util</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -26,7 +26,7 @@
<header class="page-header">
<div class="symbol-detail-labels"><span class="label label-kind">class</span></div>
<h1><small></small><span class="symbol-name">Util</span></h1>
<p class="source-link">Source: <a href="util_Util.js.html#source-line-15">util/<wbr>Util.<wbr>js:15</a></p>
<p class="source-link">Source: <a href="util_Util.js.html#source-line-16">util/<wbr>Util.<wbr>js:16</a></p>
<div class="symbol-classdesc">
<p>Utility methods</p>
</div>
@@ -42,7 +42,7 @@
<dt><a href="Util.html#.formatImageToWebpSticker">formatImageToWebpSticker(media)</a></dt>
<dd>
</dd>
<dt><a href="Util.html#.formatToWebpSticker">formatToWebpSticker(media)</a></dt>
<dt><a href="Util.html#.formatToWebpSticker">formatToWebpSticker(media, metadata)</a></dt>
<dd>
</dd>
</dl>
@@ -104,16 +104,15 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> 
<p>media in webp format</p>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
</p>
</dd>
</dl>
<div class="symbol-detail-labels"><span class="label label-async">async</span>&nbsp;<span class="label label-static">static</span></div>
<h3 id=".formatToWebpSticker"><span class="symbol-name">formatToWebpSticker</span><span class="signature"><span class="signature-params">(media)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
<h3 id=".formatToWebpSticker"><span class="symbol-name">formatToWebpSticker</span><span class="signature"><span class="signature-params">(media, metadata)</span>&nbsp;&rarr; <span class="signature-returns"> Promise containing <a href="MessageMedia.html">MessageMedia</a></span></span></h3>
<p>Formats a media to webp</p>
<section>
<h4>Parameter</h4>
<h4>Parameters</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
@@ -137,14 +136,26 @@
<td>
</td>
</tr>
<tr>
<td>
<p>metadata</p>
</td>
<td>
<p><a href="global.html#StickerMetadata">StickerMetadata</a></p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> 
<p>media in webp format</p>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
</p>
</dd>
</dl>
@@ -182,8 +193,7 @@
<dl class="dl-compact">
<dt>Returns</dt>
<dd>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> 
<p>media in webp format</p>
<p><code>Promise containing <a href="MessageMedia.html">MessageMedia</a></code> <p>media in webp format</p>
</p>
</dd>
</dl>
@@ -230,7 +240,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Globals</title>
<title>whatsapp-web.js 1.14.1 &raquo; Globals</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -87,6 +87,11 @@
</dl>
</div>
<div class="summary-column">
<dl class="dl-summary-callout">
<dt><a href="global.html#StickerMetadata">StickerMetadata</a></dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
@@ -378,6 +383,19 @@
<td>
</td>
</tr>
<tr>
<td>
<p>INCOMING_CALL</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
@@ -766,6 +784,19 @@
<td>
</td>
</tr>
<tr>
<td>
<p>ORDER</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>REVOKED</p>
@@ -779,6 +810,19 @@
<td>
</td>
</tr>
<tr>
<td>
<p>PRODUCT</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>UNKNOWN</p>
@@ -792,6 +836,19 @@
<td>
</td>
</tr>
<tr>
<td>
<p>GROUP_INVITE</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
<p>&nbsp;</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
@@ -1304,6 +1361,21 @@
<p>Defaults to <code>false</code>.</p>
</td>
</tr>
<tr>
<td>
<p>sendVideoAsGif</p>
</td>
<td>
<p>boolean</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Send video as gif</p>
<p>Defaults to <code>false</code>.</p>
</td>
</tr>
<tr>
<td>
<p>sendMediaAsSticker</p>
@@ -1406,6 +1478,48 @@
<p>Defaults to <code>true</code>.</p>
</td>
</tr>
<tr>
<td>
<p>stickerAuthor</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Sets the author of the sticker, (if sendMediaAsSticker is true).</p>
</td>
</tr>
<tr>
<td>
<p>stickerName</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Sets the name of the sticker, (if sendMediaAsSticker is true).</p>
</td>
</tr>
<tr>
<td>
<p>stickerCategories</p>
</td>
<td>
<p>Array of string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Sets the categories of the sticker, (if sendMediaAsSticker is true). Provide emoji char array, can be null.</p>
</td>
</tr>
<tr>
<td>
<p>media</p>
@@ -1425,6 +1539,65 @@
</section>
<dl class="dl-compact">
</dl>
<h3 id="StickerMetadata"><span class="symbol-name">StickerMetadata</span><small class="property-type">
&nbsp;Object</small></h3>
<p>Sticker metadata.</p>
<section>
<h4>Properties</h4>
<table class="jsdoc-details-table">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<p>name</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>author</p>
</td>
<td>
<p>string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
<tr>
<td>
<p>categories</p>
</td>
<td>
<p>Array of string</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
</td>
</tr>
</tbody>
</table>
</section>
<dl class="dl-compact">
</dl>
</section>
</section>
</div>
@@ -1435,7 +1608,7 @@
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Home</title>
<title>whatsapp-web.js 1.14.1 &raquo; Home</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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -27,20 +27,21 @@
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>
whatsapp-web.js 1.12.5
whatsapp-web.js 1.14.1
</h1>
</header>
<article>
<p><a href="https://www.npmjs.com/package/whatsapp-web.js"><img src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm"></a> <a href="https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765"><img src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu"></a> <img src="https://img.shields.io/badge/WhatsApp_Web-2.2106.5-brightgreen.svg" alt="WhatsApp_Web 2.2106.5"> <a href="https://discord.gg/H7DqQs4"><img src="https://img.shields.io/discord/698610475432411196.svg?logo=discord" alt="Discord Chat"></a></p>
<p><a href="https://www.npmjs.com/package/whatsapp-web.js"><img src="https://img.shields.io/npm/v/whatsapp-web.js.svg" alt="npm"></a> <a href="https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765"><img src="https://badges.depfu.com/badges/4a65a0de96ece65fdf39e294e0c8dcba/overview.svg" alt="Depfu"></a> <img src="https://img.shields.io/badge/WhatsApp_Web-2.2126.14-brightgreen.svg" alt="WhatsApp_Web 2.2126.14"> <a href="https://discord.gg/H7DqQs4"><img src="https://img.shields.io/discord/698610475432411196.svg?logo=discord" alt="Discord Chat"></a></p>
<h1>whatsapp-web.js</h1>
<p>A WhatsApp API client that connects through the WhatsApp Web browser app</p>
<p>It uses Puppeteer to run a real instance of Whatsapp Web to avoid getting blocked.</p>
<p><strong>NOTE:</strong> I can't guarantee you will not be blocked by using this method, although it has worked for me. WhatsApp does not allow bots or unofficial clients on their platform, so this shouldn't be considered totally safe.</p>
<h2>Installation</h2>
<p>The module is now available on npm! <code>npm i whatsapp-web.js</code></p>
<p>Please note that Node v10.18.1+ is required due to Puppeteer.</p>
<p>Please note that Node v12+ is required.</p>
<h2>Example usage</h2>
<pre class="prettyprint source lang-js"><code>const { Client } = require('whatsapp-web.js');
const client = new Client();
client.on('qr', (qr) => {
@@ -61,6 +62,33 @@ client.on('message', msg => {
client.initialize();
</code></pre>
<p>Take a look at <a href="https://github.com/pedroslopez/whatsapp-web.js/blob/master/example.js">example.js</a> for another example with more use cases.</p>
<h2>Remote Access</h2>
<p>You could also connect to any previously existing browser instance:</p>
<pre class="prettyprint source lang-js"><code>const client = new Client({
puppeteer: {
browserWSEndpoint: `ws://localhost:3000`
}
});
</code></pre>
<h3>Docker</h3>
<ol>
<li>Installing a browser using browserless:</li>
</ol>
<pre class="prettyprint source"><code>docker run \
--rm \
-p 3000:3000 \
-e &quot;MAX_CONCURRENT_SESSIONS=1&quot; \
browserless/chrome:latest
</code></pre>
<p>Reference: https://docs.browserless.io/docs/docker-quickstart.html</p>
<h3>Remote Debugging</h3>
<ol start="2">
<li>Running a browser with websocket remote debugging enabled:</li>
</ol>
<blockquote>
<p>chrome.exe --remote-debugging-port=9222</p>
</blockquote>
<p>After that check the following webpage and check http://127.0.0.1:9220/json and get the <strong>webSocketDebuggerUrl</strong></p>
<h2>Supported features</h2>
<table>
<thead>
@@ -84,7 +112,7 @@ client.initialize();
</tr>
<tr>
<td>Send media (video)</td>
<td><a href="https://waguide.pedroslopez.me/features/handling-attachments#caveat-for-sending-videos-and-gifs">(requires google chrome)</a></td>
<td><a href="https://guide.wwebjs.dev/features/handling-attachments#caveat-for-sending-videos-and-gifs">(requires google chrome)</a></td>
</tr>
<tr>
<td>Send stickers</td>
@@ -167,9 +195,10 @@ client.initialize();
<p>Something missing? Make an issue and let us know!</p>
<h2>Links</h2>
<ul>
<li><a href="https://pedroslopez.me/whatsapp-web.js">Reference</a></li>
<li><a href="https://waguide.pedroslopez.me/">Guide</a> <em>(work in progress)</em></li>
<li><a href="https://docs.wwebjs.dev/">Reference</a></li>
<li><a href="https://guide.wwebjs.dev/">Guide</a> <em>(work in progress)</em></li>
<li><a href="https://github.com/pedroslopez/whatsapp-web.js">GitHub</a></li>
<li><a href="https://npmjs.org/package/whatsapp-web.js">npm</a></li>
</ul>
<h2>Contributing</h2>
<p>Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.</p>
@@ -333,6 +362,75 @@ client.initialize();
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="Call">Call</h2>
<div class="symbol-index-section">
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Call.html" class="!symbol-index-name">Call()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#canHandleLocally" class="!symbol-index-name">Call#<wbr>canHandleLocally</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#from" class="!symbol-index-name">Call#<wbr>from</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#fromMe" class="!symbol-index-name">Call#<wbr>fromMe</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Call.html#id" class="!symbol-index-name">Call#<wbr>id</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#isGroup" class="!symbol-index-name">Call#<wbr>isGroup</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#isVideo" class="!symbol-index-name">Call#<wbr>isVideo</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#participants" class="!symbol-index-name">Call#<wbr>participants</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Call.html#timestamp" class="!symbol-index-name">Call#<wbr>timestamp</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Call.html#webClientShouldHandle" class="!symbol-index-name">Call#<wbr>webClientShouldHandle</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="Chat">Chat</h2>
@@ -537,6 +635,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#acceptGroupV4Invite" class="!symbol-index-name">Client#<wbr>acceptGroupV4Invite(inviteV4)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#acceptInvite" class="!symbol-index-name">Client#<wbr>acceptInvite(inviteCode)</a>
</dt>
@@ -597,6 +700,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#event:incoming_call" class="!symbol-index-name">Client#<wbr>event:incoming_call</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#event:media_uploaded" class="!symbol-index-name">Client#<wbr>event:media_uploaded</a>
</dt>
@@ -612,15 +720,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html#event:message_create" class="!symbol-index-name">Client#<wbr>event:message_create</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Client.html#event:message_revoke_everyone" class="!symbol-index-name">Client#<wbr>event:message_revoke_everyone</a>
</dt>
@@ -750,6 +858,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#searchMessages" class="!symbol-index-name">Client#<wbr>searchMessages(query[, options])</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Client.html#sendMessage" class="!symbol-index-name">Client#<wbr>sendMessage(chatId, content[, options])</a>
</dt>
@@ -1008,6 +1121,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#Events#.INCOMING_CALL" class="!symbol-index-name">Events.<wbr>INCOMING_CALL</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#Events#.MEDIA_UPLOADED" class="!symbol-index-name">Events.<wbr>MEDIA_UPLOADED</a>
</dt>
@@ -1028,15 +1146,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="global.html#Events#.MESSAGE_REVOKED_EVERYONE" class="!symbol-index-name">Events.<wbr>MESSAGE_REVOKED_EVERYONE</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="global.html#Events#.MESSAGE_REVOKED_ME" class="!symbol-index-name">Events.<wbr>MESSAGE_REVOKED_ME</a>
</dt>
@@ -1450,13 +1568,18 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#checkFeatureStatus" class="!symbol-index-name">InterfaceController#<wbr>checkFeatureStatus(feature)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#closeRightDrawer" class="!symbol-index-name">InterfaceController#<wbr>closeRightDrawer()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#openChatDrawer" class="!symbol-index-name">InterfaceController#<wbr>openChatDrawer(chatId)</a>
<a href="InterfaceController.html#disableFeatures" class="!symbol-index-name">InterfaceController#<wbr>disableFeatures(features)</a>
</dt>
<dd>
</dd>
@@ -1464,11 +1587,30 @@ client.initialize();
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="InterfaceController.html#enableFeatures" class="!symbol-index-name">InterfaceController#<wbr>enableFeatures(features)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#getFeatures" class="!symbol-index-name">InterfaceController#<wbr>getFeatures()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#openChatDrawer" class="!symbol-index-name">InterfaceController#<wbr>openChatDrawer(chatId)</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="InterfaceController.html#openChatSearch" class="!symbol-index-name">InterfaceController#<wbr>openChatSearch(chatId)</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="InterfaceController.html#openChatWindow" class="!symbol-index-name">InterfaceController#<wbr>openChatWindow(chatId)</a>
</dt>
@@ -1479,10 +1621,6 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="InterfaceController.html#openMessageDrawer" class="!symbol-index-name">InterfaceController#<wbr>openMessageDrawer(msgId)</a>
</dt>
@@ -1587,6 +1725,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#acceptGroupV4Invite" class="!symbol-index-name">Message#<wbr>acceptGroupV4Invite()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#ack" class="!symbol-index-name">Message#<wbr>ack</a>
</dt>
@@ -1612,6 +1755,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#deviceType" class="!symbol-index-name">Message#<wbr>deviceType</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#downloadMedia" class="!symbol-index-name">Message#<wbr>downloadMedia()</a>
</dt>
@@ -1622,6 +1770,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#forwardingScore" class="!symbol-index-name">Message#<wbr>forwardingScore</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#from" class="!symbol-index-name">Message#<wbr>from</a>
</dt>
@@ -1632,15 +1785,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Message.html#getChat" class="!symbol-index-name">Message#<wbr>getChat()</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Message.html#getContact" class="!symbol-index-name">Message#<wbr>getContact()</a>
</dt>
@@ -1656,6 +1809,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#getOrder" class="!symbol-index-name">Message#<wbr>getOrder()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#getQuotedMessage" class="!symbol-index-name">Message#<wbr>getQuotedMessage()</a>
</dt>
@@ -1676,6 +1834,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#inviteV4" class="!symbol-index-name">Message#<wbr>inviteV4</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#isForwarded" class="!symbol-index-name">Message#<wbr>isForwarded</a>
</dt>
@@ -1691,15 +1854,15 @@ client.initialize();
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Message.html#links" class="!symbol-index-name">Message#<wbr>links</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Message.html#location" class="!symbol-index-name">Message#<wbr>location</a>
</dt>
@@ -1715,6 +1878,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#orderId" class="!symbol-index-name">Message#<wbr>orderId</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#reply" class="!symbol-index-name">Message#<wbr>reply(content[, chatId][, options])</a>
</dt>
@@ -1735,6 +1903,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#token" class="!symbol-index-name">Message#<wbr>token</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Message.html#type" class="!symbol-index-name">Message#<wbr>type</a>
</dt>
@@ -1825,12 +1998,12 @@ client.initialize();
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="MessageMedia.html#data" class="!symbol-index-name">MessageMedia#<wbr>data</a>
<a href="MessageMedia.html#.fromUrl" class="!symbol-index-name">MessageMedia.<wbr>fromUrl(url[, options])</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="MessageMedia.html#filename" class="!symbol-index-name">MessageMedia#<wbr>filename</a>
<a href="MessageMedia.html#data" class="!symbol-index-name">MessageMedia#<wbr>data</a>
</dt>
<dd>
</dd>
@@ -1838,6 +2011,11 @@ client.initialize();
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="MessageMedia.html#filename" class="!symbol-index-name">MessageMedia#<wbr>filename</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="MessageMedia.html#mimetype" class="!symbol-index-name">MessageMedia#<wbr>mimetype</a>
</dt>
@@ -1874,6 +2052,11 @@ client.initialize();
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#MessageTypes#.GROUP_INVITE" class="!symbol-index-name">MessageTypes.<wbr>GROUP_INVITE</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
@@ -1889,12 +2072,17 @@ client.initialize();
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#MessageTypes#.REVOKED" class="!symbol-index-name">MessageTypes.<wbr>REVOKED</a>
<a href="global.html#MessageTypes#.ORDER" class="!symbol-index-name">MessageTypes.<wbr>ORDER</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#MessageTypes#.STICKER" class="!symbol-index-name">MessageTypes.<wbr>STICKER</a>
<a href="global.html#MessageTypes#.PRODUCT" class="!symbol-index-name">MessageTypes.<wbr>PRODUCT</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#MessageTypes#.REVOKED" class="!symbol-index-name">MessageTypes.<wbr>REVOKED</a>
</dt>
<dd>
</dd>
@@ -1902,6 +2090,11 @@ client.initialize();
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="global.html#MessageTypes#.STICKER" class="!symbol-index-name">MessageTypes.<wbr>STICKER</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="global.html#MessageTypes#.TEXT" class="!symbol-index-name">MessageTypes.<wbr>TEXT</a>
</dt>
@@ -1927,6 +2120,50 @@ client.initialize();
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="Order">Order</h2>
<div class="symbol-index-section">
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Order.html" class="!symbol-index-name">Order()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Order.html#createdAt" class="!symbol-index-name">Order#<wbr>createdAt</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Order.html#currency" class="!symbol-index-name">Order#<wbr>currency</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Order.html#subtotal" class="!symbol-index-name">Order#<wbr>subtotal</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Order.html#total" class="!symbol-index-name">Order#<wbr>total</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="PrivateChat">PrivateChat</h2>
@@ -2200,6 +2437,104 @@ client.initialize();
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="Product">Product</h2>
<div class="symbol-index-section">
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Product.html" class="!symbol-index-name">Product()</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Product.html#currency" class="!symbol-index-name">Product#<wbr>currency</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Product.html#data" class="!symbol-index-name">Product#<wbr>data</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Product.html#id" class="!symbol-index-name">Product#<wbr>id</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Product.html#name" class="!symbol-index-name">Product#<wbr>name</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Product.html#price" class="!symbol-index-name">Product#<wbr>price</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Product.html#quantity" class="!symbol-index-name">Product#<wbr>quantity</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="Product.html#thumbnailUrl" class="!symbol-index-name">Product#<wbr>thumbnailUrl</a>
</dt>
<dd>
</dd>
</dl>
</div>
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="ProductMetadata">ProductMetadata</h2>
<div class="symbol-index-section">
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="ProductMetadata.html#description" class="!symbol-index-name">ProductMetadata#<wbr>description</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="ProductMetadata.html#id" class="!symbol-index-name">ProductMetadata#<wbr>id</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="ProductMetadata.html#name" class="!symbol-index-name">ProductMetadata#<wbr>name</a>
</dt>
<dd>
</dd>
<dt class="symbol-index-name">
<a href="ProductMetadata.html#retailer_id" class="!symbol-index-name">ProductMetadata#<wbr>retailer_id</a>
</dt>
<dd>
</dd>
</dl>
</div>
<div class="symbol-index-column">
<dl class="symbol-index-list">
</dl>
</div>
</div>
</div>
</section>
<section>
<div class="symbol-index-content">
<h2 id="Status">Status</h2>
@@ -2255,7 +2590,7 @@ client.initialize();
<div class="symbol-index-column">
<dl class="symbol-index-list">
<dt class="symbol-index-name">
<a href="Util.html#.formatToWebpSticker" class="!symbol-index-name">Util.<wbr>formatToWebpSticker(media)</a>
<a href="Util.html#.formatToWebpSticker" class="!symbol-index-name">Util.<wbr>formatToWebpSticker(media, metadata)</a>
</dt>
<dd>
</dd>
@@ -2366,7 +2701,7 @@ client.initialize();
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -6,7 +6,7 @@
treeNode.tree({
autoEscape: false,
closedIcon: '&#x21e2;',
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"Label.html\">Label</a>","id":"Label","children":[]},{"label":"<a href=\"Location.html\">Location</a>","id":"Location","children":[]},{"label":"<a href=\"Message.html\">Message</a>","id":"Message","children":[]},{"label":"<a href=\"MessageMedia.html\">MessageMedia</a>","id":"MessageMedia","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Call.html\">Call</a>","id":"Call","children":[]},{"label":"<a href=\"Chat.html\">Chat</a>","id":"Chat","children":[]},{"label":"<a href=\"Client.html\">Client</a>","id":"Client","children":[]},{"label":"<a href=\"ClientInfo.html\">ClientInfo</a>","id":"ClientInfo","children":[]},{"label":"<a href=\"Contact.html\">Contact</a>","id":"Contact","children":[]},{"label":"<a href=\"GroupChat.html\">GroupChat</a>","id":"GroupChat","children":[]},{"label":"<a href=\"GroupNotification.html\">GroupNotification</a>","id":"GroupNotification","children":[]},{"label":"<a href=\"InterfaceController.html\">InterfaceController</a>","id":"InterfaceController","children":[]},{"label":"<a href=\"Label.html\">Label</a>","id":"Label","children":[]},{"label":"<a href=\"Location.html\">Location</a>","id":"Location","children":[]},{"label":"<a href=\"Message.html\">Message</a>","id":"Message","children":[]},{"label":"<a href=\"MessageMedia.html\">MessageMedia</a>","id":"MessageMedia","children":[]},{"label":"<a href=\"Order.html\">Order</a>","id":"Order","children":[]},{"label":"<a href=\"PrivateChat.html\">PrivateChat</a>","id":"PrivateChat","children":[]},{"label":"<a href=\"PrivateContact.html\">PrivateContact</a>","id":"PrivateContact","children":[]},{"label":"<a href=\"Product.html\">Product</a>","id":"Product","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
openedIcon: ' &#x21e3;',
saveState: false,
useContextMenu: false

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/Base.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Base.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -60,7 +60,7 @@ module.exports &#x3D; Base;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/BusinessContact.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/BusinessContact.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -59,7 +59,7 @@ module.exports &#x3D; BusinessContact;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -0,0 +1,121 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Call.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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-banner" role="banner">
</div>
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>Source: structures/Call.js</h1>
</header>
<article>
<pre class="prettyprint linenums"><code>&#x27;use strict&#x27;;
const Base &#x3D; require(&#x27;./Base&#x27;);
/**
* Represents a Call on WhatsApp
* @extends {Base}
*/
class Call extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* Call ID
* @type {string}
*/
this.id &#x3D; data.id;
/**
* From
* @type {string}
*/
this.from &#x3D; data.peerJid;
/**
* Unix timestamp for when the call was created
* @type {number}
*/
this.timestamp &#x3D; data.offerTime;
/**
* Is video
* @type {boolean}
*/
this.isVideo &#x3D; data.isVideo;
/**
* Is Group
* @type {boolean}
*/
this.isGroup &#x3D; data.isGroup;
/**
* Indicates if the call was sent by the current user
* @type {boolean}
*/
this.fromMe &#x3D; data.outgoing;
/**
* Indicates if the call can be handled in waweb
* @type {boolean}
*/
this.canHandleLocally &#x3D; data.canHandleLocally;
/**
* Indicates if the call Should be handled in waweb
* @type {boolean}
*/
this.webClientShouldHandle &#x3D; data.webClientShouldHandle;
/**
* Object with participants
* @type {object}
*/
this.participants &#x3D; data.participants;
return super._patch(data);
}
}
module.exports &#x3D; Call;</code></pre>
</article>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/Chat.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Chat.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -288,7 +288,7 @@ module.exports &#x3D; Chat;
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/ClientInfo.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/ClientInfo.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -108,7 +108,7 @@ module.exports &#x3D; ClientInfo;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/Contact.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Contact.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -219,7 +219,7 @@ module.exports &#x3D; Contact;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/GroupChat.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/GroupChat.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -239,7 +239,7 @@ module.exports &#x3D; GroupChat;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/GroupNotification.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/GroupNotification.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -143,7 +143,7 @@ module.exports &#x3D; GroupNotification;
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/Label.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Label.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -88,7 +88,7 @@ module.exports &#x3D; Label;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/Location.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Location.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -71,7 +71,7 @@ module.exports &#x3D; Location;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/Message.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Message.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -34,6 +34,7 @@
const Base &#x3D; require(&#x27;./Base&#x27;);
const MessageMedia &#x3D; require(&#x27;./MessageMedia&#x27;);
const Location &#x3D; require(&#x27;./Location&#x27;);
const Order &#x3D; require(&#x27;./Order&#x27;);
const { MessageTypes } &#x3D; require(&#x27;../util/Constants&#x27;);
/**
@@ -71,7 +72,7 @@ class Message extends Base {
* Indicates if the message has media available for download
* @type {boolean}
*/
this.hasMedia &#x3D; data.clientUrl || data.deprecatedMms3Url ? true : false;
this.hasMedia &#x3D; Boolean(data.mediaKey &amp;amp;&amp;amp; data.directPath);
/**
* Message content
@@ -112,12 +113,26 @@ class Message extends Base {
*/
this.author &#x3D; (typeof (data.author) &#x3D;&#x3D;&#x3D; &#x27;object&#x27; &amp;amp;&amp;amp; data.author !&#x3D;&#x3D; null) ? data.author._serialized : data.author;
/**
* String that represents from which device type the message was sent
* @type {string}
*/
this.deviceType &#x3D; data.id.id.length &gt; 21 ? &#x27;android&#x27; : data.id.id.substring(0,2) &#x3D;&#x3D;&#x27;3A&#x27; ? &#x27;ios&#x27; : &#x27;web&#x27;;
/**
* Indicates if the message was forwarded
* @type {boolean}
*/
this.isForwarded &#x3D; data.isForwarded;
/**
* Indicates how many times the message was forwarded.
*
* The maximum value is 127.
* @type {number}
*/
this.forwardingScore &#x3D; data.forwardingScore || 0;
/**
* Indicates if the message is a status update
* @type {boolean}
@@ -160,6 +175,19 @@ class Message extends Base {
*/
this.vCards &#x3D; data.type &#x3D;&#x3D;&#x3D; MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) &#x3D;&gt; c.vcard) : data.type &#x3D;&#x3D;&#x3D; MessageTypes.CONTACT_CARD ? [data.body] : [];
/**
* Group Invite Data
* @type {object}
*/
this.inviteV4 &#x3D; data.type &#x3D;&#x3D;&#x3D; MessageTypes.GROUP_INVITE ? {
inviteCode: data.inviteCode,
inviteCodeExp: data.inviteCodeExp,
groupId: data.inviteGrp,
groupName: data.inviteGrpName,
fromId: data.from._serialized,
toId: data.to._serialized
} : undefined;
/**
* Indicates the mentions in the message body.
* @type {Array&amp;lt;string&gt;}
@@ -170,9 +198,41 @@ class Message extends Base {
this.mentionedIds &#x3D; data.mentionedJidList;
}
/**
* Order ID for message type ORDER
* @type {string}
*/
this.orderId &#x3D; data.orderId ? data.orderId : undefined;
/**
* Order Token for message type ORDER
* @type {string}
*/
this.token &#x3D; data.token ? data.token : undefined;
/** Title */
if (data.title) {
this.title &#x3D; data.title;
}
/** Description */
if (data.description) {
this.description &#x3D; data.description;
}
/** Business Owner JID */
if (data.businessOwnerJid) {
this.businessOwnerJid &#x3D; data.businessOwnerJid;
}
/** Product ID */
if (data.productId) {
this.productId &#x3D; data.productId;
}
/**
* Links included in the message.
* @type {Array&amp;lt;string&gt;}
* @type {Array&amp;lt;{link: string, isSuspicious: boolean}&gt;}
*
*/
this.links &#x3D; data.links;
@@ -245,6 +305,14 @@ class Message extends Base {
return this.client.sendMessage(chatId, content, options);
}
/**
* Accept Group V4 Invite
* @returns {Promise&amp;lt;Object&gt;}
*/
async acceptGroupV4Invite() {
return await this.client.acceptGroupV4Invite(this.inviteV4);
}
/**
* Forwards this message to another chat
*
@@ -276,26 +344,39 @@ class Message extends Base {
if (msg.mediaData.mediaStage !&#x3D; &#x27;RESOLVED&#x27;) {
// try to resolve media
await msg.downloadMedia(true, 1);
await msg.downloadMedia({
downloadEvenIfExpensive: true,
rmrReason: 1
});
}
if (msg.mediaData.mediaStage.includes(&#x27;ERROR&#x27;)) {
if (msg.mediaData.mediaStage.includes(&#x27;ERROR&#x27;) || msg.mediaData.mediaStage &#x3D;&#x3D;&#x3D; &#x27;FETCHING&#x27;) {
// media could not be downloaded
return undefined;
}
const mediaUrl &#x3D; msg.clientUrl || msg.deprecatedMms3Url;
const buffer &#x3D; await window.WWebJS.downloadBuffer(mediaUrl);
const decrypted &#x3D; await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
const data &#x3D; await window.WWebJS.readBlobAsync(decrypted._blob);
return {
data: data.split(&#x27;,&#x27;)[1],
mimetype: msg.mimetype,
filename: msg.filename
};
try {
const decryptedMedia &#x3D; await window.Store.DownloadManager.downloadAndDecrypt({
directPath: msg.directPath,
encFilehash: msg.encFilehash,
filehash: msg.filehash,
mediaKey: msg.mediaKey,
mediaKeyTimestamp: msg.mediaKeyTimestamp,
type: msg.type,
signal: (new AbortController).signal
});
const data &#x3D; window.WWebJS.arrayBufferToBase64(decryptedMedia);
return {
data,
mimetype: msg.mimetype,
filename: msg.filename
};
} catch (e) {
if(e.status &amp;amp;&amp;amp; e.status &#x3D;&#x3D;&#x3D; 404) return undefined;
throw e;
}
}, this.id._serialized);
if (!result) return undefined;
@@ -373,6 +454,21 @@ class Message extends Base {
return info;
}
/**
* Gets the order associated with a given message
* @return {Promise&amp;lt;Order&gt;}
*/
async getOrder() {
if (this.type &#x3D;&#x3D;&#x3D; MessageTypes.ORDER) {
const result &#x3D; await this.client.pupPage.evaluate((orderId, token) &#x3D;&gt; {
return window.WWebJS.getOrderDetail(orderId, token);
}, this.orderId, this.token);
if (!result) return undefined;
return new Order(this.client, result);
}
return undefined;
}
}
module.exports &#x3D; Message;
@@ -386,7 +482,7 @@ module.exports &#x3D; Message;
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/MessageMedia.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/MessageMedia.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -34,6 +34,8 @@
const fs &#x3D; require(&#x27;fs&#x27;);
const path &#x3D; require(&#x27;path&#x27;);
const mime &#x3D; require(&#x27;mime&#x27;);
const fetch &#x3D; require(&#x27;node-fetch&#x27;);
const { URL } &#x3D; require(&#x27;url&#x27;);
/**
* Media attached to a message
@@ -74,6 +76,56 @@ class MessageMedia {
return new MessageMedia(mimetype, b64data, filename);
}
/**
* Creates a MessageMedia instance from a URL
* @param {string} url
* @param {Object} [options]
* @param {number} [options.unsafeMime&#x3D;false]
* @param {object} [options.client]
* @param {object} [options.reqOptions]
* @param {number} [options.reqOptions.size&#x3D;0]
* @returns {Promise&amp;lt;MessageMedia&gt;}
*/
static async fromUrl(url, options &#x3D; {}) {
let mimetype;
if (!options.unsafeMime) {
const pUrl &#x3D; new URL(url);
mimetype &#x3D; mime.getType(pUrl.pathname);
if (!mimetype)
throw new Error(&#x27;Unable to determine MIME type&#x27;);
}
async function fetchData (url, options) {
const reqOptions &#x3D; Object.assign({ headers: { accept: &#x27;image/* video/* text/* audio/*&#x27; } }, options);
const response &#x3D; await fetch(url, reqOptions);
const mime &#x3D; response.headers.get(&#x27;Content-Type&#x27;);
let data &#x3D; &#x27;&#x27;;
if (response.buffer) {
data &#x3D; (await response.buffer()).toString(&#x27;base64&#x27;);
} else {
const bArray &#x3D; new Uint8Array(await response.arrayBuffer());
bArray.forEach((b) &#x3D;&gt; {
data +&#x3D; String.fromCharCode(b);
});
data &#x3D; btoa(data);
}
return { data, mime };
}
const res &#x3D; options.client
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
: (await fetchData(url, options.reqOptions));
if (!mimetype)
mimetype &#x3D; res.mime;
return new MessageMedia(mimetype, res.data, null);
}
}
module.exports &#x3D; MessageMedia;</code></pre>
@@ -86,7 +138,7 @@ module.exports &#x3D; MessageMedia;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -0,0 +1,105 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Order.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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-banner" role="banner">
</div>
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>Source: structures/Order.js</h1>
</header>
<article>
<pre class="prettyprint linenums"><code>&#x27;use strict&#x27;;
const Base &#x3D; require(&#x27;./Base&#x27;);
const Product &#x3D; require(&#x27;./Product&#x27;);
/**
* Represents a Order on WhatsApp
* @extends {Base}
*/
class Order extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* List of products
* @type {Array&amp;lt;Product&gt;}
*/
if (data.products) {
this.products &#x3D; data.products.map(product &#x3D;&gt; new Product(this.client, product));
}
/**
* Order Subtotal
* @type {string}
*/
this.subtotal &#x3D; data.subtotal;
/**
* Order Total
* @type {string}
*/
this.total &#x3D; data.total;
/**
* Order Currency
* @type {string}
*/
this.currency &#x3D; data.currency;
/**
* Order Created At
* @type {number}
*/
this.createdAt &#x3D; data.createdAt;
return super._patch(data);
}
}
module.exports &#x3D; Order;</code></pre>
</article>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/PrivateChat.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/PrivateChat.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -51,7 +51,7 @@ module.exports &#x3D; PrivateChat;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: structures/PrivateContact.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/PrivateContact.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -51,7 +51,7 @@ module.exports &#x3D; PrivateContact;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -0,0 +1,121 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/Product.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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-banner" role="banner">
</div>
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>Source: structures/Product.js</h1>
</header>
<article>
<pre class="prettyprint linenums"><code>&#x27;use strict&#x27;;
const Base &#x3D; require(&#x27;./Base&#x27;);
const ProductMetadata &#x3D; require(&#x27;./ProductMetadata&#x27;);
/**
* Represents a Product on WhatsAppBusiness
* @extends {Base}
*/
class Product extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* Product ID
* @type {string}
*/
this.id &#x3D; data.id;
/**
* Price
* @type {string}
*/
this.price &#x3D; data.price ? data.price : &#x27;&#x27;;
/**
* Product Thumbnail
* @type {string}
*/
this.thumbnailUrl &#x3D; data.thumbnailUrl;
/**
* Currency
* @type {string}
*/
this.currency &#x3D; data.currency;
/**
* Product Name
* @type {string}
*/
this.name &#x3D; data.name;
/**
* Product Quantity
* @type {number}
*/
this.quantity &#x3D; data.quantity;
/** Product metadata */
this.data &#x3D; null;
return super._patch(data);
}
async getData() {
if (this.data &#x3D;&#x3D;&#x3D; null) {
let result &#x3D; await this.client.pupPage.evaluate((productId) &#x3D;&gt; {
return window.WWebJS.getProductMetadata(productId);
}, this.id);
if (!result) {
this.data &#x3D; undefined;
} else {
this.data &#x3D; new ProductMetadata(this.client, result);
}
}
return this.data;
}
}
module.exports &#x3D; Product;</code></pre>
</article>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -0,0 +1,78 @@
<!doctype html>
<html>
<head>
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.14.1 &raquo; Source: structures/ProductMetadata.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">
<link href="css/baseline.css" rel="stylesheet">
</head>
<body onload="prettyPrint()">
<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>14.<wbr>1</a>
</div>
</div>
</nav>
<div id="jsdoc-body-container">
<div id="jsdoc-content">
<div id="jsdoc-content-container">
<div id="jsdoc-banner" role="banner">
</div>
<div id="jsdoc-main" role="main">
<header class="page-header">
<h1>Source: structures/ProductMetadata.js</h1>
</header>
<article>
<pre class="prettyprint linenums"><code>const Base &#x3D; require(&#x27;./Base&#x27;);
class ProductMetadata extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/** Product ID */
this.id &#x3D; data.id;
/** Retailer ID */
this.retailer_id &#x3D; data.retailer_id;
/** Product Name */
this.name &#x3D; data.name;
/** Product Description */
this.description &#x3D; data.description;
return super._patch(data);
}
}
module.exports &#x3D; ProductMetadata;</code></pre>
</article>
</div>
</div>
<nav id="jsdoc-toc-nav" role="navigation"></nav>
</div>
</div>
<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 September 1, 2021.
</p>
</div>
</footer>
<script src="scripts/jquery.min.js"></script>
<script src="scripts/tree.jquery.js"></script>
<script src="scripts/prettify.js"></script>
<script src="scripts/jsdoc-toc.js"></script>
<script src="scripts/linenumber.js"></script>
<script src="scripts/scrollanchor.js"></script>
</body>
</html>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: util/Constants.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: util/Constants.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -45,7 +45,8 @@ exports.DefaultOptions &#x3D; {
takeoverOnConflict: false,
takeoverTimeoutMs: 0,
userAgent: &#x27;Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36&#x27;,
ffmpegPath: &#x27;ffmpeg&#x27;
ffmpegPath: &#x27;ffmpeg&#x27;,
bypassCSP: false
};
/**
@@ -80,7 +81,8 @@ exports.Events &#x3D; {
QR_RECEIVED: &#x27;qr&#x27;,
DISCONNECTED: &#x27;disconnected&#x27;,
STATE_CHANGED: &#x27;change_state&#x27;,
BATTERY_CHANGED: &#x27;change_battery&#x27;
BATTERY_CHANGED: &#x27;change_battery&#x27;,
INCOMING_CALL: &#x27;incoming_call&#x27;
};
/**
@@ -99,8 +101,11 @@ exports.MessageTypes &#x3D; {
LOCATION: &#x27;location&#x27;,
CONTACT_CARD: &#x27;vcard&#x27;,
CONTACT_CARD_MULTI: &#x27;multi_vcard&#x27;,
ORDER: &#x27;order&#x27;,
REVOKED: &#x27;revoked&#x27;,
UNKNOWN: &#x27;unknown&#x27;
PRODUCT: &#x27;product&#x27;,
UNKNOWN: &#x27;unknown&#x27;,
GROUP_INVITE: &#x27;groups_v4_invite&#x27;
};
/**
@@ -174,7 +179,7 @@ exports.MessageAck &#x3D; {
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: util/InterfaceController.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: util/InterfaceController.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -46,7 +46,8 @@ class InterfaceController {
*/
async openChatWindow(chatId) {
await this.pupPage.evaluate(async chatId &#x3D;&gt; {
let chat &#x3D; await window.Store.Chat.get(chatId);
let chatWid &#x3D; window.Store.WidFactory.createWid(chatId);
let chat &#x3D; await window.Store.Chat.find(chatWid);
await window.Store.Cmd.openChatAt(chat);
}, chatId);
}
@@ -103,10 +104,53 @@ class InterfaceController {
await window.Store.Cmd.closeDrawerRight();
});
}
/**
* Get all Features
*/
async getFeatures() {
return await this.pupPage.evaluate(() &#x3D;&gt; {
return window.Store.Features.F;
});
}
/**
* Check if Feature is enabled
* @param {string} feature status to check
*/
async checkFeatureStatus(feature) {
return await this.pupPage.evaluate((feature) &#x3D;&gt; {
return window.Store.Features.supportsFeature(feature);
}, feature);
}
/**
* Enable Features
* @param {string[]} features to be enabled
*/
async enableFeatures(features) {
await this.pupPage.evaluate((features) &#x3D;&gt; {
for (const feature in features) {
window.Store.Features.setFeature(features[feature], true);
}
}, features);
}
/**
* Disable Features
* @param {string[]} features to be disabled
*/
async disableFeatures(features) {
await this.pupPage.evaluate((features) &#x3D;&gt; {
for (const feature in features) {
window.Store.Features.setFeature(features[feature], false);
}
}, features);
}
}
module.exports &#x3D; InterfaceController;</code></pre>
module.exports &#x3D; InterfaceController;
</code></pre>
</article>
</div>
</div>
@@ -116,7 +160,7 @@ module.exports &#x3D; InterfaceController;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -2,9 +2,9 @@
<html>
<head>
<meta name="generator" content="JSDoc 3.6.6">
<meta name="generator" content="JSDoc 3.6.7">
<meta charset="utf-8">
<title>whatsapp-web.js 1.12.5 &raquo; Source: util/Util.js</title>
<title>whatsapp-web.js 1.14.1 &raquo; Source: util/Util.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>12.<wbr>5</a>
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>14.<wbr>1</a>
</div>
</div>
</nav>
@@ -36,6 +36,7 @@ const path &#x3D; require(&#x27;path&#x27;);
const Crypto &#x3D; require(&#x27;crypto&#x27;);
const { tmpdir } &#x3D; require(&#x27;os&#x27;);
const ffmpeg &#x3D; require(&#x27;fluent-ffmpeg&#x27;);
const webp &#x3D; require(&#x27;node-webpmux&#x27;);
const fs &#x3D; require(&#x27;fs&#x27;).promises;
const has &#x3D; (o, k) &#x3D;&gt; Object.prototype.hasOwnProperty.call(o, k);
@@ -49,6 +50,16 @@ class Util {
throw new Error(&#x60;The ${this.constructor.name} class may not be instantiated.&#x60;);
}
static generateHash(length) {
var result &#x3D; &#x27;&#x27;;
var characters &#x3D; &#x27;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&#x27;;
var charactersLength &#x3D; characters.length;
for ( var i &#x3D; 0; i &amp;lt; length; i++ ) {
result +&#x3D; characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
/**
* Sets default properties on an object that aren&#x27;t already specified.
* @param {Object} def Default properties
@@ -166,16 +177,49 @@ class Util {
};
}
/**
* Sticker metadata.
* @typedef {Object} StickerMetadata
* @property {string} [name]
* @property {string} [author]
* @property {string[]} [categories]
*/
/**
* Formats a media to webp
* @param {MessageMedia} media
* @param {StickerMetadata} metadata
*
* @returns {Promise&amp;lt;MessageMedia&gt;} media in webp format
*/
static async formatToWebpSticker(media) {
if (media.mimetype.includes(&#x27;image&#x27;)) return this.formatImageToWebpSticker(media);
else if (media.mimetype.includes(&#x27;video&#x27;)) return this.formatVideoToWebpSticker(media);
else throw new Error(&#x27;Invalid media format&#x27;);
static async formatToWebpSticker(media, metadata) {
let webpMedia;
if (media.mimetype.includes(&#x27;image&#x27;))
webpMedia &#x3D; await this.formatImageToWebpSticker(media);
else if (media.mimetype.includes(&#x27;video&#x27;))
webpMedia &#x3D; await this.formatVideoToWebpSticker(media);
else
throw new Error(&#x27;Invalid media format&#x27;);
if (metadata.name || metadata.author) {
const img &#x3D; new webp.Image();
const hash &#x3D; this.generateHash(32);
const stickerPackId &#x3D; hash;
const packname &#x3D; metadata.name;
const author &#x3D; metadata.author;
const categories &#x3D; metadata.categories || [&#x27;&#x27;];
const json &#x3D; { &#x27;sticker-pack-id&#x27;: stickerPackId, &#x27;sticker-pack-name&#x27;: packname, &#x27;sticker-pack-publisher&#x27;: author, &#x27;emojis&#x27;: categories };
let exifAttr &#x3D; Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]);
let jsonBuffer &#x3D; Buffer.from(JSON.stringify(json), &#x27;utf8&#x27;);
let exif &#x3D; Buffer.concat([exifAttr, jsonBuffer]);
exif.writeUIntLE(jsonBuffer.length, 14, 4);
await img.load(Buffer.from(webpMedia.data, &#x27;base64&#x27;));
img.exif &#x3D; exif;
webpMedia.data &#x3D; (await img.save(null)).toString(&#x27;base64&#x27;);
}
return webpMedia;
}
/**
@@ -187,7 +231,8 @@ class Util {
}
}
module.exports &#x3D; Util;</code></pre>
module.exports &#x3D; Util;
</code></pre>
</article>
</div>
</div>
@@ -197,7 +242,7 @@ module.exports &#x3D; Util;</code></pre>
<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.6 on February 25, 2021.
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on September 1, 2021.
</p>
</div>
</footer>

View File

@@ -1,5 +1,5 @@
const fs = require('fs');
const { Client, Location } = require('./index');
const { Client, Location, List, Buttons } = require('./index');
const SESSION_FILE_PATH = './session.json';
let sessionCfg;
@@ -11,6 +11,13 @@ const client = new Client({ puppeteer: { headless: false }, session: sessionCfg
// You can use an existing session and avoid scanning a QR code by adding a "session" object to the client options.
// This object must include WABrowserId, WASecretBundle, WAToken1 and WAToken2.
// You also could connect to an existing instance of a browser
// {
// puppeteer: {
// browserWSEndpoint: `ws://localhost:3000`
// }
// }
client.initialize();
client.on('qr', (qr) => {
@@ -192,11 +199,18 @@ client.on('message', async msg => {
const chat = await msg.getChat();
// stops typing or recording in the chat
chat.clearState();
} else if (msg.body === 'jumpto') {
} else if (msg.body === '!jumpto') {
if (msg.hasQuotedMsg) {
const quotedMsg = await msg.getQuotedMessage();
client.interface.openChatWindowAt(quotedMsg.id._serialized);
}
} else if (msg.body === '!buttons') {
let button = new Buttons('Button body',[{body:'bt1'},{body:'bt2'},{body:'bt3'}],'title','footer');
client.sendMessage(msg.from, button);
} else if (msg.body === '!list') {
let sections = [{title:'sectionTitle',rows:[{title:'ListItem1', description: 'desc'},{title:'ListItem2'}]}];
let list = new List('List body','btnText',sections,'Title','footer');
client.sendMessage(msg.from, list);
}
});
@@ -259,6 +273,10 @@ client.on('change_battery', (batteryInfo) => {
console.log(`Battery: ${battery}% - Charging? ${plugged}`);
});
client.on('change_state', state => {
console.log('CHANGE STATE', state );
});
client.on('disconnected', (reason) => {
console.log('Client was logged out', reason);
});

289
index.d.ts vendored
View File

@@ -1,5 +1,6 @@
import { EventEmitter } from 'events'
import { RequestInit } from 'node-fetch'
import puppeteer = require('puppeteer')
declare namespace WAWebJS {
@@ -19,6 +20,9 @@ declare namespace WAWebJS {
/**Accepts an invitation to join a group */
acceptInvite(inviteCode: string): Promise<string>
/** Accepts a private invitation to join a group (v4 invite) */
acceptGroupV4Invite: (inviteV4: InviteV4Data) => Promise<{status: number}>
/**Returns an object with information about the invite code's group */
getInviteInfo(inviteCode: string): Promise<object>
@@ -99,6 +103,9 @@ declare namespace WAWebJS {
/** Send a message to a specific chatId */
sendMessage(chatId: string, content: MessageContent, options?: MessageSendOptions): Promise<Message>
/** Searches for messages */
searchMessages(query: string, options?: { chatId?: string, page?: number, limit?: number }): Promise<Message[]>
/** Marks the client as online */
sendPresenceAvailable(): Promise<void>
@@ -149,8 +156,8 @@ declare namespace WAWebJS {
/** Emitted when the client has been disconnected */
on(event: 'disconnected', listener: (
/** state that caused the disconnect */
reason: WAState
/** reason that caused the disconnect */
reason: WAState | "NAVIGATED"
) => void): this
/** Emitted when a user joins the chat via invite link or is added by an admin */
@@ -221,6 +228,12 @@ declare namespace WAWebJS {
qr: string
) => void): this
/** Emitted when a call is received */
on(event: 'call', listener: (
/** The call that started */
call: Call
) => void): this
/** Emitted when the client has initialized and is ready to receive messages */
on(event: 'ready', listener: () => void): this
}
@@ -343,7 +356,7 @@ declare namespace WAWebJS {
reply: (content: MessageContent, options?: MessageSendOptions) => Promise<Message>,
}
/** whatsapp web url */
export const WhatsWebURL: string
@@ -413,7 +426,11 @@ declare namespace WAWebJS {
CONTACT_CARD = 'vcard',
CONTACT_CARD_MULTI = 'multi_vcard',
REVOKED = 'revoked',
ORDER = 'order',
PRODUCT = 'product',
PAYMENT = 'payment',
UNKNOWN = 'unknown',
GROUP_INVITE = 'groups_v4_invite',
}
/** Client status */
@@ -448,6 +465,15 @@ declare namespace WAWebJS {
readRemaining: number
}
export type InviteV4Data = {
inviteCode: string,
inviteCodeExp: number,
groupId: string,
groupName?: string,
fromId: string,
toId: string
}
/**
* Represents a Message on WhatsApp
*
@@ -499,12 +525,19 @@ declare namespace WAWebJS {
id: MessageId,
/** Indicates if the message was forwarded */
isForwarded: boolean,
/**
* Indicates how many times the message was forwarded.
* The maximum value is 127.
*/
forwardingScore: number,
/** Indicates if the message was starred */
isStarred: boolean,
/** Location information contained in the message, if the message is type "location" */
location: Location,
/** List of vCards contained in the message */
vCards: string[],
/** Invite v4 info */
inviteV4?: InviteV4Data,
/** MediaKey that represents the sticker 'ID' */
mediaKey?: string,
/** Indicates the mentions in the message body. */
@@ -520,8 +553,28 @@ declare namespace WAWebJS {
/** Message type */
type: MessageTypes,
/** Links included in the message. */
links: string[],
links: Array<{
link: string,
isSuspicious: boolean
}>,
/** Order ID */
orderId: string,
/** title */
title?: string,
/** description*/
description?: string,
/** Business Owner JID */
businessOwnerJid?: string,
/** Product JID */
productId?: string,
/** Message buttons */
dynamicReplyButtons?: object,
/** Selected button ID */
selectedButtonId?: string,
/** Selected list row ID */
selectedRowId?: string,
/** Accept the Group V4 Invite in message */
acceptGroupV4Invite: () => Promise<{status: number}>,
/** Deletes the message from the chat */
delete: (everyone?: boolean) => Promise<void>,
/** Downloads and returns the attatched message media */
@@ -549,7 +602,15 @@ declare namespace WAWebJS {
/** Unstar this message */
unstar: () => Promise<void>,
/** Get information about message delivery statuso */
getInfo: () => Promise<MessageInfo | null>
getInfo: () => Promise<MessageInfo | null>,
/**
* Gets the order associated with a given message
*/
getOrder: () => Order,
/**
* Gets the payment details associated with a given message
*/
getPayment: () => Payment,
}
/** ID that represents a message */
@@ -560,10 +621,13 @@ declare namespace WAWebJS {
_serialized: string,
}
export interface Location {
description?: string | null,
latitude: string,
longitude: string,
/** Location information */
export class Location {
description?: string | null
latitude: string
longitude: string
constructor(latitude: number, longitude: number, description?: string)
}
export interface Label {
@@ -584,6 +648,8 @@ declare namespace WAWebJS {
linkPreview?: boolean
/** Send audio as voice message */
sendAudioAsVoice?: boolean
/** Send video as gif */
sendVideoAsGif?: boolean
/** Send media as sticker */
sendMediaAsSticker?: boolean
/** Send media as document */
@@ -600,6 +666,20 @@ declare namespace WAWebJS {
sendSeen?: boolean
/** Media to be sent */
media?: MessageMedia
/** Extra options */
extra?: any
/** Sticker name, if sendMediaAsSticker is true */
stickerName?: string
/** Sticker author, if sendMediaAsSticker is true */
stickerAuthor?: string
/** Sticker categories, if sendMediaAsSticker is true */
stickerCategories?: string[]
}
export interface MediaFromURLOptions {
client?: Client
unsafeMime?: boolean
reqOptions?: RequestInit
}
/** Media attached to a message */
@@ -620,6 +700,9 @@ declare namespace WAWebJS {
/** Creates a MessageMedia instance from a local file path */
static fromFilePath: (filePath: string) => MessageMedia
/** Creates a MessageMedia instance from a URL */
static fromUrl: (url: string, options?: MediaFromURLOptions) => Promise<MessageMedia>
}
export type MessageContent = string | MessageMedia | Location | Contact | Contact[]
@@ -907,6 +990,192 @@ declare namespace WAWebJS {
/** Makes the bot leave the group */
leave: () => Promise<void>;
}
/**
* Represents the metadata associated with a given product
*
*/
export interface ProductMetadata {
/** Product Id */
id: string,
/** Product Name */
name: string,
/** Product Description */
description: string,
/** Retailer ID */
retailer_id?: string
}
/**
* Represents a Product on Whatsapp
* @example
* {
* "id": "123456789",
* "price": "150000",
* "thumbnailId": "123456789",
* "thumbnailUrl": "https://mmg.whatsapp.net",
* "currency": "GTQ",
* "name": "Store Name",
* "quantity": 1
* }
*/
export interface Product {
/** Product Id */
id: string,
/** Price */
price?: string,
/** Product Thumbnail*/
thumbnailUrl: string,
/** Currency */
currency: string,
/** Product Name */
name: string,
/** Product Quantity*/
quantity: number,
/** Gets the Product metadata */
getData: () => Promise<ProductMetadata>
}
/**
* Represents a Order on WhatsApp
*
* @example
* {
* "products": [
* {
* "id": "123456789",
* "price": "150000",
* "thumbnailId": "123456789",
* "thumbnailUrl": "https://mmg.whatsapp.net",
* "currency": "GTQ",
* "name": "Store Name",
* "quantity": 1
* }
* ],
* "subtotal": "150000",
* "total": "150000",
* "currency": "GTQ",
* "createdAt": 1610136796,
* "sellerJid": "55555555@s.whatsapp.net"
* }
*/
export interface Order {
/** List of products*/
products: Array<Product>,
/** Order Subtotal */
subtotal: string,
/** Order Total */
total: string,
/** Order Currency */
currency: string,
/** Order Created At*/
createdAt: number;
}
/**
* Represents a Payment on WhatsApp
*
* @example
* {
* id: {
* fromMe: true,
* remote: {
* server: 'c.us',
* user: '5511999999999',
* _serialized: '5511999999999@c.us'
* },
* id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
* _serialized: 'true_5511999999999@c.us_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
* },
* paymentCurrency: 'BRL',
* paymentAmount1000: 1000,
* paymentMessageReceiverJid: {
* server: 'c.us',
* user: '5511999999999',
* _serialized: '5511999999999@c.us'
* },
* paymentTransactionTimestamp: 1623463058,
* paymentStatus: 4,
* paymentTxnStatus: 4,
* paymentNote: 'note'
* }
*/
export interface Payment {
/** Payment Id*/
id: object,
/** Payment currency */
paymentCurrency: string,
/** Payment ammount */
paymentAmount1000 : number,
/** Payment receiver */
paymentMessageReceiverJid : object,
/** Payment transaction timestamp */
paymentTransactionTimestamp : number,
/** Payment paymentStatus */
paymentStatus : number,
/** Integer that represents the payment Text */
paymentTxnStatus : number,
/** The note sent with the payment */
paymentNote : string;
}
/**
* Represents a Call on WhatsApp
*
* @example
* Call {
* id: 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
* from: '5511999999@c.us',
* timestamp: 1625003709,
* isVideo: false,
* isGroup: false,
* fromMe: false,
* canHandleLocally: false,
* webClientShouldHandle: false,
* participants: []
* }
*/
export interface Call {
/** Call Id */
id: string,
/** from */
from?: string,
/** Unix timestamp for when the call was created*/
timestamp: number,
/** Is video */
isVideo: boolean,
/** Is Group */
isGroup: boolean,
/** Indicates if the call was sent by the current user */
fromMe: boolean,
/** indicates if the call can be handled in waweb */
canHandleLocally: boolean,
/** indicates if the call should be handled in waweb */
webClientShouldHandle: boolean,
/** Object with participants */
participants: object
}
/** Message type List */
export class List {
body: string
buttonText: string
sections: Array<any>
title?: string | null
footer?: string | null
constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
}
/** Message type buttons */
export class Buttons {
body: string | MessageMedia
buttons: Array<Array<string>>
title?: string | null
footer?: string | null
constructor(body: string, buttons: Array<Array<string>>, title?: string | null, footer?: string | null)
}
}
export = WAWebJS

View File

@@ -18,6 +18,8 @@ module.exports = {
BusinessContact: require('./src/structures/BusinessContact'),
ClientInfo: require('./src/structures/ClientInfo'),
Location: require('./src/structures/Location'),
ProductMetadata: require('./src/structures/ProductMetadata'),
List: require('./src/structures/List'),
Buttons: require('./src/structures/Buttons'),
...Constants
};

View File

@@ -1,11 +1,11 @@
{
"name": "whatsapp-web.js",
"version": "1.12.5",
"version": "1.14.1",
"description": "Library for interacting with the WhatsApp Web API ",
"main": "./index.js",
"typings": "./index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "mocha tests",
"shell": "node --experimental-repl-await ./shell.js",
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
},
@@ -26,18 +26,28 @@
"bugs": {
"url": "https://github.com/pedroslopez/whatsapp-web.js/issues"
},
"homepage": "https://waguide.pedroslopez.me/",
"homepage": "https://guide.wwebjs.dev/",
"dependencies": {
"@pedroslopez/moduleraid": "^5.0.0",
"@pedroslopez/moduleraid": "^5.0.2",
"fluent-ffmpeg": "^2.1.2",
"jsqr": "^1.3.1",
"mime": "^2.4.5",
"puppeteer": "^5.2.1",
"sharp": "^0.26.3"
"node-webpmux": "^3.1.0",
"puppeteer": "^10.1.0",
"sharp": "^0.28.3"
},
"devDependencies": {
"eslint": "^6.8.0",
"@types/node-fetch": "^2.5.11",
"chai": "^4.3.4",
"dotenv": "^10.0.0",
"eslint": "^7.27.0",
"eslint-plugin-mocha": "^9.0.0",
"jsdoc": "^3.6.4",
"jsdoc-baseline": "^0.1.5"
"jsdoc-baseline": "^0.1.5",
"mocha": "^9.0.2",
"sinon": "^11.1.1"
},
"engines": {
"node": ">=12.0.0"
}
}

View File

@@ -11,7 +11,7 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./util/Constan
const { ExposeStore, LoadUtils } = require('./util/Injected');
const ChatFactory = require('./factories/ChatFactory');
const ContactFactory = require('./factories/ContactFactory');
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label } = require('./structures');
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call, Buttons, List} = require('./structures');
/**
* Starting point for interacting with the WhatsApp Web API
* @extends {EventEmitter}
@@ -30,6 +30,7 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
* @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's Content-Security-Policy.
*
* @fires Client#qr
* @fires Client#authenticated
@@ -64,8 +65,16 @@ class Client extends EventEmitter {
* Sets up events and requirements, kicks off authentication request
*/
async initialize() {
const browser = await puppeteer.launch(this.options.puppeteer);
const page = (await browser.pages())[0];
let [browser, page] = [null, null];
if(this.options.puppeteer && this.options.puppeteer.browserWSEndpoint) {
browser = await puppeteer.connect(this.options.puppeteer);
page = await browser.newPage();
} else {
browser = await puppeteer.launch(this.options.puppeteer);
page = (await browser.pages())[0];
}
page.setUserAgent(this.options.userAgent);
this.pupBrowser = browser;
@@ -82,6 +91,10 @@ class Client extends EventEmitter {
}, this.options.session);
}
if(this.options.bypassCSP) {
await page.setBypassCSP(true);
}
await page.goto(WhatsWebURL, {
waitUntil: 'load',
timeout: 0,
@@ -116,18 +129,18 @@ class Client extends EventEmitter {
} else {
const getQrCode = async () => {
// Check if retry button is present
var QR_RETRY_SELECTOR = 'div[data-ref] > span > div';
var QR_RETRY_SELECTOR = 'div[data-ref] > span > button';
var qrRetry = await page.$(QR_RETRY_SELECTOR);
if (qrRetry) {
await qrRetry.click();
}
// Wait for QR Code
const QR_CANVAS_SELECTOR = 'canvas';
await page.waitForSelector(QR_CANVAS_SELECTOR, { timeout: this.options.qrTimeoutMs });
const qrImgData = await page.$eval(QR_CANVAS_SELECTOR, canvas => [].slice.call(canvas.getContext('2d').getImageData(0, 0, 264, 264).data));
const qr = jsQR(qrImgData, 264, 264).data;
/**
* Emitted when the QR code is received
* @event Client#qr
@@ -335,7 +348,7 @@ class Client extends EventEmitter {
/**
* Emitted when the client has been disconnected
* @event Client#disconnected
* @param {WAState} reason state that caused the disconnect
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
*/
this.emit(Events.DISCONNECTED, state);
this.destroy();
@@ -357,6 +370,24 @@ class Client extends EventEmitter {
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
});
await page.exposeFunction('onIncomingCall', (call) => {
/**
* Emitted when a call is received
* @event Client#incoming_call
* @param {object} call
* @param {number} call.id - Call id
* @param {string} call.peerJid - Who called
* @param {boolean} call.isVideo - if is video
* @param {boolean} call.isGroup - if is group
* @param {boolean} call.canHandleLocally - if we can handle in waweb
* @param {boolean} call.outgoing - if is outgoing
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
* @param {object} call.participants - Participants
*/
const cll = new Call(this,call);
this.emit(Events.INCOMING_CALL, cll);
});
await page.evaluate(() => {
window.Store.Msg.on('add', (msg) => { if (msg.isNewMsg) window.onAddMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.Msg.on('change', (msg) => { window.onChangeMessageEvent(window.WWebJS.getMessageModel(msg)); });
@@ -366,6 +397,7 @@ class Client extends EventEmitter {
window.Store.Msg.on('remove', (msg) => { if (msg.isNewMsg) window.onRemoveMessageEvent(window.WWebJS.getMessageModel(msg)); });
window.Store.AppState.on('change:state', (_AppState, state) => { window.onAppStateChangedEvent(state); });
window.Store.Conn.on('change:battery', (state) => { window.onBatteryStateChangedEvent(state); });
window.Store.Call.on('add', (call) => { window.onIncomingCall(call); });
});
/**
@@ -373,6 +405,13 @@ class Client extends EventEmitter {
* @event Client#ready
*/
this.emit(Events.READY);
// Disconnect when navigating away
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
this.pupPage.on('framenavigated', async () => {
this.emit(Events.DISCONNECTED, 'NAVIGATION');
await this.destroy();
});
}
/**
@@ -423,6 +462,7 @@ class Client extends EventEmitter {
* @typedef {Object} MessageSendOptions
* @property {boolean} [linkPreview=true] - Show links preview
* @property {boolean} [sendAudioAsVoice=false] - Send audio as voice message
* @property {boolean} [sendVideoAsGif=false] - Send video as gif
* @property {boolean} [sendMediaAsSticker=false] - Send media as a sticker
* @property {boolean} [sendMediaAsDocument=false] - Send media as a document
* @property {boolean} [parseVCards=true] - Automatically parse vCards and send them as contacts
@@ -430,13 +470,16 @@ class Client extends EventEmitter {
* @property {string} [quotedMessageId] - Id of the message that is being quoted (or replied to)
* @property {Contact[]} [mentions] - Contacts that are being mentioned in the message
* @property {boolean} [sendSeen=true] - Mark the conversation as seen after sending the message
* @property {string} [stickerAuthor=undefined] - Sets the author of the sticker, (if sendMediaAsSticker is true).
* @property {string} [stickerName=undefined] - Sets the name of the sticker, (if sendMediaAsSticker is true).
* @property {string[]} [stickerCategories=undefined] - Sets the categories of the sticker, (if sendMediaAsSticker is true). Provide emoji char array, can be null.
* @property {MessageMedia} [media] - Media to be sent
*/
/**
* Send a message to a specific chatId
* @param {string} chatId
* @param {string|MessageMedia|Location|Contact|Array<Contact>} content
* @param {string|MessageMedia|Location|Contact|Array<Contact>|Buttons|List} content
* @param {MessageSendOptions} [options] - Options used when sending the message
*
* @returns {Promise<Message>} Message that was just sent
@@ -445,12 +488,14 @@ class Client extends EventEmitter {
let internalOptions = {
linkPreview: options.linkPreview === false ? undefined : true,
sendAudioAsVoice: options.sendAudioAsVoice,
sendVideoAsGif: options.sendVideoAsGif,
sendMediaAsSticker: options.sendMediaAsSticker,
sendMediaAsDocument: options.sendMediaAsDocument,
caption: options.caption,
quotedMessageId: options.quotedMessageId,
parseVCards: options.parseVCards === false ? false : true,
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : []
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
...options.extra
};
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
@@ -471,10 +516,22 @@ class Client extends EventEmitter {
} else if(Array.isArray(content) && content.length > 0 && content[0] instanceof Contact) {
internalOptions.contactCardList = content.map(contact => contact.id._serialized);
content = '';
} else if(content instanceof Buttons){
if(content.type !== 'chat'){internalOptions.attachment = content.body;}
internalOptions.buttons = content;
content = '';
} else if(content instanceof List){
internalOptions.list = content;
content = '';
}
if (internalOptions.sendMediaAsSticker && internalOptions.attachment) {
internalOptions.attachment = await Util.formatToWebpSticker(internalOptions.attachment);
internalOptions.attachment =
await Util.formatToWebpSticker(internalOptions.attachment, {
name: options.stickerName,
author: options.stickerAuthor,
categories: options.stickerCategories
});
}
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
@@ -492,6 +549,24 @@ class Client extends EventEmitter {
return new Message(this, newMessage);
}
/**
* Searches for messages
* @param {string} query
* @param {Object} [options]
* @param {number} [options.page]
* @param {number} [options.limit]
* @param {string} [options.chatId]
* @returns {Promise<Message[]>}
*/
async searchMessages(query, options = {}) {
const messages = await this.pupPage.evaluate(async (query, page, count, remote) => {
const { messages } = await window.Store.Msg.search(query, page, count, remote);
return messages.map(msg => window.WWebJS.getMessageModel(msg));
}, query, options.page, options.limit, options.chatId);
return messages.map(msg => new Message(this, msg));
}
/**
* Get all current chat instances
* @returns {Promise<Array<Chat>>}
@@ -542,6 +617,37 @@ class Client extends EventEmitter {
return ContactFactory.create(this, contact);
}
async getMessageById(messageId) {
const msg = await this.pupPage.evaluate(async messageId => {
let msg = window.Store.Msg.get(messageId);
if(msg) return window.WWebJS.getMessageModel(msg);
const params = messageId.split('_');
if(params.length !== 3) throw new Error('Invalid serialized message id specified');
const [fromMe, chatId, id] = params;
const chatWid = window.Store.WidFactory.createWid(chatId);
const fullMsgId = {
fromMe: Boolean(fromMe),
remote: chatWid,
id,
};
const msgKey = new window.Store.MsgKey(fullMsgId);
const chat = await window.Store.Chat.find(msgKey.remote);
const ctx = await chat.getSearchContext(msgKey);
if(ctx.collection && ctx.collection.loadAroundPromise) {
await ctx.collection.loadAroundPromise;
}
msg = window.Store.Msg.get(messageId);
if(msg) return window.WWebJS.getMessageModel(msg);
}, messageId);
if(msg) return new Message(this, msg);
return null;
}
/**
* Returns an object with information about the invite code's group
* @param {string} inviteCode
@@ -566,6 +672,20 @@ class Client extends EventEmitter {
return chatId._serialized;
}
/**
* Accepts a private invitation to join a group
* @param {object} inviteV4 Invite V4 Info
* @returns {Promise<Object>}
*/
async acceptGroupV4Invite(inviteInfo) {
if(!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
if (inviteInfo.inviteCodeExp == 0) throw 'Expired invite code';
return await this.pupPage.evaluate(async inviteInfo => {
let { groupId, fromId, inviteCode, inviteCodeExp, toId } = inviteInfo;
return await window.Store.Wap.acceptGroupV4Invite(groupId, fromId, inviteCode, String(inviteCodeExp), toId);
}, inviteInfo);
}
/**
* Sets the current user's status message
* @param {string} status New status message

68
src/structures/Buttons.js Normal file
View File

@@ -0,0 +1,68 @@
'use strict';
const MessageMedia = require('./MessageMedia');
const Util = require('../util/Util');
/**
* Message type buttons
*/
class Buttons {
/**
* @param {string|MessageMedia} body
* @param {Array<Array<string>>} buttons
* @param {string?} title
* @param {string?} footer
*/
constructor(body, buttons, title, footer) {
/**
* Message body
* @type {string|MessageMedia}
*/
this.body = body;
/**
* title of message
* @type {string}
*/
this.title = title;
/**
* footer of message
* @type {string}
*/
this.footer = footer;
if (body instanceof MessageMedia) {
this.type = 'media';
this.title = '';
}else{
this.type = 'chat';
}
/**
* buttons of message
* @type {Array<Array<string>>}
*/
this.buttons = this._format(buttons);
if(!this.buttons.length){ throw '[BT01] No buttons';}
}
/**
* Creates button array from simple array
* @param {Array<Array<string>>} buttons
* @returns {Array<Array<string>>}
* @example
* Input: [{id:'customId',body:'button1'},{body:'button2'},{body:'button3'},{body:'button4'}]
* Returns: [{ buttonId:'customId',buttonText:{'displayText':'button1'},type: 1 },{buttonId:'n3XKsL',buttonText:{'displayText':'button2'},type:1},{buttonId:'NDJk0a',buttonText:{'displayText':'button3'},type:1}]
*/
_format(buttons){
buttons = buttons.slice(0,3); // phone users can only see 3 buttons, so lets limit this
return buttons.map((btn) => {
return {'buttonId':btn.id ? btn.id : Util.generateHash(6),'buttonText':{'displayText':btn.body},'type':1};
});
}
}
module.exports = Buttons;

68
src/structures/Call.js Normal file
View File

@@ -0,0 +1,68 @@
'use strict';
const Base = require('./Base');
/**
* Represents a Call on WhatsApp
* @extends {Base}
*/
class Call extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* Call ID
* @type {string}
*/
this.id = data.id;
/**
* From
* @type {string}
*/
this.from = data.peerJid;
/**
* Unix timestamp for when the call was created
* @type {number}
*/
this.timestamp = data.offerTime;
/**
* Is video
* @type {boolean}
*/
this.isVideo = data.isVideo;
/**
* Is Group
* @type {boolean}
*/
this.isGroup = data.isGroup;
/**
* Indicates if the call was sent by the current user
* @type {boolean}
*/
this.fromMe = data.outgoing;
/**
* Indicates if the call can be handled in waweb
* @type {boolean}
*/
this.canHandleLocally = data.canHandleLocally;
/**
* Indicates if the call Should be handled in waweb
* @type {boolean}
*/
this.webClientShouldHandle = data.webClientShouldHandle;
/**
* Object with participants
* @type {object}
*/
this.participants = data.participants;
return super._patch(data);
}
}
module.exports = Call;

79
src/structures/List.js Normal file
View File

@@ -0,0 +1,79 @@
'use strict';
const Util = require('../util/Util');
/**
* Message type List
*/
class List {
/**
* @param {string} body
* @param {string} buttonText
* @param {Array<any>} sections
* @param {string?} title
* @param {string?} footer
*/
constructor(body, buttonText, sections, title, footer) {
/**
* Message body
* @type {string}
*/
this.description = body;
/**
* List button text
* @type {string}
*/
this.buttonText = buttonText;
/**
* title of message
* @type {string}
*/
this.title = title;
/**
* footer of message
* @type {string}
*/
this.footer = footer;
/**
* sections of message
* @type {Array<any>}
*/
this.sections = this._format(sections);
}
/**
* Creates section array from simple array
* @param {Array<any>} sections
* @returns {Array<any>}
* @example
* Input: [{title:'sectionTitle',rows:[{id:'customId', title:'ListItem2', description: 'desc'},{title:'ListItem2'}]}}]
* Returns: [{'title':'sectionTitle','rows':[{'rowId':'customId','title':'ListItem1','description':'desc'},{'rowId':'oGSRoD','title':'ListItem2','description':''}]}]
*/
_format(sections){
if(!sections.length){throw '[LT02] List without sections';}
if(sections.length > 1){throw '[LT05] Lists with more than one section are having problems';}
return sections.map( (section) =>{
if(!section.rows.length){throw '[LT03] Section without rows';}
return {
title: section.title ? section.title : undefined,
rows: section.rows.map( (row) => {
if(!row.title){throw '[LT04] Row without title';}
return {
rowId: row.id ? row.id : Util.generateHash(6),
title: row.title,
description: row.description ? row.description : ''
};
})
};
});
}
}
module.exports = List;

View File

@@ -3,6 +3,8 @@
const Base = require('./Base');
const MessageMedia = require('./MessageMedia');
const Location = require('./Location');
const Order = require('./Order');
const Payment = require('./Payment');
const { MessageTypes } = require('../util/Constants');
/**
@@ -40,7 +42,7 @@ class Message extends Base {
* Indicates if the message has media available for download
* @type {boolean}
*/
this.hasMedia = data.clientUrl || data.deprecatedMms3Url ? true : false;
this.hasMedia = Boolean(data.mediaKey && data.directPath);
/**
* Message content
@@ -81,12 +83,26 @@ class Message extends Base {
*/
this.author = (typeof (data.author) === 'object' && data.author !== null) ? data.author._serialized : data.author;
/**
* String that represents from which device type the message was sent
* @type {string}
*/
this.deviceType = data.id.id.length > 21 ? 'android' : data.id.id.substring(0,2) =='3A' ? 'ios' : 'web';
/**
* Indicates if the message was forwarded
* @type {boolean}
*/
this.isForwarded = data.isForwarded;
/**
* Indicates how many times the message was forwarded.
*
* The maximum value is 127.
* @type {number}
*/
this.forwardingScore = data.forwardingScore || 0;
/**
* Indicates if the message is a status update
* @type {boolean}
@@ -129,6 +145,19 @@ class Message extends Base {
*/
this.vCards = data.type === MessageTypes.CONTACT_CARD_MULTI ? data.vcardList.map((c) => c.vcard) : data.type === MessageTypes.CONTACT_CARD ? [data.body] : [];
/**
* Group Invite Data
* @type {object}
*/
this.inviteV4 = data.type === MessageTypes.GROUP_INVITE ? {
inviteCode: data.inviteCode,
inviteCodeExp: data.inviteCodeExp,
groupId: data.inviteGrp,
groupName: data.inviteGrpName,
fromId: data.from._serialized,
toId: data.to._serialized
} : undefined;
/**
* Indicates the mentions in the message body.
* @type {Array<string>}
@@ -139,12 +168,59 @@ class Message extends Base {
this.mentionedIds = data.mentionedJidList;
}
/**
* Order ID for message type ORDER
* @type {string}
*/
this.orderId = data.orderId ? data.orderId : undefined;
/**
* Order Token for message type ORDER
* @type {string}
*/
this.token = data.token ? data.token : undefined;
/** Title */
if (data.title) {
this.title = data.title;
}
/** Description */
if (data.description) {
this.description = data.description;
}
/** Business Owner JID */
if (data.businessOwnerJid) {
this.businessOwnerJid = data.businessOwnerJid;
}
/** Product ID */
if (data.productId) {
this.productId = data.productId;
}
/**
* Links included in the message.
* @type {Array<string>}
* @type {Array<{link: string, isSuspicious: boolean}>}
*
*/
this.links = data.links;
/** Buttons */
if (data.dynamicReplyButtons) {
this.dynamicReplyButtons = data.dynamicReplyButtons;
}
/** Selected Button Id **/
if (data.selectedButtonId) {
this.selectedButtonId = data.selectedButtonId;
}
/** Selected List row Id **/
if (data.listResponse && data.listResponse.singleSelectReply.selectedRowId) {
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
}
return super._patch(data);
}
@@ -214,6 +290,14 @@ class Message extends Base {
return this.client.sendMessage(chatId, content, options);
}
/**
* Accept Group V4 Invite
* @returns {Promise<Object>}
*/
async acceptGroupV4Invite() {
return await this.client.acceptGroupV4Invite(this.inviteV4);
}
/**
* Forwards this message to another chat
*
@@ -245,26 +329,39 @@ class Message extends Base {
if (msg.mediaData.mediaStage != 'RESOLVED') {
// try to resolve media
await msg.downloadMedia(true, 1);
await msg.downloadMedia({
downloadEvenIfExpensive: true,
rmrReason: 1
});
}
if (msg.mediaData.mediaStage.includes('ERROR')) {
if (msg.mediaData.mediaStage.includes('ERROR') || msg.mediaData.mediaStage === 'FETCHING') {
// media could not be downloaded
return undefined;
}
const mediaUrl = msg.clientUrl || msg.deprecatedMms3Url;
const buffer = await window.WWebJS.downloadBuffer(mediaUrl);
const decrypted = await window.Store.CryptoLib.decryptE2EMedia(msg.type, buffer, msg.mediaKey, msg.mimetype);
const data = await window.WWebJS.readBlobAsync(decrypted._blob);
return {
data: data.split(',')[1],
mimetype: msg.mimetype,
filename: msg.filename
};
try {
const decryptedMedia = await window.Store.DownloadManager.downloadAndDecrypt({
directPath: msg.directPath,
encFilehash: msg.encFilehash,
filehash: msg.filehash,
mediaKey: msg.mediaKey,
mediaKeyTimestamp: msg.mediaKeyTimestamp,
type: msg.type,
signal: (new AbortController).signal
});
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
return {
data,
mimetype: msg.mimetype,
filename: msg.filename
};
} catch (e) {
if(e.status && e.status === 404) return undefined;
throw e;
}
}, this.id._serialized);
if (!result) return undefined;
@@ -342,6 +439,36 @@ class Message extends Base {
return info;
}
/**
* Gets the order associated with a given message
* @return {Promise<Order>}
*/
async getOrder() {
if (this.type === MessageTypes.ORDER) {
const result = await this.client.pupPage.evaluate((orderId, token) => {
return window.WWebJS.getOrderDetail(orderId, token);
}, this.orderId, this.token);
if (!result) return undefined;
return new Order(this.client, result);
}
return undefined;
}
/**
* Gets the payment details associated with a given message
* @return {Promise<Payment>}
*/
async getPayment() {
if (this.type === MessageTypes.PAYMENT) {
const msg = await this.client.pupPage.evaluate(async (msgId) => {
const msg = window.Store.Msg.get(msgId);
if(!msg) return null;
return msg.serialize();
}, this.id._serialized);
return new Payment(this.client, msg);
}
return undefined;
}
}
module.exports = Message;

View File

@@ -3,6 +3,8 @@
const fs = require('fs');
const path = require('path');
const mime = require('mime');
const fetch = require('node-fetch');
const { URL } = require('url');
/**
* Media attached to a message
@@ -43,6 +45,56 @@ class MessageMedia {
return new MessageMedia(mimetype, b64data, filename);
}
/**
* Creates a MessageMedia instance from a URL
* @param {string} url
* @param {Object} [options]
* @param {number} [options.unsafeMime=false]
* @param {object} [options.client]
* @param {object} [options.reqOptions]
* @param {number} [options.reqOptions.size=0]
* @returns {Promise<MessageMedia>}
*/
static async fromUrl(url, options = {}) {
let mimetype;
if (!options.unsafeMime) {
const pUrl = new URL(url);
mimetype = mime.getType(pUrl.pathname);
if (!mimetype)
throw new Error('Unable to determine MIME type');
}
async function fetchData (url, options) {
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
const response = await fetch(url, reqOptions);
const mime = response.headers.get('Content-Type');
let data = '';
if (response.buffer) {
data = (await response.buffer()).toString('base64');
} else {
const bArray = new Uint8Array(await response.arrayBuffer());
bArray.forEach((b) => {
data += String.fromCharCode(b);
});
data = btoa(data);
}
return { data, mime };
}
const res = options.client
? (await options.client.pupPage.evaluate(fetchData, url, options.reqOptions))
: (await fetchData(url, options.reqOptions));
if (!mimetype)
mimetype = res.mime;
return new MessageMedia(mimetype, res.data, null);
}
}
module.exports = MessageMedia;

52
src/structures/Order.js Normal file
View File

@@ -0,0 +1,52 @@
'use strict';
const Base = require('./Base');
const Product = require('./Product');
/**
* Represents a Order on WhatsApp
* @extends {Base}
*/
class Order extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* List of products
* @type {Array<Product>}
*/
if (data.products) {
this.products = data.products.map(product => new Product(this.client, product));
}
/**
* Order Subtotal
* @type {string}
*/
this.subtotal = data.subtotal;
/**
* Order Total
* @type {string}
*/
this.total = data.total;
/**
* Order Currency
* @type {string}
*/
this.currency = data.currency;
/**
* Order Created At
* @type {number}
*/
this.createdAt = data.createdAt;
return super._patch(data);
}
}
module.exports = Order;

78
src/structures/Payment.js Normal file
View File

@@ -0,0 +1,78 @@
const Base = require('./Base');
class Payment extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* The payment Id
* @type {object}
*/
this.id = data.id;
/**
* The payment currency
* @type {string}
*/
this.paymentCurrency = data.paymentCurrency;
/**
* The payment ammount ( R$ 1.00 = 1000 )
* @type {number}
*/
this.paymentAmount1000 = data.paymentAmount1000;
/**
* The payment receiver
* @type {object}
*/
this.paymentMessageReceiverJid = data.paymentMessageReceiverJid;
/**
* The payment transaction timestamp
* @type {number}
*/
this.paymentTransactionTimestamp = data.paymentTransactionTimestamp;
/**
* The paymentStatus
* @type {number}
*
* Possible Status
* 0:UNKNOWN_STATUS
* 1:PROCESSING
* 2:SENT
* 3:NEED_TO_ACCEPT
* 4:COMPLETE
* 5:COULD_NOT_COMPLETE
* 6:REFUNDED
* 7:EXPIRED
* 8:REJECTED
* 9:CANCELLED
* 10:WAITING_FOR_PAYER
* 11:WAITING
*/
this.paymentStatus = data.paymentStatus;
/**
* Integer that represents the payment Text
* @type {number}
*/
this.paymentTxnStatus = data.paymentTxnStatus;
/**
* The note sent with the payment
* @type {string}
*/
this.paymentNote = !data.paymentNoteMsg ? undefined : data.paymentNoteMsg.body ? data.paymentNoteMsg.body : undefined ;
return super._patch(data);
}
}
module.exports = Payment;

68
src/structures/Product.js Normal file
View File

@@ -0,0 +1,68 @@
'use strict';
const Base = require('./Base');
const ProductMetadata = require('./ProductMetadata');
/**
* Represents a Product on WhatsAppBusiness
* @extends {Base}
*/
class Product extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/**
* Product ID
* @type {string}
*/
this.id = data.id;
/**
* Price
* @type {string}
*/
this.price = data.price ? data.price : '';
/**
* Product Thumbnail
* @type {string}
*/
this.thumbnailUrl = data.thumbnailUrl;
/**
* Currency
* @type {string}
*/
this.currency = data.currency;
/**
* Product Name
* @type {string}
*/
this.name = data.name;
/**
* Product Quantity
* @type {number}
*/
this.quantity = data.quantity;
/** Product metadata */
this.data = null;
return super._patch(data);
}
async getData() {
if (this.data === null) {
let result = await this.client.pupPage.evaluate((productId) => {
return window.WWebJS.getProductMetadata(productId);
}, this.id);
if (!result) {
this.data = undefined;
} else {
this.data = new ProductMetadata(this.client, result);
}
}
return this.data;
}
}
module.exports = Product;

View File

@@ -0,0 +1,25 @@
const Base = require('./Base');
class ProductMetadata extends Base {
constructor(client, data) {
super(client);
if (data) this._patch(data);
}
_patch(data) {
/** Product ID */
this.id = data.id;
/** Retailer ID */
this.retailer_id = data.retailer_id;
/** Product Name */
this.name = data.name;
/** Product Description */
this.description = data.description;
return super._patch(data);
}
}
module.exports = ProductMetadata;

View File

@@ -11,5 +11,11 @@ module.exports = {
PrivateChat: require('./PrivateChat'),
PrivateContact: require('./PrivateContact'),
GroupNotification: require('./GroupNotification'),
Label: require('./Label.js')
};
Label: require('./Label.js'),
Order: require('./Order'),
Product: require('./Product'),
Call: require('./Call'),
Buttons: require('./Buttons'),
List: require('./List'),
Payment: require('./Payment')
};

View File

@@ -14,7 +14,8 @@ exports.DefaultOptions = {
takeoverOnConflict: false,
takeoverTimeoutMs: 0,
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36',
ffmpegPath: 'ffmpeg'
ffmpegPath: 'ffmpeg',
bypassCSP: false
};
/**
@@ -49,7 +50,8 @@ exports.Events = {
QR_RECEIVED: 'qr',
DISCONNECTED: 'disconnected',
STATE_CHANGED: 'change_state',
BATTERY_CHANGED: 'change_battery'
BATTERY_CHANGED: 'change_battery',
INCOMING_CALL: 'incoming_call'
};
/**
@@ -68,8 +70,14 @@ exports.MessageTypes = {
LOCATION: 'location',
CONTACT_CARD: 'vcard',
CONTACT_CARD_MULTI: 'multi_vcard',
ORDER: 'order',
REVOKED: 'revoked',
UNKNOWN: 'unknown'
PRODUCT: 'product',
UNKNOWN: 'unknown',
GROUP_INVITE: 'groups_v4_invite',
LIST: 'list',
BUTTONS_RESPONSE: 'buttons_response',
PAYMENT: 'payment'
};
/**

View File

@@ -32,6 +32,20 @@ exports.ExposeStore = (moduleRaidStr) => {
window.Store.Sticker = window.mR.findModule('Sticker')[0].default.Sticker;
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
window.Store.Label = window.mR.findModule('LabelCollection')[0].default;
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].default;
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
window.Store.DownloadManager = window.mR.findModule('DownloadManager')[0].default;
window.Store.Call = window.mR.findModule('CallCollection')[0].default;
if(!window.Store.Chat._find) {
window.Store.Chat._find = e => {
const target = window.Store.Chat.get(e);
return target ? Promise.resolve(target) : Promise.resolve({
id: e
});
};
}
};
exports.LoadUtils = () => {
@@ -62,7 +76,8 @@ exports.LoadUtils = () => {
? await window.WWebJS.processStickerData(options.attachment)
: await window.WWebJS.processMediaData(options.attachment, {
forceVoice: options.sendAudioAsVoice,
forceDocument: options.sendMediaAsDocument
forceDocument: options.sendMediaAsDocument,
forceGif: options.sendVideoAsGif
});
content = options.sendMediaAsSticker ? undefined : attOptions.preview;
@@ -138,7 +153,47 @@ exports.LoadUtils = () => {
options = { ...options, ...preview };
}
}
let extraOptions = {};
if(options.buttons){
let caption;
if(options.buttons.type === 'chat') {
content = options.buttons.body;
caption = content;
}else{
caption = options.caption ? options.caption : ' '; //Caption can't be empty
}
extraOptions = {
productHeaderImageRejected: false,
isFromTemplate: false,
isDynamicReplyButtonsMsg: true,
title: options.buttons.title ? options.buttons.title : undefined,
footer: options.buttons.footer ? options.buttons.footer : undefined,
dynamicReplyButtons: options.buttons.buttons,
replyButtons: options.buttons.buttons,
caption: caption
};
delete options.buttons;
}
if(options.list){
if(window.Store.Conn.platform === 'smba' || window.Store.Conn.platform === 'smbi'){
throw '[LT01] Whatsapp business can\'t send this yet';
}
extraOptions = {
...extraOptions,
type: 'list',
footer: options.list.footer,
list: {
...options.list,
listType: 1
},
body: options.list.description
};
delete options.list;
delete extraOptions.list.footer;
}
const newMsgId = new window.Store.MsgKey({
fromMe: true,
remote: chat.id,
@@ -160,7 +215,8 @@ exports.LoadUtils = () => {
...locationOptions,
...attOptions,
...quotedMsgOptions,
...vcardOptions
...vcardOptions,
...extraOptions
};
await window.Store.SendMessage.addAndSendMsgToChat(chat, message);
@@ -195,7 +251,7 @@ exports.LoadUtils = () => {
return stickerInfo;
};
window.WWebJS.processMediaData = async (mediaInfo, { forceVoice, forceDocument }) => {
window.WWebJS.processMediaData = async (mediaInfo, { forceVoice, forceDocument, forceGif }) => {
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
const mData = await window.Store.OpaqueData.createFromData(file, file.type);
const mediaPrep = window.Store.MediaPrep.prepRawMedia(mData, { asDocument: forceDocument });
@@ -211,6 +267,10 @@ exports.LoadUtils = () => {
mediaData.type = 'ptt';
}
if (forceGif && mediaData.type === 'video') {
mediaData.isGif = true;
}
if (forceDocument) {
mediaData.type = 'document';
}
@@ -255,17 +315,27 @@ exports.LoadUtils = () => {
const msg = message.serialize();
msg.isStatusV3 = message.isStatusV3;
msg.links = (message.getLinks()).map(link => link.href);
msg.links = (message.getLinks()).map(link => ({
link: link.href,
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
}));
if (msg.buttons) {
msg.buttons = msg.buttons.serialize();
}
if (msg.dynamicReplyButtons) {
msg.dynamicReplyButtons = JSON.parse(JSON.stringify(msg.dynamicReplyButtons));
}
if(msg.replyButtons) {
msg.replyButtons = JSON.parse(JSON.stringify(msg.replyButtons));
}
delete msg.pendingAckUpdate;
return msg;
};
window.WWebJS.getChatModel = async chat => {
let res = chat.serialize();
res.isGroup = chat.isGroup;
@@ -285,7 +355,8 @@ exports.LoadUtils = () => {
};
window.WWebJS.getChat = async chatId => {
const chat = window.Store.Chat.get(chatId);
const chatWid = window.Store.WidFactory.createWid(chatId);
const chat = await window.Store.Chat.find(chatWid);
return await window.WWebJS.getChatModel(chat);
};
@@ -315,8 +386,9 @@ exports.LoadUtils = () => {
return res;
};
window.WWebJS.getContact = contactId => {
const contact = window.Store.Contact.get(contactId);
window.WWebJS.getContact = async contactId => {
const wid = window.Store.WidFactory.createWid(contactId);
const contact = await window.Store.Contact.find(wid);
return window.WWebJS.getContactModel(contact);
};
@@ -341,43 +413,14 @@ exports.LoadUtils = () => {
});
};
window.WWebJS.downloadBuffer = (url) => {
return new Promise(function (resolve, reject) {
let xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'arraybuffer';
xhr.onload = function () {
if (xhr.status == 200) {
resolve(xhr.response);
} else {
reject({
status: this.status,
statusText: xhr.statusText
});
}
};
xhr.onerror = function () {
reject({
status: this.status,
statusText: xhr.statusText
});
};
xhr.send(null);
});
};
window.WWebJS.readBlobAsync = (blob) => {
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.onload = () => {
resolve(reader.result);
};
reader.onerror = reject;
reader.readAsDataURL(blob);
});
window.WWebJS.arrayBufferToBase64 = (arrayBuffer) => {
let binary = '';
const bytes = new Uint8Array( arrayBuffer );
const len = bytes.byteLength;
for (let i = 0; i < len; i++) {
binary += String.fromCharCode( bytes[ i ] );
}
return window.btoa( binary );
};
window.WWebJS.getFileHash = async (data) => {
@@ -453,6 +496,20 @@ exports.LoadUtils = () => {
const chat = await window.WWebJS.getChat(chatId);
return (chat.labels || []).map(id => window.WWebJS.getLabel(id));
};
window.WWebJS.getOrderDetail = async (orderId, token) => {
return window.Store.QueryOrder.queryOrder(orderId, 80, 80, token);
};
window.WWebJS.getProductMetadata = async (productId) => {
let sellerId = window.Store.Conn.wid;
let product = await window.Store.QueryProduct.queryProduct(sellerId, productId);
if (product && product.data) {
return product.data;
}
return undefined;
};
};
exports.MarkAllRead = () => {

View File

@@ -15,7 +15,8 @@ class InterfaceController {
*/
async openChatWindow(chatId) {
await this.pupPage.evaluate(async chatId => {
let chat = await window.Store.Chat.get(chatId);
let chatWid = window.Store.WidFactory.createWid(chatId);
let chat = await window.Store.Chat.find(chatWid);
await window.Store.Cmd.openChatAt(chat);
}, chatId);
}
@@ -72,7 +73,49 @@ class InterfaceController {
await window.Store.Cmd.closeDrawerRight();
});
}
/**
* Get all Features
*/
async getFeatures() {
return await this.pupPage.evaluate(() => {
return window.Store.Features.F;
});
}
/**
* Check if Feature is enabled
* @param {string} feature status to check
*/
async checkFeatureStatus(feature) {
return await this.pupPage.evaluate((feature) => {
return window.Store.Features.supportsFeature(feature);
}, feature);
}
/**
* Enable Features
* @param {string[]} features to be enabled
*/
async enableFeatures(features) {
await this.pupPage.evaluate((features) => {
for (const feature in features) {
window.Store.Features.setFeature(features[feature], true);
}
}, features);
}
/**
* Disable Features
* @param {string[]} features to be disabled
*/
async disableFeatures(features) {
await this.pupPage.evaluate((features) => {
for (const feature in features) {
window.Store.Features.setFeature(features[feature], false);
}
}, features);
}
}
module.exports = InterfaceController;
module.exports = InterfaceController;

View File

@@ -5,6 +5,7 @@ const path = require('path');
const Crypto = require('crypto');
const { tmpdir } = require('os');
const ffmpeg = require('fluent-ffmpeg');
const webp = require('node-webpmux');
const fs = require('fs').promises;
const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
@@ -18,6 +19,16 @@ class Util {
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
}
static generateHash(length) {
var result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
/**
* Sets default properties on an object that aren't already specified.
* @param {Object} def Default properties
@@ -135,16 +146,49 @@ class Util {
};
}
/**
* Sticker metadata.
* @typedef {Object} StickerMetadata
* @property {string} [name]
* @property {string} [author]
* @property {string[]} [categories]
*/
/**
* Formats a media to webp
* @param {MessageMedia} media
* @param {StickerMetadata} metadata
*
* @returns {Promise<MessageMedia>} media in webp format
*/
static async formatToWebpSticker(media) {
if (media.mimetype.includes('image')) return this.formatImageToWebpSticker(media);
else if (media.mimetype.includes('video')) return this.formatVideoToWebpSticker(media);
else throw new Error('Invalid media format');
static async formatToWebpSticker(media, metadata) {
let webpMedia;
if (media.mimetype.includes('image'))
webpMedia = await this.formatImageToWebpSticker(media);
else if (media.mimetype.includes('video'))
webpMedia = await this.formatVideoToWebpSticker(media);
else
throw new Error('Invalid media format');
if (metadata.name || metadata.author) {
const img = new webp.Image();
const hash = this.generateHash(32);
const stickerPackId = hash;
const packname = metadata.name;
const author = metadata.author;
const categories = metadata.categories || [''];
const json = { 'sticker-pack-id': stickerPackId, 'sticker-pack-name': packname, 'sticker-pack-publisher': author, 'emojis': categories };
let exifAttr = Buffer.from([0x49, 0x49, 0x2A, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]);
let jsonBuffer = Buffer.from(JSON.stringify(json), 'utf8');
let exif = Buffer.concat([exifAttr, jsonBuffer]);
exif.writeUIntLE(jsonBuffer.length, 14, 4);
await img.load(Buffer.from(webpMedia.data, 'base64'));
img.exif = exif;
webpMedia.data = (await img.save(null)).toString('base64');
}
return webpMedia;
}
/**
@@ -156,4 +200,4 @@ class Util {
}
}
module.exports = Util;
module.exports = Util;

10
tests/README.md Normal file
View File

@@ -0,0 +1,10 @@
## Running tests
These tests require an authenticated WhatsApp Web session, as well as an additional phone that you can send messages to.
This can be configured using the following environment variables:
- `WWEBJS_TEST_SESSION`: A JSON-formatted string with the session details. Must include `WABrowserId`, `WASecretBundle`, `WAToken1` and `WAToken2`.
- `WWEBJS_TEST_SESSION_PATH`: Path to a JSON file that contains the session details. Must include `WABrowserId`, `WASecretBundle`, `WAToken1` and `WAToken2`.
- `WWEBJS_TEST_REMOTE_ID`: A valid WhatsApp ID that you can send messages to, e.g. `123456789@c.us`. It should be different from the ID used by the provided session.
You *must* set `WWEBJS_TEST_REMOTE_ID` **and** either `WWEBJS_TEST_SESSION` or `WWEBJS_TEST_SESSION_PATH` for the tests to run properly.

427
tests/client.js Normal file
View File

@@ -0,0 +1,427 @@
const {expect} = require('chai');
const sinon = require('sinon');
const helper = require('./helper');
const Chat = require('../src/structures/Chat');
const Contact = require('../src/structures/Contact');
const Message = require('../src/structures/Message');
const MessageMedia = require('../src/structures/MessageMedia');
const Location = require('../src/structures/Location');
const { MessageTypes } = require('../src/util/Constants');
const remoteId = helper.remoteId;
describe('Client', function() {
describe('Authentication', function() {
it('should emit QR code if not authenticated', async function() {
this.timeout(25000);
const callback = sinon.spy();
const client = helper.createClient();
client.on('qr', callback);
client.initialize();
await helper.sleep(20000);
expect(callback.called).to.equal(true);
expect(callback.args[0][0]).to.have.lengthOf(152);
await client.destroy();
});
it('should fail auth if session is invalid', async function() {
this.timeout(40000);
const authFailCallback = sinon.spy();
const qrCallback = sinon.spy();
const readyCallback = sinon.spy();
const client = helper.createClient({
options: {
session: {
WABrowserId: 'invalid',
WASecretBundle: 'invalid',
WAToken1: 'invalid',
WAToken2: 'invalid'
},
authTimeoutMs: 10000,
restartOnAuthFail: false
}
});
client.on('qr', qrCallback);
client.on('auth_failure', authFailCallback);
client.on('ready', readyCallback);
client.initialize();
await helper.sleep(25000);
expect(authFailCallback.called).to.equal(true);
expect(authFailCallback.args[0][0]).to.equal('Unable to log in. Are the session details valid?');
expect(readyCallback.called).to.equal(false);
expect(qrCallback.called).to.equal(false);
await client.destroy();
});
it('can restart without a session if session was invalid and restartOnAuthFail=true', async function() {
this.timeout(40000);
const authFailCallback = sinon.spy();
const qrCallback = sinon.spy();
const client = helper.createClient({
options:{
session: {
WABrowserId: 'invalid',
WASecretBundle: 'invalid',
WAToken1: 'invalid',
WAToken2: 'invalid'
},
authTimeoutMs: 10000,
restartOnAuthFail: true
}
});
client.on('auth_failure', authFailCallback);
client.on('qr', qrCallback);
client.initialize();
await helper.sleep(35000);
expect(authFailCallback.called).to.equal(true);
expect(qrCallback.called).to.equal(true);
expect(qrCallback.args[0][0]).to.have.lengthOf(152);
await client.destroy();
});
it('should authenticate with existing session', async function() {
this.timeout(40000);
const authenticatedCallback = sinon.spy();
const qrCallback = sinon.spy();
const readyCallback = sinon.spy();
const client = helper.createClient({withSession: true});
client.on('qr', qrCallback);
client.on('authenticated', authenticatedCallback);
client.on('ready', readyCallback);
await client.initialize();
expect(authenticatedCallback.called).to.equal(true);
const newSession = authenticatedCallback.args[0][0];
expect(newSession).to.have.key([
'WABrowserId',
'WASecretBundle',
'WAToken1',
'WAToken2'
]);
expect(authenticatedCallback.called).to.equal(true);
expect(readyCallback.called).to.equal(true);
expect(qrCallback.called).to.equal(false);
await client.destroy();
});
});
describe('Authenticated', function() {
let client;
before(async function() {
this.timeout(35000);
client = helper.createClient({withSession: true});
await client.initialize();
});
after(async function () {
await client.destroy();
});
describe('Expose Store', function() {
it('exposes the store', async function() {
const exposed = await client.pupPage.evaluate(() => {
return Boolean(window.Store);
});
expect(exposed).to.equal(true);
});
it('exposes all required WhatsApp Web internal models', async function() {
const expectedModules = [
'Chat',
'Msg',
'Contact',
'Conn',
'AppState',
'CryptoLib',
'Wap',
'SendSeen',
'SendClear',
'SendDelete',
'genId',
'SendMessage',
'MsgKey',
'Invite',
'OpaqueData',
'MediaPrep',
'MediaObject',
'MediaUpload',
'Cmd',
'MediaTypes',
'VCard',
'UserConstructor',
'Validators',
'WidFactory',
'BlockContact',
'GroupMetadata',
'Sticker',
'UploadUtils',
'Label',
'Features',
'QueryOrder',
'QueryProduct',
'DownloadManager'
];
const loadedModules = await client.pupPage.evaluate(() => {
return Object.keys(window.Store);
});
expect(loadedModules).to.include.members(expectedModules);
});
});
describe('Send Messages', function () {
it('can send a message', async function() {
const msg = await client.sendMessage(remoteId, 'hello world');
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.TEXT);
expect(msg.fromMe).to.equal(true);
expect(msg.body).to.equal('hello world');
expect(msg.to).to.equal(remoteId);
});
it('can send a media message', async function() {
const media = new MessageMedia(
'image/png',
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII='
);
const msg = await client.sendMessage(remoteId, media, {caption: 'here\'s my media'});
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.IMAGE);
expect(msg.fromMe).to.equal(true);
expect(msg.hasMedia).to.equal(true);
expect(msg.body).to.equal('here\'s my media');
expect(msg.to).to.equal(remoteId);
});
it('can send a media message as a document', async function() {
const media = new MessageMedia(
'image/png',
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII=',
'this is my filename.png'
);
const msg = await client.sendMessage(remoteId, media, { sendMediaAsDocument: true});
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.DOCUMENT);
expect(msg.fromMe).to.equal(true);
expect(msg.hasMedia).to.equal(true);
expect(msg.body).to.equal('this is my filename.png');
expect(msg.to).to.equal(remoteId);
});
it('can send a sticker message', async function() {
const media = new MessageMedia(
'image/png',
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII='
);
const msg = await client.sendMessage(remoteId, media, {sendMediaAsSticker: true});
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.STICKER);
expect(msg.fromMe).to.equal(true);
expect(msg.hasMedia).to.equal(true);
expect(msg.to).to.equal(remoteId);
});
it('can send a sticker message with custom author and name', async function() {
const media = new MessageMedia(
'image/png',
'iVBORw0KGgoAAAANSUhEUgAAAV4AAACWBAMAAABkyf1EAAAAG1BMVEXMzMyWlpacnJyqqqrFxcWxsbGjo6O3t7e+vr6He3KoAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAEcElEQVR4nO2aTW/bRhCGh18ij1zKknMkbbf2UXITIEeyMhIfRaF1exQLA/JRclslRykO+rs7s7s0VwytNmhJtsA8gHZEcox9PTs7uysQgGEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmEYhmGYr2OWRK/ReIKI8Zt7Hb19wTcQ0uTkGh13bQupcw7gPOvdo12/5CzNtNR7xLUtNtT3CGBQ6g3InjY720pvofUec22LJPr8PhEp2OMPyI40PdwWUdronCu9yQpdPx53bQlfLKnfOVhlnDYRBXve4Ov+IZTeMgdedm0NR+xoXJeQvdJ3CvziykSukwil16W/Oe7aGjIjqc/9ib4jQlJy0uArtN4A0+cvXFvDkmUJ47sJ1Y1ATLDNVXZkNPIepQzxy1ki9fqiwbUj/I+64zxWNzyZnPuhvohJ9K70VvXBixpcu2SAHU+Xd9EKdEJDNpYP3AQr3bQSpPQ6Y6/4dl1z7ZDbArsszjA7L0g7ibB0CDcidUWVoErvIMKZh2Xs0LUzcLW6V5NfiUgNEbaYmAVL6bXl0nJRc+1S72ua/D/cTjGPlQj7eUqd7A096rYlRjdPYlhz7VIvxpVG3cemDKF+WAwLY/6XelOZKTXXzsC4xvDjjtSN6kHLhLke6PrwM8h1raf40qjrGO7H9aTEbduucjS04ZrYU/4iuS5Z2Hdt0rvCLFdmLEXcU30AGddST62o+sLcf5l6k7CP+ru4pLYqX/VFyxbm/utQbx/r22ZEbTb2f5I2kns1Y1OQR8ZyofX+TjJxj1Rz7QQVnf1QzR26Oth0ueJVYcRP6ZUPac/Rx/5M6ixO1dhSrT3Y1DpiYmx3tF4ZUdpz9LD/dSg9PXES0LB71BwcGjKROuV28lnvnv7HHJsezheBGH5+X2CfSfRbMKW+5aGs3JFjMrjGibJc0S7TJzqjHrh2hDybj9XRXNZa89Aro55XBdbW5wti2c/5WJ7jJ1RolVUn/HWpb0I58Tziup6Rx7Dm2hnbRP1GM9PW/NFmQ4PtVRVN63Wvxfmu5sowDMMwDMMwDMMwDMMwDMMwDMMwzL+CpT//F/6beoV8zb2Jmt4Qryx6lTUCsENQ75HOkhXAO3EPVgyQtKtUy3C/e+FJg17Zjnew1Xrdb9InbG4WqfUAftG+WhLwPVyfg536+MU7m4C1CMk4ZznpXZzDYI1PDL2nS1hpvc5cNd7E2sJg05Fe7/7d3Fln8Cvc3bwB616auxsKl4WPghjemHrDqyDWeu1UNW5s2btPnSQ75oOdunEwWazfwgVG0kqluYCM9OIjWOGnfA2b9G4Ha63XKpvQ8perTvTifJNhi6+WMWmi7smEZf6G8MmhlyGq+NqP8GV84TLuJr7UIQVx+bDEoEpRZIz42gs40OuN4Mv8hXzelV7KX1isH+ewTWckikyVv+CfHuqVF7I16gN0VKypX6wPsE+zFPzkinolU9UH8OMGvSpnZqKsv13p/RsMun6X5x/y2LeAr8O66lsBwzBMP/wJfyGq8pgBk6IAAAAASUVORK5CYII='
);
const msg = await client.sendMessage(remoteId, media, {
sendMediaAsSticker: true,
stickerAuthor: 'WWEBJS',
stickerName: 'My Sticker'
});
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.STICKER);
expect(msg.fromMe).to.equal(true);
expect(msg.hasMedia).to.equal(true);
expect(msg.to).to.equal(remoteId);
});
it('can send a location message', async function() {
const location = new Location(37.422, -122.084, 'Googleplex\nGoogle Headquarters');
const msg = await client.sendMessage(remoteId, location);
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.LOCATION);
expect(msg.fromMe).to.equal(true);
expect(msg.to).to.equal(remoteId);
expect(msg.location).to.be.instanceOf(Location);
expect(msg.location.latitude).to.equal(37.422);
expect(msg.location.longitude).to.equal(-122.084);
expect(msg.location.description).to.equal('Googleplex\nGoogle Headquarters');
});
it('can send a vCard as a contact card message', async function() {
const vCard = `BEGIN:VCARD
VERSION:3.0
FN;CHARSET=UTF-8:John Doe
N;CHARSET=UTF-8:Doe;John;;;
EMAIL;CHARSET=UTF-8;type=HOME,INTERNET:john@doe.com
TEL;TYPE=HOME,VOICE:1234567890
REV:2021-06-06T02:35:53.559Z
END:VCARD`;
const msg = await client.sendMessage(remoteId, vCard);
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.CONTACT_CARD);
expect(msg.fromMe).to.equal(true);
expect(msg.to).to.equal(remoteId);
expect(msg.body).to.equal(vCard);
expect(msg.vCards).to.have.lengthOf(1);
expect(msg.vCards[0]).to.equal(vCard);
});
it('can optionally turn off vCard parsing', async function() {
const vCard = `BEGIN:VCARD
VERSION:3.0
FN;CHARSET=UTF-8:John Doe
N;CHARSET=UTF-8:Doe;John;;;
EMAIL;CHARSET=UTF-8;type=HOME,INTERNET:john@doe.com
TEL;TYPE=HOME,VOICE:1234567890
REV:2021-06-06T02:35:53.559Z
END:VCARD`;
const msg = await client.sendMessage(remoteId, vCard, {parseVCards: false});
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.TEXT); // not a contact card
expect(msg.fromMe).to.equal(true);
expect(msg.to).to.equal(remoteId);
expect(msg.body).to.equal(vCard);
});
it('can send a Contact as a contact card message', async function() {
const contact = await client.getContactById(remoteId);
const msg = await client.sendMessage(remoteId, contact);
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.CONTACT_CARD);
expect(msg.fromMe).to.equal(true);
expect(msg.to).to.equal(remoteId);
expect(msg.body).to.match(/BEGIN:VCARD/);
expect(msg.vCards).to.have.lengthOf(1);
expect(msg.vCards[0]).to.match(/BEGIN:VCARD/);
});
it('can send multiple Contacts as a contact card message', async function () {
const contact1 = await client.getContactById(remoteId);
const contact2 = await client.getContactById('5511942167462@c.us'); //iFood
const msg = await client.sendMessage(remoteId, [contact1, contact2]);
expect(msg).to.be.instanceOf(Message);
expect(msg.type).to.equal(MessageTypes.CONTACT_CARD_MULTI);
expect(msg.fromMe).to.equal(true);
expect(msg.to).to.equal(remoteId);
expect(msg.vCards).to.have.lengthOf(2);
expect(msg.vCards[0]).to.match(/BEGIN:VCARD/);
expect(msg.vCards[1]).to.match(/BEGIN:VCARD/);
});
});
describe('Get Messages', function() {
it ('can get a message by it\'s ID', async function() {
const chat = await client.getChatById(remoteId);
const [message] = await chat.fetchMessages({limit: 1});
const messageById = await client.getMessageById(message.id._serialized);
expect(messageById).to.exist;
expect(messageById).to.be.instanceOf(Message);
expect(messageById).to.be.equal(message);
});
});
describe('Get Chats', function () {
it('can get a chat by its ID', async function () {
const chat = await client.getChatById(remoteId);
expect(chat).to.be.instanceOf(Chat);
expect(chat.id._serialized).to.eql(remoteId);
expect(chat.isGroup).to.eql(false);
});
it('can get all chats', async function () {
const chats = await client.getChats();
expect(chats.length).to.be.greaterThanOrEqual(1);
const chat = chats.find(c => c.id._serialized === remoteId);
expect(chat).to.exist;
expect(chat).to.be.instanceOf(Chat);
});
});
describe('Get Contacts', function () {
it('can get a contact by its ID', async function () {
const contact = await client.getContactById(remoteId);
expect(contact).to.be.instanceOf(Contact);
expect(contact.id._serialized).to.eql(remoteId);
expect(contact.number).to.eql(remoteId.split('@')[0]);
});
it('can get all contacts', async function () {
const contacts = await client.getContacts();
expect(contacts.length).to.be.greaterThanOrEqual(1);
const contact = contacts.find(c => c.id._serialized === remoteId);
expect(contact).to.exist;
expect(contact).to.be.instanceOf(Contact);
});
});
describe('Numbers and Users', function () {
it('can verify that a user is registered', async function () {
const isRegistered = await client.isRegisteredUser(remoteId);
expect(isRegistered).to.be.true;
});
it('can verify that a user is not registered', async function () {
const isRegistered = await client.isRegisteredUser('9999999999@c.us');
expect(isRegistered).to.be.false;
});
it('can get a number\'s whatsapp id', async function () {
const number = remoteId.split('@')[0];
const numberId = await client.getNumberId(number);
expect(numberId).to.eql({
server: 'c.us',
user: number,
_serialized: `${number}@c.us`
});
});
it('returns null when getting an unregistered number\'s whatsapp id', async function () {
const number = '9999999999';
const numberId = await client.getNumberId(number);
expect(numberId).to.eql(null);
});
});
});
});

40
tests/helper.js Normal file
View File

@@ -0,0 +1,40 @@
const path = require('path');
const Client = require('../src/Client');
const Util = require('../src/util/Util');
require('dotenv').config();
const remoteId = process.env.WWEBJS_TEST_REMOTE_ID;
if(!remoteId) throw new Error('The WWEBJS_TEST_REMOTE_ID environment variable has not been set.');
function getSessionFromEnv() {
const envSession = process.env.WWEBJS_TEST_SESSION;
if(envSession) return JSON.parse(envSession);
const envSessionPath = process.env.WWEBJS_TEST_SESSION_PATH;
if(envSessionPath) {
const absPath = path.resolve(process.cwd(), envSessionPath);
return require(absPath);
}
throw new Error('No session found in environment.');
}
function createClient({withSession, options: additionalOpts}={}) {
const options = {};
if(withSession) {
options.session = getSessionFromEnv();
}
return new Client(Util.mergeDefault(options, additionalOpts || {}));
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
module.exports = {
sleep,
createClient,
remoteId
};

View File

@@ -0,0 +1 @@
2.2126.14

View File

@@ -0,0 +1,46 @@
#!/usr/bin/env node
const fs = require('fs');
const fetch = require('node-fetch');
const getLatestVersion = async (currentVersion) => {
const res = await fetch(`https://web.whatsapp.com/check-update?version=${currentVersion}&platform=web`);
const data = await res.json();
return data.currentVersion;
};
const getCurrentVersion = () => {
try {
const versionFile = fs.readFileSync('./.version');
return versionFile ? versionFile.toString().trim() : null;
} catch(_) {
return null;
}
};
const updateVersion = async (oldVersion, newVersion) => {
const readmePath = '../../README.md';
const readme = fs.readFileSync(readmePath);
const newReadme = readme.toString().replaceAll(oldVersion, newVersion);
fs.writeFileSync(readmePath, newReadme);
fs.writeFileSync('./.version', newVersion);
};
(async () => {
const currentVersion = getCurrentVersion();
const version = await getLatestVersion(currentVersion);
console.log(`Current version: ${currentVersion}`);
console.log(`Latest version: ${version}`);
if(currentVersion !== version) {
console.log('Updating files...');
await updateVersion(currentVersion, version);
console.log('Updated!');
} else {
console.log('No changes.');
}
})();