mirror of
https://github.com/cheveguerra/whatsapp-web.js.git
synced 2026-04-18 11:39:14 +00:00
Compare commits
119 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a60f5ebf40 | ||
|
|
e8bae22b03 | ||
|
|
82120f0446 | ||
|
|
6f7c5c2dd9 | ||
|
|
9981723505 | ||
|
|
7bb7f13f07 | ||
|
|
7d672078cd | ||
|
|
088ec32b7b | ||
|
|
ef3eadc6e5 | ||
|
|
ab87fecfd9 | ||
|
|
36aa37f1ac | ||
|
|
45972fb47e | ||
|
|
55f75b8f69 | ||
|
|
b1e0fce504 | ||
|
|
62623347e8 | ||
|
|
705d4d31fd | ||
|
|
bd4df4cf75 | ||
|
|
7fe3574730 | ||
|
|
09a81d0e1e | ||
|
|
c09a22c533 | ||
|
|
bb09bb74e7 | ||
|
|
694a52bf26 | ||
|
|
c459eca799 | ||
|
|
b74246d69a | ||
|
|
ab7ee0eb4f | ||
|
|
537e843a49 | ||
|
|
76f7a6e279 | ||
|
|
f2ec77f969 | ||
|
|
fd368361df | ||
|
|
bd553f75d3 | ||
|
|
c5c705a553 | ||
|
|
6e047cb9be | ||
|
|
56343497e9 | ||
|
|
6a4fca0a77 | ||
|
|
e91077a615 | ||
|
|
0e5bd9f38e | ||
|
|
75d3c635f0 | ||
|
|
8497a3d7e5 | ||
|
|
e7025ceca1 | ||
|
|
b8b41920e3 | ||
|
|
73e4b3b6e0 | ||
|
|
af431df1c9 | ||
|
|
61c0a6be56 | ||
|
|
a0b18fb685 | ||
|
|
98ff761cfb | ||
|
|
c0ef9223ed | ||
|
|
294e5027b0 | ||
|
|
ebc56bc280 | ||
|
|
b16e1cdf83 | ||
|
|
a24294ec61 | ||
|
|
374983b9a6 | ||
|
|
5e2e9dd139 | ||
|
|
3a2acf71c2 | ||
|
|
f32f3c71ba | ||
|
|
017dd4b783 | ||
|
|
fa9f6610d7 | ||
|
|
e9104b390d | ||
|
|
a23c285f3c | ||
|
|
281aec40ad | ||
|
|
2e4890d113 | ||
|
|
0bd8eb9d96 | ||
|
|
2718c1328c | ||
|
|
24f8b4622b | ||
|
|
9ab9c48f7b | ||
|
|
b96607338a | ||
|
|
ea2cc81d47 | ||
|
|
56644f4f03 | ||
|
|
fcb78a1cd4 | ||
|
|
f88bd274be | ||
|
|
c45fae5c15 | ||
|
|
1b75d0d243 | ||
|
|
cc78e9863d | ||
|
|
fc205ff530 | ||
|
|
6ab98a5365 | ||
|
|
3c24df085a | ||
|
|
979e97ea42 | ||
|
|
1f4328c7a3 | ||
|
|
6691d25282 | ||
|
|
12d9735b73 | ||
|
|
ab5167c4ad | ||
|
|
52c8336236 | ||
|
|
9fe91692cf | ||
|
|
f6de161c7d | ||
|
|
0d55d40885 | ||
|
|
8ef37b68ae | ||
|
|
bd5cfdc936 | ||
|
|
f0e49efcf9 | ||
|
|
5d83b45ed4 | ||
|
|
e29354fca3 | ||
|
|
66283da903 | ||
|
|
d7f7889b0f | ||
|
|
11955e9f03 | ||
|
|
444abc2c76 | ||
|
|
20f3bc7a8b | ||
|
|
93c8a2b05e | ||
|
|
70ca073f38 | ||
|
|
7e36cceaf0 | ||
|
|
303ea3ab6b | ||
|
|
4aae8b0f32 | ||
|
|
64803c2ba6 | ||
|
|
aa9e19a19e | ||
|
|
7631400de1 | ||
|
|
d7478de68a | ||
|
|
a9b2a1aab8 | ||
|
|
3b4632201d | ||
|
|
2200390d4c | ||
|
|
b1f7ff01bc | ||
|
|
21d565154a | ||
|
|
09cbee0e65 | ||
|
|
fa9f5aba38 | ||
|
|
c859ac39ce | ||
|
|
221d29736a | ||
|
|
078933f061 | ||
|
|
f149516d0d | ||
|
|
2f1c894a34 | ||
|
|
32e47d818a | ||
|
|
20aee44c3b | ||
|
|
bb2ef88e0a | ||
|
|
6878598a5d |
@@ -1,2 +1,3 @@
|
||||
WWEBJS_TEST_SESSION_PATH=test_session.json
|
||||
WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us
|
||||
WWEBJS_TEST_REMOTE_ID=XXXXXXXXXX@c.us
|
||||
WWEBJS_TEST_CLIENT_ID=authenticated
|
||||
WWEBJS_TEST_MD=1
|
||||
41
.github/ISSUE_TEMPLATE/bug_report.md
vendored
41
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,41 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Is something not working as intended? Report it here.
|
||||
title: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Bug description
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
### Reproduction steps
|
||||
Steps to reproduce the behavior:
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
...
|
||||
|
||||
### Expected behavior
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
### Relevant code
|
||||
If applicable, add code snippets to help explain your problem.
|
||||
|
||||
### Environment (please complete the following information):
|
||||
**WhatsApp**
|
||||
- Account type [Standard / Business]:
|
||||
- Device OS [iOS / Android]:
|
||||
- WhatsApp Web version [run `await client.getWWebVersion()`]:
|
||||
|
||||
**Library**
|
||||
- Browser [Chrome / Chromium]:
|
||||
- NodeJS version (`node -v`):
|
||||
- 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.
|
||||
105
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
105
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
name: '🐛 Bug report'
|
||||
description: Create a report to help us improve
|
||||
labels: bug
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for reporting an issue :pray:.
|
||||
|
||||
This issue tracker is for reporting bugs found in [`whatsapp-web.js`](https://github.com/pedroslopez/whatsapp-web.js).
|
||||
|
||||
If you have a question about how to achieve something and are struggling, please post a question in our [Discord server](https://discord.gg/wyKybbF) instead.
|
||||
|
||||
Before submitting a new bug/issue, please check the links below to see if there is a solution or question posted there already:
|
||||
- `whatsapp-web.js` [Issues tab](https://github.com/pedroslopez/whatsapp-web.js/issues?q=is%3Aissue+is%3Aopen+sort%3Aupdated-desc)
|
||||
- `whatsapp-web.js` [closed Issues tab](https://github.com/pedroslopez/whatsapp-web.js/issues?q=is%3Aissue+sort%3Aupdated-desc+is%3Aclosed)
|
||||
|
||||
The more information you fill in, the better the community can help you.
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Is there an existing issue for this?
|
||||
description: Please search to see if an issue already exists for the bug you encountered.
|
||||
options:
|
||||
- label: I have searched the existing issues
|
||||
required: true
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: Provide a clear and concise description of the challenge you are running into.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: Provide a clear and concise description of what you expected to happen.
|
||||
placeholder: |
|
||||
As a user, I expected ___ behavior but I am seeing ___
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: steps
|
||||
attributes:
|
||||
label: Steps to Reproduce the Bug or Issue
|
||||
description: Describe the steps we have to take to reproduce the behavior.
|
||||
placeholder: |
|
||||
1. Do X
|
||||
2. Do Y
|
||||
3. Do Z
|
||||
4. See error
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: relevant_code
|
||||
attributes:
|
||||
label: Relevant Code
|
||||
description: If applicable, add code snippets to help explain your problem.
|
||||
validations:
|
||||
required: false
|
||||
- type: dropdown
|
||||
id: browser_type
|
||||
attributes:
|
||||
label: Browser Type
|
||||
description: What web browser are you using?
|
||||
options:
|
||||
- Chromium
|
||||
- Google Chrome
|
||||
- Other (please write in Additional Context)
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: whatsapp_type
|
||||
attributes:
|
||||
label: WhatsApp Account Type
|
||||
options:
|
||||
- Standard
|
||||
- WhatsApp Business
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: multidevice
|
||||
attributes:
|
||||
label: Does your WhatsApp account have multidevice enabled?
|
||||
options:
|
||||
- Yes, I am using Multi Device
|
||||
- No, I am not using Multi Device
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Environment
|
||||
description: |
|
||||
- OS: [e.g. Mac, Windows, Linux, Docker + Ubuntu 18, etc]
|
||||
- Phone OS: [e.g. Android, iOS]
|
||||
- whatsapp-web.js version [e.g. 1.2.3]
|
||||
- WhatsApp Web version [run `await client.getWWebVersion()`]:
|
||||
- Node.js Version [e.g. 1.2.3]
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: additional
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here.
|
||||
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
42
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
42
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
name: 🚀 Feature request
|
||||
description: Suggest an idea for this project
|
||||
labels: enhancement
|
||||
|
||||
body:
|
||||
- type: checkboxes
|
||||
attributes:
|
||||
label: Is there an existing issue for this?
|
||||
description: Please search to see if an issue related to this feature request already exists.
|
||||
options:
|
||||
- label: I have searched the existing issues
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe.
|
||||
description: A concise description of the problem you are facing or the motivetion behind this feature request.
|
||||
placeholder: I faced a problem due to ...
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the solution you'd like.
|
||||
description: A concise description of the solution for the issue.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe an alternate solution.
|
||||
description: Is there any other approach to solve the problem?
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: |
|
||||
Links? Screenshots? References? Anything that will give us more context about what you would like to see!
|
||||
validations:
|
||||
required: false
|
||||
41
.github/pull_request_template.md
vendored
Normal file
41
.github/pull_request_template.md
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# PR Details
|
||||
|
||||
<!--- Provide a general summary of your changes in the Title above -->
|
||||
|
||||
## Description
|
||||
|
||||
<!--- Describe your changes in detail -->
|
||||
|
||||
## Related Issue
|
||||
|
||||
<!--- Optional --->
|
||||
<!--- If there is an issue link it here: -->
|
||||
|
||||
## Motivation and Context
|
||||
|
||||
<!--- Optional --->
|
||||
<!--- Why is this change required? What problem does it solve? -->
|
||||
|
||||
## How Has This Been Tested
|
||||
|
||||
<!--- Please describe in detail how you tested your changes. -->
|
||||
<!--- Include details of your testing environment, and the tests you ran to -->
|
||||
|
||||
## Types of changes
|
||||
|
||||
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
|
||||
|
||||
- [ ] Dependency change
|
||||
- [ ] Bug fix (non-breaking change which fixes an issue)
|
||||
- [ ] New feature (non-breaking change which adds functionality)
|
||||
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
|
||||
|
||||
## Checklist
|
||||
|
||||
<!--- Go over all the following points, and put an `x` in all the boxes that apply. -->
|
||||
|
||||
- [ ] My code follows the code style of this project.
|
||||
- [ ] I have updated the documentation accordingly (index.d.ts).
|
||||
|
||||
|
||||
|
||||
32
.github/workflows/release.yml
vendored
Normal file
32
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_type:
|
||||
description: "`alpha`, `alpha-minor`, `alpha-major` release?"
|
||||
required: true
|
||||
default: "alpha"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository == 'pedroslopez/whatsapp-web.js' }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
|
||||
- run: git config --global user.email "hello@wwebjs.dev"
|
||||
- run: git config --global user.name "WWebJS Bot"
|
||||
- name: Bump version and publish to NPM
|
||||
id: publish
|
||||
run: ./tools/publish ${{ github.event.inputs.release_type }}
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.RELEASE_NPM_TOKEN }}
|
||||
- name: Create GitHub Release
|
||||
id: create_release
|
||||
uses: ncipollo/release-action@v1
|
||||
with:
|
||||
prerelease: ${{ steps.publish.outputs.PRERELEASE }}
|
||||
generateReleaseNotes: true
|
||||
tag: v${{ steps.publish.outputs.NEW_VERSION }}
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -64,8 +64,10 @@ typings/
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# macOS Thumbnails
|
||||
# macOS
|
||||
._*
|
||||
.DS_Store
|
||||
|
||||
# Test sessions
|
||||
*session.json
|
||||
*session.json
|
||||
.wwebjs_auth/
|
||||
@@ -12,6 +12,8 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
|
||||
*session.json
|
||||
.wwebjs_auth/
|
||||
|
||||
.env
|
||||
tools/
|
||||
tests/
|
||||
|
||||
133
CODE_OF_CONDUCT.md
Normal file
133
CODE_OF_CONDUCT.md
Normal file
@@ -0,0 +1,133 @@
|
||||
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity
|
||||
and orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the
|
||||
overall community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or
|
||||
advances of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email
|
||||
address, without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
||||
decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail address,
|
||||
posting via an official social media account, or acting as an appointed
|
||||
representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
[pedroslopez@me.com](mailto:pedroslopez@me.com).
|
||||
All complaints will be reviewed and investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series
|
||||
of actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or
|
||||
permanent ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited interaction
|
||||
with those enforcing the Code of Conduct, is allowed during this period.
|
||||
Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within
|
||||
the community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
||||
version 2.0, available at
|
||||
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
||||
at [https://www.contributor-covenant.org/translations][translations].
|
||||
|
||||
[homepage]: https://www.contributor-covenant.org
|
||||
[v2.0]: https://www.contributor-covenant.org/version/2/0/code_of_conduct.html
|
||||
[Mozilla CoC]: https://github.com/mozilla/diversity
|
||||
[FAQ]: https://www.contributor-covenant.org/faq
|
||||
[translations]: https://www.contributor-covenant.org/translations
|
||||
44
README.md
44
README.md
@@ -1,4 +1,4 @@
|
||||
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
||||
[](https://www.npmjs.com/package/whatsapp-web.js) [](https://depfu.com/github/pedroslopez/whatsapp-web.js?project_id=9765)  [](https://discord.gg/H7DqQs4)
|
||||
|
||||
# whatsapp-web.js
|
||||
A WhatsApp API client that connects through the WhatsApp Web browser app
|
||||
@@ -47,43 +47,14 @@ 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
|
||||
For more information on saving and restoring sessions, check out the available [Authentication Strategies](https://wwebjs.dev/guide/authentication.html).
|
||||
|
||||
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 |
|
||||
| ------------- | ------------- |
|
||||
| Multi Device | ✅ |
|
||||
| Send messages | ✅ |
|
||||
| Receive messages | ✅ |
|
||||
| Send media (images/audio/documents) | ✅ |
|
||||
@@ -109,6 +80,7 @@ After that check the following webpage and check http://127.0.0.1:9220/json and
|
||||
| Get contact info | ✅ |
|
||||
| Get profile pictures | ✅ |
|
||||
| Set user status message | ✅ |
|
||||
| React to messages | ✅ |
|
||||
|
||||
Something missing? Make an issue and let us know!
|
||||
|
||||
@@ -116,11 +88,13 @@ Something missing? Make an issue and let us know!
|
||||
|
||||
Pull requests are welcome! If you see something you'd like to add, please do. For drastic changes, please open an issue first.
|
||||
|
||||
## Donating
|
||||
## Supporting the project
|
||||
|
||||
You can support the maintainer of this project through the link below
|
||||
You can support the maintainer of this project through the links below
|
||||
|
||||
[](https://www.paypal.me/psla/)
|
||||
- [Support via GitHub Sponsors](https://github.com/sponsors/pedroslopez)
|
||||
- [Support via PayPal](https://www.paypal.me/psla/)
|
||||
- [Sign up for DigitalOcean](https://m.do.co/c/73f906a36ed4) and get $100 in credit when you sign up (Referral)
|
||||
|
||||
## Disclaimer
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Base</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
65
docs/BaseAuthStrategy.html
Normal file
65
docs/BaseAuthStrategy.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Class: BaseAuthStrategy</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>18.<wbr>3</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">BaseAuthStrategy</span></h1>
|
||||
<p class="source-link">Source: <a href="authStrategies_BaseAuthStrategy.js.html#source-line-6">authStrategies/<wbr>BaseAuthStrategy.<wbr>js:6</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Base class which all authentication strategies extend</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="BaseAuthStrategy">new <span class="symbol-name">BaseAuthStrategy</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<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.11 on November 13, 2022.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: BusinessContact</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -111,19 +111,22 @@
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#getCommonGroups">getCommonGroups()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getCountryCode">getCountryCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="BusinessContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="BusinessContact.html#unblock">unblock()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -269,6 +272,15 @@
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common group.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getCommonGroups">Contact#getCommonGroups</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -314,7 +326,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Buttons</title>
|
||||
<title>whatsapp-web.js 1.18.3 » Class: Buttons</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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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">Buttons</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Buttons.js.html#source-line-9">structures/<wbr>Buttons.<wbr>js:9</a></p>
|
||||
<p class="source-link">Source: <a href="structures_Buttons.js.html#source-line-23">structures/<wbr>Buttons.<wbr>js:23</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Message type buttons</p>
|
||||
</div>
|
||||
@@ -116,6 +116,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>See <a href="global.html#ButtonSpec"><code>ButtonSpec</code></a></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -161,7 +162,7 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="buttons"><span class="symbol-name">buttons</span><small class="property-type">
|
||||
Array of Array of string</small></h3>
|
||||
Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></small></h3>
|
||||
<p>buttons of message</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
@@ -178,7 +179,7 @@
|
||||
</section>
|
||||
<h2>Method</h2>
|
||||
<section>
|
||||
<h3 id="_format"><span class="symbol-name">_format</span><span class="signature"><span class="signature-params">(buttons)</span> → <span class="signature-returns"> Array of Array of string</span></span></h3>
|
||||
<h3 id="_format"><span class="symbol-name">_format</span><span class="signature"><span class="signature-params">(buttons)</span> → <span class="signature-returns"> Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></span></span></h3>
|
||||
<p>Creates button array from simple array</p>
|
||||
<section>
|
||||
<h4>
|
||||
@@ -206,7 +207,7 @@ Returns: [{ buttonId:'customId',buttonText:{'displayText':&#
|
||||
<p>buttons</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Array of Array of string</p>
|
||||
<p>Array of <a href="global.html#ButtonSpec">ButtonSpec</a></p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
@@ -220,7 +221,7 @@ Returns: [{ buttonId:'customId',buttonText:{'displayText':&#
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Array of Array of string</code> </p>
|
||||
<p><code>Array of <a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
</section>
|
||||
@@ -233,7 +234,7 @@ Returns: [{ buttonId:'customId',buttonText:{'displayText':&#
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Call</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -144,7 +144,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Chat</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -176,7 +176,7 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isMuted"><span class="symbol-name">isMuted</span><small class="property-type">
|
||||
number</small></h3>
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the chat is muted or not</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
@@ -224,7 +224,8 @@
|
||||
<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>
|
||||
@@ -239,7 +240,8 @@
|
||||
<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>
|
||||
@@ -269,7 +271,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||
<p>Options for searching messages. Right now only limit and fromMe is supported.</p>
|
||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
@@ -292,8 +294,21 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>fromMe</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -373,7 +388,8 @@
|
||||
<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>
|
||||
@@ -424,7 +440,8 @@
|
||||
<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>
|
||||
@@ -434,7 +451,8 @@
|
||||
<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>
|
||||
@@ -464,7 +482,8 @@
|
||||
<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>
|
||||
@@ -478,7 +497,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
485
docs/Client.html
485
docs/Client.html
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Client</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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-53">Client.<wbr>js:53</a></p>
|
||||
<p class="source-link">Source: <a href="Client.js.html#source-line-49">Client.<wbr>js:49</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Starting point for interacting with the WhatsApp Web API</p>
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Client.html#acceptGroupV4Invite">acceptGroupV4Invite(inviteV4)</a></dt>
|
||||
<dt><a href="Client.html#acceptGroupV4Invite">acceptGroupV4Invite(inviteInfo)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#acceptInvite">acceptInvite(inviteCode)</a></dt>
|
||||
@@ -85,19 +85,22 @@
|
||||
<dt><a href="Client.html#getChatsByLabelId">getChatsByLabelId(labelId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getCommonGroups">getCommonGroups(contactId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getContactById">getContactById(contactId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getContacts">getContacts()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getCountryCode">getCountryCode(number)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Client.html#getCountryCode">getCountryCode(number)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#getFormattedNumber">getFormattedNumber(number)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -134,13 +137,13 @@
|
||||
<dt><a href="Client.html#markChatUnread">markChatUnread(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Client.html#muteChat">muteChat(chatId, unmuteDate)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#pinChat">pinChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -156,6 +159,9 @@
|
||||
<dt><a href="Client.html#sendPresenceAvailable">sendPresenceAvailable()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#sendPresenceUnavailable">sendPresenceUnavailable()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#sendSeen">sendSeen(chatId)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -230,6 +236,9 @@
|
||||
<dt><a href="Client.html#event:message_create">message_create</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#event:message_reaction">message_reaction</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Client.html#event:message_revoke_everyone">message_revoke_everyone</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -284,6 +293,20 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>authStrategy</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>authTimeoutMs</p>
|
||||
@@ -312,34 +335,6 @@
|
||||
<p>Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>qrRefreshIntervalMs</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Refresh interval for qr code (how much time to wait before checking if the qr code has changed)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>qrTimeoutMs</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Timeout for qr code selector in puppeteer</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>qrMaxRetries</p>
|
||||
@@ -365,7 +360,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Restart client with a new session (i.e. use null 'session' var) if authentication fails</p>
|
||||
<p>@deprecated This option should be set directly on the LegacySessionAuth.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -379,59 +374,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Whatsapp session to restore. If not set, will start a new session</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WABrowserId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WASecretBundle</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WAToken1</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WAToken2</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>@deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -530,7 +473,6 @@
|
||||
<dd><a href="Client.html#event:group_update">Client#event:group_update</a></dd>
|
||||
<dd><a href="Client.html#event:disconnected">Client#event:disconnected</a></dd>
|
||||
<dd><a href="Client.html#event:change_state">Client#event:change_state</a></dd>
|
||||
<dd><a href="Client.html#event:change_battery">Client#event:change_battery</a></dd>
|
||||
</dl>
|
||||
</section>
|
||||
<section>
|
||||
@@ -545,7 +487,7 @@
|
||||
<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> → <span class="signature-returns"> Promise containing Object</span></span></h3>
|
||||
<h3 id="acceptGroupV4Invite"><span class="symbol-name">acceptGroupV4Invite</span><span class="signature"><span class="signature-params">(inviteInfo)</span> → <span class="signature-returns"> Promise containing Object</span></span></h3>
|
||||
<p>Accepts a private invitation to join a group</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -561,7 +503,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<p>inviteV4</p>
|
||||
<p>inviteInfo</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
@@ -617,7 +559,8 @@
|
||||
<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>
|
||||
@@ -679,15 +622,18 @@
|
||||
<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>
|
||||
@@ -826,6 +772,44 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">(contactId)</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common 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>contactId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>the whatsapp user's ID (_serialized format)</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of WAWebJS.ChatId</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getContactById"><span class="symbol-name">getContactById</span><span class="signature"><span class="signature-params">(contactId)</span> → <span class="signature-returns"> Promise containing <a href="Contact.html">Contact</a></span></span></h3>
|
||||
<p>Get contact instance by ID</p>
|
||||
<section>
|
||||
@@ -981,7 +965,8 @@
|
||||
<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>
|
||||
@@ -1263,7 +1248,8 @@
|
||||
<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>
|
||||
@@ -1435,7 +1421,8 @@
|
||||
<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>
|
||||
@@ -1445,6 +1432,11 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendPresenceUnavailable"><span class="symbol-name">sendPresenceUnavailable</span><span class="signature"><span class="signature-params">()</span></span></h3>
|
||||
<p>Marks the client as unavailable</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="sendSeen"><span class="symbol-name">sendSeen</span><span class="signature"><span class="signature-params">(chatId)</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Mark as seen for the Chat</p>
|
||||
<section>
|
||||
@@ -1478,12 +1470,13 @@
|
||||
<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>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setDisplayName"><span class="symbol-name">setDisplayName</span><span class="signature"><span class="signature-params">(displayName)</span></span></h3>
|
||||
<h3 id="setDisplayName"><span class="symbol-name">setDisplayName</span><span class="signature"><span class="signature-params">(displayName)</span> → <span class="signature-returns"> Promise containing Boolean</span></span></h3>
|
||||
<p>Sets the current user's display name.
|
||||
This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.</p>
|
||||
<section>
|
||||
@@ -1516,6 +1509,10 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Boolean</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setStatus"><span class="symbol-name">setStatus</span><span class="signature"><span class="signature-params">(status)</span></span></h3>
|
||||
@@ -1600,7 +1597,8 @@
|
||||
<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>
|
||||
@@ -1641,104 +1639,10 @@
|
||||
</dl>
|
||||
<h3 id="event:authenticated"><span class="symbol-name">authenticated</span></h3>
|
||||
<p>Emitted when authentication is successful</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>session</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Object containing session information. Can be used to restore the session.</p>
|
||||
<p>Values in <code>session</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>WABrowserId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>WASecretBundle</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>WAToken1</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>WAToken2</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="event:change_battery"><span class="symbol-name">change_battery</span></h3>
|
||||
<p>Emitted when the battery percentage for the attached device changes</p>
|
||||
<p>Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.</p>
|
||||
<section>
|
||||
<h4>Parameters</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -1809,6 +1713,8 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Deprecated</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<h3 id="event:change_state"><span class="symbol-name">change_state</span></h3>
|
||||
<p>Emitted when the connection state changes</p>
|
||||
@@ -2278,6 +2184,179 @@
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="event:message_reaction"><span class="symbol-name">message_reaction</span></h3>
|
||||
<p>Emitted when a reaction is sent, received, updated or removed</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>reaction</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Values in <code>reaction</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>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Reaction id</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>orphan</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Orphan</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>orphanReason</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Orphan reason</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>timestamp</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Timestamp</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>reaction</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Reaction</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>read</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>boolean</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Read</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>msgId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Parent message id</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>senderId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Sender id</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>ack</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Ack</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="event:message_revoke_everyone"><span class="symbol-name">message_revoke_everyone</span></h3>
|
||||
<p>Emitted when a message is deleted for everyone in the chat.</p>
|
||||
<section>
|
||||
@@ -2361,7 +2440,7 @@
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="event:qr"><span class="symbol-name">qr</span></h3>
|
||||
<p>Emitted when the QR code is received</p>
|
||||
<p>Emitted when a QR code is received</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -2407,7 +2486,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: Client.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -34,7 +34,6 @@
|
||||
const EventEmitter = require('events');
|
||||
const puppeteer = require('puppeteer');
|
||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||
const jsQR = require('jsqr');
|
||||
|
||||
const Util = require('./util/Util');
|
||||
const InterfaceController = require('./util/InterfaceController');
|
||||
@@ -42,22 +41,20 @@ const { WhatsWebURL, DefaultOptions, Events, WAState } = require('./ut
|
||||
const { ExposeStore, LoadUtils } = require('./util/Injected');
|
||||
const ChatFactory = require('./factories/ChatFactory');
|
||||
const ContactFactory = require('./factories/ContactFactory');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification , Label, Call, Buttons, List} = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures');
|
||||
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
||||
const NoAuth = require('./authStrategies/NoAuth');
|
||||
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @param {object} options - Client options
|
||||
* @param {AuthStrategy} options.authStrategy - Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used.
|
||||
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
||||
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
||||
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
|
||||
* @param {number} options.qrMaxRetries - How many times should the qrcode be refreshed before giving up
|
||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||
* @param {string} options.session.WABrowserId
|
||||
* @param {string} options.session.WASecretBundle
|
||||
* @param {string} options.session.WAToken1
|
||||
* @param {string} options.session.WAToken2
|
||||
* @param {string} options.restartOnAuthFail - @deprecated This option should be set directly on the LegacySessionAuth.
|
||||
* @param {object} options.session - @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
|
||||
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
||||
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||
@@ -79,13 +76,33 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
|
||||
* @fires Client#group_update
|
||||
* @fires Client#disconnected
|
||||
* @fires Client#change_state
|
||||
* @fires Client#change_battery
|
||||
*/
|
||||
class Client extends EventEmitter {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
|
||||
this.options = Util.mergeDefault(DefaultOptions, options);
|
||||
|
||||
if(!this.options.authStrategy) {
|
||||
if(Object.prototype.hasOwnProperty.call(this.options, 'session')) {
|
||||
process.emitWarning(
|
||||
'options.session is deprecated and will be removed in a future release due to incompatibility with multi-device. ' +
|
||||
'Use the LocalAuth authStrategy, don\'t pass in a session as an option, or suppress this warning by using the LegacySessionAuth strategy explicitly (see https://wwebjs.dev/guide/authentication.html#legacysessionauth-strategy).',
|
||||
'DeprecationWarning'
|
||||
);
|
||||
|
||||
this.authStrategy = new LegacySessionAuth({
|
||||
session: this.options.session,
|
||||
restartOnAuthFail: this.options.restartOnAuthFail
|
||||
});
|
||||
} else {
|
||||
this.authStrategy = new NoAuth();
|
||||
}
|
||||
} else {
|
||||
this.authStrategy = this.options.authStrategy;
|
||||
}
|
||||
|
||||
this.authStrategy.setup(this);
|
||||
|
||||
this.pupBrowser = null;
|
||||
this.pupPage = null;
|
||||
@@ -98,95 +115,131 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async initialize() {
|
||||
let [browser, page] = [null, null];
|
||||
|
||||
if(this.options.puppeteer &amp;&amp; this.options.puppeteer.browserWSEndpoint) {
|
||||
browser = await puppeteer.connect(this.options.puppeteer);
|
||||
|
||||
await this.authStrategy.beforeBrowserInitialized();
|
||||
|
||||
const puppeteerOpts = this.options.puppeteer;
|
||||
if (puppeteerOpts &amp;&amp; puppeteerOpts.browserWSEndpoint) {
|
||||
browser = await puppeteer.connect(puppeteerOpts);
|
||||
page = await browser.newPage();
|
||||
} else {
|
||||
browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const browserArgs = [...(puppeteerOpts.args || [])];
|
||||
if(!browserArgs.find(arg => arg.includes('--user-agent'))) {
|
||||
browserArgs.push(`--user-agent=${this.options.userAgent}`);
|
||||
}
|
||||
|
||||
browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs});
|
||||
page = (await browser.pages())[0];
|
||||
}
|
||||
|
||||
page.setUserAgent(this.options.userAgent);
|
||||
}
|
||||
|
||||
await page.setUserAgent(this.options.userAgent);
|
||||
if (this.options.bypassCSP) await page.setBypassCSP(true);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
// remember me
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
localStorage.setItem('remember-me', 'true');
|
||||
});
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
session => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
||||
localStorage.setItem('WAToken1', session.WAToken1);
|
||||
localStorage.setItem('WAToken2', session.WAToken2);
|
||||
}, this.options.session);
|
||||
}
|
||||
|
||||
if(this.options.bypassCSP) {
|
||||
await page.setBypassCSP(true);
|
||||
}
|
||||
await this.authStrategy.afterBrowserInitialized();
|
||||
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
referer: 'https://whatsapp.com/'
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-icon="intro-md-beta-logo-dark"], [data-icon="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
await page.evaluate(`function getElementByXpath(path) {
|
||||
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||
}`);
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
if (err.name === 'TimeoutError') {
|
||||
/**
|
||||
* Emitted when there has been an error while trying to restore an existing session
|
||||
* @event Client#auth_failure
|
||||
* @param {string} message
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
|
||||
browser.close();
|
||||
if (this.options.restartOnAuthFail) {
|
||||
// session restore failed so try again but without session to force new authentication
|
||||
this.options.session = null;
|
||||
this.initialize();
|
||||
let lastPercent = null,
|
||||
lastPercentMessage = null;
|
||||
|
||||
await page.exposeFunction('loadingScreen', async (percent, message) => {
|
||||
if (lastPercent !== percent || lastPercentMessage !== message) {
|
||||
this.emit(Events.LOADING_SCREEN, percent, message);
|
||||
lastPercent = percent;
|
||||
lastPercentMessage = message;
|
||||
}
|
||||
});
|
||||
|
||||
await page.evaluate(
|
||||
async function (selectors) {
|
||||
var observer = new MutationObserver(function () {
|
||||
let progressBar = window.getElementByXpath(
|
||||
selectors.PROGRESS
|
||||
);
|
||||
let progressMessage = window.getElementByXpath(
|
||||
selectors.PROGRESS_MESSAGE
|
||||
);
|
||||
|
||||
if (progressBar) {
|
||||
window.loadingScreen(
|
||||
progressBar.value,
|
||||
progressMessage.innerText
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
throw err;
|
||||
observer.observe(document, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true,
|
||||
});
|
||||
},
|
||||
{
|
||||
PROGRESS: '//*[@id=\'app\']/div/div/div[2]/progress',
|
||||
PROGRESS_MESSAGE: '//*[@id=\'app\']/div/div/div[3]',
|
||||
}
|
||||
);
|
||||
|
||||
const INTRO_IMG_SELECTOR = '[data-testid="intro-md-beta-logo-dark"], [data-testid="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
const INTRO_QRCODE_SELECTOR = 'div[data-ref] canvas';
|
||||
|
||||
// Checks which selector appears first
|
||||
const needAuthentication = await Promise.race([
|
||||
new Promise(resolve => {
|
||||
page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: this.options.authTimeoutMs })
|
||||
.then(() => resolve(false))
|
||||
.catch((err) => resolve(err));
|
||||
}),
|
||||
new Promise(resolve => {
|
||||
page.waitForSelector(INTRO_QRCODE_SELECTOR, { timeout: this.options.authTimeoutMs })
|
||||
.then(() => resolve(true))
|
||||
.catch((err) => resolve(err));
|
||||
})
|
||||
]);
|
||||
|
||||
// Checks if an error occurred on the first found selector. The second will be discarded and ignored by .race;
|
||||
if (needAuthentication instanceof Error) throw needAuthentication;
|
||||
|
||||
// Scan-qrcode selector was found. Needs authentication
|
||||
if (needAuthentication) {
|
||||
const { failed, failureEventPayload, restart } = await this.authStrategy.onAuthenticationNeeded();
|
||||
if(failed) {
|
||||
/**
|
||||
* Emitted when there has been an error while trying to restore an existing session
|
||||
* @event Client#auth_failure
|
||||
* @param {string} message
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATION_FAILURE, failureEventPayload);
|
||||
await this.destroy();
|
||||
if (restart) {
|
||||
// session restore failed so try again but without session to force new authentication
|
||||
return this.initialize();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
const QR_CONTAINER = 'div[data-ref]';
|
||||
const QR_RETRY_BUTTON = 'div[data-ref] > span > button';
|
||||
let qrRetries = 0;
|
||||
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
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;
|
||||
|
||||
await page.exposeFunction('qrChanged', async (qr) => {
|
||||
/**
|
||||
* Emitted when the QR code is received
|
||||
* Emitted when a QR code is received
|
||||
* @event Client#qr
|
||||
* @param {string} qr QR Code
|
||||
*/
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
|
||||
if (this.options.qrMaxRetries > 0) {
|
||||
qrRetries++;
|
||||
if (qrRetries > this.options.qrMaxRetries) {
|
||||
@@ -194,53 +247,74 @@ class Client extends EventEmitter {
|
||||
await this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
getQrCode();
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
});
|
||||
|
||||
await page.evaluate(function (selectors) {
|
||||
const qr_container = document.querySelector(selectors.QR_CONTAINER);
|
||||
window.qrChanged(qr_container.dataset.ref);
|
||||
|
||||
const obs = new MutationObserver((muts) => {
|
||||
muts.forEach(mut => {
|
||||
// Listens to qr token change
|
||||
if (mut.type === 'attributes' &amp;&amp; mut.attributeName === 'data-ref') {
|
||||
window.qrChanged(mut.target.dataset.ref);
|
||||
} else
|
||||
// Listens to retry button, when found, click it
|
||||
if (mut.type === 'childList') {
|
||||
const retry_button = document.querySelector(selectors.QR_RETRY_BUTTON);
|
||||
if (retry_button) retry_button.click();
|
||||
}
|
||||
});
|
||||
});
|
||||
obs.observe(qr_container.parentElement, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['data-ref'],
|
||||
});
|
||||
}, {
|
||||
QR_CONTAINER,
|
||||
QR_RETRY_BUTTON
|
||||
});
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
try {
|
||||
await page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: 0 });
|
||||
} catch(error) {
|
||||
if (
|
||||
error.name === 'ProtocolError' &amp;&amp;
|
||||
error.message &amp;&amp;
|
||||
error.message.match(/Target closed/)
|
||||
) {
|
||||
// something has called .destroy() while waiting
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||
|
||||
// Get session tokens
|
||||
const localStorage = JSON.parse(await page.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
}));
|
||||
|
||||
const session = {
|
||||
WABrowserId: localStorage.WABrowserId,
|
||||
WASecretBundle: localStorage.WASecretBundle,
|
||||
WAToken1: localStorage.WAToken1,
|
||||
WAToken2: localStorage.WAToken2
|
||||
};
|
||||
const authEventPayload = await this.authStrategy.getAuthEventPayload();
|
||||
|
||||
/**
|
||||
* Emitted when authentication is successful
|
||||
* @event Client#authenticated
|
||||
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||
* @param {string} session.WABrowserId
|
||||
* @param {string} session.WASecretBundle
|
||||
* @param {string} session.WAToken1
|
||||
* @param {string} session.WAToken2
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATED, session);
|
||||
this.emit(Events.AUTHENTICATED, authEventPayload);
|
||||
|
||||
// Check window.Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
const isMD = await page.evaluate(() => {
|
||||
return window.Store.Features.features.MD_BACKEND;
|
||||
await page.evaluate(async () => {
|
||||
// safely unregister service workers
|
||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
|
||||
if(isMD) {
|
||||
throw new Error('Multi-device is not yet supported by whatsapp-web.js. Please check out https://github.com/pedroslopez/whatsapp-web.js/pull/889 to follow the progress.');
|
||||
}
|
||||
|
||||
//Load util functions (serializers, helper functions)
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
@@ -250,7 +324,7 @@ class Client extends EventEmitter {
|
||||
* @type {ClientInfo}
|
||||
*/
|
||||
this.info = new ClientInfo(this, await page.evaluate(() => {
|
||||
return window.Store.Conn.serialize();
|
||||
return { ...window.Store.Conn.serialize(), wid: window.Store.User.getMeUser() };
|
||||
}));
|
||||
|
||||
// Add InterfaceController
|
||||
@@ -258,8 +332,6 @@ class Client extends EventEmitter {
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
if (msg.type === 'gp2') {
|
||||
const notification = new GroupNotification(this, msg);
|
||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||
@@ -378,7 +450,7 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.MEDIA_UPLOADED, message);
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||
await page.exposeFunction('onAppStateChangedEvent', async (state) => {
|
||||
|
||||
/**
|
||||
* Emitted when the connection state changes
|
||||
@@ -405,6 +477,7 @@ class Client extends EventEmitter {
|
||||
* @event Client#disconnected
|
||||
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
||||
*/
|
||||
await this.authStrategy.disconnect();
|
||||
this.emit(Events.DISCONNECTED, state);
|
||||
this.destroy();
|
||||
}
|
||||
@@ -416,11 +489,12 @@ class Client extends EventEmitter {
|
||||
if (battery === undefined) return;
|
||||
|
||||
/**
|
||||
* Emitted when the battery percentage for the attached device changes
|
||||
* Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.
|
||||
* @event Client#change_battery
|
||||
* @param {object} batteryInfo
|
||||
* @param {number} batteryInfo.battery - The current battery percentage
|
||||
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
* @deprecated
|
||||
*/
|
||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||
});
|
||||
@@ -439,20 +513,66 @@ class Client extends EventEmitter {
|
||||
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
||||
* @param {object} call.participants - Participants
|
||||
*/
|
||||
const cll = new Call(this,call);
|
||||
const cll = new Call(this, call);
|
||||
this.emit(Events.INCOMING_CALL, cll);
|
||||
});
|
||||
|
||||
|
||||
await page.exposeFunction('onReaction', (reactions) => {
|
||||
for (const reaction of reactions) {
|
||||
/**
|
||||
* Emitted when a reaction is sent, received, updated or removed
|
||||
* @event Client#message_reaction
|
||||
* @param {object} reaction
|
||||
* @param {object} reaction.id - Reaction id
|
||||
* @param {number} reaction.orphan - Orphan
|
||||
* @param {?string} reaction.orphanReason - Orphan reason
|
||||
* @param {number} reaction.timestamp - Timestamp
|
||||
* @param {string} reaction.reaction - Reaction
|
||||
* @param {boolean} reaction.read - Read
|
||||
* @param {object} reaction.msgId - Parent message id
|
||||
* @param {string} reaction.senderId - Sender id
|
||||
* @param {?number} reaction.ack - Ack
|
||||
*/
|
||||
|
||||
this.emit(Events.MESSAGE_REACTION, new Reaction(this, reaction));
|
||||
}
|
||||
});
|
||||
|
||||
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)); });
|
||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.Msg.on('change:ack', (msg,ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
||||
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe &amp;&amp; !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
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); });
|
||||
window.Store.Msg.on('add', (msg) => {
|
||||
if (msg.isNewMsg) {
|
||||
if(msg.type === 'ciphertext') {
|
||||
// defer message event until ciphertext is resolved (type changed)
|
||||
msg.once('change:type', (_msg) => window.onAddMessageEvent(window.WWebJS.getMessageModel(_msg)));
|
||||
} else {
|
||||
window.onAddMessageEvent(window.WWebJS.getMessageModel(msg));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
const module = window.Store.createOrUpdateReactionsModule;
|
||||
const ogMethod = module.createOrUpdateReactions;
|
||||
module.createOrUpdateReactions = ((...args) => {
|
||||
window.onReaction(args[0].map(reaction => {
|
||||
const msgKey = window.Store.MsgKey.fromString(reaction.msgKey);
|
||||
const parentMsgKey = window.Store.MsgKey.fromString(reaction.parentMsgKey);
|
||||
const timestamp = reaction.timestamp / 1000;
|
||||
|
||||
return {...reaction, msgKey, parentMsgKey, timestamp };
|
||||
}));
|
||||
|
||||
return ogMethod(...args);
|
||||
}).bind(module);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -460,12 +580,16 @@ class Client extends EventEmitter {
|
||||
* @event Client#ready
|
||||
*/
|
||||
this.emit(Events.READY);
|
||||
this.authStrategy.afterAuthReady();
|
||||
|
||||
// Disconnect when navigating away
|
||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||
// Disconnect when navigating away when in PAIRING state (detect logout)
|
||||
this.pupPage.on('framenavigated', async () => {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
const appState = await this.getState();
|
||||
if(!appState || appState === WAState.PAIRING) {
|
||||
await this.authStrategy.disconnect();
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -473,19 +597,19 @@ class Client extends EventEmitter {
|
||||
* Closes the client
|
||||
*/
|
||||
async destroy() {
|
||||
if (this._qrRefreshInterval) {
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
}
|
||||
await this.pupBrowser.close();
|
||||
await this.authStrategy.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the client, closing the current session
|
||||
*/
|
||||
async logout() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
await this.pupPage.evaluate(() => {
|
||||
return window.Store.AppState.logout();
|
||||
});
|
||||
|
||||
await this.authStrategy.logout();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -515,7 +639,7 @@ class Client extends EventEmitter {
|
||||
/**
|
||||
* Message options.
|
||||
* @typedef {Object} MessageSendOptions
|
||||
* @property {boolean} [linkPreview=true] - Show links preview
|
||||
* @property {boolean} [linkPreview=true] - Show links preview. Has no effect on multi-device accounts.
|
||||
* @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
|
||||
@@ -550,7 +674,7 @@ class Client extends EventEmitter {
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
parseVCards: options.parseVCards === false ? false : true,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
||||
...options.extra
|
||||
extraOptions: options.extra
|
||||
};
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
@@ -565,34 +689,36 @@ class Client extends EventEmitter {
|
||||
} else if (content instanceof Location) {
|
||||
internalOptions.location = content;
|
||||
content = '';
|
||||
} else if(content instanceof Contact) {
|
||||
} else if (content instanceof Contact) {
|
||||
internalOptions.contactCard = content.id._serialized;
|
||||
content = '';
|
||||
} else if(Array.isArray(content) &amp;&amp; content.length > 0 &amp;&amp; content[0] instanceof Contact) {
|
||||
} else if (Array.isArray(content) &amp;&amp; content.length > 0 &amp;&amp; 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;}
|
||||
} else if (content instanceof Buttons) {
|
||||
if (content.type !== 'chat') { internalOptions.attachment = content.body; }
|
||||
internalOptions.buttons = content;
|
||||
content = '';
|
||||
} else if(content instanceof List){
|
||||
} else if (content instanceof List) {
|
||||
internalOptions.list = content;
|
||||
content = '';
|
||||
}
|
||||
|
||||
|
||||
if (internalOptions.sendMediaAsSticker &amp;&amp; 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
|
||||
});
|
||||
}, this.pupPage
|
||||
);
|
||||
}
|
||||
|
||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
|
||||
|
||||
if (sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
@@ -679,7 +805,7 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async getInviteInfo(inviteCode) {
|
||||
return await this.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
return window.Store.InviteInfo.sendQueryGroupInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
@@ -698,25 +824,25 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Accepts a private invitation to join a group
|
||||
* @param {object} inviteV4 Invite V4 Info
|
||||
* @param {object} inviteInfo Invite V4 Info
|
||||
* @returns {Promise&lt;Object>}
|
||||
*/
|
||||
async acceptGroupV4Invite(inviteInfo) {
|
||||
if(!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
|
||||
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);
|
||||
return this.pupPage.evaluate(async inviteInfo => {
|
||||
let { groupId, fromId, inviteCode, inviteCodeExp } = inviteInfo;
|
||||
return await window.Store.JoinInviteV4.sendJoinGroupViaInviteV4(inviteCode, String(inviteCodeExp), groupId, fromId);
|
||||
}, inviteInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current user's status message
|
||||
* @param {string} status New status message
|
||||
*/
|
||||
async setStatus(status) {
|
||||
await this.pupPage.evaluate(async status => {
|
||||
return await window.Store.Wap.sendSetStatus(status);
|
||||
return await window.Store.StatusUtils.setMyStatus(status);
|
||||
}, status);
|
||||
}
|
||||
|
||||
@@ -724,19 +850,31 @@ class Client extends EventEmitter {
|
||||
* Sets the current user's display name.
|
||||
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
||||
* @param {string} displayName New display name
|
||||
* @returns {Promise&lt;Boolean>}
|
||||
*/
|
||||
async setDisplayName(displayName) {
|
||||
await this.pupPage.evaluate(async displayName => {
|
||||
return await window.Store.Wap.setPushname(displayName);
|
||||
}, displayName);
|
||||
}
|
||||
const couldSet = await this.pupPage.evaluate(async displayName => {
|
||||
if(!window.Store.Conn.canSetMyPushname()) return false;
|
||||
|
||||
if(window.Store.MDBackend) {
|
||||
// TODO
|
||||
return false;
|
||||
} else {
|
||||
const res = await window.Store.Wap.setPushname(displayName);
|
||||
return !res.status || res.status === 200;
|
||||
}
|
||||
}, displayName);
|
||||
|
||||
return couldSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current connection state for the client
|
||||
* @returns {WAState}
|
||||
*/
|
||||
async getState() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
if(!window.Store) return null;
|
||||
return window.Store.AppState.state;
|
||||
});
|
||||
}
|
||||
@@ -746,7 +884,16 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async sendPresenceAvailable() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.Wap.sendPresenceAvailable();
|
||||
return window.Store.PresenceUtils.sendPresenceAvailable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the client as unavailable
|
||||
*/
|
||||
async sendPresenceUnavailable() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.PresenceUtils.sendPresenceUnavailable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -758,7 +905,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
return true;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -770,7 +917,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -785,8 +932,9 @@ class Client extends EventEmitter {
|
||||
return true;
|
||||
}
|
||||
const MAX_PIN_COUNT = 3;
|
||||
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
|
||||
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
|
||||
const chatModels = window.Store.Chat.getModelsArray();
|
||||
if (chatModels.length > MAX_PIN_COUNT) {
|
||||
let maxPinned = chatModels[MAX_PIN_COUNT - 1].pin;
|
||||
if (maxPinned) {
|
||||
return false;
|
||||
}
|
||||
@@ -852,13 +1000,49 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getProfilePicUrl(contactId) {
|
||||
const profilePic = await this.pupPage.evaluate((contactId) => {
|
||||
return window.Store.Wap.profilePicFind(contactId);
|
||||
const profilePic = await this.pupPage.evaluate(async contactId => {
|
||||
try {
|
||||
const chatWid = window.Store.WidFactory.createWid(contactId);
|
||||
return await window.Store.ProfilePic.profilePicFind(chatWid);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return undefined;
|
||||
throw err;
|
||||
}
|
||||
}, contactId);
|
||||
|
||||
|
||||
return profilePic ? profilePic.eurl : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
||||
* @param {string} contactId the whatsapp user's ID (_serialized format)
|
||||
* @returns {Promise&lt;WAWebJS.ChatId[]>}
|
||||
*/
|
||||
async getCommonGroups(contactId) {
|
||||
const commonGroups = await this.pupPage.evaluate(async (contactId) => {
|
||||
let contact = window.Store.Contact.get(contactId);
|
||||
if (!contact) {
|
||||
const wid = window.Store.WidFactory.createUserWid(contactId);
|
||||
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
|
||||
contact = new chatConstructor({id: wid});
|
||||
}
|
||||
|
||||
if (contact.commonGroups) {
|
||||
return contact.commonGroups.serialize();
|
||||
}
|
||||
const status = await window.Store.findCommonGroups(contact);
|
||||
if (status) {
|
||||
return contact.commonGroups.serialize();
|
||||
}
|
||||
return [];
|
||||
}, contactId);
|
||||
const chats = [];
|
||||
for (const group of commonGroups) {
|
||||
chats.push(group.id);
|
||||
}
|
||||
return chats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force reset of connection state for the client
|
||||
*/
|
||||
@@ -874,10 +1058,7 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;Boolean>}
|
||||
*/
|
||||
async isRegisteredUser(id) {
|
||||
return await this.pupPage.evaluate(async (id) => {
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
return result.jid !== undefined;
|
||||
}, id);
|
||||
return Boolean(await this.getNumberId(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -887,14 +1068,16 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;Object|null>}
|
||||
*/
|
||||
async getNumberId(number) {
|
||||
if (!number.endsWith('@c.us')) number += '@c.us';
|
||||
try {
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.WWebJS.getNumberId(numberId);
|
||||
}, number);
|
||||
} catch(_) {
|
||||
return null;
|
||||
if (!number.endsWith('@c.us')) {
|
||||
number += '@c.us';
|
||||
}
|
||||
|
||||
return await this.pupPage.evaluate(async number => {
|
||||
const wid = window.Store.WidFactory.createWid(number);
|
||||
const result = await window.Store.QueryExist(wid);
|
||||
if (!result || result.wid === undefined) return null;
|
||||
return result.wid;
|
||||
}, number);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -903,14 +1086,14 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise&lt;string>}
|
||||
*/
|
||||
async getFormattedNumber(number) {
|
||||
if(!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
||||
if(!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
||||
|
||||
if (!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
||||
if (!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
||||
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the country code of a WhatsApp ID.
|
||||
* @param {string} number Number or ID
|
||||
@@ -923,7 +1106,7 @@ class Client extends EventEmitter {
|
||||
return window.Store.NumberInfo.findCC(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param {string} name group title
|
||||
@@ -942,12 +1125,9 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
||||
const res = await window.Store.Wap.createGroup(name, participantIds);
|
||||
console.log(res);
|
||||
if (!res.status === 200) {
|
||||
throw 'An error occurred while creating the group!';
|
||||
}
|
||||
|
||||
const participantWIDs = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
const id = window.Store.MsgKey.newId();
|
||||
const res = await window.Store.GroupUtils.sendCreateGroup(name, participantWIDs, undefined, id);
|
||||
return res;
|
||||
}, name, participants);
|
||||
|
||||
@@ -968,9 +1148,9 @@ class Client extends EventEmitter {
|
||||
async getLabels() {
|
||||
const labels = await this.pupPage.evaluate(async () => {
|
||||
return window.WWebJS.getLabels();
|
||||
});
|
||||
});
|
||||
|
||||
return labels.map(data => new Label(this , data));
|
||||
return labels.map(data => new Label(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -981,7 +1161,7 @@ class Client extends EventEmitter {
|
||||
async getLabelById(labelId) {
|
||||
const label = await this.pupPage.evaluate(async (labelId) => {
|
||||
return window.WWebJS.getLabel(labelId);
|
||||
}, labelId);
|
||||
}, labelId);
|
||||
|
||||
return new Label(this, label);
|
||||
}
|
||||
@@ -991,12 +1171,12 @@ class Client extends EventEmitter {
|
||||
* @param {string} chatId
|
||||
* @returns {Promise&lt;Array&lt;Label>>}
|
||||
*/
|
||||
async getChatLabels(chatId){
|
||||
async getChatLabels(chatId) {
|
||||
const labels = await this.pupPage.evaluate(async (chatId) => {
|
||||
return window.WWebJS.getChatLabels(chatId);
|
||||
}, chatId);
|
||||
|
||||
return labels.map(data => new Label(this, data));
|
||||
return labels.map(data => new Label(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1004,16 +1184,16 @@ class Client extends EventEmitter {
|
||||
* @param {string} labelId
|
||||
* @returns {Promise&lt;Array&lt;Chat>>}
|
||||
*/
|
||||
async getChatsByLabelId(labelId){
|
||||
async getChatsByLabelId(labelId) {
|
||||
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
||||
const label = window.Store.Label.get(labelId);
|
||||
const labelItems = label.labelItemCollection.models;
|
||||
const labelItems = label.labelItemCollection.getModelsArray();
|
||||
return labelItems.reduce((result, item) => {
|
||||
if(item.parentType === 'Chat'){
|
||||
if (item.parentType === 'Chat') {
|
||||
result.push(item.parentId);
|
||||
}
|
||||
return result;
|
||||
},[]);
|
||||
}, []);
|
||||
}, labelId);
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
@@ -1025,8 +1205,8 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async getBlockedContacts() {
|
||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
||||
let chatIds = window.Store.Blocklist.models.map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
let chatIds = window.Store.Blocklist.getModelsArray().map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
});
|
||||
|
||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
||||
@@ -1044,7 +1224,7 @@ module.exports = Client;
|
||||
<footer id="jsdoc-footer" class="jsdoc-footer">
|
||||
<div id="jsdoc-footer-container">
|
||||
<p>
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: ClientInfo</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -101,7 +101,7 @@
|
||||
</dl>
|
||||
<h3 id="phone"><span class="symbol-name">phone</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Information about the phone this client is connected to</p>
|
||||
<p>Information about the phone this client is connected to. Not available in multi-device.</p>
|
||||
<section>
|
||||
<h4>Properties</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -188,10 +188,12 @@
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Deprecated</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<h3 id="platform"><span class="symbol-name">platform</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Platform the phone is running on</p>
|
||||
<p>Platform WhatsApp is running on</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="pushname"><span class="symbol-name">pushname</span><small class="property-type">
|
||||
@@ -211,17 +213,22 @@
|
||||
<h3 id="getBatteryStatus"><span class="symbol-name">getBatteryStatus</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> (object, number, or boolean)</span></span></h3>
|
||||
<p>Get current battery percentage and charging status for the attached device</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Deprecated</dt>
|
||||
<dd></dd>
|
||||
<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>
|
||||
@@ -235,7 +242,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Contact</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -108,19 +108,22 @@
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#getCommonGroups">getCommonGroups()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getCountryCode">getCountryCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Contact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Contact.html#unblock">unblock()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -236,6 +239,15 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common group.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing Array of WAWebJS.ChatId</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -281,7 +293,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: GroupChat</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -405,7 +405,8 @@
|
||||
<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>
|
||||
@@ -435,7 +436,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||
<p>Options for searching messages. Right now only limit and fromMe is supported.</p>
|
||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
@@ -458,8 +459,21 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>fromMe</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -490,7 +504,8 @@
|
||||
<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>
|
||||
@@ -601,7 +616,8 @@
|
||||
<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>
|
||||
@@ -643,12 +659,14 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="revokeInvite"><span class="symbol-name">revokeInvite</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<h3 id="revokeInvite"><span class="symbol-name">revokeInvite</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Invalidates the current group invite code and generates a new one</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
<p><code>Promise containing string</code>
|
||||
<p>New invite code</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
@@ -729,7 +747,7 @@
|
||||
<dd><a href="Chat.html#sendStateTyping">Chat#sendStateTyping</a></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setDescription"><span class="symbol-name">setDescription</span><span class="signature"><span class="signature-params">(description)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<h3 id="setDescription"><span class="symbol-name">setDescription</span><span class="signature"><span class="signature-params">(description)</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Updates the group description</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -762,7 +780,9 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
<p><code>Promise containing boolean</code>
|
||||
<p>Returns true if the description was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
@@ -801,7 +821,8 @@
|
||||
<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>
|
||||
@@ -841,12 +862,13 @@
|
||||
<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>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<h3 id="setSubject"><span class="symbol-name">setSubject</span><span class="signature"><span class="signature-params">(subject)</span> → <span class="signature-returns"> Promise containing boolean</span></span></h3>
|
||||
<p>Updates the group subject</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
@@ -879,7 +901,9 @@
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
<p><code>Promise containing boolean</code>
|
||||
<p>Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.</p>
|
||||
</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
@@ -917,7 +941,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: GroupNotification</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: InterfaceController</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -382,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Label</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
188
docs/LegacySessionAuth.html
Normal file
188
docs/LegacySessionAuth.html
Normal file
@@ -0,0 +1,188 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Class: LegacySessionAuth</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>18.<wbr>3</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">LegacySessionAuth</span></h1>
|
||||
<p class="source-link">Source: <a href="authStrategies_LegacySessionAuth.js.html#source-line-16">authStrategies/<wbr>LegacySessionAuth.<wbr>js:16</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Legacy session auth strategy
|
||||
Not compatible with multi-device accounts.</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="LegacySessionAuth">new <span class="symbol-name">LegacySessionAuth</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
|
||||
<section>
|
||||
<h3>Parameters</h3>
|
||||
<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>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>options</p>
|
||||
<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>restartOnAuthFail</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Restart client with a new session (i.e. use null 'session' var) if authentication fails</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Whatsapp session to restore. If not set, will start a new session</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WABrowserId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WASecretBundle</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WAToken1</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>session.WAToken2</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<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.11 on November 13, 2022.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: List</title>
|
||||
<title>whatsapp-web.js 1.18.3 » Class: List</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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -256,7 +256,7 @@ Returns: [{'title':'sectionTitle','rows':[{'r
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
135
docs/LocalAuth.html
Normal file
135
docs/LocalAuth.html
Normal file
@@ -0,0 +1,135 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Class: LocalAuth</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>18.<wbr>3</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">LocalAuth</span></h1>
|
||||
<p class="source-link">Source: <a href="authStrategies_LocalAuth.js.html#source-line-13">authStrategies/<wbr>LocalAuth.<wbr>js:13</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Local directory-based authentication</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="LocalAuth">new <span class="symbol-name">LocalAuth</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
|
||||
<section>
|
||||
<h3>Parameters</h3>
|
||||
<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>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>options</p>
|
||||
<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>clientId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>dataPath</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Change the default path for saving session files, default is: "./.wwebjs_auth/"</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<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.11 on November 13, 2022.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Location</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Message</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -54,6 +54,9 @@
|
||||
<dt><a href="Message.html#deviceType">deviceType</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#duration">duration</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#forwardingScore">forwardingScore</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -79,6 +82,9 @@
|
||||
<dt><a href="Message.html#inviteV4">inviteV4</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isEphemeral">isEphemeral</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#isForwarded">isForwarded</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -110,6 +116,9 @@
|
||||
<dt><a href="Message.html#orderId">orderId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#rawData">rawData</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -149,13 +158,13 @@
|
||||
<dt><a href="Message.html#getChat">getChat()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#getContact">getContact()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getInfo">getInfo()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -168,11 +177,17 @@
|
||||
<dt><a href="Message.html#getPayment">getPayment()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#react">react(reaction)</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Message.html#getQuotedMessage">getQuotedMessage()</a></dt>
|
||||
<dt><a href="Message.html#reload">reload()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Message.html#reply">reply(content[, chatId][, options])</a></dt>
|
||||
@@ -224,6 +239,11 @@
|
||||
<p>String that represents from which device type the message was sent</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="duration"><span class="symbol-name">duration</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Indicates the duration of the message in seconds</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="forwardingScore"><span class="symbol-name">forwardingScore</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Indicates how many times the message was forwarded.</p>
|
||||
@@ -260,6 +280,11 @@
|
||||
<p>Group Invite Data</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isEphemeral"><span class="symbol-name">isEphemeral</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message will disappear after it expires</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="isForwarded"><span class="symbol-name">isForwarded</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Indicates if the message was forwarded</p>
|
||||
@@ -305,6 +330,11 @@
|
||||
<p>Order ID for message type ORDER</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="rawData"><span class="symbol-name">rawData</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Returns message in a raw format</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Unix timestamp for when the message was created</p>
|
||||
@@ -370,7 +400,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>If true and the message is sent by the current user, will delete it for everyone in the chat.</p>
|
||||
<p>If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -390,7 +420,7 @@
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="forward"><span class="symbol-name">forward</span><span class="signature"><span class="signature-params">(chat)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>Forwards this message to another chat</p>
|
||||
<p>Forwards this message to another chat (that you chatted before, otherwise it will fail)</p>
|
||||
<section>
|
||||
<h4>Parameter</h4>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -488,6 +518,54 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="react"><span class="symbol-name">react</span><span class="signature"><span class="signature-params">(reaction)</span> → <span class="signature-returns"> Promise</span></span></h3>
|
||||
<p>React to this message with an emoji</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>reaction</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Emoji to react with. Send an empty string to remove the reaction.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise</code> </p>
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="reload"><span class="symbol-name">reload</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
||||
Note that the Message must still be in the web app cache for this to work, otherwise will return null.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Returns</dt>
|
||||
<dd>
|
||||
<p><code>Promise containing <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="reply"><span class="symbol-name">reply</span><span class="signature"><span class="signature-params">(content[, chatId][, options])</span> → <span class="signature-returns"> Promise containing <a href="Message.html">Message</a></span></span></h3>
|
||||
<p>Sends a message as a reply to this message. If chatId is specified, it will be sent
|
||||
through the specified Chat. If not, it will send the message
|
||||
@@ -572,7 +650,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: MessageMedia</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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-15">structures/<wbr>MessageMedia.<wbr>js:15</a></p>
|
||||
<p class="source-link">Source: <a href="structures_MessageMedia.js.html#source-line-16">structures/<wbr>MessageMedia.<wbr>js:16</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Media attached to a message</p>
|
||||
</div>
|
||||
@@ -42,10 +42,6 @@
|
||||
<dt><a href="MessageMedia.html#data">data</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="MessageMedia.html#filename">filename</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -53,11 +49,16 @@
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="MessageMedia.html#filesize">filesize</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="MessageMedia.html#mimetype">mimetype</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="summary-callout">
|
||||
@@ -83,7 +84,7 @@
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="MessageMedia">new <span class="symbol-name">MessageMedia</span><span class="signature"><span class="signature-params">(mimetype, data, filename)</span></span></h2>
|
||||
<h2 id="MessageMedia">new <span class="symbol-name">MessageMedia</span><span class="signature"><span class="signature-params">(mimetype, data, filename, filesize)</span></span></h2>
|
||||
<section>
|
||||
<h3>Parameters</h3>
|
||||
<table class="jsdoc-details-table">
|
||||
@@ -135,7 +136,22 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Document file name</p>
|
||||
<p>Document file name. Value can be null</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>filesize</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Document file size in bytes. Value can be null</p>
|
||||
<p>Value can be null.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -155,7 +171,12 @@
|
||||
</dl>
|
||||
<h3 id="filename"><span class="symbol-name">filename</span><small class="property-type">
|
||||
nullable string</small></h3>
|
||||
<p>Name of the file (for documents)</p>
|
||||
<p>Document file name. Value can be null</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="filesize"><span class="symbol-name">filesize</span><small class="property-type">
|
||||
nullable number</small></h3>
|
||||
<p>Document file size in bytes. Value can be null</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="mimetype"><span class="symbol-name">mimetype</span><small class="property-type">
|
||||
@@ -343,7 +364,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
66
docs/NoAuth.html
Normal file
66
docs/NoAuth.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Class: NoAuth</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>18.<wbr>3</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">NoAuth</span></h1>
|
||||
<p class="source-link">Source: <a href="authStrategies_NoAuth.js.html#source-line-9">authStrategies/<wbr>NoAuth.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>No session restoring functionality
|
||||
Will need to authenticate via QR code every time</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="NoAuth">new <span class="symbol-name">NoAuth</span><span class="signature"><span class="signature-params">()</span></span></h2>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<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.11 on November 13, 2022.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Order</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -102,7 +102,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: PrivateChat</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -295,7 +295,7 @@
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Options for searching messages. Right now only limit is supported.</p>
|
||||
<p>Options for searching messages. Right now only limit and fromMe is supported.</p>
|
||||
<p>Values in <code>searchOptions</code> have the following properties:</p>
|
||||
<table class="jsdoc-details-table">
|
||||
<thead>
|
||||
@@ -318,8 +318,21 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
<p>Defaults to <code>50</code>.</p>
|
||||
<p>The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>fromMe</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -520,7 +533,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: PrivateContact</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -108,19 +108,22 @@
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#getCommonGroups">getCommonGroups()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getCountryCode">getCountryCode()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getFormattedNumber">getFormattedNumber()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="PrivateContact.html#getProfilePicUrl">getProfilePicUrl()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="PrivateContact.html#unblock">unblock()</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -262,6 +265,15 @@
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCommonGroups"><span class="symbol-name">getCommonGroups</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing Array of WAWebJS.ChatId</span></span></h3>
|
||||
<p>Gets the Contact's common groups with you. Returns empty array if you don't have any common group.</p>
|
||||
<dl class="dl-compact">
|
||||
<dt>Inherited from</dt>
|
||||
<dd><a href="Contact.html#getCommonGroups">Contact#getCommonGroups</a></dd>
|
||||
<dt>Returns</dt>
|
||||
<dd></dd>
|
||||
</dl>
|
||||
<div class="symbol-detail-labels"><span class="label label-async">async</span></div>
|
||||
<h3 id="getCountryCode"><span class="symbol-name">getCountryCode</span><span class="signature"><span class="signature-params">()</span> → <span class="signature-returns"> Promise containing string</span></span></h3>
|
||||
<p>Returns the contact's countrycode, (1541859685@c.us) => (1)</p>
|
||||
<dl class="dl-compact">
|
||||
@@ -307,7 +319,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Product</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -127,7 +127,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
159
docs/Reaction.html
Normal file
159
docs/Reaction.html
Normal file
@@ -0,0 +1,159 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Class: Reaction</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>18.<wbr>3</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">Reaction</span></h1>
|
||||
<p class="source-link">Source: <a href="structures_Reaction.js.html#source-line-9">structures/<wbr>Reaction.<wbr>js:9</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Represents a Reaction 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="Reaction.html#ack">ack</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Reaction.html#id">id</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Reaction.html#msgId">msgId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Reaction.html#orphan">orphan</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Reaction.html#orphanReason">orphanReason</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Reaction.html#reaction">reaction</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="Reaction.html#read">read</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Reaction.html#senderId">senderId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="Reaction.html#timestamp">timestamp</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="Reaction">new <span class="symbol-name">Reaction</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="ack"><span class="symbol-name">ack</span><small class="property-type">
|
||||
nullable number</small></h3>
|
||||
<p>ACK</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="id"><span class="symbol-name">id</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Reaction ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="msgId"><span class="symbol-name">msgId</span><small class="property-type">
|
||||
object</small></h3>
|
||||
<p>Message ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="orphan"><span class="symbol-name">orphan</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Orphan</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="orphanReason"><span class="symbol-name">orphanReason</span><small class="property-type">
|
||||
nullable string</small></h3>
|
||||
<p>Orphan reason</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="reaction"><span class="symbol-name">reaction</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Reaction</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="read"><span class="symbol-name">read</span><small class="property-type">
|
||||
boolean</small></h3>
|
||||
<p>Read</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="senderId"><span class="symbol-name">senderId</span><small class="property-type">
|
||||
string</small></h3>
|
||||
<p>Sender ID</p>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="timestamp"><span class="symbol-name">timestamp</span><small class="property-type">
|
||||
number</small></h3>
|
||||
<p>Unix timestamp for when the reaction was created</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.11 on November 13, 2022.
|
||||
</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>
|
||||
163
docs/RemoteAuth.html
Normal file
163
docs/RemoteAuth.html
Normal file
@@ -0,0 +1,163 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Class: RemoteAuth</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>18.<wbr>3</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">RemoteAuth</span></h1>
|
||||
<p class="source-link">Source: <a href="authStrategies_RemoteAuth.js.html#source-line-26">authStrategies/<wbr>RemoteAuth.<wbr>js:26</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Remote-based authentication</p>
|
||||
</div>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</header>
|
||||
<section id="summary">
|
||||
</section>
|
||||
<section>
|
||||
<h2 id="RemoteAuth">new <span class="symbol-name">RemoteAuth</span><span class="signature"><span class="signature-params">(options)</span></span></h2>
|
||||
<section>
|
||||
<h3>Parameters</h3>
|
||||
<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>options</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>options</p>
|
||||
<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>store</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Remote database store instance</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>clientId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>dataPath</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Change the default path for saving session files, default is: "./.wwebjs_auth/"</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>backupSyncIntervalMs</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
</section>
|
||||
<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.11 on November 13, 2022.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Class: Util</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</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-16">util/<wbr>Util.<wbr>js:16</a></p>
|
||||
<p class="source-link">Source: <a href="util_Util.js.html#source-line-14">util/<wbr>Util.<wbr>js:14</a></p>
|
||||
<div class="symbol-classdesc">
|
||||
<p>Utility methods</p>
|
||||
</div>
|
||||
@@ -104,7 +104,8 @@
|
||||
<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>
|
||||
@@ -155,7 +156,8 @@
|
||||
<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>
|
||||
@@ -193,7 +195,8 @@
|
||||
<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>
|
||||
@@ -240,7 +243,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
80
docs/authStrategies_BaseAuthStrategy.js.html
Normal file
80
docs/authStrategies_BaseAuthStrategy.js.html
Normal file
@@ -0,0 +1,80 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Source: authStrategies/BaseAuthStrategy.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>18.<wbr>3</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: authStrategies/BaseAuthStrategy.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
/**
|
||||
* Base class which all authentication strategies extend
|
||||
*/
|
||||
class BaseAuthStrategy {
|
||||
constructor() {}
|
||||
setup(client) {
|
||||
this.client = client;
|
||||
}
|
||||
async beforeBrowserInitialized() {}
|
||||
async afterBrowserInitialized() {}
|
||||
async onAuthenticationNeeded() {
|
||||
return {
|
||||
failed: false,
|
||||
restart: false,
|
||||
failureEventPayload: undefined
|
||||
};
|
||||
}
|
||||
async getAuthEventPayload() {}
|
||||
async afterAuthReady() {}
|
||||
async disconnect() {}
|
||||
async destroy() {}
|
||||
async logout() {}
|
||||
}
|
||||
|
||||
module.exports = BaseAuthStrategy;</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.11 on November 13, 2022.
|
||||
</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>
|
||||
126
docs/authStrategies_LegacySessionAuth.js.html
Normal file
126
docs/authStrategies_LegacySessionAuth.js.html
Normal file
@@ -0,0 +1,126 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Source: authStrategies/LegacySessionAuth.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>18.<wbr>3</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: authStrategies/LegacySessionAuth.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* Legacy session auth strategy
|
||||
* Not compatible with multi-device accounts.
|
||||
* @param {object} options - options
|
||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||
* @param {string} options.session.WABrowserId
|
||||
* @param {string} options.session.WASecretBundle
|
||||
* @param {string} options.session.WAToken1
|
||||
* @param {string} options.session.WAToken2
|
||||
*/
|
||||
class LegacySessionAuth extends BaseAuthStrategy {
|
||||
constructor({ session, restartOnAuthFail }={}) {
|
||||
super();
|
||||
this.session = session;
|
||||
this.restartOnAuthFail = restartOnAuthFail;
|
||||
}
|
||||
|
||||
async afterBrowserInitialized() {
|
||||
if(this.session) {
|
||||
await this.client.pupPage.evaluateOnNewDocument(session => {
|
||||
if (document.referrer === 'https://whatsapp.com/') {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
||||
localStorage.setItem('WAToken1', session.WAToken1);
|
||||
localStorage.setItem('WAToken2', session.WAToken2);
|
||||
}
|
||||
|
||||
localStorage.setItem('remember-me', 'true');
|
||||
}, this.session);
|
||||
}
|
||||
}
|
||||
|
||||
async onAuthenticationNeeded() {
|
||||
if(this.session) {
|
||||
this.session = null;
|
||||
return {
|
||||
failed: true,
|
||||
restart: this.restartOnAuthFail,
|
||||
failureEventPayload: 'Unable to log in. Are the session details valid?'
|
||||
};
|
||||
}
|
||||
|
||||
return { failed: false };
|
||||
}
|
||||
|
||||
async getAuthEventPayload() {
|
||||
const isMD = await this.client.pupPage.evaluate(() => {
|
||||
return window.Store.MDBackend;
|
||||
});
|
||||
|
||||
if(isMD) throw new Error('Authenticating via JSON session is not supported for MultiDevice-enabled WhatsApp accounts.');
|
||||
|
||||
const localStorage = JSON.parse(await this.client.pupPage.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
}));
|
||||
|
||||
return {
|
||||
WABrowserId: localStorage.WABrowserId,
|
||||
WASecretBundle: localStorage.WASecretBundle,
|
||||
WAToken1: localStorage.WAToken1,
|
||||
WAToken2: localStorage.WAToken2
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LegacySessionAuth;
|
||||
</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.11 on November 13, 2022.
|
||||
</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>
|
||||
106
docs/authStrategies_LocalAuth.js.html
Normal file
106
docs/authStrategies_LocalAuth.js.html
Normal file
@@ -0,0 +1,106 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Source: authStrategies/LocalAuth.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>18.<wbr>3</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: authStrategies/LocalAuth.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* Local directory-based authentication
|
||||
* @param {object} options - options
|
||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
||||
*/
|
||||
class LocalAuth extends BaseAuthStrategy {
|
||||
constructor({ clientId, dataPath }={}) {
|
||||
super();
|
||||
|
||||
const idRegex = /^[-_\w]+$/i;
|
||||
if(clientId &amp;&amp; !idRegex.test(clientId)) {
|
||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
||||
}
|
||||
|
||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
async beforeBrowserInitialized() {
|
||||
const puppeteerOpts = this.client.options.puppeteer;
|
||||
const sessionDirName = this.clientId ? `session-${this.clientId}` : 'session';
|
||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
||||
|
||||
if(puppeteerOpts.userDataDir &amp;&amp; puppeteerOpts.userDataDir !== dirPath) {
|
||||
throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.');
|
||||
}
|
||||
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
|
||||
this.client.options.puppeteer = {
|
||||
...puppeteerOpts,
|
||||
userDataDir: dirPath
|
||||
};
|
||||
|
||||
this.userDataDir = dirPath;
|
||||
}
|
||||
|
||||
async logout() {
|
||||
if (this.userDataDir) {
|
||||
return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = LocalAuth;</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.11 on November 13, 2022.
|
||||
</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>
|
||||
65
docs/authStrategies_NoAuth.js.html
Normal file
65
docs/authStrategies_NoAuth.js.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Source: authStrategies/NoAuth.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>18.<wbr>3</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: authStrategies/NoAuth.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* No session restoring functionality
|
||||
* Will need to authenticate via QR code every time
|
||||
*/
|
||||
class NoAuth extends BaseAuthStrategy { }
|
||||
|
||||
|
||||
module.exports = NoAuth;</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.11 on November 13, 2022.
|
||||
</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>
|
||||
258
docs/authStrategies_RemoteAuth.js.html
Normal file
258
docs/authStrategies_RemoteAuth.js.html
Normal file
@@ -0,0 +1,258 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Source: authStrategies/RemoteAuth.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>18.<wbr>3</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: authStrategies/RemoteAuth.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
/* Require Optional Dependencies */
|
||||
try {
|
||||
var fs = require('fs-extra');
|
||||
var unzipper = require('unzipper');
|
||||
var archiver = require('archiver');
|
||||
} catch {
|
||||
fs = undefined;
|
||||
unzipper = undefined;
|
||||
archiver = undefined;
|
||||
}
|
||||
|
||||
const path = require('path');
|
||||
const { Events } = require('./../util/Constants');
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* Remote-based authentication
|
||||
* @param {object} options - options
|
||||
* @param {object} options.store - Remote database store instance
|
||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
||||
* @param {number} options.backupSyncIntervalMs - Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}
|
||||
*/
|
||||
class RemoteAuth extends BaseAuthStrategy {
|
||||
constructor({ clientId, dataPath, store, backupSyncIntervalMs } = {}) {
|
||||
if (!fs &amp;&amp; !unzipper &amp;&amp; !archiver) throw new Error('Optional Dependencies [fs-extra, unzipper, archiver] are required to use RemoteAuth. Make sure to run npm install correctly and remove the --no-optional flag');
|
||||
super();
|
||||
|
||||
const idRegex = /^[-_\w]+$/i;
|
||||
if (clientId &amp;&amp; !idRegex.test(clientId)) {
|
||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
||||
}
|
||||
if (!backupSyncIntervalMs || backupSyncIntervalMs &lt; 60000) {
|
||||
throw new Error('Invalid backupSyncIntervalMs. Accepts values starting from 60000ms {1 minute}.');
|
||||
}
|
||||
if(!store) throw new Error('Remote database store is required.');
|
||||
|
||||
this.store = store;
|
||||
this.clientId = clientId;
|
||||
this.backupSyncIntervalMs = backupSyncIntervalMs;
|
||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
||||
this.tempDir = `${this.dataPath}/wwebjs_temp_session`;
|
||||
this.requiredDirs = ['Default', 'IndexedDB', 'Local Storage']; /* => Required Files &amp; Dirs in WWebJS to restore session */
|
||||
}
|
||||
|
||||
async beforeBrowserInitialized() {
|
||||
const puppeteerOpts = this.client.options.puppeteer;
|
||||
const sessionDirName = this.clientId ? `RemoteAuth-${this.clientId}` : 'RemoteAuth';
|
||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
||||
|
||||
if (puppeteerOpts.userDataDir &amp;&amp; puppeteerOpts.userDataDir !== dirPath) {
|
||||
throw new Error('RemoteAuth is not compatible with a user-supplied userDataDir.');
|
||||
}
|
||||
|
||||
this.userDataDir = dirPath;
|
||||
this.sessionName = sessionDirName;
|
||||
|
||||
await this.extractRemoteSession();
|
||||
|
||||
this.client.options.puppeteer = {
|
||||
...puppeteerOpts,
|
||||
userDataDir: dirPath
|
||||
};
|
||||
}
|
||||
|
||||
async logout() {
|
||||
await this.disconnect();
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
clearInterval(this.backupSync);
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
await this.deleteRemoteSession();
|
||||
|
||||
let pathExists = await this.isValidPath(this.userDataDir);
|
||||
if (pathExists) {
|
||||
await fs.promises.rm(this.userDataDir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
}
|
||||
clearInterval(this.backupSync);
|
||||
}
|
||||
|
||||
async afterAuthReady() {
|
||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
||||
if(!sessionExists) {
|
||||
await this.delay(60000); /* Initial delay sync required for session to be stable enough to recover */
|
||||
await this.storeRemoteSession({emit: true});
|
||||
}
|
||||
var self = this;
|
||||
this.backupSync = setInterval(async function () {
|
||||
await self.storeRemoteSession();
|
||||
}, this.backupSyncIntervalMs);
|
||||
}
|
||||
|
||||
async storeRemoteSession(options) {
|
||||
/* Compress &amp; Store Session */
|
||||
const pathExists = await this.isValidPath(this.userDataDir);
|
||||
if (pathExists) {
|
||||
await this.compressSession();
|
||||
await this.store.save({session: this.sessionName});
|
||||
await fs.promises.unlink(`${this.sessionName}.zip`);
|
||||
await fs.promises.rm(`${this.tempDir}`, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
if(options &amp;&amp; options.emit) this.client.emit(Events.REMOTE_SESSION_SAVED);
|
||||
}
|
||||
}
|
||||
|
||||
async extractRemoteSession() {
|
||||
const pathExists = await this.isValidPath(this.userDataDir);
|
||||
const compressedSessionPath = `${this.sessionName}.zip`;
|
||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
||||
if (pathExists) {
|
||||
await fs.promises.rm(this.userDataDir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
}
|
||||
if (sessionExists) {
|
||||
await this.store.extract({session: this.sessionName, path: compressedSessionPath});
|
||||
await this.unCompressSession(compressedSessionPath);
|
||||
} else {
|
||||
fs.mkdirSync(this.userDataDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
async deleteRemoteSession() {
|
||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
||||
if (sessionExists) await this.store.delete({session: this.sessionName});
|
||||
}
|
||||
|
||||
async compressSession() {
|
||||
const archive = archiver('zip');
|
||||
const stream = fs.createWriteStream(`${this.sessionName}.zip`);
|
||||
|
||||
await fs.copy(this.userDataDir, this.tempDir).catch(() => {});
|
||||
await this.deleteMetadata();
|
||||
return new Promise((resolve, reject) => {
|
||||
archive
|
||||
.directory(this.tempDir, false)
|
||||
.on('error', err => reject(err))
|
||||
.pipe(stream);
|
||||
|
||||
stream.on('close', () => resolve());
|
||||
archive.finalize();
|
||||
});
|
||||
}
|
||||
|
||||
async unCompressSession(compressedSessionPath) {
|
||||
var stream = fs.createReadStream(compressedSessionPath);
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.pipe(unzipper.Extract({
|
||||
path: this.userDataDir
|
||||
}))
|
||||
.on('error', err => reject(err))
|
||||
.on('finish', () => resolve());
|
||||
});
|
||||
await fs.promises.unlink(compressedSessionPath);
|
||||
}
|
||||
|
||||
async deleteMetadata() {
|
||||
const sessionDirs = [this.tempDir, path.join(this.tempDir, 'Default')];
|
||||
for (const dir of sessionDirs) {
|
||||
const sessionFiles = await fs.promises.readdir(dir);
|
||||
for (const element of sessionFiles) {
|
||||
if (!this.requiredDirs.includes(element)) {
|
||||
const dirElement = path.join(dir, element);
|
||||
const stats = await fs.promises.lstat(dirElement);
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
await fs.promises.rm(dirElement, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
} else {
|
||||
await fs.promises.unlink(dirElement).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async isValidPath(path) {
|
||||
try {
|
||||
await fs.promises.access(path);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RemoteAuth;
|
||||
</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.11 on November 13, 2022.
|
||||
</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>
|
||||
384
docs/global.html
384
docs/global.html
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Globals</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -68,16 +68,22 @@
|
||||
<div class="summary-content">
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="global.html#ButtonSpec">ButtonSpec</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#ContactId">ContactId</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
||||
<dt><a href="global.html#FormattedButtonSpec">FormattedButtonSpec</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="summary-column">
|
||||
<dl class="dl-summary-callout">
|
||||
<dt><a href="global.html#GroupParticipant">GroupParticipant</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt><a href="global.html#MessageInfo">MessageInfo</a></dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -279,6 +285,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>MESSAGE_REACTION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>MEDIA_UPLOADED</p>
|
||||
@@ -344,6 +363,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>LOADING_SCREEN</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>DISCONNECTED</p>
|
||||
@@ -396,6 +428,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>REMOTE_SESSION_SAVED</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -862,6 +907,19 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>LIST_RESPONSE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>BUTTONS_RESPONSE</p>
|
||||
@@ -888,6 +946,214 @@
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>BROADCAST_NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>CALL_LOG</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>CIPHERTEXT</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>DEBUG</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>E2E_NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>GP2</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>GROUP_NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>HSM</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>INTERACTIVE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>NATIVE_FLOW</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>NOTIFICATION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>NOTIFICATION_TEMPLATE</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>OVERSIZED</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>PROTOCOL</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>REACTION</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>TEMPLATE_BUTTON_REPLY</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
@@ -1133,6 +1399,54 @@
|
||||
</section>
|
||||
<h2>Abstract types</h2>
|
||||
<section>
|
||||
<h3 id="ButtonSpec"><span class="symbol-name">ButtonSpec</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Button spec used in Buttons constructor</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>id</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Custom ID to set on the button. A random one will be generated if one is not passed.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>body</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
<p>The text to show on the button.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="ContactId"><span class="symbol-name">ContactId</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>ID that represents a contact</p>
|
||||
@@ -1192,6 +1506,64 @@
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="FormattedButtonSpec"><span class="symbol-name">FormattedButtonSpec</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<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>buttonId</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>string</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>type</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>number</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<p>buttonText</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Object</p>
|
||||
</td>
|
||||
<td>
|
||||
<p> </p>
|
||||
</td>
|
||||
<td>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
<dl class="dl-compact">
|
||||
</dl>
|
||||
<h3 id="GroupParticipant"><span class="symbol-name">GroupParticipant</span><small class="property-type">
|
||||
Object</small></h3>
|
||||
<p>Group participant information</p>
|
||||
@@ -1381,7 +1753,7 @@
|
||||
<p>Yes</p>
|
||||
</td>
|
||||
<td>
|
||||
<p>Show links preview</p>
|
||||
<p>Show links preview. Has no effect on multi-device accounts.</p>
|
||||
<p>Defaults to <code>true</code>.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1647,7 +2019,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
493
docs/index.html
493
docs/index.html
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Home</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -27,11 +27,11 @@
|
||||
<div id="jsdoc-main" role="main">
|
||||
<header class="page-header">
|
||||
<h1>
|
||||
whatsapp-web.js 1.15.4
|
||||
whatsapp-web.js 1.18.3
|
||||
</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.2202.8-brightgreen.svg" alt="WhatsApp_Web 2.2202.8"> <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.2241.6-brightgreen.svg" alt="WhatsApp_Web 2.2241.6"> <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>
|
||||
@@ -69,33 +69,7 @@ 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 "MAX_CONCURRENT_SESSIONS=1" \
|
||||
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>
|
||||
<p>For more information on saving and restoring sessions, check out the available <a href="https://wwebjs.dev/guide/authentication.html">Authentication Strategies</a>.</p>
|
||||
<h2>Supported features</h2>
|
||||
<table>
|
||||
<thead>
|
||||
@@ -105,6 +79,10 @@ client.initialize();
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Multi Device</td>
|
||||
<td>✅</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Send messages</td>
|
||||
<td>✅</td>
|
||||
@@ -205,14 +183,22 @@ client.initialize();
|
||||
<td>Set user status message</td>
|
||||
<td>✅</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>React to messages</td>
|
||||
<td>✅</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>Something missing? Make an issue and let us know!</p>
|
||||
<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>
|
||||
<h2>Donating</h2>
|
||||
<p>You can support the maintainer of this project through the link below</p>
|
||||
<p><a href="https://www.paypal.me/psla/"><img src="https://cdn.rawgit.com/twolfson/paypal-github-button/1.0.0/dist/button.svg" alt="Support via PayPal"></a></p>
|
||||
<h2>Supporting the project</h2>
|
||||
<p>You can support the maintainer of this project through the links below</p>
|
||||
<ul>
|
||||
<li><a href="https://github.com/sponsors/pedroslopez">Support via GitHub Sponsors</a></li>
|
||||
<li><a href="https://www.paypal.me/psla/">Support via PayPal</a></li>
|
||||
<li><a href="https://m.do.co/c/73f906a36ed4">Sign up for DigitalOcean</a> and get $100 in credit when you sign up (Referral)</li>
|
||||
</ul>
|
||||
<h2>Disclaimer</h2>
|
||||
<p>This project is not affiliated, associated, authorized, endorsed by, or in any way officially connected with WhatsApp or any of its subsidiaries or its affiliates. The official WhatsApp website can be found at https://whatsapp.com. "WhatsApp" as well as related names, marks, emblems and images are registered trademarks of their respective owners.</p>
|
||||
<h2>License</h2>
|
||||
@@ -251,6 +237,30 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="BaseAuthStrategy">BaseAuthStrategy</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BaseAuthStrategy.html" class="!symbol-index-name">BaseAuthStrategy()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
</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="BusinessContact">BusinessContact</h2>
|
||||
@@ -282,6 +292,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#getCommonGroups" class="!symbol-index-name">BusinessContact#<wbr>getCommonGroups()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#getCountryCode" class="!symbol-index-name">BusinessContact#<wbr>getCountryCode()</a>
|
||||
</dt>
|
||||
@@ -292,15 +307,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="BusinessContact.html#getProfilePicUrl" class="!symbol-index-name">BusinessContact#<wbr>getProfilePicUrl()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#id" class="!symbol-index-name">BusinessContact#<wbr>id</a>
|
||||
</dt>
|
||||
@@ -336,15 +351,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="BusinessContact.html#isUser" class="!symbol-index-name">BusinessContact#<wbr>isUser</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="BusinessContact.html#isWAContact" class="!symbol-index-name">BusinessContact#<wbr>isWAContact</a>
|
||||
</dt>
|
||||
@@ -703,7 +718,7 @@ client.initialize();
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#acceptGroupV4Invite" class="!symbol-index-name">Client#<wbr>acceptGroupV4Invite(inviteV4)</a>
|
||||
<a href="Client.html#acceptGroupV4Invite" class="!symbol-index-name">Client#<wbr>acceptGroupV4Invite(inviteInfo)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -792,6 +807,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#event:message_reaction" class="!symbol-index-name">Client#<wbr>event:message_reaction</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
@@ -841,6 +861,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getCommonGroups" class="!symbol-index-name">Client#<wbr>getCommonGroups(contactId)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#getContactById" class="!symbol-index-name">Client#<wbr>getContactById(contactId)</a>
|
||||
</dt>
|
||||
@@ -955,6 +980,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#sendPresenceUnavailable" class="!symbol-index-name">Client#<wbr>sendPresenceUnavailable()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Client.html#sendSeen" class="!symbol-index-name">Client#<wbr>sendSeen(chatId)</a>
|
||||
</dt>
|
||||
@@ -1070,6 +1100,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Contact.html#getCommonGroups" class="!symbol-index-name">Contact#<wbr>getCommonGroups()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Contact.html#getCountryCode" class="!symbol-index-name">Contact#<wbr>getCountryCode()</a>
|
||||
</dt>
|
||||
@@ -1124,15 +1159,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="Contact.html#isUser" class="!symbol-index-name">Contact#<wbr>isUser</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Contact.html#isWAContact" class="!symbol-index-name">Contact#<wbr>isWAContact</a>
|
||||
</dt>
|
||||
@@ -1204,20 +1239,25 @@ 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#.GROUP_UPDATE" class="!symbol-index-name">Events.<wbr>GROUP_UPDATE</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#.INCOMING_CALL" class="!symbol-index-name">Events.<wbr>INCOMING_CALL</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.LOADING_SCREEN" class="!symbol-index-name">Events.<wbr>LOADING_SCREEN</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>
|
||||
@@ -1233,6 +1273,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.MESSAGE_REACTION" class="!symbol-index-name">Events.<wbr>MESSAGE_REACTION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.MESSAGE_RECEIVED" class="!symbol-index-name">Events.<wbr>MESSAGE_RECEIVED</a>
|
||||
</dt>
|
||||
@@ -1262,6 +1307,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.REMOTE_SESSION_SAVED" class="!symbol-index-name">Events.<wbr>REMOTE_SESSION_SAVED</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#Events#.STATE_CHANGED" class="!symbol-index-name">Events.<wbr>STATE_CHANGED</a>
|
||||
</dt>
|
||||
@@ -1767,6 +1817,30 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="LegacySessionAuth">LegacySessionAuth</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="LegacySessionAuth.html" class="!symbol-index-name">LegacySessionAuth(options)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
</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="List">List</h2>
|
||||
@@ -1821,6 +1895,30 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="LocalAuth">LocalAuth</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="LocalAuth.html" class="!symbol-index-name">LocalAuth(options)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
</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="Location">Location</h2>
|
||||
@@ -1911,6 +2009,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#duration" class="!symbol-index-name">Message#<wbr>duration</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#forward" class="!symbol-index-name">Message#<wbr>forward(chat)</a>
|
||||
</dt>
|
||||
@@ -1936,15 +2039,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#getContact" class="!symbol-index-name">Message#<wbr>getContact()</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#getInfo" class="!symbol-index-name">Message#<wbr>getInfo()</a>
|
||||
</dt>
|
||||
@@ -1990,6 +2093,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#isEphemeral" class="!symbol-index-name">Message#<wbr>isEphemeral</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#isForwarded" class="!symbol-index-name">Message#<wbr>isForwarded</a>
|
||||
</dt>
|
||||
@@ -2010,10 +2118,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="Message.html#links" class="!symbol-index-name">Message#<wbr>links</a>
|
||||
</dt>
|
||||
@@ -2024,6 +2128,10 @@ 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#mediaKey" class="!symbol-index-name">Message#<wbr>mediaKey</a>
|
||||
</dt>
|
||||
@@ -2039,6 +2147,21 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#rawData" class="!symbol-index-name">Message#<wbr>rawData</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#react" class="!symbol-index-name">Message#<wbr>react(reaction)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Message.html#reload" class="!symbol-index-name">Message#<wbr>reload()</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>
|
||||
@@ -2140,7 +2263,7 @@ client.initialize();
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="MessageMedia.html" class="!symbol-index-name">MessageMedia(mimetype, data, filename)</a>
|
||||
<a href="MessageMedia.html" class="!symbol-index-name">MessageMedia(mimetype, data, filename, filesize)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
@@ -2149,29 +2272,34 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="MessageMedia.html#.fromUrl" class="!symbol-index-name">MessageMedia.<wbr>fromUrl(url[, options])</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<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>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<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#filesize" class="!symbol-index-name">MessageMedia#<wbr>filesize</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</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>
|
||||
@@ -2193,11 +2321,26 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.BROADCAST_NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>BROADCAST_NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.BUTTONS_RESPONSE" class="!symbol-index-name">MessageTypes.<wbr>BUTTONS_RESPONSE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.CALL_LOG" class="!symbol-index-name">MessageTypes.<wbr>CALL_LOG</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.CIPHERTEXT" class="!symbol-index-name">MessageTypes.<wbr>CIPHERTEXT</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.CONTACT_CARD" class="!symbol-index-name">MessageTypes.<wbr>CONTACT_CARD</a>
|
||||
</dt>
|
||||
@@ -2208,11 +2351,26 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.DEBUG" class="!symbol-index-name">MessageTypes.<wbr>DEBUG</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.DOCUMENT" class="!symbol-index-name">MessageTypes.<wbr>DOCUMENT</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.E2E_NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>E2E_NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.GP2" class="!symbol-index-name">MessageTypes.<wbr>GP2</a>
|
||||
</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>
|
||||
@@ -2222,26 +2380,70 @@ client.initialize();
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.GROUP_NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>GROUP_NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.HSM" class="!symbol-index-name">MessageTypes.<wbr>HSM</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.IMAGE" class="!symbol-index-name">MessageTypes.<wbr>IMAGE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.INTERACTIVE" class="!symbol-index-name">MessageTypes.<wbr>INTERACTIVE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.LIST" class="!symbol-index-name">MessageTypes.<wbr>LIST</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.LIST_RESPONSE" class="!symbol-index-name">MessageTypes.<wbr>LIST_RESPONSE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.LOCATION" class="!symbol-index-name">MessageTypes.<wbr>LOCATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.NATIVE_FLOW" class="!symbol-index-name">MessageTypes.<wbr>NATIVE_FLOW</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.NOTIFICATION" class="!symbol-index-name">MessageTypes.<wbr>NOTIFICATION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.NOTIFICATION_TEMPLATE" class="!symbol-index-name">MessageTypes.<wbr>NOTIFICATION_TEMPLATE</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<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#.OVERSIZED" class="!symbol-index-name">MessageTypes.<wbr>OVERSIZED</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#MessageTypes#.PAYMENT" class="!symbol-index-name">MessageTypes.<wbr>PAYMENT</a>
|
||||
</dt>
|
||||
@@ -2252,10 +2454,16 @@ 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#MessageTypes#.PROTOCOL" class="!symbol-index-name">MessageTypes.<wbr>PROTOCOL</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.REACTION" class="!symbol-index-name">MessageTypes.<wbr>REACTION</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.REVOKED" class="!symbol-index-name">MessageTypes.<wbr>REVOKED</a>
|
||||
</dt>
|
||||
@@ -2266,6 +2474,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.TEMPLATE_BUTTON_REPLY" class="!symbol-index-name">MessageTypes.<wbr>TEMPLATE_BUTTON_REPLY</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="global.html#MessageTypes#.TEXT" class="!symbol-index-name">MessageTypes.<wbr>TEXT</a>
|
||||
</dt>
|
||||
@@ -2291,6 +2504,30 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="NoAuth">NoAuth</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="NoAuth.html" class="!symbol-index-name">NoAuth()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
</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="Order">Order</h2>
|
||||
@@ -2579,6 +2816,11 @@ client.initialize();
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="PrivateContact.html#getCommonGroups" class="!symbol-index-name">PrivateContact#<wbr>getCommonGroups()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="PrivateContact.html#getCountryCode" class="!symbol-index-name">PrivateContact#<wbr>getCountryCode()</a>
|
||||
</dt>
|
||||
@@ -2633,15 +2875,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="PrivateContact.html#isUser" class="!symbol-index-name">PrivateContact#<wbr>isUser</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="PrivateContact.html#isWAContact" class="!symbol-index-name">PrivateContact#<wbr>isWAContact</a>
|
||||
</dt>
|
||||
@@ -2775,6 +3017,99 @@ client.initialize();
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="Reaction">Reaction</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html" class="!symbol-index-name">Reaction()</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#ack" class="!symbol-index-name">Reaction#<wbr>ack</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#id" class="!symbol-index-name">Reaction#<wbr>id</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#msgId" class="!symbol-index-name">Reaction#<wbr>msgId</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#orphan" class="!symbol-index-name">Reaction#<wbr>orphan</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#orphanReason" class="!symbol-index-name">Reaction#<wbr>orphanReason</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#reaction" class="!symbol-index-name">Reaction#<wbr>reaction</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#read" class="!symbol-index-name">Reaction#<wbr>read</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#senderId" class="!symbol-index-name">Reaction#<wbr>senderId</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
<dt class="symbol-index-name">
|
||||
<a href="Reaction.html#timestamp" class="!symbol-index-name">Reaction#<wbr>timestamp</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="symbol-index-content">
|
||||
<h2 id="RemoteAuth">RemoteAuth</h2>
|
||||
<div class="symbol-index-section">
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
<dt class="symbol-index-name">
|
||||
<a href="RemoteAuth.html" class="!symbol-index-name">RemoteAuth(options)</a>
|
||||
</dt>
|
||||
<dd>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="symbol-index-column">
|
||||
<dl class="symbol-index-list">
|
||||
</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>
|
||||
@@ -2941,7 +3276,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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
treeNode.tree({
|
||||
autoEscape: false,
|
||||
closedIcon: '⇢',
|
||||
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=\"Buttons.html\">Buttons</a>","id":"Buttons","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=\"List.html\">List</a>","id":"List","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":[]}],
|
||||
data: [{"label":"<a href=\"global.html\">Globals</a>","id":"global","children":[]},{"label":"<a href=\"Base.html\">Base</a>","id":"Base","children":[]},{"label":"<a href=\"BaseAuthStrategy.html\">BaseAuthStrategy</a>","id":"BaseAuthStrategy","children":[]},{"label":"<a href=\"BusinessContact.html\">BusinessContact</a>","id":"BusinessContact","children":[]},{"label":"<a href=\"Buttons.html\">Buttons</a>","id":"Buttons","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=\"LegacySessionAuth.html\">LegacySessionAuth</a>","id":"LegacySessionAuth","children":[]},{"label":"<a href=\"List.html\">List</a>","id":"List","children":[]},{"label":"<a href=\"LocalAuth.html\">LocalAuth</a>","id":"LocalAuth","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=\"NoAuth.html\">NoAuth</a>","id":"NoAuth","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=\"Reaction.html\">Reaction</a>","id":"Reaction","children":[]},{"label":"<a href=\"RemoteAuth.html\">RemoteAuth</a>","id":"RemoteAuth","children":[]},{"label":"<a href=\"Util.html\">Util</a>","id":"Util","children":[]}],
|
||||
openedIcon: ' ⇣',
|
||||
saveState: false,
|
||||
useContextMenu: false
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Base.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -60,7 +60,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/BusinessContact.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -59,7 +59,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Buttons.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » Source: structures/Buttons.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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -34,13 +34,27 @@
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Button spec used in Buttons constructor
|
||||
* @typedef {Object} ButtonSpec
|
||||
* @property {string=} id - Custom ID to set on the button. A random one will be generated if one is not passed.
|
||||
* @property {string} body - The text to show on the button.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FormattedButtonSpec
|
||||
* @property {string} buttonId
|
||||
* @property {number} type
|
||||
* @property {Object} buttonText
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message type buttons
|
||||
*/
|
||||
class Buttons {
|
||||
/**
|
||||
* @param {string|MessageMedia} body
|
||||
* @param {Array&lt;Array&lt;string>>} buttons
|
||||
* @param {ButtonSpec[]} buttons - See {@link ButtonSpec}
|
||||
* @param {string?} title
|
||||
* @param {string?} footer
|
||||
*/
|
||||
@@ -72,7 +86,7 @@ class Buttons {
|
||||
|
||||
/**
|
||||
* buttons of message
|
||||
* @type {Array&lt;Array&lt;string>>}
|
||||
* @type {FormattedButtonSpec[]}
|
||||
*/
|
||||
this.buttons = this._format(buttons);
|
||||
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
||||
@@ -81,8 +95,8 @@ class Buttons {
|
||||
|
||||
/**
|
||||
* Creates button array from simple array
|
||||
* @param {Array&lt;Array&lt;string>>} buttons
|
||||
* @returns {Array&lt;Array&lt;string>>}
|
||||
* @param {ButtonSpec[]} buttons
|
||||
* @returns {FormattedButtonSpec[]}
|
||||
* @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}]
|
||||
@@ -106,7 +120,7 @@ module.exports = Buttons;</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Call.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -106,7 +106,7 @@ module.exports = Call;</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Chat.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -96,7 +96,7 @@ class Chat extends Base {
|
||||
|
||||
/**
|
||||
* Indicates if the chat is muted or not
|
||||
* @type {number}
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMuted = data.isMuted;
|
||||
|
||||
@@ -201,31 +201,42 @@ class Chat extends Base {
|
||||
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
* @param {Number} [searchOptions.limit=50] The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit and fromMe is supported.
|
||||
* @param {Number} [searchOptions.limit] The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||
* @param {Boolean} [searchOptions.fromMe] Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
|
||||
* @returns {Promise&lt;Array&lt;Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if (!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = { limit: 50 };
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, searchOptions) => {
|
||||
const msgFilter = (m) => {
|
||||
if (m.isNotification) {
|
||||
return false; // dont include notification messages
|
||||
}
|
||||
if (searchOptions &amp;&amp; searchOptions.fromMe &amp;&amp; m.id.fromMe !== searchOptions.fromMe) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
let msgs = chat.msgs.models.filter(msgFilter);
|
||||
let msgs = chat.msgs.getModelsArray().filter(msgFilter);
|
||||
|
||||
while (msgs.length &lt; limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
if (searchOptions &amp;&amp; searchOptions.limit > 0) {
|
||||
while (msgs.length &lt; searchOptions.limit) {
|
||||
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat);
|
||||
if (!loadedMessages || !loadedMessages.length) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
}, this.id._serialized, searchOptions);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
@@ -288,7 +299,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/ClientInfo.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -51,12 +51,6 @@ class ClientInfo extends Base {
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
/**
|
||||
* @type {object}
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
this.me = data.wid;
|
||||
|
||||
/**
|
||||
* Current user ID
|
||||
* @type {object}
|
||||
@@ -64,18 +58,25 @@ class ClientInfo extends Base {
|
||||
this.wid = data.wid;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
* @type {object}
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
this.me = data.wid;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to. Not available in multi-device.
|
||||
* @type {object}
|
||||
* @property {string} wa_version WhatsApp Version running on the phone
|
||||
* @property {string} os_version OS Version running on the phone (iOS or Android version)
|
||||
* @property {string} device_manufacturer Device manufacturer
|
||||
* @property {string} device_model Device model
|
||||
* @property {string} os_build_number OS build number
|
||||
* @deprecated
|
||||
*/
|
||||
this.phone = data.phone;
|
||||
|
||||
/**
|
||||
* Platform the phone is running on
|
||||
* Platform WhatsApp is running on
|
||||
* @type {string}
|
||||
*/
|
||||
this.platform = data.platform;
|
||||
@@ -88,6 +89,7 @@ class ClientInfo extends Base {
|
||||
* @returns {object} batteryStatus
|
||||
* @returns {number} batteryStatus.battery - The current battery percentage
|
||||
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
* @deprecated
|
||||
*/
|
||||
async getBatteryStatus() {
|
||||
return await this.client.pupPage.evaluate(() => {
|
||||
@@ -95,7 +97,6 @@ class ClientInfo extends Base {
|
||||
return { battery, plugged };
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ClientInfo;</code></pre>
|
||||
@@ -108,7 +109,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Contact.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -214,7 +214,8 @@ class Contact extends Base {
|
||||
*/
|
||||
async getAbout() {
|
||||
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
||||
return window.Store.Wap.statusFind(contactId);
|
||||
const wid = window.Store.WidFactory.createWid(contactId);
|
||||
return window.Store.StatusUtils.getStatus(wid);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (typeof about.status !== 'string')
|
||||
@@ -222,6 +223,14 @@ class Contact extends Base {
|
||||
|
||||
return about.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
||||
* @returns {Promise&lt;WAWebJS.ChatId[]>}
|
||||
*/
|
||||
async getCommonGroups() {
|
||||
return await this.client.getCommonGroups(this.id._serialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -236,7 +245,7 @@ module.exports = Contact;
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/GroupChat.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -91,7 +91,9 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendAddParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -102,7 +104,9 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendRemoveParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -113,7 +117,9 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendPromoteParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -124,53 +130,73 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendDemoteParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group subject
|
||||
* @param {string} subject
|
||||
* @returns {Promise}
|
||||
* @returns {Promise&lt;boolean>} Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
return window.Store.Wap.changeSubject(chatId, subject);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, subject) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupSubject(chatWid, subject);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, subject);
|
||||
|
||||
if(res.status == 200) {
|
||||
this.name = subject;
|
||||
}
|
||||
if(!success) return false;
|
||||
this.name = subject;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group description
|
||||
* @param {string} description
|
||||
* @returns {Promise}
|
||||
* @returns {Promise&lt;boolean>} Returns true if the description was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, description) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
let descId = window.Store.GroupMetadata.get(chatWid).descId;
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupDescription(chatWid, description, window.Store.MsgKey.newId(), descId);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, description);
|
||||
|
||||
if (res.status == 200) {
|
||||
this.groupMetadata.desc = description;
|
||||
}
|
||||
if(!success) return false;
|
||||
this.groupMetadata.desc = description;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the group settings to only allow admins to send messages.
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
|
||||
if(!success) return false;
|
||||
|
||||
this.groupMetadata.announce = adminsOnly;
|
||||
return true;
|
||||
}
|
||||
@@ -181,11 +207,17 @@ class GroupChat extends Chat {
|
||||
* @returns {Promise&lt;boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setInfoAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
if(!success) return false;
|
||||
|
||||
this.groupMetadata.restrict = adminsOnly;
|
||||
return true;
|
||||
@@ -196,25 +228,25 @@ class GroupChat extends Chat {
|
||||
* @returns {Promise&lt;string>} Group's invite code
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.groupInviteCode(chatId);
|
||||
const code = await this.client.pupPage.evaluate(async chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.Invite.sendQueryGroupInviteCode(chatWid);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (res.status == 200) {
|
||||
return res.code;
|
||||
}
|
||||
|
||||
throw new Error('Not authorized');
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the current group invite code and generates a new one
|
||||
* @returns {Promise}
|
||||
* @returns {Promise&lt;string>} New invite code
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||
const code = await this.client.pupPage.evaluate(chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.Invite.sendRevokeGroupInviteCode(chatWid);
|
||||
}, this.id._serialized);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -222,8 +254,9 @@ class GroupChat extends Chat {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.leaveGroup(chatId);
|
||||
await this.client.pupPage.evaluate(chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.GroupUtils.sendExitGroup(chatWid);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
@@ -239,7 +272,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/GroupNotification.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -74,7 +74,7 @@ class GroupNotification extends Base {
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.chatId = typeof (data.id.remote) === 'object' ? data.id.remote._serialized : data.id.remote;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
@@ -143,7 +143,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Label.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -88,7 +88,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/List.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » Source: structures/List.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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -118,7 +118,7 @@ module.exports = List;
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Location.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -71,7 +71,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Message.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -50,13 +50,14 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
this._data = data;
|
||||
|
||||
/**
|
||||
* MediaKey that represents the sticker 'ID'
|
||||
* @type {string}
|
||||
*/
|
||||
this.mediaKey = data.mediaKey;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ID that represents the message
|
||||
* @type {object}
|
||||
@@ -81,7 +82,7 @@ class Message extends Base {
|
||||
*/
|
||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Message type
|
||||
* @type {MessageTypes}
|
||||
*/
|
||||
@@ -101,9 +102,9 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* ID for who this message is for.
|
||||
*
|
||||
*
|
||||
* If the message is sent by the current user, it will be the Chat to which the message is being sent.
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
* @type {string}
|
||||
*/
|
||||
this.to = (typeof (data.to) === 'object' &amp;&amp; data.to !== null) ? data.to._serialized : data.to;
|
||||
@@ -118,8 +119,8 @@ class Message extends Base {
|
||||
* 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';
|
||||
|
||||
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}
|
||||
@@ -145,14 +146,14 @@ class Message extends Base {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isStarred = data.star;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates if the message was a broadcast
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.broadcast = data.broadcast;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Indicates if the message was sent by the current user
|
||||
* @type {boolean}
|
||||
*/
|
||||
@@ -164,6 +165,12 @@ class Message extends Base {
|
||||
*/
|
||||
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
||||
|
||||
/**
|
||||
* Indicates the duration of the message in seconds
|
||||
* @type {string}
|
||||
*/
|
||||
this.duration = data.duration ? data.duration : undefined;
|
||||
|
||||
/**
|
||||
* Location information contained in the message, if the message is type "location"
|
||||
* @type {Location}
|
||||
@@ -188,7 +195,7 @@ class Message extends Base {
|
||||
fromId: data.from._serialized,
|
||||
toId: data.to._serialized
|
||||
} : undefined;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array&lt;string>}
|
||||
@@ -216,6 +223,12 @@ class Message extends Base {
|
||||
*/
|
||||
this.isGif = Boolean(data.isGif);
|
||||
|
||||
/**
|
||||
* Indicates if the message will disappear after it expires
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isEphemeral = data.isEphemeral;
|
||||
|
||||
/** Title */
|
||||
if (data.title) {
|
||||
this.title = data.title;
|
||||
@@ -239,7 +252,7 @@ class Message extends Base {
|
||||
/**
|
||||
* Links included in the message.
|
||||
* @type {Array&lt;{link: string, isSuspicious: boolean}>}
|
||||
*
|
||||
*
|
||||
*/
|
||||
this.links = data.links;
|
||||
|
||||
@@ -247,7 +260,7 @@ class Message extends Base {
|
||||
if (data.dynamicReplyButtons) {
|
||||
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
||||
}
|
||||
|
||||
|
||||
/** Selected Button Id **/
|
||||
if (data.selectedButtonId) {
|
||||
this.selectedButtonId = data.selectedButtonId;
|
||||
@@ -257,7 +270,7 @@ class Message extends Base {
|
||||
if (data.listResponse &amp;&amp; data.listResponse.singleSelectReply.selectedRowId) {
|
||||
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
||||
}
|
||||
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -265,6 +278,32 @@ class Message extends Base {
|
||||
return this.fromMe ? this.to : this.from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
||||
* @returns {Promise&lt;Message>}
|
||||
*/
|
||||
async reload() {
|
||||
const newData = await this.client.pupPage.evaluate((msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
return window.WWebJS.getMessageModel(msg);
|
||||
}, this.id._serialized);
|
||||
|
||||
if(!newData) return null;
|
||||
|
||||
this._patch(newData);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns message in a raw format
|
||||
* @type {Object}
|
||||
*/
|
||||
get rawData() {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat this message was sent in
|
||||
* @returns {Promise&lt;Chat>}
|
||||
@@ -305,12 +344,12 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message as a reply to this message. If chatId is specified, it will be sent
|
||||
* through the specified Chat. If not, it will send the message
|
||||
* Sends a message as a reply to this message. If chatId is specified, it will be sent
|
||||
* through the specified Chat. If not, it will send the message
|
||||
* in the same Chat as the original message was sent.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {string} [chatId]
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {string} [chatId]
|
||||
* @param {MessageSendOptions} [options]
|
||||
* @returns {Promise&lt;Message>}
|
||||
*/
|
||||
@@ -327,6 +366,20 @@ class Message extends Base {
|
||||
return this.client.sendMessage(chatId, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* React to this message with an emoji
|
||||
* @param {string} reaction - Emoji to react with. Send an empty string to remove the reaction.
|
||||
* @return {Promise}
|
||||
*/
|
||||
async react(reaction){
|
||||
await this.client.pupPage.evaluate(async (messageId, reaction) => {
|
||||
if (!messageId) { return undefined; }
|
||||
|
||||
const msg = await window.Store.Msg.get(messageId);
|
||||
await window.Store.sendReactionToMsg(msg, reaction);
|
||||
}, this.id._serialized, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept Group V4 Invite
|
||||
* @returns {Promise&lt;Object>}
|
||||
@@ -334,10 +387,10 @@ class Message extends Base {
|
||||
async acceptGroupV4Invite() {
|
||||
return await this.client.acceptGroupV4Invite(this.inviteV4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forwards this message to another chat
|
||||
*
|
||||
* Forwards this message to another chat (that you chatted before, otherwise it will fail)
|
||||
*
|
||||
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
||||
* @returns {Promise}
|
||||
*/
|
||||
@@ -367,7 +420,7 @@ class Message extends Base {
|
||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||
// try to resolve media
|
||||
await msg.downloadMedia({
|
||||
downloadEvenIfExpensive: true,
|
||||
downloadEvenIfExpensive: true,
|
||||
rmrReason: 1
|
||||
});
|
||||
}
|
||||
@@ -387,13 +440,14 @@ class Message extends Base {
|
||||
type: msg.type,
|
||||
signal: (new AbortController).signal
|
||||
});
|
||||
|
||||
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||
|
||||
|
||||
const data = await window.WWebJS.arrayBufferToBase64Async(decryptedMedia);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
filename: msg.filename,
|
||||
filesize: msg.size
|
||||
};
|
||||
} catch (e) {
|
||||
if(e.status &amp;&amp; e.status === 404) return undefined;
|
||||
@@ -402,19 +456,19 @@ class Message extends Base {
|
||||
}, this.id._serialized);
|
||||
|
||||
if (!result) return undefined;
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename, result.filesize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a message from the chat
|
||||
* @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat.
|
||||
* @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.
|
||||
*/
|
||||
async delete(everyone) {
|
||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (everyone &amp;&amp; msg.id.fromMe &amp;&amp; msg.canRevoke()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||
if (everyone &amp;&amp; msg._canRevoke()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' });
|
||||
}
|
||||
|
||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||
@@ -429,7 +483,7 @@ class Message extends Base {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], true);
|
||||
return window.Store.Cmd.sendStarMsgs(msg.chat, [msg], false);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
@@ -442,7 +496,7 @@ class Message extends Base {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], false);
|
||||
return window.Store.Cmd.sendUnstarMsgs(msg.chat, [msg], false);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
@@ -465,14 +519,10 @@ class Message extends Base {
|
||||
async getInfo() {
|
||||
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
|
||||
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||
}, this.id._serialized);
|
||||
if (!msg) return null;
|
||||
|
||||
if(info.status) {
|
||||
return null;
|
||||
}
|
||||
return await window.Store.MessageInfo.sendQueryMsgInfo(msg);
|
||||
}, this.id._serialized);
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -483,9 +533,9 @@ class Message extends Base {
|
||||
*/
|
||||
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);
|
||||
const result = await this.client.pupPage.evaluate((orderId, token, chatId) => {
|
||||
return window.WWebJS.getOrderDetail(orderId, token, chatId);
|
||||
}, this.orderId, this.token, this._getChatId());
|
||||
if (!result) return undefined;
|
||||
return new Order(this.client, result);
|
||||
}
|
||||
@@ -519,7 +569,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/MessageMedia.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -41,10 +41,11 @@ const { URL } = require('url');
|
||||
* Media attached to a message
|
||||
* @param {string} mimetype MIME type of the attachment
|
||||
* @param {string} data Base64-encoded data of the file
|
||||
* @param {?string} filename Document file name
|
||||
* @param {?string} filename Document file name. Value can be null
|
||||
* @param {?number} filesize Document file size in bytes. Value can be null
|
||||
*/
|
||||
class MessageMedia {
|
||||
constructor(mimetype, data, filename) {
|
||||
constructor(mimetype, data, filename, filesize) {
|
||||
/**
|
||||
* MIME type of the attachment
|
||||
* @type {string}
|
||||
@@ -58,10 +59,16 @@ class MessageMedia {
|
||||
this.data = data;
|
||||
|
||||
/**
|
||||
* Name of the file (for documents)
|
||||
* Document file name. Value can be null
|
||||
* @type {?string}
|
||||
*/
|
||||
this.filename = filename;
|
||||
|
||||
/**
|
||||
* Document file size in bytes. Value can be null
|
||||
* @type {?number}
|
||||
*/
|
||||
this.filesize = filesize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,6 +106,7 @@ class MessageMedia {
|
||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||
const response = await fetch(url, reqOptions);
|
||||
const mime = response.headers.get('Content-Type');
|
||||
const size = response.headers.get('Content-Length');
|
||||
|
||||
const contentDisposition = response.headers.get('Content-Disposition');
|
||||
const name = contentDisposition ? contentDisposition.match(/((?&lt;=filename=")(.*)(?="))/) : null;
|
||||
@@ -114,7 +122,7 @@ class MessageMedia {
|
||||
data = btoa(data);
|
||||
}
|
||||
|
||||
return { data, mime, name };
|
||||
return { data, mime, name, size };
|
||||
}
|
||||
|
||||
const res = options.client
|
||||
@@ -127,7 +135,7 @@ class MessageMedia {
|
||||
if (!mimetype)
|
||||
mimetype = res.mime;
|
||||
|
||||
return new MessageMedia(mimetype, res.data, filename);
|
||||
return new MessageMedia(mimetype, res.data, filename, res.size || null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,7 +150,7 @@ module.exports = MessageMedia;
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Order.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -90,7 +90,7 @@ module.exports = Order;</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Payment.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » Source: structures/Payment.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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -118,7 +118,7 @@ module.exports = Payment;
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/PrivateChat.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -51,7 +51,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/PrivateContact.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -51,7 +51,7 @@ module.exports = 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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/Product.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -106,7 +106,7 @@ module.exports = Product;</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: structures/ProductMetadata.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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">
|
||||
@@ -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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -63,7 +63,7 @@ module.exports = ProductMetadata;</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.7 on January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
122
docs/structures_Reaction.js.html
Normal file
122
docs/structures_Reaction.js.html
Normal file
@@ -0,0 +1,122 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.18.3 » Source: structures/Reaction.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>18.<wbr>3</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/Reaction.js</h1>
|
||||
</header>
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Reaction on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Reaction extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* Reaction ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.msgKey;
|
||||
/**
|
||||
* Orphan
|
||||
* @type {number}
|
||||
*/
|
||||
this.orphan = data.orphan;
|
||||
/**
|
||||
* Orphan reason
|
||||
* @type {?string}
|
||||
*/
|
||||
this.orphanReason = data.orphanReason;
|
||||
/**
|
||||
* Unix timestamp for when the reaction was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.timestamp;
|
||||
/**
|
||||
* Reaction
|
||||
* @type {string}
|
||||
*/
|
||||
this.reaction = data.reactionText;
|
||||
/**
|
||||
* Read
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.read = data.read;
|
||||
/**
|
||||
* Message ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.msgId = data.parentMsgKey;
|
||||
/**
|
||||
* Sender ID
|
||||
* @type {string}
|
||||
*/
|
||||
this.senderId = data.senderUserJid;
|
||||
/**
|
||||
* ACK
|
||||
* @type {?number}
|
||||
*/
|
||||
this.ack = data.ack;
|
||||
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Reaction;</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.11 on November 13, 2022.
|
||||
</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>
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: util/Constants.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -38,14 +38,11 @@ exports.DefaultOptions = {
|
||||
headless: true,
|
||||
defaultViewport: null
|
||||
},
|
||||
session: false,
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
authTimeoutMs: 0,
|
||||
qrMaxRetries: 0,
|
||||
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',
|
||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36',
|
||||
ffmpegPath: 'ffmpeg',
|
||||
bypassCSP: false
|
||||
};
|
||||
@@ -75,15 +72,18 @@ exports.Events = {
|
||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||
MESSAGE_ACK: 'message_ack',
|
||||
MESSAGE_REACTION: 'message_reaction',
|
||||
MEDIA_UPLOADED: 'media_uploaded',
|
||||
GROUP_JOIN: 'group_join',
|
||||
GROUP_LEAVE: 'group_leave',
|
||||
GROUP_UPDATE: 'group_update',
|
||||
QR_RECEIVED: 'qr',
|
||||
LOADING_SCREEN: 'loading_screen',
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery',
|
||||
INCOMING_CALL: 'incoming_call'
|
||||
INCOMING_CALL: 'incoming_call',
|
||||
REMOTE_SESSION_SAVED: 'remote_session_saved'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -108,8 +108,25 @@ exports.MessageTypes = {
|
||||
UNKNOWN: 'unknown',
|
||||
GROUP_INVITE: 'groups_v4_invite',
|
||||
LIST: 'list',
|
||||
LIST_RESPONSE: 'list_response',
|
||||
BUTTONS_RESPONSE: 'buttons_response',
|
||||
PAYMENT: 'payment'
|
||||
PAYMENT: 'payment',
|
||||
BROADCAST_NOTIFICATION: 'broadcast_notification',
|
||||
CALL_LOG: 'call_log',
|
||||
CIPHERTEXT: 'ciphertext',
|
||||
DEBUG: 'debug',
|
||||
E2E_NOTIFICATION: 'e2e_notification',
|
||||
GP2: 'gp2',
|
||||
GROUP_NOTIFICATION: 'group_notification',
|
||||
HSM: 'hsm',
|
||||
INTERACTIVE: 'interactive',
|
||||
NATIVE_FLOW: 'native_flow',
|
||||
NOTIFICATION: 'notification',
|
||||
NOTIFICATION_TEMPLATE: 'notification_template',
|
||||
OVERSIZED: 'oversized',
|
||||
PROTOCOL: 'protocol',
|
||||
REACTION: 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -183,7 +200,7 @@ exports.MessageAck = {
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: util/InterfaceController.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -160,7 +160,7 @@ module.exports = InterfaceController;
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta name="generator" content="JSDoc 3.6.7">
|
||||
<meta name="generator" content="JSDoc 3.6.11">
|
||||
<meta charset="utf-8">
|
||||
<title>whatsapp-web.js 1.15.4 » Source: util/Util.js</title>
|
||||
<title>whatsapp-web.js 1.18.3 » 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>15.<wbr>4</a>
|
||||
<a href="index.html" class="jsdoc-navbar-package-name">whatsapp-web.<wbr>js 1.<wbr>18.<wbr>3</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
@@ -31,21 +31,18 @@
|
||||
<article>
|
||||
<pre class="prettyprint linenums"><code>'use strict';
|
||||
|
||||
const sharp = require('sharp');
|
||||
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);
|
||||
|
||||
/**
|
||||
* Utility methods
|
||||
*/
|
||||
class Util {
|
||||
|
||||
constructor() {
|
||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||
}
|
||||
@@ -54,7 +51,7 @@ class Util {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i &lt; length; i++ ) {
|
||||
for (var i = 0; i &lt; length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
@@ -86,33 +83,19 @@ class Util {
|
||||
*
|
||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatImageToWebpSticker(media) {
|
||||
static async formatImageToWebpSticker(media, pupPage) {
|
||||
if (!media.mimetype.includes('image'))
|
||||
throw new Error('media is not a image');
|
||||
|
||||
|
||||
if (media.mimetype.includes('webp')) {
|
||||
return media;
|
||||
}
|
||||
|
||||
const buff = Buffer.from(media.data, 'base64');
|
||||
|
||||
let sharpImg = sharp(buff);
|
||||
sharpImg = sharpImg.webp();
|
||||
|
||||
sharpImg = sharpImg.resize(512, 512, {
|
||||
fit: 'contain',
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
});
|
||||
|
||||
let webpBase64 = (await sharpImg.toBuffer()).toString('base64');
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: webpBase64,
|
||||
filename: media.filename,
|
||||
};
|
||||
|
||||
return pupPage.evaluate((media) => {
|
||||
return window.WWebJS.toStickerData(media);
|
||||
}, media);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats a video to webp
|
||||
* @param {MessageMedia} media
|
||||
@@ -122,14 +105,14 @@ class Util {
|
||||
static async formatVideoToWebpSticker(media) {
|
||||
if (!media.mimetype.includes('video'))
|
||||
throw new Error('media is not a video');
|
||||
|
||||
|
||||
const videoType = media.mimetype.split('/')[1];
|
||||
|
||||
const tempFile = path.join(
|
||||
tmpdir(),
|
||||
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
||||
);
|
||||
|
||||
|
||||
const stream = new (require('stream').Readable)();
|
||||
const buffer = Buffer.from(
|
||||
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
||||
@@ -166,17 +149,17 @@ class Util {
|
||||
.toFormat('webp')
|
||||
.save(tempFile);
|
||||
});
|
||||
|
||||
|
||||
const data = await fs.readFile(tempFile, 'base64');
|
||||
await fs.unlink(tempFile);
|
||||
|
||||
return {
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: data,
|
||||
filename: media.filename,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sticker metadata.
|
||||
* @typedef {Object} StickerMetadata
|
||||
@@ -192,14 +175,14 @@ class Util {
|
||||
*
|
||||
* @returns {Promise&lt;MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatToWebpSticker(media, metadata) {
|
||||
static async formatToWebpSticker(media, metadata, pupPage) {
|
||||
let webpMedia;
|
||||
|
||||
if (media.mimetype.includes('image'))
|
||||
webpMedia = await this.formatImageToWebpSticker(media);
|
||||
else if (media.mimetype.includes('video'))
|
||||
if (media.mimetype.includes('image'))
|
||||
webpMedia = await this.formatImageToWebpSticker(media, pupPage);
|
||||
else if (media.mimetype.includes('video'))
|
||||
webpMedia = await this.formatVideoToWebpSticker(media);
|
||||
else
|
||||
else
|
||||
throw new Error('Invalid media format');
|
||||
|
||||
if (metadata.name || metadata.author) {
|
||||
@@ -242,7 +225,7 @@ module.exports = Util;
|
||||
<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 January 25, 2022.
|
||||
Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc</a> 3.6.11 on November 13, 2022.
|
||||
</p>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
50
example.js
50
example.js
@@ -1,42 +1,27 @@
|
||||
const fs = require('fs');
|
||||
const { Client, Location, List, Buttons } = require('./index');
|
||||
const { Client, Location, List, Buttons, LocalAuth} = require('./index');
|
||||
|
||||
const SESSION_FILE_PATH = './session.json';
|
||||
let sessionCfg;
|
||||
if (fs.existsSync(SESSION_FILE_PATH)) {
|
||||
sessionCfg = require(SESSION_FILE_PATH);
|
||||
}
|
||||
|
||||
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`
|
||||
// }
|
||||
// }
|
||||
const client = new Client({
|
||||
authStrategy: new LocalAuth(),
|
||||
puppeteer: { headless: false }
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
|
||||
client.on('loading_screen', (percent, message) => {
|
||||
console.log('LOADING SCREEN', percent, message);
|
||||
});
|
||||
|
||||
client.on('qr', (qr) => {
|
||||
// NOTE: This event will not be fired if a session is specified.
|
||||
console.log('QR RECEIVED', qr);
|
||||
});
|
||||
|
||||
client.on('authenticated', (session) => {
|
||||
console.log('AUTHENTICATED', session);
|
||||
sessionCfg=session;
|
||||
fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), function (err) {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
client.on('authenticated', () => {
|
||||
console.log('AUTHENTICATED');
|
||||
});
|
||||
|
||||
client.on('auth_failure', msg => {
|
||||
// Fired if session restore was unsuccessfull
|
||||
// Fired if session restore was unsuccessful
|
||||
console.error('AUTHENTICATION FAILURE', msg);
|
||||
});
|
||||
|
||||
@@ -124,9 +109,8 @@ client.on('message', async msg => {
|
||||
client.sendMessage(msg.from, `
|
||||
*Connection info*
|
||||
User name: ${info.pushname}
|
||||
My number: ${info.me.user}
|
||||
My number: ${info.wid.user}
|
||||
Platform: ${info.platform}
|
||||
WhatsApp version: ${info.phone.wa_version}
|
||||
`);
|
||||
} else if (msg.body === '!mediainfo' && msg.hasMedia) {
|
||||
const attachmentData = await msg.downloadMedia();
|
||||
@@ -211,6 +195,8 @@ client.on('message', async msg => {
|
||||
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);
|
||||
} else if (msg.body === '!reaction') {
|
||||
msg.react('👍');
|
||||
}
|
||||
});
|
||||
|
||||
@@ -267,12 +253,6 @@ client.on('group_update', (notification) => {
|
||||
console.log('update', notification);
|
||||
});
|
||||
|
||||
client.on('change_battery', (batteryInfo) => {
|
||||
// Battery percentage for attached device has changed
|
||||
const { battery, plugged } = batteryInfo;
|
||||
console.log(`Battery: ${battery}% - Charging? ${plugged}`);
|
||||
});
|
||||
|
||||
client.on('change_state', state => {
|
||||
console.log('CHANGE STATE', state );
|
||||
});
|
||||
|
||||
243
index.d.ts
vendored
243
index.d.ts
vendored
@@ -1,7 +1,7 @@
|
||||
|
||||
import { EventEmitter } from 'events'
|
||||
import { RequestInit } from 'node-fetch'
|
||||
import puppeteer from 'puppeteer'
|
||||
import * as puppeteer from 'puppeteer'
|
||||
|
||||
declare namespace WAWebJS {
|
||||
|
||||
@@ -84,6 +84,9 @@ declare namespace WAWebJS {
|
||||
/** Returns the contact ID's profile picture URL, if privacy settings allow it */
|
||||
getProfilePicUrl(contactId: string): Promise<string>
|
||||
|
||||
/** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
|
||||
getCommonGroups(contactId: string): Promise<ChatId[]>
|
||||
|
||||
/** Gets the current connection state for the client */
|
||||
getState(): Promise<WAState>
|
||||
|
||||
@@ -111,13 +114,16 @@ 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>
|
||||
|
||||
/** Marks the client as offline */
|
||||
sendPresenceUnavailable(): Promise<void>
|
||||
|
||||
/** Mark as seen for the Chat */
|
||||
sendSeen(chatId: string): Promise<boolean>
|
||||
|
||||
@@ -134,8 +140,8 @@ declare namespace WAWebJS {
|
||||
* Sets the current user's display name
|
||||
* @param displayName New display name
|
||||
*/
|
||||
setDisplayName(displayName: string): Promise<void>
|
||||
|
||||
setDisplayName(displayName: string): Promise<boolean>
|
||||
|
||||
/** Changes and returns the archive state of the Chat */
|
||||
unarchiveChat(chatId: string): Promise<boolean>
|
||||
|
||||
@@ -150,11 +156,16 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Emitted when authentication is successful */
|
||||
on(event: 'authenticated', listener: (
|
||||
/** Object containing session information. Can be used to restore the session */
|
||||
session: ClientSession
|
||||
/**
|
||||
* Object containing session information, when using LegacySessionAuth. Can be used to restore the session
|
||||
*/
|
||||
session?: ClientSession
|
||||
) => void): this
|
||||
|
||||
/** Emitted when the battery percentage for the attached device changes */
|
||||
/**
|
||||
* Emitted when the battery percentage for the attached device changes
|
||||
* @deprecated
|
||||
*/
|
||||
on(event: 'change_battery', listener: (batteryInfo: BatteryInfo) => void): this
|
||||
|
||||
/** Emitted when the connection state changes */
|
||||
@@ -166,7 +177,7 @@ declare namespace WAWebJS {
|
||||
/** Emitted when the client has been disconnected */
|
||||
on(event: 'disconnected', listener: (
|
||||
/** reason that caused the disconnect */
|
||||
reason: WAState | "NAVIGATED"
|
||||
reason: WAState | "NAVIGATION"
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a user joins the chat via invite link or is added by an admin */
|
||||
@@ -230,6 +241,15 @@ declare namespace WAWebJS {
|
||||
message: Message
|
||||
) => void): this
|
||||
|
||||
/** Emitted when a reaction is sent, received, updated or removed */
|
||||
on(event: 'message_reaction', listener: (
|
||||
/** The reaction object */
|
||||
reaction: Reaction
|
||||
) => void): this
|
||||
|
||||
/** Emitted when loading screen is appearing */
|
||||
on(event: 'loading_screen', listener: (percent: string, message: string) => void): this
|
||||
|
||||
/** Emitted when the QR code is received */
|
||||
on(event: 'qr', listener: (
|
||||
/** qr code string
|
||||
@@ -245,6 +265,9 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Emitted when the client has initialized and is ready to receive messages */
|
||||
on(event: 'ready', listener: () => void): this
|
||||
|
||||
/** Emitted when the RemoteAuth session is saved successfully on the external Database */
|
||||
on(event: 'remote_session_saved', listener: () => void): this
|
||||
}
|
||||
|
||||
/** Current connection information */
|
||||
@@ -256,7 +279,10 @@ declare namespace WAWebJS {
|
||||
me: ContactId
|
||||
/** Current user ID */
|
||||
wid: ContactId
|
||||
/** Information about the phone this client is connected to */
|
||||
/**
|
||||
* Information about the phone this client is connected to. Not available in multi-device.
|
||||
* @deprecated
|
||||
*/
|
||||
phone: ClientInfoPhone
|
||||
/** Platform the phone is running on */
|
||||
platform: string
|
||||
@@ -267,7 +293,10 @@ declare namespace WAWebJS {
|
||||
getBatteryStatus: () => Promise<BatteryInfo>
|
||||
}
|
||||
|
||||
/** Information about the phone this client is connected to */
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
* @deprecated
|
||||
*/
|
||||
export interface ClientInfoPhone {
|
||||
/** WhatsApp Version running on the phone */
|
||||
wa_version: string
|
||||
@@ -284,23 +313,22 @@ declare namespace WAWebJS {
|
||||
/** Options for initializing the whatsapp client */
|
||||
export interface ClientOptions {
|
||||
/** Timeout for authentication selector in puppeteer
|
||||
* @default 45000 */
|
||||
* @default 0 */
|
||||
authTimeoutMs?: number,
|
||||
/** Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/ */
|
||||
puppeteer?: puppeteer.LaunchOptions & puppeteer.BrowserLaunchArgumentOptions & puppeteer.BrowserConnectOptions
|
||||
/** Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||
* @default 20000 */
|
||||
qrRefreshIntervalMs?: number
|
||||
/** Timeout for qr code selector in puppeteer
|
||||
* @default 45000 */
|
||||
qrTimeoutMs?: number,
|
||||
/** How many times should the qrcode be refreshed before giving up
|
||||
puppeteer?: puppeteer.PuppeteerNodeLaunchOptions & puppeteer.ConnectOptions
|
||||
/** Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used. */
|
||||
authStrategy?: AuthStrategy,
|
||||
/** How many times should the qrcode be refreshed before giving up
|
||||
* @default 0 (disabled) */
|
||||
qrMaxRetries?: number,
|
||||
/** Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @default false */
|
||||
/**
|
||||
* @deprecated This option should be set directly on the LegacySessionAuth
|
||||
*/
|
||||
restartOnAuthFail?: boolean
|
||||
/** Whatsapp session to restore. If not set, will start a new session */
|
||||
/**
|
||||
* @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
|
||||
*/
|
||||
session?: ClientSession
|
||||
/** If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||
* @default false */
|
||||
@@ -316,7 +344,81 @@ declare namespace WAWebJS {
|
||||
ffmpegPath?: string
|
||||
}
|
||||
|
||||
/** Represents a Whatsapp client session */
|
||||
/**
|
||||
* Base class which all authentication strategies extend
|
||||
*/
|
||||
export abstract class AuthStrategy {
|
||||
setup: (client: Client) => void;
|
||||
beforeBrowserInitialized: () => Promise<void>;
|
||||
afterBrowserInitialized: () => Promise<void>;
|
||||
onAuthenticationNeeded: () => Promise<{
|
||||
failed?: boolean;
|
||||
restart?: boolean;
|
||||
failureEventPayload?: any
|
||||
}>;
|
||||
getAuthEventPayload: () => Promise<any>;
|
||||
afterAuthReady: () => Promise<void>;
|
||||
disconnect: () => Promise<void>;
|
||||
destroy: () => Promise<void>;
|
||||
logout: () => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
* No session restoring functionality
|
||||
* Will need to authenticate via QR code every time
|
||||
*/
|
||||
export class NoAuth extends AuthStrategy {}
|
||||
|
||||
/**
|
||||
* Local directory-based authentication
|
||||
*/
|
||||
export class LocalAuth extends AuthStrategy {
|
||||
public clientId?: string;
|
||||
public dataPath?: string;
|
||||
constructor(options?: {
|
||||
clientId?: string,
|
||||
dataPath?: string
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote-based authentication
|
||||
*/
|
||||
export class RemoteAuth extends AuthStrategy {
|
||||
public clientId?: string;
|
||||
public dataPath?: string;
|
||||
constructor(options?: {
|
||||
store: Store,
|
||||
clientId?: string,
|
||||
dataPath?: string,
|
||||
backupSyncIntervalMs: number
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remote store interface
|
||||
*/
|
||||
export interface Store {
|
||||
sessionExists: (options: { session: string }) => Promise<boolean> | boolean,
|
||||
delete: (options: { session: string }) => Promise<any> | any,
|
||||
save: (options: { session: string }) => Promise<any> | any,
|
||||
extract: (options: { session: string, path: string }) => Promise<any> | any,
|
||||
}
|
||||
|
||||
/**
|
||||
* Legacy session auth strategy
|
||||
* Not compatible with multi-device accounts.
|
||||
*/
|
||||
export class LegacySessionAuth extends AuthStrategy {
|
||||
constructor(options?: {
|
||||
session?: ClientSession,
|
||||
restartOnAuthFail?: boolean,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a WhatsApp client session
|
||||
*/
|
||||
export interface ClientSession {
|
||||
WABrowserId: string,
|
||||
WASecretBundle: string,
|
||||
@@ -324,6 +426,9 @@ declare namespace WAWebJS {
|
||||
WAToken2: string,
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
export interface BatteryInfo {
|
||||
/** The current battery percentage */
|
||||
battery: number,
|
||||
@@ -397,9 +502,11 @@ declare namespace WAWebJS {
|
||||
GROUP_LEAVE = 'group_leave',
|
||||
GROUP_UPDATE = 'group_update',
|
||||
QR_RECEIVED = 'qr',
|
||||
LOADING_SCREEN = 'loading_screen',
|
||||
DISCONNECTED = 'disconnected',
|
||||
STATE_CHANGED = 'change_state',
|
||||
BATTERY_CHANGED = 'change_battery',
|
||||
REMOTE_SESSION_SAVED = 'remote_session_saved'
|
||||
}
|
||||
|
||||
/** Group notification types */
|
||||
@@ -443,6 +550,25 @@ declare namespace WAWebJS {
|
||||
PAYMENT = 'payment',
|
||||
UNKNOWN = 'unknown',
|
||||
GROUP_INVITE = 'groups_v4_invite',
|
||||
LIST = 'list',
|
||||
LIST_RESPONSE = 'list_response',
|
||||
BUTTONS_RESPONSE = 'buttons_response',
|
||||
BROADCAST_NOTIFICATION = 'broadcast_notification',
|
||||
CALL_LOG = 'call_log',
|
||||
CIPHERTEXT = 'ciphertext',
|
||||
DEBUG = 'debug',
|
||||
E2E_NOTIFICATION = 'e2e_notification',
|
||||
GP2 = 'gp2',
|
||||
GROUP_NOTIFICATION = 'group_notification',
|
||||
HSM = 'hsm',
|
||||
INTERACTIVE = 'interactive',
|
||||
NATIVE_FLOW = 'native_flow',
|
||||
NOTIFICATION = 'notification',
|
||||
NOTIFICATION_TEMPLATE = 'notification_template',
|
||||
OVERSIZED = 'oversized',
|
||||
PROTOCOL = 'protocol',
|
||||
REACTION = 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY = 'template_button_reply',
|
||||
}
|
||||
|
||||
/** Client status */
|
||||
@@ -519,6 +645,8 @@ declare namespace WAWebJS {
|
||||
ack: MessageAck,
|
||||
/** If the message was sent to a group, this field will contain the user that sent the message. */
|
||||
author?: string,
|
||||
/** String that represents from which device type the message was sent */
|
||||
deviceType: string,
|
||||
/** Message content */
|
||||
body: string,
|
||||
/** Indicates if the message was a broadcast */
|
||||
@@ -527,6 +655,8 @@ declare namespace WAWebJS {
|
||||
isStatus: boolean,
|
||||
/** Indicates if the message is a Gif */
|
||||
isGif: boolean,
|
||||
/** Indicates if the message will disappear after it expires */
|
||||
isEphemeral: boolean,
|
||||
/** ID for the Chat that this message was sent to, except if the message was sent by the current user */
|
||||
from: string,
|
||||
/** Indicates if the message was sent by the current user */
|
||||
@@ -535,6 +665,8 @@ declare namespace WAWebJS {
|
||||
hasMedia: boolean,
|
||||
/** Indicates if the message was sent as a reply to another message */
|
||||
hasQuotedMsg: boolean,
|
||||
/** Indicates the duration of the message in seconds */
|
||||
duration: string,
|
||||
/** ID that represents the message */
|
||||
id: MessageId,
|
||||
/** Indicates if the message was forwarded */
|
||||
@@ -587,11 +719,18 @@ declare namespace WAWebJS {
|
||||
selectedButtonId?: string,
|
||||
/** Selected list row ID */
|
||||
selectedRowId?: string,
|
||||
/** Returns message in a raw format */
|
||||
rawData: object,
|
||||
/*
|
||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
||||
*/
|
||||
reload: () => Promise<Message>,
|
||||
/** 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 */
|
||||
/** Downloads and returns the attached message media */
|
||||
downloadMedia: () => Promise<MessageMedia>,
|
||||
/** Returns the Chat this message was sent in */
|
||||
getChat: () => Promise<Chat>,
|
||||
@@ -607,24 +746,26 @@ declare namespace WAWebJS {
|
||||
* If not, it will send the message in the same Chat as the original message was sent.
|
||||
*/
|
||||
reply: (content: MessageContent, chatId?: string, options?: MessageSendOptions) => Promise<Message>,
|
||||
/** React to this message with an emoji*/
|
||||
react: (reaction: string) => Promise<void>,
|
||||
/**
|
||||
* Forwards this message to another chat
|
||||
* Forwards this message to another chat (that you chatted before, otherwise it will fail)
|
||||
*/
|
||||
forward: (chat: Chat | string) => Promise<void>,
|
||||
/** Star this message */
|
||||
star: () => Promise<void>,
|
||||
/** Unstar this message */
|
||||
unstar: () => Promise<void>,
|
||||
/** Get information about message delivery statuso */
|
||||
/** Get information about message delivery status */
|
||||
getInfo: () => Promise<MessageInfo | null>,
|
||||
/**
|
||||
* Gets the order associated with a given message
|
||||
*/
|
||||
getOrder: () => Order,
|
||||
getOrder: () => Promise<Order>,
|
||||
/**
|
||||
* Gets the payment details associated with a given message
|
||||
*/
|
||||
getPayment: () => Payment,
|
||||
getPayment: () => Promise<Payment>,
|
||||
}
|
||||
|
||||
/** ID that represents a message */
|
||||
@@ -658,7 +799,7 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Options for sending a message */
|
||||
export interface MessageSendOptions {
|
||||
/** Show links preview */
|
||||
/** Show links preview. Has no effect on multi-device accounts. */
|
||||
linkPreview?: boolean
|
||||
/** Send audio as voice message */
|
||||
sendAudioAsVoice?: boolean
|
||||
@@ -705,13 +846,16 @@ declare namespace WAWebJS {
|
||||
data: string
|
||||
/** Document file name. Value can be null */
|
||||
filename?: string | null
|
||||
/** Document file size in bytes. Value can be null. */
|
||||
filesize?: number | null
|
||||
|
||||
/**
|
||||
* @param {string} mimetype MIME type of the attachment
|
||||
* @param {string} data Base64-encoded data of the file
|
||||
* @param {?string} filename Document file name. Value can be null
|
||||
* @param {?number} filesize Document file size in bytes. Value can be null.
|
||||
*/
|
||||
constructor(mimetype: string, data: string, filename?: string | null)
|
||||
constructor(mimetype: string, data: string, filename?: string | null, filesize?: number | null)
|
||||
|
||||
/** Creates a MessageMedia instance from a local file path */
|
||||
static fromFilePath: (filePath: string) => MessageMedia
|
||||
@@ -813,6 +957,9 @@ declare namespace WAWebJS {
|
||||
|
||||
/** Gets the Contact's current "about" info. Returns null if you don't have permission to read their status. */
|
||||
getAbout: () => Promise<string | null>,
|
||||
|
||||
/** Gets the Contact's common groups with you. Returns empty array if you don't have any common group. */
|
||||
getCommonGroups: () => Promise<ChatId[]>
|
||||
|
||||
}
|
||||
|
||||
@@ -910,12 +1057,15 @@ declare namespace WAWebJS {
|
||||
|
||||
export interface MessageSearchOptions {
|
||||
/**
|
||||
* The amount of messages to return.
|
||||
* The amount of messages to return. If no limit is specified, the available messages will be returned.
|
||||
* Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation.
|
||||
* Set this to Infinity to load all messages.
|
||||
* @default 50
|
||||
*/
|
||||
limit?: number
|
||||
/**
|
||||
* Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
|
||||
*/
|
||||
fromMe?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -957,7 +1107,7 @@ declare namespace WAWebJS {
|
||||
}
|
||||
|
||||
/** Promotes or demotes participants by IDs to regular users or admins */
|
||||
export type ChangeParticipantsPermisions =
|
||||
export type ChangeParticipantsPermissions =
|
||||
(participantIds: Array<string>) => Promise<{ status: number }>
|
||||
|
||||
/** Adds or removes a list of participants by ID to the group */
|
||||
@@ -987,13 +1137,13 @@ declare namespace WAWebJS {
|
||||
/** Removes a list of participants by ID to the group */
|
||||
removeParticipants: ChangeGroupParticipants;
|
||||
/** Promotes participants by IDs to admins */
|
||||
promoteParticipants: ChangeParticipantsPermisions;
|
||||
promoteParticipants: ChangeParticipantsPermissions;
|
||||
/** Demotes participants by IDs to regular users */
|
||||
demoteParticipants: ChangeParticipantsPermisions;
|
||||
demoteParticipants: ChangeParticipantsPermissions;
|
||||
/** Updates the group subject */
|
||||
setSubject: (subject: string) => Promise<void>;
|
||||
setSubject: (subject: string) => Promise<boolean>;
|
||||
/** Updates the group description */
|
||||
setDescription: (description: string) => Promise<void>;
|
||||
setDescription: (description: string) => Promise<boolean>;
|
||||
/** Updates the group settings to only allow admins to send messages
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
@@ -1189,14 +1339,27 @@ declare namespace WAWebJS {
|
||||
constructor(body: string, buttonText: string, sections: Array<any>, title?: string | null, footer?: string | null)
|
||||
}
|
||||
|
||||
/** Message type buttons */
|
||||
/** Message type Buttons */
|
||||
export class Buttons {
|
||||
body: string | MessageMedia
|
||||
buttons: Array<Array<string>>
|
||||
buttons: Array<{ buttonId: string; buttonText: {displayText: string}; type: number }>
|
||||
title?: string | null
|
||||
footer?: string | null
|
||||
|
||||
constructor(body: string, buttons: Array<Array<string>>, title?: string | null, footer?: string | null)
|
||||
constructor(body: string, buttons: Array<{ id?: string; body: string }>, title?: string | null, footer?: string | null)
|
||||
}
|
||||
|
||||
/** Message type Reaction */
|
||||
export class Reaction {
|
||||
id: MessageId
|
||||
orphan: number
|
||||
orphanReason?: string
|
||||
timestamp: number
|
||||
reaction: string
|
||||
read: boolean
|
||||
msgId: MessageId
|
||||
senderId: string
|
||||
ack?: number
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
7
index.js
7
index.js
@@ -21,5 +21,12 @@ module.exports = {
|
||||
ProductMetadata: require('./src/structures/ProductMetadata'),
|
||||
List: require('./src/structures/List'),
|
||||
Buttons: require('./src/structures/Buttons'),
|
||||
|
||||
// Auth Strategies
|
||||
NoAuth: require('./src/authStrategies/NoAuth'),
|
||||
LocalAuth: require('./src/authStrategies/LocalAuth'),
|
||||
RemoteAuth: require('./src/authStrategies/RemoteAuth'),
|
||||
LegacySessionAuth: require('./src/authStrategies/LegacySessionAuth'),
|
||||
|
||||
...Constants
|
||||
};
|
||||
|
||||
20
package.json
20
package.json
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "whatsapp-web.js",
|
||||
"version": "1.15.4",
|
||||
"version": "1.18.3",
|
||||
"description": "Library for interacting with the WhatsApp Web API ",
|
||||
"main": "./index.js",
|
||||
"typings": "./index.d.ts",
|
||||
"scripts": {
|
||||
"test": "mocha tests",
|
||||
"test": "mocha tests --recursive --timeout 5000",
|
||||
"test-single": "mocha",
|
||||
"shell": "node --experimental-repl-await ./shell.js",
|
||||
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose"
|
||||
},
|
||||
@@ -34,21 +35,26 @@
|
||||
"mime": "^3.0.0",
|
||||
"node-fetch": "^2.6.5",
|
||||
"node-webpmux": "^3.1.0",
|
||||
"puppeteer": "^13.0.0",
|
||||
"sharp": "^0.28.3"
|
||||
"puppeteer": "^13.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node-fetch": "^2.5.12",
|
||||
"chai": "^4.3.4",
|
||||
"dotenv": "^10.0.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"dotenv": "^16.0.0",
|
||||
"eslint": "^8.4.1",
|
||||
"eslint-plugin-mocha": "^9.0.0",
|
||||
"eslint-plugin-mocha": "^10.0.3",
|
||||
"jsdoc": "^3.6.4",
|
||||
"jsdoc-baseline": "^0.1.5",
|
||||
"mocha": "^9.0.2",
|
||||
"sinon": "^12.0.1"
|
||||
"sinon": "^13.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"archiver": "^5.3.1",
|
||||
"fs-extra": "^10.1.0",
|
||||
"unzipper": "^0.10.11"
|
||||
}
|
||||
}
|
||||
|
||||
17
shell.js
17
shell.js
@@ -2,24 +2,17 @@
|
||||
* ==== wwebjs-shell ====
|
||||
* Used for quickly testing library features
|
||||
*
|
||||
* Running `npm run shell` will start WhatsApp Web in headless mode
|
||||
* Running `npm run shell` will start WhatsApp Web with headless=false
|
||||
* and then drop you into Node REPL with `client` in its context.
|
||||
*/
|
||||
|
||||
const repl = require('repl');
|
||||
const fs = require('fs');
|
||||
|
||||
const { Client } = require('./index');
|
||||
|
||||
const SESSION_FILE_PATH = './session.json';
|
||||
let sessionCfg;
|
||||
if (fs.existsSync(SESSION_FILE_PATH)) {
|
||||
sessionCfg = require(SESSION_FILE_PATH);
|
||||
}
|
||||
const { Client, LocalAuth } = require('./index');
|
||||
|
||||
const client = new Client({
|
||||
puppeteer: { headless: false },
|
||||
session: sessionCfg
|
||||
authStrategy: new LocalAuth()
|
||||
});
|
||||
|
||||
console.log('Initializing...');
|
||||
@@ -30,6 +23,10 @@ client.on('qr', () => {
|
||||
console.log('Please scan the QR code on the browser.');
|
||||
});
|
||||
|
||||
client.on('authenticated', (session) => {
|
||||
console.log(JSON.stringify(session));
|
||||
});
|
||||
|
||||
client.on('ready', () => {
|
||||
const shell = repl.start('wwebjs> ');
|
||||
shell.context.client = client;
|
||||
|
||||
554
src/Client.js
554
src/Client.js
@@ -3,7 +3,6 @@
|
||||
const EventEmitter = require('events');
|
||||
const puppeteer = require('puppeteer');
|
||||
const moduleRaid = require('@pedroslopez/moduleraid/moduleraid');
|
||||
const jsQR = require('jsqr');
|
||||
|
||||
const Util = require('./util/Util');
|
||||
const InterfaceController = require('./util/InterfaceController');
|
||||
@@ -11,22 +10,20 @@ 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, Call, Buttons, List} = require('./structures');
|
||||
const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification, Label, Call, Buttons, List, Reaction } = require('./structures');
|
||||
const LegacySessionAuth = require('./authStrategies/LegacySessionAuth');
|
||||
const NoAuth = require('./authStrategies/NoAuth');
|
||||
|
||||
/**
|
||||
* Starting point for interacting with the WhatsApp Web API
|
||||
* @extends {EventEmitter}
|
||||
* @param {object} options - Client options
|
||||
* @param {AuthStrategy} options.authStrategy - Determines how to save and restore sessions. Will use LegacySessionAuth if options.session is set. Otherwise, NoAuth will be used.
|
||||
* @param {number} options.authTimeoutMs - Timeout for authentication selector in puppeteer
|
||||
* @param {object} options.puppeteer - Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/
|
||||
* @param {number} options.qrRefreshIntervalMs - Refresh interval for qr code (how much time to wait before checking if the qr code has changed)
|
||||
* @param {number} options.qrTimeoutMs - Timeout for qr code selector in puppeteer
|
||||
* @param {number} options.qrMaxRetries - How many times should the qrcode be refreshed before giving up
|
||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||
* @param {string} options.session.WABrowserId
|
||||
* @param {string} options.session.WASecretBundle
|
||||
* @param {string} options.session.WAToken1
|
||||
* @param {string} options.session.WAToken2
|
||||
* @param {string} options.restartOnAuthFail - @deprecated This option should be set directly on the LegacySessionAuth.
|
||||
* @param {object} options.session - @deprecated Only here for backwards-compatibility. You should move to using LocalAuth, or set the authStrategy to LegacySessionAuth explicitly.
|
||||
* @param {number} options.takeoverOnConflict - If another whatsapp web session is detected (another browser), take over the session in the current browser
|
||||
* @param {number} options.takeoverTimeoutMs - How much time to wait before taking over the session
|
||||
* @param {string} options.userAgent - User agent to use in puppeteer
|
||||
@@ -48,13 +45,33 @@ const { ClientInfo, Message, MessageMedia, Contact, Location, GroupNotification
|
||||
* @fires Client#group_update
|
||||
* @fires Client#disconnected
|
||||
* @fires Client#change_state
|
||||
* @fires Client#change_battery
|
||||
*/
|
||||
class Client extends EventEmitter {
|
||||
constructor(options = {}) {
|
||||
super();
|
||||
|
||||
this.options = Util.mergeDefault(DefaultOptions, options);
|
||||
|
||||
if(!this.options.authStrategy) {
|
||||
if(Object.prototype.hasOwnProperty.call(this.options, 'session')) {
|
||||
process.emitWarning(
|
||||
'options.session is deprecated and will be removed in a future release due to incompatibility with multi-device. ' +
|
||||
'Use the LocalAuth authStrategy, don\'t pass in a session as an option, or suppress this warning by using the LegacySessionAuth strategy explicitly (see https://wwebjs.dev/guide/authentication.html#legacysessionauth-strategy).',
|
||||
'DeprecationWarning'
|
||||
);
|
||||
|
||||
this.authStrategy = new LegacySessionAuth({
|
||||
session: this.options.session,
|
||||
restartOnAuthFail: this.options.restartOnAuthFail
|
||||
});
|
||||
} else {
|
||||
this.authStrategy = new NoAuth();
|
||||
}
|
||||
} else {
|
||||
this.authStrategy = this.options.authStrategy;
|
||||
}
|
||||
|
||||
this.authStrategy.setup(this);
|
||||
|
||||
this.pupBrowser = null;
|
||||
this.pupPage = null;
|
||||
@@ -67,95 +84,131 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async initialize() {
|
||||
let [browser, page] = [null, null];
|
||||
|
||||
if(this.options.puppeteer && this.options.puppeteer.browserWSEndpoint) {
|
||||
browser = await puppeteer.connect(this.options.puppeteer);
|
||||
|
||||
await this.authStrategy.beforeBrowserInitialized();
|
||||
|
||||
const puppeteerOpts = this.options.puppeteer;
|
||||
if (puppeteerOpts && puppeteerOpts.browserWSEndpoint) {
|
||||
browser = await puppeteer.connect(puppeteerOpts);
|
||||
page = await browser.newPage();
|
||||
} else {
|
||||
browser = await puppeteer.launch(this.options.puppeteer);
|
||||
const browserArgs = [...(puppeteerOpts.args || [])];
|
||||
if(!browserArgs.find(arg => arg.includes('--user-agent'))) {
|
||||
browserArgs.push(`--user-agent=${this.options.userAgent}`);
|
||||
}
|
||||
|
||||
browser = await puppeteer.launch({...puppeteerOpts, args: browserArgs});
|
||||
page = (await browser.pages())[0];
|
||||
}
|
||||
|
||||
page.setUserAgent(this.options.userAgent);
|
||||
}
|
||||
|
||||
await page.setUserAgent(this.options.userAgent);
|
||||
if (this.options.bypassCSP) await page.setBypassCSP(true);
|
||||
|
||||
this.pupBrowser = browser;
|
||||
this.pupPage = page;
|
||||
|
||||
// remember me
|
||||
await page.evaluateOnNewDocument(() => {
|
||||
localStorage.setItem('remember-me', 'true');
|
||||
});
|
||||
|
||||
if (this.options.session) {
|
||||
await page.evaluateOnNewDocument(
|
||||
session => {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
||||
localStorage.setItem('WAToken1', session.WAToken1);
|
||||
localStorage.setItem('WAToken2', session.WAToken2);
|
||||
}, this.options.session);
|
||||
}
|
||||
|
||||
if(this.options.bypassCSP) {
|
||||
await page.setBypassCSP(true);
|
||||
}
|
||||
await this.authStrategy.afterBrowserInitialized();
|
||||
|
||||
await page.goto(WhatsWebURL, {
|
||||
waitUntil: 'load',
|
||||
timeout: 0,
|
||||
referer: 'https://whatsapp.com/'
|
||||
});
|
||||
|
||||
const KEEP_PHONE_CONNECTED_IMG_SELECTOR = '[data-icon="intro-md-beta-logo-dark"], [data-icon="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
await page.evaluate(`function getElementByXpath(path) {
|
||||
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
|
||||
}`);
|
||||
|
||||
if (this.options.session) {
|
||||
// Check if session restore was successfull
|
||||
try {
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: this.options.authTimeoutMs });
|
||||
} catch (err) {
|
||||
if (err.name === 'TimeoutError') {
|
||||
/**
|
||||
* Emitted when there has been an error while trying to restore an existing session
|
||||
* @event Client#auth_failure
|
||||
* @param {string} message
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATION_FAILURE, 'Unable to log in. Are the session details valid?');
|
||||
browser.close();
|
||||
if (this.options.restartOnAuthFail) {
|
||||
// session restore failed so try again but without session to force new authentication
|
||||
this.options.session = null;
|
||||
this.initialize();
|
||||
let lastPercent = null,
|
||||
lastPercentMessage = null;
|
||||
|
||||
await page.exposeFunction('loadingScreen', async (percent, message) => {
|
||||
if (lastPercent !== percent || lastPercentMessage !== message) {
|
||||
this.emit(Events.LOADING_SCREEN, percent, message);
|
||||
lastPercent = percent;
|
||||
lastPercentMessage = message;
|
||||
}
|
||||
});
|
||||
|
||||
await page.evaluate(
|
||||
async function (selectors) {
|
||||
var observer = new MutationObserver(function () {
|
||||
let progressBar = window.getElementByXpath(
|
||||
selectors.PROGRESS
|
||||
);
|
||||
let progressMessage = window.getElementByXpath(
|
||||
selectors.PROGRESS_MESSAGE
|
||||
);
|
||||
|
||||
if (progressBar) {
|
||||
window.loadingScreen(
|
||||
progressBar.value,
|
||||
progressMessage.innerText
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
throw err;
|
||||
observer.observe(document, {
|
||||
attributes: true,
|
||||
childList: true,
|
||||
characterData: true,
|
||||
subtree: true,
|
||||
});
|
||||
},
|
||||
{
|
||||
PROGRESS: '//*[@id=\'app\']/div/div/div[2]/progress',
|
||||
PROGRESS_MESSAGE: '//*[@id=\'app\']/div/div/div[3]',
|
||||
}
|
||||
);
|
||||
|
||||
const INTRO_IMG_SELECTOR = '[data-testid="intro-md-beta-logo-dark"], [data-testid="intro-md-beta-logo-light"], [data-asset-intro-image-light="true"], [data-asset-intro-image-dark="true"]';
|
||||
const INTRO_QRCODE_SELECTOR = 'div[data-ref] canvas';
|
||||
|
||||
// Checks which selector appears first
|
||||
const needAuthentication = await Promise.race([
|
||||
new Promise(resolve => {
|
||||
page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: this.options.authTimeoutMs })
|
||||
.then(() => resolve(false))
|
||||
.catch((err) => resolve(err));
|
||||
}),
|
||||
new Promise(resolve => {
|
||||
page.waitForSelector(INTRO_QRCODE_SELECTOR, { timeout: this.options.authTimeoutMs })
|
||||
.then(() => resolve(true))
|
||||
.catch((err) => resolve(err));
|
||||
})
|
||||
]);
|
||||
|
||||
// Checks if an error occurred on the first found selector. The second will be discarded and ignored by .race;
|
||||
if (needAuthentication instanceof Error) throw needAuthentication;
|
||||
|
||||
// Scan-qrcode selector was found. Needs authentication
|
||||
if (needAuthentication) {
|
||||
const { failed, failureEventPayload, restart } = await this.authStrategy.onAuthenticationNeeded();
|
||||
if(failed) {
|
||||
/**
|
||||
* Emitted when there has been an error while trying to restore an existing session
|
||||
* @event Client#auth_failure
|
||||
* @param {string} message
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATION_FAILURE, failureEventPayload);
|
||||
await this.destroy();
|
||||
if (restart) {
|
||||
// session restore failed so try again but without session to force new authentication
|
||||
return this.initialize();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
const QR_CONTAINER = 'div[data-ref]';
|
||||
const QR_RETRY_BUTTON = 'div[data-ref] > span > button';
|
||||
let qrRetries = 0;
|
||||
|
||||
const getQrCode = async () => {
|
||||
// Check if retry button is present
|
||||
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;
|
||||
|
||||
await page.exposeFunction('qrChanged', async (qr) => {
|
||||
/**
|
||||
* Emitted when the QR code is received
|
||||
* Emitted when a QR code is received
|
||||
* @event Client#qr
|
||||
* @param {string} qr QR Code
|
||||
*/
|
||||
this.emit(Events.QR_RECEIVED, qr);
|
||||
|
||||
if (this.options.qrMaxRetries > 0) {
|
||||
qrRetries++;
|
||||
if (qrRetries > this.options.qrMaxRetries) {
|
||||
@@ -163,53 +216,74 @@ class Client extends EventEmitter {
|
||||
await this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
getQrCode();
|
||||
this._qrRefreshInterval = setInterval(getQrCode, this.options.qrRefreshIntervalMs);
|
||||
});
|
||||
|
||||
await page.evaluate(function (selectors) {
|
||||
const qr_container = document.querySelector(selectors.QR_CONTAINER);
|
||||
window.qrChanged(qr_container.dataset.ref);
|
||||
|
||||
const obs = new MutationObserver((muts) => {
|
||||
muts.forEach(mut => {
|
||||
// Listens to qr token change
|
||||
if (mut.type === 'attributes' && mut.attributeName === 'data-ref') {
|
||||
window.qrChanged(mut.target.dataset.ref);
|
||||
} else
|
||||
// Listens to retry button, when found, click it
|
||||
if (mut.type === 'childList') {
|
||||
const retry_button = document.querySelector(selectors.QR_RETRY_BUTTON);
|
||||
if (retry_button) retry_button.click();
|
||||
}
|
||||
});
|
||||
});
|
||||
obs.observe(qr_container.parentElement, {
|
||||
subtree: true,
|
||||
childList: true,
|
||||
attributes: true,
|
||||
attributeFilter: ['data-ref'],
|
||||
});
|
||||
}, {
|
||||
QR_CONTAINER,
|
||||
QR_RETRY_BUTTON
|
||||
});
|
||||
|
||||
// Wait for code scan
|
||||
await page.waitForSelector(KEEP_PHONE_CONNECTED_IMG_SELECTOR, { timeout: 0 });
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
this._qrRefreshInterval = undefined;
|
||||
try {
|
||||
await page.waitForSelector(INTRO_IMG_SELECTOR, { timeout: 0 });
|
||||
} catch(error) {
|
||||
if (
|
||||
error.name === 'ProtocolError' &&
|
||||
error.message &&
|
||||
error.message.match(/Target closed/)
|
||||
) {
|
||||
// something has called .destroy() while waiting
|
||||
return;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await page.evaluate(ExposeStore, moduleRaid.toString());
|
||||
|
||||
// Get session tokens
|
||||
const localStorage = JSON.parse(await page.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
}));
|
||||
|
||||
const session = {
|
||||
WABrowserId: localStorage.WABrowserId,
|
||||
WASecretBundle: localStorage.WASecretBundle,
|
||||
WAToken1: localStorage.WAToken1,
|
||||
WAToken2: localStorage.WAToken2
|
||||
};
|
||||
const authEventPayload = await this.authStrategy.getAuthEventPayload();
|
||||
|
||||
/**
|
||||
* Emitted when authentication is successful
|
||||
* @event Client#authenticated
|
||||
* @param {object} session Object containing session information. Can be used to restore the session.
|
||||
* @param {string} session.WABrowserId
|
||||
* @param {string} session.WASecretBundle
|
||||
* @param {string} session.WAToken1
|
||||
* @param {string} session.WAToken2
|
||||
*/
|
||||
this.emit(Events.AUTHENTICATED, session);
|
||||
this.emit(Events.AUTHENTICATED, authEventPayload);
|
||||
|
||||
// Check window.Store Injection
|
||||
await page.waitForFunction('window.Store != undefined');
|
||||
|
||||
const isMD = await page.evaluate(() => {
|
||||
return window.Store.Features.features.MD_BACKEND;
|
||||
await page.evaluate(async () => {
|
||||
// safely unregister service workers
|
||||
const registrations = await navigator.serviceWorker.getRegistrations();
|
||||
for (let registration of registrations) {
|
||||
registration.unregister();
|
||||
}
|
||||
});
|
||||
|
||||
if(isMD) {
|
||||
throw new Error('Multi-device is not yet supported by whatsapp-web.js. Please check out https://github.com/pedroslopez/whatsapp-web.js/pull/889 to follow the progress.');
|
||||
}
|
||||
|
||||
//Load util functions (serializers, helper functions)
|
||||
await page.evaluate(LoadUtils);
|
||||
|
||||
@@ -219,7 +293,7 @@ class Client extends EventEmitter {
|
||||
* @type {ClientInfo}
|
||||
*/
|
||||
this.info = new ClientInfo(this, await page.evaluate(() => {
|
||||
return window.Store.Conn.serialize();
|
||||
return { ...window.Store.Conn.serialize(), wid: window.Store.User.getMeUser() };
|
||||
}));
|
||||
|
||||
// Add InterfaceController
|
||||
@@ -227,8 +301,6 @@ class Client extends EventEmitter {
|
||||
|
||||
// Register events
|
||||
await page.exposeFunction('onAddMessageEvent', msg => {
|
||||
if (!msg.isNewMsg) return;
|
||||
|
||||
if (msg.type === 'gp2') {
|
||||
const notification = new GroupNotification(this, msg);
|
||||
if (msg.subtype === 'add' || msg.subtype === 'invite') {
|
||||
@@ -347,7 +419,7 @@ class Client extends EventEmitter {
|
||||
this.emit(Events.MEDIA_UPLOADED, message);
|
||||
});
|
||||
|
||||
await page.exposeFunction('onAppStateChangedEvent', (state) => {
|
||||
await page.exposeFunction('onAppStateChangedEvent', async (state) => {
|
||||
|
||||
/**
|
||||
* Emitted when the connection state changes
|
||||
@@ -374,6 +446,7 @@ class Client extends EventEmitter {
|
||||
* @event Client#disconnected
|
||||
* @param {WAState|"NAVIGATION"} reason reason that caused the disconnect
|
||||
*/
|
||||
await this.authStrategy.disconnect();
|
||||
this.emit(Events.DISCONNECTED, state);
|
||||
this.destroy();
|
||||
}
|
||||
@@ -385,11 +458,12 @@ class Client extends EventEmitter {
|
||||
if (battery === undefined) return;
|
||||
|
||||
/**
|
||||
* Emitted when the battery percentage for the attached device changes
|
||||
* Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.
|
||||
* @event Client#change_battery
|
||||
* @param {object} batteryInfo
|
||||
* @param {number} batteryInfo.battery - The current battery percentage
|
||||
* @param {boolean} batteryInfo.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
* @deprecated
|
||||
*/
|
||||
this.emit(Events.BATTERY_CHANGED, { battery, plugged });
|
||||
});
|
||||
@@ -408,20 +482,66 @@ class Client extends EventEmitter {
|
||||
* @param {boolean} call.webClientShouldHandle - If Waweb should handle
|
||||
* @param {object} call.participants - Participants
|
||||
*/
|
||||
const cll = new Call(this,call);
|
||||
const cll = new Call(this, call);
|
||||
this.emit(Events.INCOMING_CALL, cll);
|
||||
});
|
||||
|
||||
|
||||
await page.exposeFunction('onReaction', (reactions) => {
|
||||
for (const reaction of reactions) {
|
||||
/**
|
||||
* Emitted when a reaction is sent, received, updated or removed
|
||||
* @event Client#message_reaction
|
||||
* @param {object} reaction
|
||||
* @param {object} reaction.id - Reaction id
|
||||
* @param {number} reaction.orphan - Orphan
|
||||
* @param {?string} reaction.orphanReason - Orphan reason
|
||||
* @param {number} reaction.timestamp - Timestamp
|
||||
* @param {string} reaction.reaction - Reaction
|
||||
* @param {boolean} reaction.read - Read
|
||||
* @param {object} reaction.msgId - Parent message id
|
||||
* @param {string} reaction.senderId - Sender id
|
||||
* @param {?number} reaction.ack - Ack
|
||||
*/
|
||||
|
||||
this.emit(Events.MESSAGE_REACTION, new Reaction(this, reaction));
|
||||
}
|
||||
});
|
||||
|
||||
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)); });
|
||||
window.Store.Msg.on('change:type', (msg) => { window.onChangeMessageTypeEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
window.Store.Msg.on('change:ack', (msg,ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
||||
window.Store.Msg.on('change:ack', (msg, ack) => { window.onMessageAckEvent(window.WWebJS.getMessageModel(msg), ack); });
|
||||
window.Store.Msg.on('change:isUnsentMedia', (msg, unsent) => { if (msg.id.fromMe && !unsent) window.onMessageMediaUploadedEvent(window.WWebJS.getMessageModel(msg)); });
|
||||
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); });
|
||||
window.Store.Msg.on('add', (msg) => {
|
||||
if (msg.isNewMsg) {
|
||||
if(msg.type === 'ciphertext') {
|
||||
// defer message event until ciphertext is resolved (type changed)
|
||||
msg.once('change:type', (_msg) => window.onAddMessageEvent(window.WWebJS.getMessageModel(_msg)));
|
||||
} else {
|
||||
window.onAddMessageEvent(window.WWebJS.getMessageModel(msg));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
const module = window.Store.createOrUpdateReactionsModule;
|
||||
const ogMethod = module.createOrUpdateReactions;
|
||||
module.createOrUpdateReactions = ((...args) => {
|
||||
window.onReaction(args[0].map(reaction => {
|
||||
const msgKey = window.Store.MsgKey.fromString(reaction.msgKey);
|
||||
const parentMsgKey = window.Store.MsgKey.fromString(reaction.parentMsgKey);
|
||||
const timestamp = reaction.timestamp / 1000;
|
||||
|
||||
return {...reaction, msgKey, parentMsgKey, timestamp };
|
||||
}));
|
||||
|
||||
return ogMethod(...args);
|
||||
}).bind(module);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -429,12 +549,16 @@ class Client extends EventEmitter {
|
||||
* @event Client#ready
|
||||
*/
|
||||
this.emit(Events.READY);
|
||||
this.authStrategy.afterAuthReady();
|
||||
|
||||
// Disconnect when navigating away
|
||||
// Because WhatsApp Web now reloads when logging out from the device, this also covers that case
|
||||
// Disconnect when navigating away when in PAIRING state (detect logout)
|
||||
this.pupPage.on('framenavigated', async () => {
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
const appState = await this.getState();
|
||||
if(!appState || appState === WAState.PAIRING) {
|
||||
await this.authStrategy.disconnect();
|
||||
this.emit(Events.DISCONNECTED, 'NAVIGATION');
|
||||
await this.destroy();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -442,19 +566,19 @@ class Client extends EventEmitter {
|
||||
* Closes the client
|
||||
*/
|
||||
async destroy() {
|
||||
if (this._qrRefreshInterval) {
|
||||
clearInterval(this._qrRefreshInterval);
|
||||
}
|
||||
await this.pupBrowser.close();
|
||||
await this.authStrategy.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the client, closing the current session
|
||||
*/
|
||||
async logout() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
await this.pupPage.evaluate(() => {
|
||||
return window.Store.AppState.logout();
|
||||
});
|
||||
|
||||
await this.authStrategy.logout();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -484,7 +608,7 @@ class Client extends EventEmitter {
|
||||
/**
|
||||
* Message options.
|
||||
* @typedef {Object} MessageSendOptions
|
||||
* @property {boolean} [linkPreview=true] - Show links preview
|
||||
* @property {boolean} [linkPreview=true] - Show links preview. Has no effect on multi-device accounts.
|
||||
* @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
|
||||
@@ -519,7 +643,7 @@ class Client extends EventEmitter {
|
||||
quotedMessageId: options.quotedMessageId,
|
||||
parseVCards: options.parseVCards === false ? false : true,
|
||||
mentionedJidList: Array.isArray(options.mentions) ? options.mentions.map(contact => contact.id._serialized) : [],
|
||||
...options.extra
|
||||
extraOptions: options.extra
|
||||
};
|
||||
|
||||
const sendSeen = typeof options.sendSeen === 'undefined' ? true : options.sendSeen;
|
||||
@@ -534,34 +658,36 @@ class Client extends EventEmitter {
|
||||
} else if (content instanceof Location) {
|
||||
internalOptions.location = content;
|
||||
content = '';
|
||||
} else if(content instanceof Contact) {
|
||||
} else if (content instanceof Contact) {
|
||||
internalOptions.contactCard = content.id._serialized;
|
||||
content = '';
|
||||
} else if(Array.isArray(content) && content.length > 0 && content[0] instanceof Contact) {
|
||||
} 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;}
|
||||
} else if (content instanceof Buttons) {
|
||||
if (content.type !== 'chat') { internalOptions.attachment = content.body; }
|
||||
internalOptions.buttons = content;
|
||||
content = '';
|
||||
} else if(content instanceof List){
|
||||
} 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
|
||||
});
|
||||
}, this.pupPage
|
||||
);
|
||||
}
|
||||
|
||||
const newMessage = await this.pupPage.evaluate(async (chatId, message, options, sendSeen) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const chat = await window.Store.Chat.find(chatWid);
|
||||
|
||||
|
||||
if (sendSeen) {
|
||||
window.WWebJS.sendSeen(chatId);
|
||||
}
|
||||
@@ -648,7 +774,7 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async getInviteInfo(inviteCode) {
|
||||
return await this.pupPage.evaluate(inviteCode => {
|
||||
return window.Store.Wap.groupInviteInfo(inviteCode);
|
||||
return window.Store.InviteInfo.sendQueryGroupInvite(inviteCode);
|
||||
}, inviteCode);
|
||||
}
|
||||
|
||||
@@ -667,25 +793,25 @@ class Client extends EventEmitter {
|
||||
|
||||
/**
|
||||
* Accepts a private invitation to join a group
|
||||
* @param {object} inviteV4 Invite V4 Info
|
||||
* @param {object} inviteInfo Invite V4 Info
|
||||
* @returns {Promise<Object>}
|
||||
*/
|
||||
async acceptGroupV4Invite(inviteInfo) {
|
||||
if(!inviteInfo.inviteCode) throw 'Invalid invite code, try passing the message.inviteV4 object';
|
||||
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);
|
||||
return this.pupPage.evaluate(async inviteInfo => {
|
||||
let { groupId, fromId, inviteCode, inviteCodeExp } = inviteInfo;
|
||||
return await window.Store.JoinInviteV4.sendJoinGroupViaInviteV4(inviteCode, String(inviteCodeExp), groupId, fromId);
|
||||
}, inviteInfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the current user's status message
|
||||
* @param {string} status New status message
|
||||
*/
|
||||
async setStatus(status) {
|
||||
await this.pupPage.evaluate(async status => {
|
||||
return await window.Store.Wap.sendSetStatus(status);
|
||||
return await window.Store.StatusUtils.setMyStatus(status);
|
||||
}, status);
|
||||
}
|
||||
|
||||
@@ -693,19 +819,31 @@ class Client extends EventEmitter {
|
||||
* Sets the current user's display name.
|
||||
* This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.
|
||||
* @param {string} displayName New display name
|
||||
* @returns {Promise<Boolean>}
|
||||
*/
|
||||
async setDisplayName(displayName) {
|
||||
await this.pupPage.evaluate(async displayName => {
|
||||
return await window.Store.Wap.setPushname(displayName);
|
||||
}, displayName);
|
||||
}
|
||||
const couldSet = await this.pupPage.evaluate(async displayName => {
|
||||
if(!window.Store.Conn.canSetMyPushname()) return false;
|
||||
|
||||
if(window.Store.MDBackend) {
|
||||
// TODO
|
||||
return false;
|
||||
} else {
|
||||
const res = await window.Store.Wap.setPushname(displayName);
|
||||
return !res.status || res.status === 200;
|
||||
}
|
||||
}, displayName);
|
||||
|
||||
return couldSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current connection state for the client
|
||||
* @returns {WAState}
|
||||
*/
|
||||
async getState() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
if(!window.Store) return null;
|
||||
return window.Store.AppState.state;
|
||||
});
|
||||
}
|
||||
@@ -715,7 +853,16 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async sendPresenceAvailable() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.Wap.sendPresenceAvailable();
|
||||
return window.Store.PresenceUtils.sendPresenceAvailable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the client as unavailable
|
||||
*/
|
||||
async sendPresenceUnavailable() {
|
||||
return await this.pupPage.evaluate(() => {
|
||||
return window.Store.PresenceUtils.sendPresenceUnavailable();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -727,7 +874,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, true);
|
||||
return chat.archive;
|
||||
return true;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -739,7 +886,7 @@ class Client extends EventEmitter {
|
||||
return await this.pupPage.evaluate(async chatId => {
|
||||
let chat = await window.Store.Chat.get(chatId);
|
||||
await window.Store.Cmd.archiveChat(chat, false);
|
||||
return chat.archive;
|
||||
return false;
|
||||
}, chatId);
|
||||
}
|
||||
|
||||
@@ -754,8 +901,9 @@ class Client extends EventEmitter {
|
||||
return true;
|
||||
}
|
||||
const MAX_PIN_COUNT = 3;
|
||||
if (window.Store.Chat.models.length > MAX_PIN_COUNT) {
|
||||
let maxPinned = window.Store.Chat.models[MAX_PIN_COUNT - 1].pin;
|
||||
const chatModels = window.Store.Chat.getModelsArray();
|
||||
if (chatModels.length > MAX_PIN_COUNT) {
|
||||
let maxPinned = chatModels[MAX_PIN_COUNT - 1].pin;
|
||||
if (maxPinned) {
|
||||
return false;
|
||||
}
|
||||
@@ -821,13 +969,49 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getProfilePicUrl(contactId) {
|
||||
const profilePic = await this.pupPage.evaluate((contactId) => {
|
||||
return window.Store.Wap.profilePicFind(contactId);
|
||||
const profilePic = await this.pupPage.evaluate(async contactId => {
|
||||
try {
|
||||
const chatWid = window.Store.WidFactory.createWid(contactId);
|
||||
return await window.Store.ProfilePic.profilePicFind(chatWid);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return undefined;
|
||||
throw err;
|
||||
}
|
||||
}, contactId);
|
||||
|
||||
|
||||
return profilePic ? profilePic.eurl : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
||||
* @param {string} contactId the whatsapp user's ID (_serialized format)
|
||||
* @returns {Promise<WAWebJS.ChatId[]>}
|
||||
*/
|
||||
async getCommonGroups(contactId) {
|
||||
const commonGroups = await this.pupPage.evaluate(async (contactId) => {
|
||||
let contact = window.Store.Contact.get(contactId);
|
||||
if (!contact) {
|
||||
const wid = window.Store.WidFactory.createUserWid(contactId);
|
||||
const chatConstructor = window.Store.Contact.getModelsArray().find(c=>!c.isGroup).constructor;
|
||||
contact = new chatConstructor({id: wid});
|
||||
}
|
||||
|
||||
if (contact.commonGroups) {
|
||||
return contact.commonGroups.serialize();
|
||||
}
|
||||
const status = await window.Store.findCommonGroups(contact);
|
||||
if (status) {
|
||||
return contact.commonGroups.serialize();
|
||||
}
|
||||
return [];
|
||||
}, contactId);
|
||||
const chats = [];
|
||||
for (const group of commonGroups) {
|
||||
chats.push(group.id);
|
||||
}
|
||||
return chats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force reset of connection state for the client
|
||||
*/
|
||||
@@ -843,10 +1027,7 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<Boolean>}
|
||||
*/
|
||||
async isRegisteredUser(id) {
|
||||
return await this.pupPage.evaluate(async (id) => {
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
return result.jid !== undefined;
|
||||
}, id);
|
||||
return Boolean(await this.getNumberId(id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -856,14 +1037,16 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<Object|null>}
|
||||
*/
|
||||
async getNumberId(number) {
|
||||
if (!number.endsWith('@c.us')) number += '@c.us';
|
||||
try {
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.WWebJS.getNumberId(numberId);
|
||||
}, number);
|
||||
} catch(_) {
|
||||
return null;
|
||||
if (!number.endsWith('@c.us')) {
|
||||
number += '@c.us';
|
||||
}
|
||||
|
||||
return await this.pupPage.evaluate(async number => {
|
||||
const wid = window.Store.WidFactory.createWid(number);
|
||||
const result = await window.Store.QueryExist(wid);
|
||||
if (!result || result.wid === undefined) return null;
|
||||
return result.wid;
|
||||
}, number);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -872,14 +1055,14 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async getFormattedNumber(number) {
|
||||
if(!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
||||
if(!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
||||
|
||||
if (!number.endsWith('@s.whatsapp.net')) number = number.replace('c.us', 's.whatsapp.net');
|
||||
if (!number.includes('@s.whatsapp.net')) number = `${number}@s.whatsapp.net`;
|
||||
|
||||
return await this.pupPage.evaluate(async numberId => {
|
||||
return window.Store.NumberInfo.formattedPhoneNumber(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the country code of a WhatsApp ID.
|
||||
* @param {string} number Number or ID
|
||||
@@ -892,7 +1075,7 @@ class Client extends EventEmitter {
|
||||
return window.Store.NumberInfo.findCC(numberId);
|
||||
}, number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a new group
|
||||
* @param {string} name group title
|
||||
@@ -911,12 +1094,9 @@ class Client extends EventEmitter {
|
||||
}
|
||||
|
||||
const createRes = await this.pupPage.evaluate(async (name, participantIds) => {
|
||||
const res = await window.Store.Wap.createGroup(name, participantIds);
|
||||
console.log(res);
|
||||
if (!res.status === 200) {
|
||||
throw 'An error occurred while creating the group!';
|
||||
}
|
||||
|
||||
const participantWIDs = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
const id = window.Store.MsgKey.newId();
|
||||
const res = await window.Store.GroupUtils.sendCreateGroup(name, participantWIDs, undefined, id);
|
||||
return res;
|
||||
}, name, participants);
|
||||
|
||||
@@ -937,9 +1117,9 @@ class Client extends EventEmitter {
|
||||
async getLabels() {
|
||||
const labels = await this.pupPage.evaluate(async () => {
|
||||
return window.WWebJS.getLabels();
|
||||
});
|
||||
});
|
||||
|
||||
return labels.map(data => new Label(this , data));
|
||||
return labels.map(data => new Label(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -950,7 +1130,7 @@ class Client extends EventEmitter {
|
||||
async getLabelById(labelId) {
|
||||
const label = await this.pupPage.evaluate(async (labelId) => {
|
||||
return window.WWebJS.getLabel(labelId);
|
||||
}, labelId);
|
||||
}, labelId);
|
||||
|
||||
return new Label(this, label);
|
||||
}
|
||||
@@ -960,12 +1140,12 @@ class Client extends EventEmitter {
|
||||
* @param {string} chatId
|
||||
* @returns {Promise<Array<Label>>}
|
||||
*/
|
||||
async getChatLabels(chatId){
|
||||
async getChatLabels(chatId) {
|
||||
const labels = await this.pupPage.evaluate(async (chatId) => {
|
||||
return window.WWebJS.getChatLabels(chatId);
|
||||
}, chatId);
|
||||
|
||||
return labels.map(data => new Label(this, data));
|
||||
return labels.map(data => new Label(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -973,16 +1153,16 @@ class Client extends EventEmitter {
|
||||
* @param {string} labelId
|
||||
* @returns {Promise<Array<Chat>>}
|
||||
*/
|
||||
async getChatsByLabelId(labelId){
|
||||
async getChatsByLabelId(labelId) {
|
||||
const chatIds = await this.pupPage.evaluate(async (labelId) => {
|
||||
const label = window.Store.Label.get(labelId);
|
||||
const labelItems = label.labelItemCollection.models;
|
||||
const labelItems = label.labelItemCollection.getModelsArray();
|
||||
return labelItems.reduce((result, item) => {
|
||||
if(item.parentType === 'Chat'){
|
||||
if (item.parentType === 'Chat') {
|
||||
result.push(item.parentId);
|
||||
}
|
||||
return result;
|
||||
},[]);
|
||||
}, []);
|
||||
}, labelId);
|
||||
|
||||
return Promise.all(chatIds.map(id => this.getChatById(id)));
|
||||
@@ -994,8 +1174,8 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
async getBlockedContacts() {
|
||||
const blockedContacts = await this.pupPage.evaluate(() => {
|
||||
let chatIds = window.Store.Blocklist.models.map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
let chatIds = window.Store.Blocklist.getModelsArray().map(a => a.id._serialized);
|
||||
return Promise.all(chatIds.map(id => window.WWebJS.getContact(id)));
|
||||
});
|
||||
|
||||
return blockedContacts.map(contact => ContactFactory.create(this.client, contact));
|
||||
|
||||
27
src/authStrategies/BaseAuthStrategy.js
Normal file
27
src/authStrategies/BaseAuthStrategy.js
Normal file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Base class which all authentication strategies extend
|
||||
*/
|
||||
class BaseAuthStrategy {
|
||||
constructor() {}
|
||||
setup(client) {
|
||||
this.client = client;
|
||||
}
|
||||
async beforeBrowserInitialized() {}
|
||||
async afterBrowserInitialized() {}
|
||||
async onAuthenticationNeeded() {
|
||||
return {
|
||||
failed: false,
|
||||
restart: false,
|
||||
failureEventPayload: undefined
|
||||
};
|
||||
}
|
||||
async getAuthEventPayload() {}
|
||||
async afterAuthReady() {}
|
||||
async disconnect() {}
|
||||
async destroy() {}
|
||||
async logout() {}
|
||||
}
|
||||
|
||||
module.exports = BaseAuthStrategy;
|
||||
72
src/authStrategies/LegacySessionAuth.js
Normal file
72
src/authStrategies/LegacySessionAuth.js
Normal file
@@ -0,0 +1,72 @@
|
||||
'use strict';
|
||||
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* Legacy session auth strategy
|
||||
* Not compatible with multi-device accounts.
|
||||
* @param {object} options - options
|
||||
* @param {string} options.restartOnAuthFail - Restart client with a new session (i.e. use null 'session' var) if authentication fails
|
||||
* @param {object} options.session - Whatsapp session to restore. If not set, will start a new session
|
||||
* @param {string} options.session.WABrowserId
|
||||
* @param {string} options.session.WASecretBundle
|
||||
* @param {string} options.session.WAToken1
|
||||
* @param {string} options.session.WAToken2
|
||||
*/
|
||||
class LegacySessionAuth extends BaseAuthStrategy {
|
||||
constructor({ session, restartOnAuthFail }={}) {
|
||||
super();
|
||||
this.session = session;
|
||||
this.restartOnAuthFail = restartOnAuthFail;
|
||||
}
|
||||
|
||||
async afterBrowserInitialized() {
|
||||
if(this.session) {
|
||||
await this.client.pupPage.evaluateOnNewDocument(session => {
|
||||
if (document.referrer === 'https://whatsapp.com/') {
|
||||
localStorage.clear();
|
||||
localStorage.setItem('WABrowserId', session.WABrowserId);
|
||||
localStorage.setItem('WASecretBundle', session.WASecretBundle);
|
||||
localStorage.setItem('WAToken1', session.WAToken1);
|
||||
localStorage.setItem('WAToken2', session.WAToken2);
|
||||
}
|
||||
|
||||
localStorage.setItem('remember-me', 'true');
|
||||
}, this.session);
|
||||
}
|
||||
}
|
||||
|
||||
async onAuthenticationNeeded() {
|
||||
if(this.session) {
|
||||
this.session = null;
|
||||
return {
|
||||
failed: true,
|
||||
restart: this.restartOnAuthFail,
|
||||
failureEventPayload: 'Unable to log in. Are the session details valid?'
|
||||
};
|
||||
}
|
||||
|
||||
return { failed: false };
|
||||
}
|
||||
|
||||
async getAuthEventPayload() {
|
||||
const isMD = await this.client.pupPage.evaluate(() => {
|
||||
return window.Store.MDBackend;
|
||||
});
|
||||
|
||||
if(isMD) throw new Error('Authenticating via JSON session is not supported for MultiDevice-enabled WhatsApp accounts.');
|
||||
|
||||
const localStorage = JSON.parse(await this.client.pupPage.evaluate(() => {
|
||||
return JSON.stringify(window.localStorage);
|
||||
}));
|
||||
|
||||
return {
|
||||
WABrowserId: localStorage.WABrowserId,
|
||||
WASecretBundle: localStorage.WASecretBundle,
|
||||
WAToken1: localStorage.WAToken1,
|
||||
WAToken2: localStorage.WAToken2
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = LegacySessionAuth;
|
||||
53
src/authStrategies/LocalAuth.js
Normal file
53
src/authStrategies/LocalAuth.js
Normal file
@@ -0,0 +1,53 @@
|
||||
'use strict';
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* Local directory-based authentication
|
||||
* @param {object} options - options
|
||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
||||
*/
|
||||
class LocalAuth extends BaseAuthStrategy {
|
||||
constructor({ clientId, dataPath }={}) {
|
||||
super();
|
||||
|
||||
const idRegex = /^[-_\w]+$/i;
|
||||
if(clientId && !idRegex.test(clientId)) {
|
||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
||||
}
|
||||
|
||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
async beforeBrowserInitialized() {
|
||||
const puppeteerOpts = this.client.options.puppeteer;
|
||||
const sessionDirName = this.clientId ? `session-${this.clientId}` : 'session';
|
||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
||||
|
||||
if(puppeteerOpts.userDataDir && puppeteerOpts.userDataDir !== dirPath) {
|
||||
throw new Error('LocalAuth is not compatible with a user-supplied userDataDir.');
|
||||
}
|
||||
|
||||
fs.mkdirSync(dirPath, { recursive: true });
|
||||
|
||||
this.client.options.puppeteer = {
|
||||
...puppeteerOpts,
|
||||
userDataDir: dirPath
|
||||
};
|
||||
|
||||
this.userDataDir = dirPath;
|
||||
}
|
||||
|
||||
async logout() {
|
||||
if (this.userDataDir) {
|
||||
return (fs.rmSync ? fs.rmSync : fs.rmdirSync).call(this, this.userDataDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = LocalAuth;
|
||||
12
src/authStrategies/NoAuth.js
Normal file
12
src/authStrategies/NoAuth.js
Normal file
@@ -0,0 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* No session restoring functionality
|
||||
* Will need to authenticate via QR code every time
|
||||
*/
|
||||
class NoAuth extends BaseAuthStrategy { }
|
||||
|
||||
|
||||
module.exports = NoAuth;
|
||||
204
src/authStrategies/RemoteAuth.js
Normal file
204
src/authStrategies/RemoteAuth.js
Normal file
@@ -0,0 +1,204 @@
|
||||
'use strict';
|
||||
|
||||
/* Require Optional Dependencies */
|
||||
try {
|
||||
var fs = require('fs-extra');
|
||||
var unzipper = require('unzipper');
|
||||
var archiver = require('archiver');
|
||||
} catch {
|
||||
fs = undefined;
|
||||
unzipper = undefined;
|
||||
archiver = undefined;
|
||||
}
|
||||
|
||||
const path = require('path');
|
||||
const { Events } = require('./../util/Constants');
|
||||
const BaseAuthStrategy = require('./BaseAuthStrategy');
|
||||
|
||||
/**
|
||||
* Remote-based authentication
|
||||
* @param {object} options - options
|
||||
* @param {object} options.store - Remote database store instance
|
||||
* @param {string} options.clientId - Client id to distinguish instances if you are using multiple, otherwise keep null if you are using only one instance
|
||||
* @param {string} options.dataPath - Change the default path for saving session files, default is: "./.wwebjs_auth/"
|
||||
* @param {number} options.backupSyncIntervalMs - Sets the time interval for periodic session backups. Accepts values starting from 60000ms {1 minute}
|
||||
*/
|
||||
class RemoteAuth extends BaseAuthStrategy {
|
||||
constructor({ clientId, dataPath, store, backupSyncIntervalMs } = {}) {
|
||||
if (!fs && !unzipper && !archiver) throw new Error('Optional Dependencies [fs-extra, unzipper, archiver] are required to use RemoteAuth. Make sure to run npm install correctly and remove the --no-optional flag');
|
||||
super();
|
||||
|
||||
const idRegex = /^[-_\w]+$/i;
|
||||
if (clientId && !idRegex.test(clientId)) {
|
||||
throw new Error('Invalid clientId. Only alphanumeric characters, underscores and hyphens are allowed.');
|
||||
}
|
||||
if (!backupSyncIntervalMs || backupSyncIntervalMs < 60000) {
|
||||
throw new Error('Invalid backupSyncIntervalMs. Accepts values starting from 60000ms {1 minute}.');
|
||||
}
|
||||
if(!store) throw new Error('Remote database store is required.');
|
||||
|
||||
this.store = store;
|
||||
this.clientId = clientId;
|
||||
this.backupSyncIntervalMs = backupSyncIntervalMs;
|
||||
this.dataPath = path.resolve(dataPath || './.wwebjs_auth/');
|
||||
this.tempDir = `${this.dataPath}/wwebjs_temp_session`;
|
||||
this.requiredDirs = ['Default', 'IndexedDB', 'Local Storage']; /* => Required Files & Dirs in WWebJS to restore session */
|
||||
}
|
||||
|
||||
async beforeBrowserInitialized() {
|
||||
const puppeteerOpts = this.client.options.puppeteer;
|
||||
const sessionDirName = this.clientId ? `RemoteAuth-${this.clientId}` : 'RemoteAuth';
|
||||
const dirPath = path.join(this.dataPath, sessionDirName);
|
||||
|
||||
if (puppeteerOpts.userDataDir && puppeteerOpts.userDataDir !== dirPath) {
|
||||
throw new Error('RemoteAuth is not compatible with a user-supplied userDataDir.');
|
||||
}
|
||||
|
||||
this.userDataDir = dirPath;
|
||||
this.sessionName = sessionDirName;
|
||||
|
||||
await this.extractRemoteSession();
|
||||
|
||||
this.client.options.puppeteer = {
|
||||
...puppeteerOpts,
|
||||
userDataDir: dirPath
|
||||
};
|
||||
}
|
||||
|
||||
async logout() {
|
||||
await this.disconnect();
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
clearInterval(this.backupSync);
|
||||
}
|
||||
|
||||
async disconnect() {
|
||||
await this.deleteRemoteSession();
|
||||
|
||||
let pathExists = await this.isValidPath(this.userDataDir);
|
||||
if (pathExists) {
|
||||
await fs.promises.rm(this.userDataDir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
}
|
||||
clearInterval(this.backupSync);
|
||||
}
|
||||
|
||||
async afterAuthReady() {
|
||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
||||
if(!sessionExists) {
|
||||
await this.delay(60000); /* Initial delay sync required for session to be stable enough to recover */
|
||||
await this.storeRemoteSession({emit: true});
|
||||
}
|
||||
var self = this;
|
||||
this.backupSync = setInterval(async function () {
|
||||
await self.storeRemoteSession();
|
||||
}, this.backupSyncIntervalMs);
|
||||
}
|
||||
|
||||
async storeRemoteSession(options) {
|
||||
/* Compress & Store Session */
|
||||
const pathExists = await this.isValidPath(this.userDataDir);
|
||||
if (pathExists) {
|
||||
await this.compressSession();
|
||||
await this.store.save({session: this.sessionName});
|
||||
await fs.promises.unlink(`${this.sessionName}.zip`);
|
||||
await fs.promises.rm(`${this.tempDir}`, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
if(options && options.emit) this.client.emit(Events.REMOTE_SESSION_SAVED);
|
||||
}
|
||||
}
|
||||
|
||||
async extractRemoteSession() {
|
||||
const pathExists = await this.isValidPath(this.userDataDir);
|
||||
const compressedSessionPath = `${this.sessionName}.zip`;
|
||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
||||
if (pathExists) {
|
||||
await fs.promises.rm(this.userDataDir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
}
|
||||
if (sessionExists) {
|
||||
await this.store.extract({session: this.sessionName, path: compressedSessionPath});
|
||||
await this.unCompressSession(compressedSessionPath);
|
||||
} else {
|
||||
fs.mkdirSync(this.userDataDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
async deleteRemoteSession() {
|
||||
const sessionExists = await this.store.sessionExists({session: this.sessionName});
|
||||
if (sessionExists) await this.store.delete({session: this.sessionName});
|
||||
}
|
||||
|
||||
async compressSession() {
|
||||
const archive = archiver('zip');
|
||||
const stream = fs.createWriteStream(`${this.sessionName}.zip`);
|
||||
|
||||
await fs.copy(this.userDataDir, this.tempDir).catch(() => {});
|
||||
await this.deleteMetadata();
|
||||
return new Promise((resolve, reject) => {
|
||||
archive
|
||||
.directory(this.tempDir, false)
|
||||
.on('error', err => reject(err))
|
||||
.pipe(stream);
|
||||
|
||||
stream.on('close', () => resolve());
|
||||
archive.finalize();
|
||||
});
|
||||
}
|
||||
|
||||
async unCompressSession(compressedSessionPath) {
|
||||
var stream = fs.createReadStream(compressedSessionPath);
|
||||
await new Promise((resolve, reject) => {
|
||||
stream.pipe(unzipper.Extract({
|
||||
path: this.userDataDir
|
||||
}))
|
||||
.on('error', err => reject(err))
|
||||
.on('finish', () => resolve());
|
||||
});
|
||||
await fs.promises.unlink(compressedSessionPath);
|
||||
}
|
||||
|
||||
async deleteMetadata() {
|
||||
const sessionDirs = [this.tempDir, path.join(this.tempDir, 'Default')];
|
||||
for (const dir of sessionDirs) {
|
||||
const sessionFiles = await fs.promises.readdir(dir);
|
||||
for (const element of sessionFiles) {
|
||||
if (!this.requiredDirs.includes(element)) {
|
||||
const dirElement = path.join(dir, element);
|
||||
const stats = await fs.promises.lstat(dirElement);
|
||||
|
||||
if (stats.isDirectory()) {
|
||||
await fs.promises.rm(dirElement, {
|
||||
recursive: true,
|
||||
force: true
|
||||
}).catch(() => {});
|
||||
} else {
|
||||
await fs.promises.unlink(dirElement).catch(() => {});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async isValidPath(path) {
|
||||
try {
|
||||
await fs.promises.access(path);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async delay(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RemoteAuth;
|
||||
@@ -3,13 +3,27 @@
|
||||
const MessageMedia = require('./MessageMedia');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
* Button spec used in Buttons constructor
|
||||
* @typedef {Object} ButtonSpec
|
||||
* @property {string=} id - Custom ID to set on the button. A random one will be generated if one is not passed.
|
||||
* @property {string} body - The text to show on the button.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} FormattedButtonSpec
|
||||
* @property {string} buttonId
|
||||
* @property {number} type
|
||||
* @property {Object} buttonText
|
||||
*/
|
||||
|
||||
/**
|
||||
* Message type buttons
|
||||
*/
|
||||
class Buttons {
|
||||
/**
|
||||
* @param {string|MessageMedia} body
|
||||
* @param {Array<Array<string>>} buttons
|
||||
* @param {ButtonSpec[]} buttons - See {@link ButtonSpec}
|
||||
* @param {string?} title
|
||||
* @param {string?} footer
|
||||
*/
|
||||
@@ -41,7 +55,7 @@ class Buttons {
|
||||
|
||||
/**
|
||||
* buttons of message
|
||||
* @type {Array<Array<string>>}
|
||||
* @type {FormattedButtonSpec[]}
|
||||
*/
|
||||
this.buttons = this._format(buttons);
|
||||
if(!this.buttons.length){ throw '[BT01] No buttons';}
|
||||
@@ -50,8 +64,8 @@ class Buttons {
|
||||
|
||||
/**
|
||||
* Creates button array from simple array
|
||||
* @param {Array<Array<string>>} buttons
|
||||
* @returns {Array<Array<string>>}
|
||||
* @param {ButtonSpec[]} buttons
|
||||
* @returns {FormattedButtonSpec[]}
|
||||
* @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}]
|
||||
|
||||
@@ -65,7 +65,7 @@ class Chat extends Base {
|
||||
|
||||
/**
|
||||
* Indicates if the chat is muted or not
|
||||
* @type {number}
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isMuted = data.isMuted;
|
||||
|
||||
@@ -170,31 +170,42 @@ class Chat extends Base {
|
||||
|
||||
/**
|
||||
* Loads chat messages, sorted from earliest to latest.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit is supported.
|
||||
* @param {Number} [searchOptions.limit=50] The amount of messages to return. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||
* @param {Object} searchOptions Options for searching messages. Right now only limit and fromMe is supported.
|
||||
* @param {Number} [searchOptions.limit] The amount of messages to return. If no limit is specified, the available messages will be returned. Note that the actual number of returned messages may be smaller if there aren't enough messages in the conversation. Set this to Infinity to load all messages.
|
||||
* @param {Boolean} [searchOptions.fromMe] Return only messages from the bot number or vise versa. To get all messages, leave the option undefined.
|
||||
* @returns {Promise<Array<Message>>}
|
||||
*/
|
||||
async fetchMessages(searchOptions) {
|
||||
if (!searchOptions || !searchOptions.limit) {
|
||||
searchOptions = { limit: 50 };
|
||||
}
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, limit) => {
|
||||
const msgFilter = m => !m.isNotification; // dont include notification messages
|
||||
let messages = await this.client.pupPage.evaluate(async (chatId, searchOptions) => {
|
||||
const msgFilter = (m) => {
|
||||
if (m.isNotification) {
|
||||
return false; // dont include notification messages
|
||||
}
|
||||
if (searchOptions && searchOptions.fromMe && m.id.fromMe !== searchOptions.fromMe) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const chat = window.Store.Chat.get(chatId);
|
||||
let msgs = chat.msgs.models.filter(msgFilter);
|
||||
let msgs = chat.msgs.getModelsArray().filter(msgFilter);
|
||||
|
||||
while (msgs.length < limit) {
|
||||
const loadedMessages = await chat.loadEarlierMsgs();
|
||||
if (!loadedMessages) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
if (searchOptions && searchOptions.limit > 0) {
|
||||
while (msgs.length < searchOptions.limit) {
|
||||
const loadedMessages = await window.Store.ConversationMsgs.loadEarlierMsgs(chat);
|
||||
if (!loadedMessages || !loadedMessages.length) break;
|
||||
msgs = [...loadedMessages.filter(msgFilter), ...msgs];
|
||||
}
|
||||
|
||||
if (msgs.length > searchOptions.limit) {
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
msgs = msgs.splice(msgs.length - searchOptions.limit);
|
||||
}
|
||||
}
|
||||
|
||||
msgs.sort((a, b) => (a.t > b.t) ? 1 : -1);
|
||||
if (msgs.length > limit) msgs = msgs.splice(msgs.length - limit);
|
||||
return msgs.map(m => window.WWebJS.getMessageModel(m));
|
||||
|
||||
}, this.id._serialized, searchOptions.limit);
|
||||
}, this.id._serialized, searchOptions);
|
||||
|
||||
return messages.map(m => new Message(this.client, m));
|
||||
}
|
||||
|
||||
@@ -20,12 +20,6 @@ class ClientInfo extends Base {
|
||||
*/
|
||||
this.pushname = data.pushname;
|
||||
|
||||
/**
|
||||
* @type {object}
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
this.me = data.wid;
|
||||
|
||||
/**
|
||||
* Current user ID
|
||||
* @type {object}
|
||||
@@ -33,18 +27,25 @@ class ClientInfo extends Base {
|
||||
this.wid = data.wid;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to
|
||||
* @type {object}
|
||||
* @deprecated Use .wid instead
|
||||
*/
|
||||
this.me = data.wid;
|
||||
|
||||
/**
|
||||
* Information about the phone this client is connected to. Not available in multi-device.
|
||||
* @type {object}
|
||||
* @property {string} wa_version WhatsApp Version running on the phone
|
||||
* @property {string} os_version OS Version running on the phone (iOS or Android version)
|
||||
* @property {string} device_manufacturer Device manufacturer
|
||||
* @property {string} device_model Device model
|
||||
* @property {string} os_build_number OS build number
|
||||
* @deprecated
|
||||
*/
|
||||
this.phone = data.phone;
|
||||
|
||||
/**
|
||||
* Platform the phone is running on
|
||||
* Platform WhatsApp is running on
|
||||
* @type {string}
|
||||
*/
|
||||
this.platform = data.platform;
|
||||
@@ -57,6 +58,7 @@ class ClientInfo extends Base {
|
||||
* @returns {object} batteryStatus
|
||||
* @returns {number} batteryStatus.battery - The current battery percentage
|
||||
* @returns {boolean} batteryStatus.plugged - Indicates if the phone is plugged in (true) or not (false)
|
||||
* @deprecated
|
||||
*/
|
||||
async getBatteryStatus() {
|
||||
return await this.client.pupPage.evaluate(() => {
|
||||
@@ -64,7 +66,6 @@ class ClientInfo extends Base {
|
||||
return { battery, plugged };
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = ClientInfo;
|
||||
@@ -183,7 +183,8 @@ class Contact extends Base {
|
||||
*/
|
||||
async getAbout() {
|
||||
const about = await this.client.pupPage.evaluate(async (contactId) => {
|
||||
return window.Store.Wap.statusFind(contactId);
|
||||
const wid = window.Store.WidFactory.createWid(contactId);
|
||||
return window.Store.StatusUtils.getStatus(wid);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (typeof about.status !== 'string')
|
||||
@@ -191,6 +192,14 @@ class Contact extends Base {
|
||||
|
||||
return about.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Contact's common groups with you. Returns empty array if you don't have any common group.
|
||||
* @returns {Promise<WAWebJS.ChatId[]>}
|
||||
*/
|
||||
async getCommonGroups() {
|
||||
return await this.client.getCommonGroups(this.id._serialized);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,9 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async addParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.addParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendAddParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -71,7 +73,9 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async removeParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.removeParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendRemoveParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -82,7 +86,9 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async promoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.promoteParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendPromoteParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
@@ -93,53 +99,73 @@ class GroupChat extends Chat {
|
||||
*/
|
||||
async demoteParticipants(participantIds) {
|
||||
return await this.client.pupPage.evaluate((chatId, participantIds) => {
|
||||
return window.Store.Wap.demoteParticipants(chatId, participantIds);
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
const participantWids = participantIds.map(p => window.Store.WidFactory.createWid(p));
|
||||
return window.Store.GroupParticipants.sendDemoteParticipants(chatWid, participantWids);
|
||||
}, this.id._serialized, participantIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group subject
|
||||
* @param {string} subject
|
||||
* @returns {Promise}
|
||||
* @returns {Promise<boolean>} Returns true if the subject was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setSubject(subject) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, subject) => {
|
||||
return window.Store.Wap.changeSubject(chatId, subject);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, subject) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupSubject(chatWid, subject);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, subject);
|
||||
|
||||
if(res.status == 200) {
|
||||
this.name = subject;
|
||||
}
|
||||
if(!success) return false;
|
||||
this.name = subject;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the group description
|
||||
* @param {string} description
|
||||
* @returns {Promise}
|
||||
* @returns {Promise<boolean>} Returns true if the description was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setDescription(description) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, description) => {
|
||||
let descId = window.Store.GroupMetadata.get(chatId).descId;
|
||||
return window.Store.Wap.setGroupDescription(chatId, description, window.Store.genId(), descId);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, description) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
let descId = window.Store.GroupMetadata.get(chatWid).descId;
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupDescription(chatWid, description, window.Store.MsgKey.newId(), descId);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, description);
|
||||
|
||||
if (res.status == 200) {
|
||||
this.groupMetadata.desc = description;
|
||||
}
|
||||
if(!success) return false;
|
||||
this.groupMetadata.desc = description;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the group settings to only allow admins to send messages.
|
||||
* @param {boolean} [adminsOnly=true] Enable or disable this option
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setMessagesAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'announcement', value);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupProperty(chatWid, 'announcement', adminsOnly ? 1 : 0);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
|
||||
if(!success) return false;
|
||||
|
||||
this.groupMetadata.announce = adminsOnly;
|
||||
return true;
|
||||
}
|
||||
@@ -150,11 +176,17 @@ class GroupChat extends Chat {
|
||||
* @returns {Promise<boolean>} Returns true if the setting was properly updated. This can return false if the user does not have the necessary permissions.
|
||||
*/
|
||||
async setInfoAdminsOnly(adminsOnly=true) {
|
||||
let res = await this.client.pupPage.evaluate((chatId, value) => {
|
||||
return window.Store.Wap.setGroupProperty(chatId, 'restrict', value);
|
||||
const success = await this.client.pupPage.evaluate(async (chatId, adminsOnly) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
try {
|
||||
return await window.Store.GroupUtils.sendSetGroupProperty(chatWid, 'restrict', adminsOnly ? 1 : 0);
|
||||
} catch (err) {
|
||||
if(err.name === 'ServerStatusCodeError') return false;
|
||||
throw err;
|
||||
}
|
||||
}, this.id._serialized, adminsOnly);
|
||||
|
||||
if (res.status !== 200) return false;
|
||||
if(!success) return false;
|
||||
|
||||
this.groupMetadata.restrict = adminsOnly;
|
||||
return true;
|
||||
@@ -165,25 +197,25 @@ class GroupChat extends Chat {
|
||||
* @returns {Promise<string>} Group's invite code
|
||||
*/
|
||||
async getInviteCode() {
|
||||
let res = await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.groupInviteCode(chatId);
|
||||
const code = await this.client.pupPage.evaluate(async chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.Invite.sendQueryGroupInviteCode(chatWid);
|
||||
}, this.id._serialized);
|
||||
|
||||
if (res.status == 200) {
|
||||
return res.code;
|
||||
}
|
||||
|
||||
throw new Error('Not authorized');
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the current group invite code and generates a new one
|
||||
* @returns {Promise}
|
||||
* @returns {Promise<string>} New invite code
|
||||
*/
|
||||
async revokeInvite() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.revokeGroupInvite(chatId);
|
||||
const code = await this.client.pupPage.evaluate(chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.Invite.sendRevokeGroupInviteCode(chatWid);
|
||||
}, this.id._serialized);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,8 +223,9 @@ class GroupChat extends Chat {
|
||||
* @returns {Promise}
|
||||
*/
|
||||
async leave() {
|
||||
return await this.client.pupPage.evaluate(chatId => {
|
||||
return window.Store.Wap.leaveGroup(chatId);
|
||||
await this.client.pupPage.evaluate(chatId => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.GroupUtils.sendExitGroup(chatWid);
|
||||
}, this.id._serialized);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class GroupNotification extends Base {
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
this.chatId = typeof (data.to) === 'object' ? data.to._serialized : data.to;
|
||||
this.chatId = typeof (data.id.remote) === 'object' ? data.id.remote._serialized : data.id.remote;
|
||||
|
||||
/**
|
||||
* ContactId for the user that produced the GroupNotification.
|
||||
|
||||
@@ -19,13 +19,14 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
this._data = data;
|
||||
|
||||
/**
|
||||
* MediaKey that represents the sticker 'ID'
|
||||
* @type {string}
|
||||
*/
|
||||
this.mediaKey = data.mediaKey;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ID that represents the message
|
||||
* @type {object}
|
||||
@@ -50,7 +51,7 @@ class Message extends Base {
|
||||
*/
|
||||
this.body = this.hasMedia ? data.caption || '' : data.body || '';
|
||||
|
||||
/**
|
||||
/**
|
||||
* Message type
|
||||
* @type {MessageTypes}
|
||||
*/
|
||||
@@ -70,9 +71,9 @@ class Message extends Base {
|
||||
|
||||
/**
|
||||
* ID for who this message is for.
|
||||
*
|
||||
*
|
||||
* If the message is sent by the current user, it will be the Chat to which the message is being sent.
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
* If the message is sent by another user, it will be the ID for the current user.
|
||||
* @type {string}
|
||||
*/
|
||||
this.to = (typeof (data.to) === 'object' && data.to !== null) ? data.to._serialized : data.to;
|
||||
@@ -87,8 +88,8 @@ class Message extends Base {
|
||||
* 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';
|
||||
|
||||
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}
|
||||
@@ -114,14 +115,14 @@ class Message extends Base {
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isStarred = data.star;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates if the message was a broadcast
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.broadcast = data.broadcast;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Indicates if the message was sent by the current user
|
||||
* @type {boolean}
|
||||
*/
|
||||
@@ -133,6 +134,12 @@ class Message extends Base {
|
||||
*/
|
||||
this.hasQuotedMsg = data.quotedMsg ? true : false;
|
||||
|
||||
/**
|
||||
* Indicates the duration of the message in seconds
|
||||
* @type {string}
|
||||
*/
|
||||
this.duration = data.duration ? data.duration : undefined;
|
||||
|
||||
/**
|
||||
* Location information contained in the message, if the message is type "location"
|
||||
* @type {Location}
|
||||
@@ -157,7 +164,7 @@ class Message extends Base {
|
||||
fromId: data.from._serialized,
|
||||
toId: data.to._serialized
|
||||
} : undefined;
|
||||
|
||||
|
||||
/**
|
||||
* Indicates the mentions in the message body.
|
||||
* @type {Array<string>}
|
||||
@@ -185,6 +192,12 @@ class Message extends Base {
|
||||
*/
|
||||
this.isGif = Boolean(data.isGif);
|
||||
|
||||
/**
|
||||
* Indicates if the message will disappear after it expires
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.isEphemeral = data.isEphemeral;
|
||||
|
||||
/** Title */
|
||||
if (data.title) {
|
||||
this.title = data.title;
|
||||
@@ -208,7 +221,7 @@ class Message extends Base {
|
||||
/**
|
||||
* Links included in the message.
|
||||
* @type {Array<{link: string, isSuspicious: boolean}>}
|
||||
*
|
||||
*
|
||||
*/
|
||||
this.links = data.links;
|
||||
|
||||
@@ -216,7 +229,7 @@ class Message extends Base {
|
||||
if (data.dynamicReplyButtons) {
|
||||
this.dynamicReplyButtons = data.dynamicReplyButtons;
|
||||
}
|
||||
|
||||
|
||||
/** Selected Button Id **/
|
||||
if (data.selectedButtonId) {
|
||||
this.selectedButtonId = data.selectedButtonId;
|
||||
@@ -226,7 +239,7 @@ class Message extends Base {
|
||||
if (data.listResponse && data.listResponse.singleSelectReply.selectedRowId) {
|
||||
this.selectedRowId = data.listResponse.singleSelectReply.selectedRowId;
|
||||
}
|
||||
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
@@ -234,6 +247,32 @@ class Message extends Base {
|
||||
return this.fromMe ? this.to : this.from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads this Message object's data in-place with the latest values from WhatsApp Web.
|
||||
* Note that the Message must still be in the web app cache for this to work, otherwise will return null.
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
async reload() {
|
||||
const newData = await this.client.pupPage.evaluate((msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
return window.WWebJS.getMessageModel(msg);
|
||||
}, this.id._serialized);
|
||||
|
||||
if(!newData) return null;
|
||||
|
||||
this._patch(newData);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns message in a raw format
|
||||
* @type {Object}
|
||||
*/
|
||||
get rawData() {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Chat this message was sent in
|
||||
* @returns {Promise<Chat>}
|
||||
@@ -274,12 +313,12 @@ class Message extends Base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message as a reply to this message. If chatId is specified, it will be sent
|
||||
* through the specified Chat. If not, it will send the message
|
||||
* Sends a message as a reply to this message. If chatId is specified, it will be sent
|
||||
* through the specified Chat. If not, it will send the message
|
||||
* in the same Chat as the original message was sent.
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {string} [chatId]
|
||||
*
|
||||
* @param {string|MessageMedia|Location} content
|
||||
* @param {string} [chatId]
|
||||
* @param {MessageSendOptions} [options]
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
@@ -296,6 +335,20 @@ class Message extends Base {
|
||||
return this.client.sendMessage(chatId, content, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* React to this message with an emoji
|
||||
* @param {string} reaction - Emoji to react with. Send an empty string to remove the reaction.
|
||||
* @return {Promise}
|
||||
*/
|
||||
async react(reaction){
|
||||
await this.client.pupPage.evaluate(async (messageId, reaction) => {
|
||||
if (!messageId) { return undefined; }
|
||||
|
||||
const msg = await window.Store.Msg.get(messageId);
|
||||
await window.Store.sendReactionToMsg(msg, reaction);
|
||||
}, this.id._serialized, reaction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Accept Group V4 Invite
|
||||
* @returns {Promise<Object>}
|
||||
@@ -303,10 +356,10 @@ class Message extends Base {
|
||||
async acceptGroupV4Invite() {
|
||||
return await this.client.acceptGroupV4Invite(this.inviteV4);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Forwards this message to another chat
|
||||
*
|
||||
* Forwards this message to another chat (that you chatted before, otherwise it will fail)
|
||||
*
|
||||
* @param {string|Chat} chat Chat model or chat ID to which the message will be forwarded
|
||||
* @returns {Promise}
|
||||
*/
|
||||
@@ -336,7 +389,7 @@ class Message extends Base {
|
||||
if (msg.mediaData.mediaStage != 'RESOLVED') {
|
||||
// try to resolve media
|
||||
await msg.downloadMedia({
|
||||
downloadEvenIfExpensive: true,
|
||||
downloadEvenIfExpensive: true,
|
||||
rmrReason: 1
|
||||
});
|
||||
}
|
||||
@@ -356,13 +409,14 @@ class Message extends Base {
|
||||
type: msg.type,
|
||||
signal: (new AbortController).signal
|
||||
});
|
||||
|
||||
const data = window.WWebJS.arrayBufferToBase64(decryptedMedia);
|
||||
|
||||
|
||||
const data = await window.WWebJS.arrayBufferToBase64Async(decryptedMedia);
|
||||
|
||||
return {
|
||||
data,
|
||||
mimetype: msg.mimetype,
|
||||
filename: msg.filename
|
||||
filename: msg.filename,
|
||||
filesize: msg.size
|
||||
};
|
||||
} catch (e) {
|
||||
if(e.status && e.status === 404) return undefined;
|
||||
@@ -371,19 +425,19 @@ class Message extends Base {
|
||||
}, this.id._serialized);
|
||||
|
||||
if (!result) return undefined;
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename);
|
||||
return new MessageMedia(result.mimetype, result.data, result.filename, result.filesize);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a message from the chat
|
||||
* @param {?boolean} everyone If true and the message is sent by the current user, will delete it for everyone in the chat.
|
||||
* @param {?boolean} everyone If true and the message is sent by the current user or the user is an admin, will delete it for everyone in the chat.
|
||||
*/
|
||||
async delete(everyone) {
|
||||
await this.client.pupPage.evaluate((msgId, everyone) => {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (everyone && msg.id.fromMe && msg.canRevoke()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], true);
|
||||
if (everyone && msg._canRevoke()) {
|
||||
return window.Store.Cmd.sendRevokeMsgs(msg.chat, [msg], { type: msg.id.fromMe ? 'Sender' : 'Admin' });
|
||||
}
|
||||
|
||||
return window.Store.Cmd.sendDeleteMsgs(msg.chat, [msg], true);
|
||||
@@ -398,7 +452,7 @@ class Message extends Base {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], true);
|
||||
return window.Store.Cmd.sendStarMsgs(msg.chat, [msg], false);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
@@ -411,7 +465,7 @@ class Message extends Base {
|
||||
let msg = window.Store.Msg.get(msgId);
|
||||
|
||||
if (msg.canStar()) {
|
||||
return msg.chat.sendStarMsgs([msg], false);
|
||||
return window.Store.Cmd.sendUnstarMsgs(msg.chat, [msg], false);
|
||||
}
|
||||
}, this.id._serialized);
|
||||
}
|
||||
@@ -434,14 +488,10 @@ class Message extends Base {
|
||||
async getInfo() {
|
||||
const info = await this.client.pupPage.evaluate(async (msgId) => {
|
||||
const msg = window.Store.Msg.get(msgId);
|
||||
if(!msg) return null;
|
||||
|
||||
return await window.Store.Wap.queryMsgInfo(msg.id);
|
||||
}, this.id._serialized);
|
||||
if (!msg) return null;
|
||||
|
||||
if(info.status) {
|
||||
return null;
|
||||
}
|
||||
return await window.Store.MessageInfo.sendQueryMsgInfo(msg);
|
||||
}, this.id._serialized);
|
||||
|
||||
return info;
|
||||
}
|
||||
@@ -452,9 +502,9 @@ class Message extends Base {
|
||||
*/
|
||||
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);
|
||||
const result = await this.client.pupPage.evaluate((orderId, token, chatId) => {
|
||||
return window.WWebJS.getOrderDetail(orderId, token, chatId);
|
||||
}, this.orderId, this.token, this._getChatId());
|
||||
if (!result) return undefined;
|
||||
return new Order(this.client, result);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,11 @@ const { URL } = require('url');
|
||||
* Media attached to a message
|
||||
* @param {string} mimetype MIME type of the attachment
|
||||
* @param {string} data Base64-encoded data of the file
|
||||
* @param {?string} filename Document file name
|
||||
* @param {?string} filename Document file name. Value can be null
|
||||
* @param {?number} filesize Document file size in bytes. Value can be null
|
||||
*/
|
||||
class MessageMedia {
|
||||
constructor(mimetype, data, filename) {
|
||||
constructor(mimetype, data, filename, filesize) {
|
||||
/**
|
||||
* MIME type of the attachment
|
||||
* @type {string}
|
||||
@@ -27,10 +28,16 @@ class MessageMedia {
|
||||
this.data = data;
|
||||
|
||||
/**
|
||||
* Name of the file (for documents)
|
||||
* Document file name. Value can be null
|
||||
* @type {?string}
|
||||
*/
|
||||
this.filename = filename;
|
||||
|
||||
/**
|
||||
* Document file size in bytes. Value can be null
|
||||
* @type {?number}
|
||||
*/
|
||||
this.filesize = filesize;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -68,6 +75,7 @@ class MessageMedia {
|
||||
const reqOptions = Object.assign({ headers: { accept: 'image/* video/* text/* audio/*' } }, options);
|
||||
const response = await fetch(url, reqOptions);
|
||||
const mime = response.headers.get('Content-Type');
|
||||
const size = response.headers.get('Content-Length');
|
||||
|
||||
const contentDisposition = response.headers.get('Content-Disposition');
|
||||
const name = contentDisposition ? contentDisposition.match(/((?<=filename=")(.*)(?="))/) : null;
|
||||
@@ -83,7 +91,7 @@ class MessageMedia {
|
||||
data = btoa(data);
|
||||
}
|
||||
|
||||
return { data, mime, name };
|
||||
return { data, mime, name, size };
|
||||
}
|
||||
|
||||
const res = options.client
|
||||
@@ -96,7 +104,7 @@ class MessageMedia {
|
||||
if (!mimetype)
|
||||
mimetype = res.mime;
|
||||
|
||||
return new MessageMedia(mimetype, res.data, filename);
|
||||
return new MessageMedia(mimetype, res.data, filename, res.size || null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
69
src/structures/Reaction.js
Normal file
69
src/structures/Reaction.js
Normal file
@@ -0,0 +1,69 @@
|
||||
'use strict';
|
||||
|
||||
const Base = require('./Base');
|
||||
|
||||
/**
|
||||
* Represents a Reaction on WhatsApp
|
||||
* @extends {Base}
|
||||
*/
|
||||
class Reaction extends Base {
|
||||
constructor(client, data) {
|
||||
super(client);
|
||||
|
||||
if (data) this._patch(data);
|
||||
}
|
||||
|
||||
_patch(data) {
|
||||
/**
|
||||
* Reaction ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.id = data.msgKey;
|
||||
/**
|
||||
* Orphan
|
||||
* @type {number}
|
||||
*/
|
||||
this.orphan = data.orphan;
|
||||
/**
|
||||
* Orphan reason
|
||||
* @type {?string}
|
||||
*/
|
||||
this.orphanReason = data.orphanReason;
|
||||
/**
|
||||
* Unix timestamp for when the reaction was created
|
||||
* @type {number}
|
||||
*/
|
||||
this.timestamp = data.timestamp;
|
||||
/**
|
||||
* Reaction
|
||||
* @type {string}
|
||||
*/
|
||||
this.reaction = data.reactionText;
|
||||
/**
|
||||
* Read
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.read = data.read;
|
||||
/**
|
||||
* Message ID
|
||||
* @type {object}
|
||||
*/
|
||||
this.msgId = data.parentMsgKey;
|
||||
/**
|
||||
* Sender ID
|
||||
* @type {string}
|
||||
*/
|
||||
this.senderId = data.senderUserJid;
|
||||
/**
|
||||
* ACK
|
||||
* @type {?number}
|
||||
*/
|
||||
this.ack = data.ack;
|
||||
|
||||
|
||||
return super._patch(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Reaction;
|
||||
@@ -17,5 +17,6 @@ module.exports = {
|
||||
Call: require('./Call'),
|
||||
Buttons: require('./Buttons'),
|
||||
List: require('./List'),
|
||||
Payment: require('./Payment')
|
||||
Payment: require('./Payment'),
|
||||
Reaction: require('./Reaction'),
|
||||
};
|
||||
|
||||
@@ -7,14 +7,11 @@ exports.DefaultOptions = {
|
||||
headless: true,
|
||||
defaultViewport: null
|
||||
},
|
||||
session: false,
|
||||
qrTimeoutMs: 45000,
|
||||
qrRefreshIntervalMs: 20000,
|
||||
authTimeoutMs: 45000,
|
||||
authTimeoutMs: 0,
|
||||
qrMaxRetries: 0,
|
||||
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',
|
||||
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36',
|
||||
ffmpegPath: 'ffmpeg',
|
||||
bypassCSP: false
|
||||
};
|
||||
@@ -44,15 +41,18 @@ exports.Events = {
|
||||
MESSAGE_REVOKED_EVERYONE: 'message_revoke_everyone',
|
||||
MESSAGE_REVOKED_ME: 'message_revoke_me',
|
||||
MESSAGE_ACK: 'message_ack',
|
||||
MESSAGE_REACTION: 'message_reaction',
|
||||
MEDIA_UPLOADED: 'media_uploaded',
|
||||
GROUP_JOIN: 'group_join',
|
||||
GROUP_LEAVE: 'group_leave',
|
||||
GROUP_UPDATE: 'group_update',
|
||||
QR_RECEIVED: 'qr',
|
||||
LOADING_SCREEN: 'loading_screen',
|
||||
DISCONNECTED: 'disconnected',
|
||||
STATE_CHANGED: 'change_state',
|
||||
BATTERY_CHANGED: 'change_battery',
|
||||
INCOMING_CALL: 'incoming_call'
|
||||
INCOMING_CALL: 'incoming_call',
|
||||
REMOTE_SESSION_SAVED: 'remote_session_saved'
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -77,8 +77,25 @@ exports.MessageTypes = {
|
||||
UNKNOWN: 'unknown',
|
||||
GROUP_INVITE: 'groups_v4_invite',
|
||||
LIST: 'list',
|
||||
LIST_RESPONSE: 'list_response',
|
||||
BUTTONS_RESPONSE: 'buttons_response',
|
||||
PAYMENT: 'payment'
|
||||
PAYMENT: 'payment',
|
||||
BROADCAST_NOTIFICATION: 'broadcast_notification',
|
||||
CALL_LOG: 'call_log',
|
||||
CIPHERTEXT: 'ciphertext',
|
||||
DEBUG: 'debug',
|
||||
E2E_NOTIFICATION: 'e2e_notification',
|
||||
GP2: 'gp2',
|
||||
GROUP_NOTIFICATION: 'group_notification',
|
||||
HSM: 'hsm',
|
||||
INTERACTIVE: 'interactive',
|
||||
NATIVE_FLOW: 'native_flow',
|
||||
NOTIFICATION: 'notification',
|
||||
NOTIFICATION_TEMPLATE: 'notification_template',
|
||||
OVERSIZED: 'oversized',
|
||||
PROTOCOL: 'protocol',
|
||||
REACTION: 'reaction',
|
||||
TEMPLATE_BUTTON_REPLY: 'template_button_reply',
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,39 +6,63 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
// eslint-disable-next-line no-undef
|
||||
window.mR = moduleRaid();
|
||||
window.Store = Object.assign({}, window.mR.findModule(m => m.default && m.default.Chat)[0].default);
|
||||
window.Store.AppState = window.mR.findModule('STREAM')[0].Socket;
|
||||
window.Store.AppState = window.mR.findModule('Socket')[0].Socket;
|
||||
window.Store.Conn = window.mR.findModule('Conn')[0].Conn;
|
||||
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
||||
window.Store.Call = window.mR.findModule('CallCollection')[0].CallCollection;
|
||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
||||
window.Store.CryptoLib = window.mR.findModule('decryptE2EMedia')[0];
|
||||
window.Store.Wap = window.mR.findModule('queryLinkPreview')[0].default;
|
||||
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
||||
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
||||
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
||||
window.Store.genId = window.mR.findModule('randomId')[0].randomId;
|
||||
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
||||
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
||||
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
||||
window.Store.Features = window.mR.findModule('FEATURE_CHANGE_EVENT')[0].LegacyPhoneFeatures;
|
||||
window.Store.GroupMetadata = window.mR.findModule('GroupMetadata')[0].default.GroupMetadata;
|
||||
window.Store.Invite = window.mR.findModule('sendJoinGroupViaInvite')[0];
|
||||
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
||||
window.Store.InviteInfo = window.mR.findModule('sendQueryGroupInvite')[0];
|
||||
window.Store.Label = window.mR.findModule('LabelCollection')[0].LabelCollection;
|
||||
window.Store.MediaPrep = window.mR.findModule('MediaPrep')[0];
|
||||
window.Store.MediaObject = window.mR.findModule('getOrCreateMediaObject')[0];
|
||||
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
||||
window.Store.NumberInfo = window.mR.findModule('formattedPhoneNumber')[0];
|
||||
window.Store.Cmd = window.mR.findModule('Cmd')[0].Cmd;
|
||||
window.Store.MediaTypes = window.mR.findModule('msgToMediaType')[0];
|
||||
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
||||
window.Store.MediaUpload = window.mR.findModule('uploadMedia')[0];
|
||||
window.Store.MsgKey = window.mR.findModule((module) => module.default && module.default.fromString)[0].default;
|
||||
window.Store.MessageInfo = window.mR.findModule('sendQueryMsgInfo')[0];
|
||||
window.Store.OpaqueData = window.mR.findModule(module => module.default && module.default.createFromData)[0].default;
|
||||
window.Store.QueryExist = window.mR.findModule('queryExists')[0].queryExists;
|
||||
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
||||
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
||||
window.Store.SendClear = window.mR.findModule('sendClear')[0];
|
||||
window.Store.SendDelete = window.mR.findModule('sendDelete')[0];
|
||||
window.Store.SendMessage = window.mR.findModule('addAndSendMsgToChat')[0];
|
||||
window.Store.SendSeen = window.mR.findModule('sendSeen')[0];
|
||||
window.Store.User = window.mR.findModule('getMaybeMeUser')[0];
|
||||
window.Store.UploadUtils = window.mR.findModule((module) => (module.default && module.default.encryptAndUpload) ? module.default : null)[0].default;
|
||||
window.Store.UserConstructor = window.mR.findModule((module) => (module.default && module.default.prototype && module.default.prototype.isServer && module.default.prototype.isUser) ? module.default : null)[0].default;
|
||||
window.Store.Validators = window.mR.findModule('findLinks')[0];
|
||||
window.Store.VCard = window.mR.findModule('vcardFromContactModel')[0];
|
||||
window.Store.WidFactory = window.mR.findModule('createWid')[0];
|
||||
window.Store.BlockContact = window.mR.findModule('blockContact')[0];
|
||||
window.Store.GroupMetadata = window.mR.findModule((module) => module.default && module.default.handlePendingInvite)[0].default;
|
||||
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].GK;
|
||||
window.Store.QueryOrder = window.mR.findModule('queryOrder')[0];
|
||||
window.Store.QueryProduct = window.mR.findModule('queryProduct')[0];
|
||||
window.Store.DownloadManager = window.mR.findModule('downloadManager')[0].downloadManager;
|
||||
window.Store.Call = window.mR.findModule('CallCollection')[0].CallCollection;
|
||||
window.Store.ProfilePic = window.mR.findModule('profilePicResync')[0];
|
||||
window.Store.PresenceUtils = window.mR.findModule('sendPresenceAvailable')[0];
|
||||
window.Store.ChatState = window.mR.findModule('sendChatStateComposing')[0];
|
||||
window.Store.GroupParticipants = window.mR.findModule('sendPromoteParticipants')[0];
|
||||
window.Store.JoinInviteV4 = window.mR.findModule('sendJoinGroupViaInviteV4')[0];
|
||||
window.Store.findCommonGroups = window.mR.findModule('findCommonGroups')[0].findCommonGroups;
|
||||
window.Store.StatusUtils = window.mR.findModule('setMyStatus')[0];
|
||||
window.Store.ConversationMsgs = window.mR.findModule('loadEarlierMsgs')[0];
|
||||
window.Store.sendReactionToMsg = window.mR.findModule('sendReactionToMsg')[0].sendReactionToMsg;
|
||||
window.Store.createOrUpdateReactionsModule = window.mR.findModule('createOrUpdateReactions')[0];
|
||||
window.Store.EphemeralFields = window.mR.findModule('getEphemeralFields')[0];
|
||||
window.Store.ReplyUtils = window.mR.findModule('canReplyMsg').length > 0 && window.mR.findModule('canReplyMsg')[0];
|
||||
window.Store.StickerTools = {
|
||||
...window.mR.findModule('toWebpSticker')[0],
|
||||
...window.mR.findModule('addWebpMetadata')[0]
|
||||
};
|
||||
|
||||
window.Store.GroupUtils = {
|
||||
...window.mR.findModule('sendCreateGroup')[0],
|
||||
...window.mR.findModule('sendSetGroupSubject')[0],
|
||||
...window.mR.findModule('markExited')[0]
|
||||
};
|
||||
|
||||
if(!window.Store.Chat._find) {
|
||||
if (!window.Store.Chat._find) {
|
||||
window.Store.Chat._find = e => {
|
||||
const target = window.Store.Chat.get(e);
|
||||
return target ? Promise.resolve(target) : Promise.resolve({
|
||||
@@ -46,19 +70,24 @@ exports.ExposeStore = (moduleRaidStr) => {
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// TODO remove these once everybody has been updated to WWebJS with legacy sessions removed
|
||||
const _linkPreview = window.mR.findModule('queryLinkPreview');
|
||||
if (_linkPreview && _linkPreview[0] && _linkPreview[0].default) {
|
||||
window.Store.Wap = _linkPreview[0].default;
|
||||
}
|
||||
|
||||
const _isMDBackend = window.mR.findModule('isMDBackend');
|
||||
if(_isMDBackend && _isMDBackend[0] && _isMDBackend[0].isMDBackend) {
|
||||
window.Store.MDBackend = _isMDBackend[0].isMDBackend();
|
||||
} else {
|
||||
window.Store.MDBackend = true;
|
||||
}
|
||||
};
|
||||
|
||||
exports.LoadUtils = () => {
|
||||
window.WWebJS = {};
|
||||
|
||||
window.WWebJS.getNumberId = async (id) => {
|
||||
|
||||
let result = await window.Store.Wap.queryExist(id);
|
||||
if (result.jid === undefined)
|
||||
throw 'The number provided is not a registered whatsapp user';
|
||||
return result.jid;
|
||||
};
|
||||
|
||||
window.WWebJS.sendSeen = async (chatId) => {
|
||||
let chat = window.Store.Chat.get(chatId);
|
||||
if (chat !== undefined) {
|
||||
@@ -68,14 +97,14 @@ exports.LoadUtils = () => {
|
||||
return false;
|
||||
|
||||
};
|
||||
|
||||
|
||||
window.WWebJS.sendMessage = async (chat, content, options = {}) => {
|
||||
let attOptions = {};
|
||||
if (options.attachment) {
|
||||
attOptions = options.sendMediaAsSticker
|
||||
attOptions = options.sendMediaAsSticker
|
||||
? await window.WWebJS.processStickerData(options.attachment)
|
||||
: await window.WWebJS.processMediaData(options.attachment, {
|
||||
forceVoice: options.sendAudioAsVoice,
|
||||
forceVoice: options.sendAudioAsVoice,
|
||||
forceDocument: options.sendMediaAsDocument,
|
||||
forceGif: options.sendVideoAsGif
|
||||
});
|
||||
@@ -85,11 +114,16 @@ exports.LoadUtils = () => {
|
||||
delete options.attachment;
|
||||
delete options.sendMediaAsSticker;
|
||||
}
|
||||
|
||||
let quotedMsgOptions = {};
|
||||
if (options.quotedMessageId) {
|
||||
let quotedMessage = window.Store.Msg.get(options.quotedMessageId);
|
||||
if (quotedMessage.canReply()) {
|
||||
|
||||
// TODO remove .canReply() once all clients are updated to >= v2.2241.6
|
||||
const canReply = window.Store.ReplyUtils ?
|
||||
window.Store.ReplyUtils.canReplyMsg(quotedMessage.unsafe()) :
|
||||
quotedMessage.canReply();
|
||||
|
||||
if (canReply) {
|
||||
quotedMsgOptions = quotedMessage.msgContextInfo(chat);
|
||||
}
|
||||
delete options.quotedMessageId;
|
||||
@@ -145,25 +179,29 @@ exports.LoadUtils = () => {
|
||||
|
||||
if (options.linkPreview) {
|
||||
delete options.linkPreview;
|
||||
const link = window.Store.Validators.findLink(content);
|
||||
if (link) {
|
||||
const preview = await window.Store.Wap.queryLinkPreview(link.url);
|
||||
preview.preview = true;
|
||||
preview.subtype = 'url';
|
||||
options = { ...options, ...preview };
|
||||
|
||||
// Not supported yet by WhatsApp Web on MD
|
||||
if(!window.Store.MDBackend) {
|
||||
const link = window.Store.Validators.findLink(content);
|
||||
if (link) {
|
||||
const preview = await window.Store.Wap.queryLinkPreview(link.url);
|
||||
preview.preview = true;
|
||||
preview.subtype = 'url';
|
||||
options = { ...options, ...preview };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let extraOptions = {};
|
||||
let buttonOptions = {};
|
||||
if(options.buttons){
|
||||
let caption;
|
||||
if(options.buttons.type === 'chat') {
|
||||
if (options.buttons.type === 'chat') {
|
||||
content = options.buttons.body;
|
||||
caption = content;
|
||||
}else{
|
||||
} else {
|
||||
caption = options.caption ? options.caption : ' '; //Caption can't be empty
|
||||
}
|
||||
extraOptions = {
|
||||
buttonOptions = {
|
||||
productHeaderImageRejected: false,
|
||||
isFromTemplate: false,
|
||||
isDynamicReplyButtonsMsg: true,
|
||||
@@ -176,12 +214,12 @@ exports.LoadUtils = () => {
|
||||
delete options.buttons;
|
||||
}
|
||||
|
||||
let listOptions = {};
|
||||
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,
|
||||
listOptions = {
|
||||
type: 'list',
|
||||
footer: options.list.footer,
|
||||
list: {
|
||||
@@ -191,31 +229,44 @@ exports.LoadUtils = () => {
|
||||
body: options.list.description
|
||||
};
|
||||
delete options.list;
|
||||
delete extraOptions.list.footer;
|
||||
delete listOptions.list.footer;
|
||||
}
|
||||
|
||||
|
||||
const meUser = window.Store.User.getMaybeMeUser();
|
||||
const isMD = window.Store.MDBackend;
|
||||
|
||||
const newMsgId = new window.Store.MsgKey({
|
||||
fromMe: true,
|
||||
remote: chat.id,
|
||||
id: window.Store.genId(),
|
||||
from: meUser,
|
||||
to: chat.id,
|
||||
id: window.Store.MsgKey.newId(),
|
||||
participant: isMD && chat.id.isGroup() ? meUser : undefined,
|
||||
selfDir: 'out',
|
||||
});
|
||||
|
||||
const extraOptions = options.extraOptions || {};
|
||||
delete options.extraOptions;
|
||||
|
||||
const ephemeralFields = window.Store.EphemeralFields.getEphemeralFields(chat);
|
||||
|
||||
const message = {
|
||||
...options,
|
||||
id: newMsgId,
|
||||
ack: 0,
|
||||
body: content,
|
||||
from: window.Store.Conn.wid,
|
||||
from: meUser,
|
||||
to: chat.id,
|
||||
local: true,
|
||||
self: 'out',
|
||||
t: parseInt(new Date().getTime() / 1000),
|
||||
isNewMsg: true,
|
||||
type: 'chat',
|
||||
...ephemeralFields,
|
||||
...locationOptions,
|
||||
...attOptions,
|
||||
...quotedMsgOptions,
|
||||
...vcardOptions,
|
||||
...buttonOptions,
|
||||
...listOptions,
|
||||
...extraOptions
|
||||
};
|
||||
|
||||
@@ -223,11 +274,25 @@ exports.LoadUtils = () => {
|
||||
return window.Store.Msg.get(newMsgId._serialized);
|
||||
};
|
||||
|
||||
window.WWebJS.toStickerData = async (mediaInfo) => {
|
||||
if (mediaInfo.mimetype == 'image/webp') return mediaInfo;
|
||||
|
||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||
const webpSticker = await window.Store.StickerTools.toWebpSticker(file);
|
||||
const webpBuffer = await webpSticker.arrayBuffer();
|
||||
const data = window.WWebJS.arrayBufferToBase64(webpBuffer);
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data
|
||||
};
|
||||
};
|
||||
|
||||
window.WWebJS.processStickerData = async (mediaInfo) => {
|
||||
if (mediaInfo.mimetype !== 'image/webp') throw new Error('Invalid media type');
|
||||
|
||||
const file = window.WWebJS.mediaInfoToFile(mediaInfo);
|
||||
let filehash = await window.WWebJS.getFileHash(file);
|
||||
let filehash = await window.WWebJS.getFileHash(file);
|
||||
let mediaKey = await window.WWebJS.generateHash(32);
|
||||
|
||||
const controller = new AbortController();
|
||||
@@ -313,10 +378,11 @@ exports.LoadUtils = () => {
|
||||
|
||||
window.WWebJS.getMessageModel = message => {
|
||||
const msg = message.serialize();
|
||||
|
||||
|
||||
msg.isEphemeral = message.isEphemeral;
|
||||
msg.isStatusV3 = message.isStatusV3;
|
||||
msg.links = (message.getLinks()).map(link => ({
|
||||
link: link.href,
|
||||
msg.links = (message.getRawLinks()).map(link => ({
|
||||
link: link.href,
|
||||
isSuspicious: Boolean(link.suspiciousCharacters && link.suspiciousCharacters.size)
|
||||
}));
|
||||
|
||||
@@ -326,28 +392,30 @@ exports.LoadUtils = () => {
|
||||
if (msg.dynamicReplyButtons) {
|
||||
msg.dynamicReplyButtons = JSON.parse(JSON.stringify(msg.dynamicReplyButtons));
|
||||
}
|
||||
if(msg.replyButtons) {
|
||||
if (msg.replyButtons) {
|
||||
msg.replyButtons = JSON.parse(JSON.stringify(msg.replyButtons));
|
||||
}
|
||||
|
||||
if(typeof msg.id.remote === 'object') {
|
||||
msg.id = Object.assign({}, msg.id, {remote: msg.id.remote._serialized});
|
||||
if (typeof msg.id.remote === 'object') {
|
||||
msg.id = Object.assign({}, msg.id, { remote: msg.id.remote._serialized });
|
||||
}
|
||||
|
||||
|
||||
delete msg.pendingAckUpdate;
|
||||
|
||||
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
window.WWebJS.getChatModel = async chat => {
|
||||
|
||||
let res = chat.serialize();
|
||||
res.isGroup = chat.isGroup;
|
||||
res.formattedTitle = chat.formattedTitle;
|
||||
res.isMuted = chat.mute && chat.mute.isMuted;
|
||||
|
||||
if (chat.groupMetadata) {
|
||||
await window.Store.GroupMetadata.update(chat.id._serialized);
|
||||
const chatWid = window.Store.WidFactory.createWid((chat.id._serialized));
|
||||
await window.Store.GroupMetadata.update(chatWid);
|
||||
res.groupMetadata = chat.groupMetadata.serialize();
|
||||
}
|
||||
|
||||
@@ -365,7 +433,7 @@ exports.LoadUtils = () => {
|
||||
};
|
||||
|
||||
window.WWebJS.getChats = async () => {
|
||||
const chats = window.Store.Chat.models;
|
||||
const chats = window.Store.Chat.getModelsArray();
|
||||
|
||||
const chatPromises = chats.map(chat => window.WWebJS.getChatModel(chat));
|
||||
return await Promise.all(chatPromises);
|
||||
@@ -397,12 +465,12 @@ exports.LoadUtils = () => {
|
||||
};
|
||||
|
||||
window.WWebJS.getContacts = () => {
|
||||
const contacts = window.Store.Contact.models;
|
||||
const contacts = window.Store.Contact.getModelsArray();
|
||||
return contacts.map(contact => window.WWebJS.getContactModel(contact));
|
||||
};
|
||||
|
||||
window.WWebJS.mediaInfoToFile = ({ data, mimetype, filename }) => {
|
||||
const binaryData = atob(data);
|
||||
const binaryData = window.atob(data);
|
||||
|
||||
const buffer = new ArrayBuffer(binaryData.length);
|
||||
const view = new Uint8Array(buffer);
|
||||
@@ -419,15 +487,29 @@ exports.LoadUtils = () => {
|
||||
|
||||
window.WWebJS.arrayBufferToBase64 = (arrayBuffer) => {
|
||||
let binary = '';
|
||||
const bytes = new Uint8Array( arrayBuffer );
|
||||
const bytes = new Uint8Array(arrayBuffer);
|
||||
const len = bytes.byteLength;
|
||||
for (let i = 0; i < len; i++) {
|
||||
binary += String.fromCharCode( bytes[ i ] );
|
||||
binary += String.fromCharCode(bytes[i]);
|
||||
}
|
||||
return window.btoa( binary );
|
||||
return window.btoa(binary);
|
||||
};
|
||||
|
||||
window.WWebJS.getFileHash = async (data) => {
|
||||
window.WWebJS.arrayBufferToBase64Async = (arrayBuffer) =>
|
||||
new Promise((resolve, reject) => {
|
||||
const blob = new Blob([arrayBuffer], {
|
||||
type: 'application/octet-stream',
|
||||
});
|
||||
const fileReader = new FileReader();
|
||||
fileReader.onload = () => {
|
||||
const [, data] = fileReader.result.split(',');
|
||||
resolve(data);
|
||||
};
|
||||
fileReader.onerror = (e) => reject(e);
|
||||
fileReader.readAsDataURL(blob);
|
||||
});
|
||||
|
||||
window.WWebJS.getFileHash = async (data) => {
|
||||
let buffer = await data.arrayBuffer();
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', buffer);
|
||||
return btoa(String.fromCharCode(...new Uint8Array(hashBuffer)));
|
||||
@@ -437,7 +519,7 @@ exports.LoadUtils = () => {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
for (var i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
@@ -462,15 +544,18 @@ exports.LoadUtils = () => {
|
||||
};
|
||||
|
||||
window.WWebJS.sendChatstate = async (state, chatId) => {
|
||||
if (window.Store.MDBackend) {
|
||||
chatId = window.Store.WidFactory.createWid(chatId);
|
||||
}
|
||||
switch (state) {
|
||||
case 'typing':
|
||||
await window.Store.Wap.sendChatstateComposing(chatId);
|
||||
await window.Store.ChatState.sendChatStateComposing(chatId);
|
||||
break;
|
||||
case 'recording':
|
||||
await window.Store.Wap.sendChatstateRecording(chatId);
|
||||
await window.Store.ChatState.sendChatStateRecording(chatId);
|
||||
break;
|
||||
case 'stop':
|
||||
await window.Store.Wap.sendChatstatePaused(chatId);
|
||||
await window.Store.ChatState.sendChatStatePaused(chatId);
|
||||
break;
|
||||
default:
|
||||
throw 'Invalid chatstate';
|
||||
@@ -482,12 +567,12 @@ exports.LoadUtils = () => {
|
||||
window.WWebJS.getLabelModel = label => {
|
||||
let res = label.serialize();
|
||||
res.hexColor = label.hexColor;
|
||||
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
window.WWebJS.getLabels = () => {
|
||||
const labels = window.Store.Label.models;
|
||||
const labels = window.Store.Label.getModelsArray();
|
||||
return labels.map(label => window.WWebJS.getLabelModel(label));
|
||||
};
|
||||
|
||||
@@ -501,8 +586,9 @@ exports.LoadUtils = () => {
|
||||
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.getOrderDetail = async (orderId, token, chatId) => {
|
||||
const chatWid = window.Store.WidFactory.createWid(chatId);
|
||||
return window.Store.QueryOrder.queryOrder(chatWid, orderId, 80, 80, token);
|
||||
};
|
||||
|
||||
window.WWebJS.getProductMetadata = async (productId) => {
|
||||
@@ -515,20 +601,3 @@ exports.LoadUtils = () => {
|
||||
return undefined;
|
||||
};
|
||||
};
|
||||
|
||||
exports.MarkAllRead = () => {
|
||||
let Chats = window.Store.Chat.models;
|
||||
|
||||
for (let chatIndex in Chats) {
|
||||
if (isNaN(chatIndex)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let chat = Chats[chatIndex];
|
||||
|
||||
if (chat.unreadCount > 0) {
|
||||
chat.markSeen();
|
||||
window.Store.Wap.sendConversationSeen(chat.id, chat.getLastMsgKeyForAction(), chat.unreadCount - chat.pendingSeenCount);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
'use strict';
|
||||
|
||||
const sharp = require('sharp');
|
||||
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);
|
||||
|
||||
/**
|
||||
* Utility methods
|
||||
*/
|
||||
class Util {
|
||||
|
||||
constructor() {
|
||||
throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
|
||||
}
|
||||
@@ -23,7 +20,7 @@ class Util {
|
||||
var result = '';
|
||||
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
var charactersLength = characters.length;
|
||||
for ( var i = 0; i < length; i++ ) {
|
||||
for (var i = 0; i < length; i++) {
|
||||
result += characters.charAt(Math.floor(Math.random() * charactersLength));
|
||||
}
|
||||
return result;
|
||||
@@ -55,33 +52,19 @@ class Util {
|
||||
*
|
||||
* @returns {Promise<MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatImageToWebpSticker(media) {
|
||||
static async formatImageToWebpSticker(media, pupPage) {
|
||||
if (!media.mimetype.includes('image'))
|
||||
throw new Error('media is not a image');
|
||||
|
||||
|
||||
if (media.mimetype.includes('webp')) {
|
||||
return media;
|
||||
}
|
||||
|
||||
const buff = Buffer.from(media.data, 'base64');
|
||||
|
||||
let sharpImg = sharp(buff);
|
||||
sharpImg = sharpImg.webp();
|
||||
|
||||
sharpImg = sharpImg.resize(512, 512, {
|
||||
fit: 'contain',
|
||||
background: { r: 0, g: 0, b: 0, alpha: 0 },
|
||||
});
|
||||
|
||||
let webpBase64 = (await sharpImg.toBuffer()).toString('base64');
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: webpBase64,
|
||||
filename: media.filename,
|
||||
};
|
||||
|
||||
return pupPage.evaluate((media) => {
|
||||
return window.WWebJS.toStickerData(media);
|
||||
}, media);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Formats a video to webp
|
||||
* @param {MessageMedia} media
|
||||
@@ -91,14 +74,14 @@ class Util {
|
||||
static async formatVideoToWebpSticker(media) {
|
||||
if (!media.mimetype.includes('video'))
|
||||
throw new Error('media is not a video');
|
||||
|
||||
|
||||
const videoType = media.mimetype.split('/')[1];
|
||||
|
||||
const tempFile = path.join(
|
||||
tmpdir(),
|
||||
`${Crypto.randomBytes(6).readUIntLE(0, 6).toString(36)}.webp`
|
||||
);
|
||||
|
||||
|
||||
const stream = new (require('stream').Readable)();
|
||||
const buffer = Buffer.from(
|
||||
media.data.replace(`data:${media.mimetype};base64,`, ''),
|
||||
@@ -135,17 +118,17 @@ class Util {
|
||||
.toFormat('webp')
|
||||
.save(tempFile);
|
||||
});
|
||||
|
||||
|
||||
const data = await fs.readFile(tempFile, 'base64');
|
||||
await fs.unlink(tempFile);
|
||||
|
||||
return {
|
||||
|
||||
return {
|
||||
mimetype: 'image/webp',
|
||||
data: data,
|
||||
filename: media.filename,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sticker metadata.
|
||||
* @typedef {Object} StickerMetadata
|
||||
@@ -161,14 +144,14 @@ class Util {
|
||||
*
|
||||
* @returns {Promise<MessageMedia>} media in webp format
|
||||
*/
|
||||
static async formatToWebpSticker(media, metadata) {
|
||||
static async formatToWebpSticker(media, metadata, pupPage) {
|
||||
let webpMedia;
|
||||
|
||||
if (media.mimetype.includes('image'))
|
||||
webpMedia = await this.formatImageToWebpSticker(media);
|
||||
else if (media.mimetype.includes('video'))
|
||||
if (media.mimetype.includes('image'))
|
||||
webpMedia = await this.formatImageToWebpSticker(media, pupPage);
|
||||
else if (media.mimetype.includes('video'))
|
||||
webpMedia = await this.formatVideoToWebpSticker(media);
|
||||
else
|
||||
else
|
||||
throw new Error('Invalid media format');
|
||||
|
||||
if (metadata.name || metadata.author) {
|
||||
|
||||
@@ -3,8 +3,12 @@
|
||||
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_SESSION`: A JSON-formatted string with legacy auth session details. Must include `WABrowserId`, `WASecretBundle`, `WAToken1` and `WAToken2`.
|
||||
- `WWEBJS_TEST_SESSION_PATH`: Path to a JSON file that contains the legacy auth session details. Must include `WABrowserId`, `WASecretBundle`, `WAToken1` and `WAToken2`.
|
||||
- `WWEBJS_TEST_CLIENT_ID`: `clientId` to use for local file based authentication.
|
||||
- `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.
|
||||
You *must* set `WWEBJS_TEST_REMOTE_ID` **and** either `WWEBJS_TEST_SESSION`, `WWEBJS_TEST_SESSION_PATH` or `WWEBJS_TEST_CLIENT_ID` for the tests to run properly.
|
||||
|
||||
### Multidevice
|
||||
Some of the tested functionality depends on whether the account has multidevice enabled or not. If you are using multidevice, you should set `WWEBJS_TEST_MD=1`.
|
||||
427
tests/client.js
427
tests/client.js
@@ -1,4 +1,5 @@
|
||||
const {expect} = require('chai');
|
||||
const chai = require('chai');
|
||||
const chaiAsPromised = require('chai-as-promised');
|
||||
const sinon = require('sinon');
|
||||
|
||||
const helper = require('./helper');
|
||||
@@ -7,11 +8,84 @@ 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 LegacySessionAuth = require('../src/authStrategies/LegacySessionAuth');
|
||||
const { MessageTypes, WAState, DefaultOptions } = require('../src/util/Constants');
|
||||
|
||||
const expect = chai.expect;
|
||||
chai.use(chaiAsPromised);
|
||||
|
||||
const remoteId = helper.remoteId;
|
||||
const isMD = helper.isMD();
|
||||
|
||||
describe('Client', function() {
|
||||
describe('User Agent', function () {
|
||||
it('should set user agent on browser', async function () {
|
||||
this.timeout(25000);
|
||||
|
||||
const client = helper.createClient();
|
||||
client.initialize();
|
||||
|
||||
await helper.sleep(20000);
|
||||
|
||||
const browserUA = await client.pupBrowser.userAgent();
|
||||
expect(browserUA).to.equal(DefaultOptions.userAgent);
|
||||
|
||||
const pageUA = await client.pupPage.evaluate(() => window.navigator.userAgent);
|
||||
expect(pageUA).to.equal(DefaultOptions.userAgent);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('should set custom user agent on browser', async function () {
|
||||
this.timeout(25000);
|
||||
const customUA = DefaultOptions.userAgent.replace(/Chrome\/.* /, 'Chrome/99.9.9999.999 ');
|
||||
|
||||
const client = helper.createClient({
|
||||
options: {
|
||||
userAgent: customUA
|
||||
}
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
await helper.sleep(20000);
|
||||
|
||||
const browserUA = await client.pupBrowser.userAgent();
|
||||
expect(browserUA).to.equal(customUA);
|
||||
expect(browserUA.includes('Chrome/99.9.9999.999')).to.equal(true);
|
||||
|
||||
const pageUA = await client.pupPage.evaluate(() => window.navigator.userAgent);
|
||||
expect(pageUA).to.equal(customUA);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('should respect an existing user agent arg', async function () {
|
||||
this.timeout(25000);
|
||||
|
||||
const customUA = DefaultOptions.userAgent.replace(/Chrome\/.* /, 'Chrome/99.9.9999.999 ');
|
||||
|
||||
const client = helper.createClient({
|
||||
options: {
|
||||
puppeteer: {
|
||||
args: [`--user-agent=${customUA}`]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
client.initialize();
|
||||
await helper.sleep(20000);
|
||||
|
||||
const browserUA = await client.pupBrowser.userAgent();
|
||||
expect(browserUA).to.equal(customUA);
|
||||
expect(browserUA.includes('Chrome/99.9.9999.999')).to.equal(true);
|
||||
|
||||
const pageUA = await client.pupPage.evaluate(() => window.navigator.userAgent);
|
||||
expect(pageUA).to.equal(DefaultOptions.userAgent);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Authentication', function() {
|
||||
it('should emit QR code if not authenticated', async function() {
|
||||
this.timeout(25000);
|
||||
@@ -24,7 +98,7 @@ describe('Client', function() {
|
||||
await helper.sleep(20000);
|
||||
|
||||
expect(callback.called).to.equal(true);
|
||||
expect(callback.args[0][0]).to.have.lengthOf(152);
|
||||
expect(callback.args[0][0]).to.have.length.greaterThanOrEqual(152);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
@@ -47,76 +121,6 @@ describe('Client', function() {
|
||||
expect(disconnectedCallback.calledOnceWith('Max qrcode retries reached')).to.eql(true);
|
||||
});
|
||||
|
||||
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);
|
||||
|
||||
@@ -124,7 +128,10 @@ describe('Client', function() {
|
||||
const qrCallback = sinon.spy();
|
||||
const readyCallback = sinon.spy();
|
||||
|
||||
const client = helper.createClient({withSession: true});
|
||||
const client = helper.createClient({
|
||||
authenticated: true,
|
||||
});
|
||||
|
||||
client.on('qr', qrCallback);
|
||||
client.on('authenticated', authenticatedCallback);
|
||||
client.on('ready', readyCallback);
|
||||
@@ -132,19 +139,139 @@ describe('Client', function() {
|
||||
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);
|
||||
|
||||
if(helper.isUsingLegacySession()) {
|
||||
const newSession = authenticatedCallback.args[0][0];
|
||||
expect(newSession).to.have.key([
|
||||
'WABrowserId',
|
||||
'WASecretBundle',
|
||||
'WAToken1',
|
||||
'WAToken2'
|
||||
]);
|
||||
}
|
||||
|
||||
expect(readyCallback.called).to.equal(true);
|
||||
expect(qrCallback.called).to.equal(false);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('LegacySessionAuth', function () {
|
||||
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: {
|
||||
authStrategy: new LegacySessionAuth({
|
||||
session: {
|
||||
WABrowserId: 'invalid',
|
||||
WASecretBundle: 'invalid',
|
||||
WAToken1: 'invalid',
|
||||
WAToken2: 'invalid'
|
||||
},
|
||||
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: {
|
||||
authStrategy: new LegacySessionAuth({
|
||||
session: {
|
||||
WABrowserId: 'invalid',
|
||||
WASecretBundle: 'invalid',
|
||||
WAToken1: 'invalid',
|
||||
WAToken2: 'invalid'
|
||||
},
|
||||
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.length.greaterThanOrEqual(152);
|
||||
|
||||
await client.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Non-MD only', function () {
|
||||
if(!isMD) {
|
||||
it('can take over if client was logged in somewhere else with takeoverOnConflict=true', async function() {
|
||||
this.timeout(40000);
|
||||
|
||||
const readyCallback1 = sinon.spy();
|
||||
const readyCallback2 = sinon.spy();
|
||||
const disconnectedCallback1 = sinon.spy();
|
||||
const disconnectedCallback2 = sinon.spy();
|
||||
|
||||
const client1 = helper.createClient({
|
||||
authenticated: true,
|
||||
options: { takeoverOnConflict: true, takeoverTimeoutMs: 5000 }
|
||||
});
|
||||
const client2 = helper.createClient({authenticated: true});
|
||||
|
||||
client1.on('ready', readyCallback1);
|
||||
client2.on('ready', readyCallback2);
|
||||
client1.on('disconnected', disconnectedCallback1);
|
||||
client2.on('disconnected', disconnectedCallback2);
|
||||
|
||||
await client1.initialize();
|
||||
expect(readyCallback1.called).to.equal(true);
|
||||
expect(readyCallback2.called).to.equal(false);
|
||||
expect(disconnectedCallback1.called).to.equal(false);
|
||||
expect(disconnectedCallback2.called).to.equal(false);
|
||||
|
||||
await client2.initialize();
|
||||
expect(readyCallback2.called).to.equal(true);
|
||||
expect(disconnectedCallback1.called).to.equal(false);
|
||||
expect(disconnectedCallback2.called).to.equal(false);
|
||||
|
||||
// wait for takeoverTimeoutMs to kick in
|
||||
await helper.sleep(5200);
|
||||
expect(disconnectedCallback1.called).to.equal(false);
|
||||
expect(disconnectedCallback2.called).to.equal(true);
|
||||
expect(disconnectedCallback2.calledWith(WAState.CONFLICT)).to.equal(true);
|
||||
|
||||
await client1.destroy();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('Authenticated', function() {
|
||||
@@ -152,7 +279,7 @@ describe('Client', function() {
|
||||
|
||||
before(async function() {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({withSession: true});
|
||||
client = helper.createClient({authenticated: true});
|
||||
await client.initialize();
|
||||
});
|
||||
|
||||
@@ -160,6 +287,12 @@ describe('Client', function() {
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('can get current WhatsApp Web version', async function () {
|
||||
const version = await client.getWWebVersion();
|
||||
expect(typeof version).to.equal('string');
|
||||
console.log(`WA Version: ${version}`);
|
||||
});
|
||||
|
||||
describe('Expose Store', function() {
|
||||
it('exposes the store', async function() {
|
||||
const exposed = await client.pupPage.evaluate(() => {
|
||||
@@ -171,46 +304,58 @@ describe('Client', function() {
|
||||
|
||||
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',
|
||||
'Call',
|
||||
'Chat',
|
||||
'ChatState',
|
||||
'Cmd',
|
||||
'Conn',
|
||||
'Contact',
|
||||
'DownloadManager',
|
||||
'EphemeralFields',
|
||||
'Features',
|
||||
'GroupMetadata',
|
||||
'GroupParticipants',
|
||||
'GroupUtils',
|
||||
'Invite',
|
||||
'InviteInfo',
|
||||
'JoinInviteV4',
|
||||
'Label',
|
||||
'MediaObject',
|
||||
'MediaPrep',
|
||||
'MediaTypes',
|
||||
'MediaUpload',
|
||||
'MessageInfo',
|
||||
'Msg',
|
||||
'MsgKey',
|
||||
'OpaqueData',
|
||||
'QueryOrder',
|
||||
'QueryProduct',
|
||||
'DownloadManager'
|
||||
];
|
||||
'PresenceUtils',
|
||||
'ProfilePic',
|
||||
'QueryExist',
|
||||
'QueryProduct',
|
||||
'QueryOrder',
|
||||
'SendClear',
|
||||
'SendDelete',
|
||||
'SendMessage',
|
||||
'SendSeen',
|
||||
'StatusUtils',
|
||||
'UploadUtils',
|
||||
'UserConstructor',
|
||||
'VCard',
|
||||
'Validators',
|
||||
'WidFactory',
|
||||
'findCommonGroups',
|
||||
'sendReactionToMsg',
|
||||
];
|
||||
|
||||
const loadedModules = await client.pupPage.evaluate(() => {
|
||||
return Object.keys(window.Store);
|
||||
});
|
||||
const loadedModules = await client.pupPage.evaluate((expectedModules) => {
|
||||
return expectedModules.filter(m => Boolean(window.Store[m]));
|
||||
}, expectedModules);
|
||||
|
||||
expect(loadedModules).to.include.members(expectedModules);
|
||||
expect(loadedModules).to.have.members(expectedModules);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -486,5 +631,51 @@ END:VCARD`;
|
||||
expect(formatted).to.eql('+1 (809) 220-1111');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Search messages', function () {
|
||||
it('can search for messages', async function () {
|
||||
const m1 = await client.sendMessage(remoteId, 'I\'m searching for Super Mario Brothers');
|
||||
const m2 = await client.sendMessage(remoteId, 'This also contains Mario');
|
||||
const m3 = await client.sendMessage(remoteId, 'Nothing of interest here, just Luigi');
|
||||
|
||||
// wait for search index to catch up
|
||||
await helper.sleep(1000);
|
||||
|
||||
const msgs = await client.searchMessages('Mario', {chatId: remoteId});
|
||||
expect(msgs.length).to.be.greaterThanOrEqual(2);
|
||||
const msgIds = msgs.map(m => m.id._serialized);
|
||||
expect(msgIds).to.include.members([
|
||||
m1.id._serialized, m2.id._serialized
|
||||
]);
|
||||
expect(msgIds).to.not.include.members([m3.id._serialized]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Status/About', function () {
|
||||
let me, previousStatus;
|
||||
|
||||
before(async function () {
|
||||
me = await client.getContactById(client.info.wid._serialized);
|
||||
previousStatus = await me.getAbout();
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await client.setStatus(previousStatus);
|
||||
});
|
||||
|
||||
it('can set the status text', async function () {
|
||||
await client.setStatus('My shiny new status');
|
||||
|
||||
const status = await me.getAbout();
|
||||
expect(status).to.eql('My shiny new status');
|
||||
});
|
||||
|
||||
it('can set the status text to something else', async function () {
|
||||
await client.setStatus('Busy');
|
||||
|
||||
const status = await me.getAbout();
|
||||
expect(status).to.eql('Busy');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,13 +1,24 @@
|
||||
const path = require('path');
|
||||
const Client = require('../src/Client');
|
||||
const Util = require('../src/util/Util');
|
||||
const { Client, LegacySessionAuth, LocalAuth } = require('..');
|
||||
|
||||
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 isUsingLegacySession() {
|
||||
return Boolean(process.env.WWEBJS_TEST_SESSION || process.env.WWEBJS_TEST_SESSION_PATH);
|
||||
}
|
||||
|
||||
function isMD() {
|
||||
return Boolean(process.env.WWEBJS_TEST_MD);
|
||||
}
|
||||
|
||||
if(isUsingLegacySession() && isMD()) throw 'Cannot use legacy sessions with WWEBJS_TEST_MD=true';
|
||||
|
||||
function getSessionFromEnv() {
|
||||
if (!isUsingLegacySession()) return null;
|
||||
|
||||
const envSession = process.env.WWEBJS_TEST_SESSION;
|
||||
if(envSession) return JSON.parse(envSession);
|
||||
|
||||
@@ -16,17 +27,28 @@ function getSessionFromEnv() {
|
||||
const absPath = path.resolve(process.cwd(), envSessionPath);
|
||||
return require(absPath);
|
||||
}
|
||||
|
||||
throw new Error('No session found in environment.');
|
||||
}
|
||||
|
||||
function createClient({withSession, options: additionalOpts}={}) {
|
||||
function createClient({authenticated, options: additionalOpts}={}) {
|
||||
const options = {};
|
||||
if(withSession) {
|
||||
options.session = getSessionFromEnv();
|
||||
|
||||
if(authenticated) {
|
||||
const legacySession = getSessionFromEnv();
|
||||
if(legacySession) {
|
||||
options.authStrategy = new LegacySessionAuth({
|
||||
session: legacySession
|
||||
});
|
||||
} else {
|
||||
const clientId = process.env.WWEBJS_TEST_CLIENT_ID;
|
||||
if(!clientId) throw new Error('No session found in environment.');
|
||||
options.authStrategy = new LocalAuth({
|
||||
clientId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return new Client(Util.mergeDefault(options, additionalOpts || {}));
|
||||
const allOpts = {...options, ...(additionalOpts || {})};
|
||||
return new Client(allOpts);
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
@@ -36,5 +58,7 @@ function sleep(ms) {
|
||||
module.exports = {
|
||||
sleep,
|
||||
createClient,
|
||||
remoteId
|
||||
isUsingLegacySession,
|
||||
isMD,
|
||||
remoteId,
|
||||
};
|
||||
193
tests/structures/chat.js
Normal file
193
tests/structures/chat.js
Normal file
@@ -0,0 +1,193 @@
|
||||
const { expect } = require('chai');
|
||||
|
||||
const helper = require('../helper');
|
||||
const Message = require('../../src/structures/Message');
|
||||
const { MessageTypes } = require('../../src/util/Constants');
|
||||
const { Contact } = require('../../src/structures');
|
||||
|
||||
const remoteId = helper.remoteId;
|
||||
|
||||
describe('Chat', function () {
|
||||
let client;
|
||||
let chat;
|
||||
|
||||
before(async function() {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({ authenticated: true });
|
||||
await client.initialize();
|
||||
chat = await client.getChatById(remoteId);
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
it('can send a message to a chat', async function () {
|
||||
const msg = await chat.sendMessage('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 fetch messages sent in a chat', async function () {
|
||||
await helper.sleep(1000);
|
||||
const msg = await chat.sendMessage('another message');
|
||||
await helper.sleep(500);
|
||||
|
||||
const messages = await chat.fetchMessages();
|
||||
expect(messages.length).to.be.greaterThanOrEqual(2);
|
||||
|
||||
const fetchedMsg = messages[messages.length-1];
|
||||
expect(fetchedMsg).to.be.instanceOf(Message);
|
||||
expect(fetchedMsg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(fetchedMsg.id._serialized).to.equal(msg.id._serialized);
|
||||
expect(fetchedMsg.body).to.equal(msg.body);
|
||||
});
|
||||
|
||||
it('can use a limit when fetching messages sent in a chat', async function () {
|
||||
await helper.sleep(1000);
|
||||
const msg = await chat.sendMessage('yet another message');
|
||||
await helper.sleep(500);
|
||||
|
||||
const messages = await chat.fetchMessages({limit: 1});
|
||||
expect(messages).to.have.lengthOf(1);
|
||||
|
||||
const fetchedMsg = messages[0];
|
||||
expect(fetchedMsg).to.be.instanceOf(Message);
|
||||
expect(fetchedMsg.type).to.equal(MessageTypes.TEXT);
|
||||
expect(fetchedMsg.id._serialized).to.equal(msg.id._serialized);
|
||||
expect(fetchedMsg.body).to.equal(msg.body);
|
||||
});
|
||||
|
||||
it('can get the related contact', async function () {
|
||||
const contact = await chat.getContact();
|
||||
expect(contact).to.be.instanceOf(Contact);
|
||||
expect(contact.id._serialized).to.equal(chat.id._serialized);
|
||||
});
|
||||
|
||||
describe('Seen', function () {
|
||||
it('can mark a chat as unread', async function () {
|
||||
await chat.markUnread();
|
||||
await helper.sleep(500);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.unreadCount).to.equal(-1);
|
||||
});
|
||||
|
||||
it('can mark a chat as seen', async function () {
|
||||
const res = await chat.sendSeen();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.unreadCount).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Archiving', function (){
|
||||
it('can archive a chat', async function () {
|
||||
const res = await chat.archive();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.archived).to.equal(true);
|
||||
});
|
||||
|
||||
it('can unarchive a chat', async function () {
|
||||
const res = await chat.unarchive();
|
||||
expect(res).to.equal(false);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.archived).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Pinning', function () {
|
||||
it('can pin a chat', async function () {
|
||||
const res = await chat.pin();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.pinned).to.equal(true);
|
||||
});
|
||||
|
||||
it('can unpin a chat', async function () {
|
||||
const res = await chat.unpin();
|
||||
expect(res).to.equal(false);
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.pinned).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Muting', function () {
|
||||
it('can mute a chat forever', async function() {
|
||||
await chat.mute();
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(true);
|
||||
expect(chat.muteExpiration).to.equal(-1);
|
||||
});
|
||||
|
||||
it('can mute a chat until a specific date', async function() {
|
||||
const unmuteDate = new Date(new Date().getTime() + (1000*60*60));
|
||||
await chat.mute(unmuteDate);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(true);
|
||||
expect(chat.muteExpiration).to.equal(
|
||||
Math.round(unmuteDate.getTime() / 1000)
|
||||
);
|
||||
});
|
||||
|
||||
it('can unmute a chat', async function () {
|
||||
await chat.unmute();
|
||||
await helper.sleep(500);
|
||||
|
||||
// refresh chat
|
||||
chat = await client.getChatById(remoteId);
|
||||
expect(chat.isMuted).to.equal(false);
|
||||
expect(chat.muteExpiration).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
// eslint-disable-next-line mocha/no-skipped-tests
|
||||
describe.skip('Destructive operations', function () {
|
||||
it('can clear all messages from chat', async function () {
|
||||
const res = await chat.clearMessages();
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(3000);
|
||||
|
||||
const msgs = await chat.fetchMessages();
|
||||
expect(msgs).to.have.lengthOf(0);
|
||||
});
|
||||
|
||||
it('can delete a chat', async function () {
|
||||
const res = await chat.delete();
|
||||
expect(res).to.equal(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
227
tests/structures/group.js
Normal file
227
tests/structures/group.js
Normal file
@@ -0,0 +1,227 @@
|
||||
const { expect } = require('chai');
|
||||
const helper = require('../helper');
|
||||
|
||||
const remoteId = helper.remoteId;
|
||||
|
||||
describe('Group', function() {
|
||||
let client;
|
||||
let group;
|
||||
|
||||
before(async function() {
|
||||
this.timeout(35000);
|
||||
client = helper.createClient({
|
||||
authenticated: true,
|
||||
});
|
||||
await client.initialize();
|
||||
|
||||
const createRes = await client.createGroup('My Awesome Group', [remoteId]);
|
||||
expect(createRes.gid).to.exist;
|
||||
await helper.sleep(500);
|
||||
group = await client.getChatById(createRes.gid._serialized);
|
||||
expect(group).to.exist;
|
||||
});
|
||||
|
||||
beforeEach(async function () {
|
||||
await helper.sleep(500);
|
||||
});
|
||||
|
||||
describe('Settings', function () {
|
||||
it('can change the group subject', async function () {
|
||||
expect(group.name).to.equal('My Awesome Group');
|
||||
const res = await group.setSubject('My Amazing Group');
|
||||
expect(res).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.name).to.equal('My Amazing Group');
|
||||
});
|
||||
|
||||
it('can change the group description', async function () {
|
||||
expect(group.description).to.equal(undefined);
|
||||
const res = await group.setDescription('some description');
|
||||
expect(res).to.equal(true);
|
||||
expect(group.description).to.equal('some description');
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.description).to.equal('some description');
|
||||
});
|
||||
|
||||
it('can set only admins able to send messages', async function () {
|
||||
expect(group.groupMetadata.announce).to.equal(false);
|
||||
const res = await group.setMessagesAdminsOnly();
|
||||
expect(res).to.equal(true);
|
||||
expect(group.groupMetadata.announce).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.groupMetadata.announce).to.equal(true);
|
||||
});
|
||||
|
||||
it('can set all participants able to send messages', async function () {
|
||||
expect(group.groupMetadata.announce).to.equal(true);
|
||||
const res = await group.setMessagesAdminsOnly(false);
|
||||
expect(res).to.equal(true);
|
||||
expect(group.groupMetadata.announce).to.equal(false);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.groupMetadata.announce).to.equal(false);
|
||||
});
|
||||
|
||||
it('can set only admins able to set group info', async function () {
|
||||
expect(group.groupMetadata.restrict).to.equal(false);
|
||||
const res = await group.setInfoAdminsOnly();
|
||||
expect(res).to.equal(true);
|
||||
expect(group.groupMetadata.restrict).to.equal(true);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.groupMetadata.restrict).to.equal(true);
|
||||
});
|
||||
|
||||
it('can set all participants able to set group info', async function () {
|
||||
expect(group.groupMetadata.restrict).to.equal(true);
|
||||
const res = await group.setInfoAdminsOnly(false);
|
||||
expect(res).to.equal(true);
|
||||
expect(group.groupMetadata.restrict).to.equal(false);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.groupMetadata.restrict).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Invites', function () {
|
||||
it('can get the invite code', async function () {
|
||||
const code = await group.getInviteCode();
|
||||
expect(typeof code).to.equal('string');
|
||||
});
|
||||
|
||||
it('can get invite info', async function () {
|
||||
const code = await group.getInviteCode();
|
||||
const info = await client.getInviteInfo(code);
|
||||
expect(info.id._serialized).to.equal(group.id._serialized);
|
||||
expect(info.participants.length).to.equal(2);
|
||||
});
|
||||
|
||||
it('can revoke the invite code', async function () {
|
||||
const code = await group.getInviteCode();
|
||||
const newCode = await group.revokeInvite();
|
||||
expect(typeof newCode).to.equal('string');
|
||||
expect(newCode).to.not.equal(code);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Participants', function () {
|
||||
it('can promote a user to admin', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized === remoteId);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(false);
|
||||
|
||||
const res = await group.promoteParticipants([remoteId]);
|
||||
expect(res.status).to.be.greaterThanOrEqual(200);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(true);
|
||||
});
|
||||
|
||||
it('can demote a user', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(true);
|
||||
|
||||
const res = await group.demoteParticipants([remoteId]);
|
||||
expect(res.status).to.be.greaterThanOrEqual(200);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.exist;
|
||||
expect(participant.isAdmin).to.equal(false);
|
||||
});
|
||||
|
||||
it('can remove a user from the group', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.exist;
|
||||
|
||||
const res = await group.removeParticipants([remoteId]);
|
||||
expect(res.status).to.be.greaterThanOrEqual(200);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.not.exist;
|
||||
});
|
||||
|
||||
it('can add back a user to the group', async function () {
|
||||
let participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.not.exist;
|
||||
|
||||
const res = await group.addParticipants([remoteId]);
|
||||
expect(res.status).to.be.greaterThanOrEqual(200);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
participant = group.participants.find(p => p.id._serialized=== remoteId);
|
||||
expect(participant).to.exist;
|
||||
});
|
||||
});
|
||||
|
||||
describe('Leave / re-join', function () {
|
||||
let code;
|
||||
before(async function () {
|
||||
code = await group.getInviteCode();
|
||||
});
|
||||
|
||||
it('can leave the group', async function () {
|
||||
expect(group.isReadOnly).to.equal(false);
|
||||
await group.leave();
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.isReadOnly).to.equal(true);
|
||||
});
|
||||
|
||||
it('can join a group via invite code', async function () {
|
||||
const chatId = await client.acceptInvite(code);
|
||||
expect(chatId).to.equal(group.id._serialized);
|
||||
|
||||
await helper.sleep(1000);
|
||||
|
||||
// reload and check
|
||||
group = await client.getChatById(group.id._serialized);
|
||||
expect(group.isReadOnly).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
after(async function () {
|
||||
await client.destroy();
|
||||
});
|
||||
|
||||
});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user