@another-trial/whatsapp-web.js 1.34.0 → 1.34.5-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/.env.example +2 -2
  2. package/CODE_OF_CONDUCT.md +133 -133
  3. package/LICENSE +201 -201
  4. package/README.md +155 -185
  5. package/example.js +706 -690
  6. package/index.d.ts +2259 -2202
  7. package/index.js +35 -35
  8. package/package.json +59 -59
  9. package/shell.js +36 -36
  10. package/src/Client.js +2533 -2361
  11. package/src/authStrategies/BaseAuthStrategy.js +26 -26
  12. package/src/authStrategies/LocalAuth.js +58 -58
  13. package/src/authStrategies/NoAuth.js +11 -11
  14. package/src/authStrategies/RemoteAuth.js +210 -210
  15. package/src/factories/ChatFactory.js +21 -21
  16. package/src/factories/ContactFactory.js +15 -15
  17. package/src/structures/Base.js +21 -21
  18. package/src/structures/Broadcast.js +69 -69
  19. package/src/structures/BusinessContact.js +20 -20
  20. package/src/structures/Buttons.js +81 -81
  21. package/src/structures/Call.js +75 -75
  22. package/src/structures/Channel.js +382 -382
  23. package/src/structures/Chat.js +329 -299
  24. package/src/structures/ClientInfo.js +70 -70
  25. package/src/structures/Contact.js +215 -208
  26. package/src/structures/GroupChat.js +485 -485
  27. package/src/structures/GroupNotification.js +104 -104
  28. package/src/structures/Label.js +49 -49
  29. package/src/structures/List.js +79 -79
  30. package/src/structures/Location.js +61 -61
  31. package/src/structures/Message.js +787 -747
  32. package/src/structures/MessageMedia.js +111 -111
  33. package/src/structures/Order.js +51 -51
  34. package/src/structures/Payment.js +79 -79
  35. package/src/structures/Poll.js +44 -44
  36. package/src/structures/PollVote.js +75 -75
  37. package/src/structures/PrivateChat.js +12 -12
  38. package/src/structures/PrivateContact.js +12 -12
  39. package/src/structures/Product.js +67 -67
  40. package/src/structures/ProductMetadata.js +24 -24
  41. package/src/structures/Reaction.js +68 -68
  42. package/src/structures/ScheduledEvent.js +71 -71
  43. package/src/structures/index.js +27 -27
  44. package/src/util/Constants.js +186 -183
  45. package/src/util/Injected/AuthStore/AuthStore.js +16 -16
  46. package/src/util/Injected/AuthStore/LegacyAuthStore.js +21 -21
  47. package/src/util/Injected/LegacyStore.js +145 -145
  48. package/src/util/Injected/Store.js +263 -231
  49. package/src/util/Injected/Utils.js +1221 -1169
  50. package/src/util/InterfaceController.js +126 -126
  51. package/src/util/Puppeteer.js +23 -23
  52. package/src/util/Util.js +186 -186
  53. package/src/webCache/LocalWebCache.js +40 -40
  54. package/src/webCache/RemoteWebCache.js +39 -39
  55. package/src/webCache/WebCache.js +13 -13
  56. package/src/webCache/WebCacheFactory.js +19 -19
@@ -1,40 +1,40 @@
1
- const path = require('path');
2
- const fs = require('fs');
3
-
4
- const { WebCache, VersionResolveError } = require('./WebCache');
5
-
6
- /**
7
- * LocalWebCache - Fetches a WhatsApp Web version from a local file store
8
- * @param {object} options - options
9
- * @param {string} options.path - Path to the directory where cached versions are saved, default is: "./.wwebjs_cache/"
10
- * @param {boolean} options.strict - If true, will throw an error if the requested version can't be fetched. If false, will resolve to the latest version.
11
- */
12
- class LocalWebCache extends WebCache {
13
- constructor(options = {}) {
14
- super();
15
-
16
- this.path = options.path || './.wwebjs_cache/';
17
- this.strict = options.strict || false;
18
- }
19
-
20
- async resolve(version) {
21
- const filePath = path.join(this.path, `${version}.html`);
22
-
23
- try {
24
- return fs.readFileSync(filePath, 'utf-8');
25
- }
26
- catch (err) {
27
- if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the cache`);
28
- return null;
29
- }
30
- }
31
-
32
- async persist(indexHtml, version) {
33
- // version = (version+'').replace(/[^0-9.]/g,'');
34
- const filePath = path.join(this.path, `${version}.html`);
35
- fs.mkdirSync(this.path, { recursive: true });
36
- fs.writeFileSync(filePath, indexHtml);
37
- }
38
- }
39
-
40
- module.exports = LocalWebCache;
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+
4
+ const { WebCache, VersionResolveError } = require('./WebCache');
5
+
6
+ /**
7
+ * LocalWebCache - Fetches a WhatsApp Web version from a local file store
8
+ * @param {object} options - options
9
+ * @param {string} options.path - Path to the directory where cached versions are saved, default is: "./.wwebjs_cache/"
10
+ * @param {boolean} options.strict - If true, will throw an error if the requested version can't be fetched. If false, will resolve to the latest version.
11
+ */
12
+ class LocalWebCache extends WebCache {
13
+ constructor(options = {}) {
14
+ super();
15
+
16
+ this.path = options.path || './.wwebjs_cache/';
17
+ this.strict = options.strict || false;
18
+ }
19
+
20
+ async resolve(version) {
21
+ const filePath = path.join(this.path, `${version}.html`);
22
+
23
+ try {
24
+ return fs.readFileSync(filePath, 'utf-8');
25
+ }
26
+ catch (err) {
27
+ if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the cache`);
28
+ return null;
29
+ }
30
+ }
31
+
32
+ async persist(indexHtml, version) {
33
+ // version = (version+'').replace(/[^0-9.]/g,'');
34
+ const filePath = path.join(this.path, `${version}.html`);
35
+ fs.mkdirSync(this.path, { recursive: true });
36
+ fs.writeFileSync(filePath, indexHtml);
37
+ }
38
+ }
39
+
40
+ module.exports = LocalWebCache;
@@ -1,40 +1,40 @@
1
- const fetch = require('node-fetch');
2
- const { WebCache, VersionResolveError } = require('./WebCache');
3
-
4
- /**
5
- * RemoteWebCache - Fetches a WhatsApp Web version index from a remote server
6
- * @param {object} options - options
7
- * @param {string} options.remotePath - Endpoint that should be used to fetch the version index. Use {version} as a placeholder for the version number.
8
- * @param {boolean} options.strict - If true, will throw an error if the requested version can't be fetched. If false, will resolve to the latest version. Defaults to false.
9
- */
10
- class RemoteWebCache extends WebCache {
11
- constructor(options = {}) {
12
- super();
13
-
14
- if (!options.remotePath) throw new Error('webVersionCache.remotePath is required when using the remote cache');
15
- this.remotePath = options.remotePath;
16
- this.strict = options.strict || false;
17
- }
18
-
19
- async resolve(version) {
20
- const remotePath = this.remotePath.replace('{version}', version);
21
-
22
- try {
23
- const cachedRes = await fetch(remotePath);
24
- if (cachedRes.ok) {
25
- return cachedRes.text();
26
- }
27
- } catch (err) {
28
- console.error(`Error fetching version ${version} from remote`, err);
29
- }
30
-
31
- if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the archive`);
32
- return null;
33
- }
34
-
35
- async persist() {
36
- // Nothing to do here
37
- }
38
- }
39
-
1
+ const fetch = require('node-fetch');
2
+ const { WebCache, VersionResolveError } = require('./WebCache');
3
+
4
+ /**
5
+ * RemoteWebCache - Fetches a WhatsApp Web version index from a remote server
6
+ * @param {object} options - options
7
+ * @param {string} options.remotePath - Endpoint that should be used to fetch the version index. Use {version} as a placeholder for the version number.
8
+ * @param {boolean} options.strict - If true, will throw an error if the requested version can't be fetched. If false, will resolve to the latest version. Defaults to false.
9
+ */
10
+ class RemoteWebCache extends WebCache {
11
+ constructor(options = {}) {
12
+ super();
13
+
14
+ if (!options.remotePath) throw new Error('webVersionCache.remotePath is required when using the remote cache');
15
+ this.remotePath = options.remotePath;
16
+ this.strict = options.strict || false;
17
+ }
18
+
19
+ async resolve(version) {
20
+ const remotePath = this.remotePath.replace('{version}', version);
21
+
22
+ try {
23
+ const cachedRes = await fetch(remotePath);
24
+ if (cachedRes.ok) {
25
+ return cachedRes.text();
26
+ }
27
+ } catch (err) {
28
+ console.error(`Error fetching version ${version} from remote`, err);
29
+ }
30
+
31
+ if (this.strict) throw new VersionResolveError(`Couldn't load version ${version} from the archive`);
32
+ return null;
33
+ }
34
+
35
+ async persist() {
36
+ // Nothing to do here
37
+ }
38
+ }
39
+
40
40
  module.exports = RemoteWebCache;
@@ -1,14 +1,14 @@
1
- /**
2
- * Default implementation of a web version cache that does nothing.
3
- */
4
- class WebCache {
5
- async resolve() { return null; }
6
- async persist() { }
7
- }
8
-
9
- class VersionResolveError extends Error { }
10
-
11
- module.exports = {
12
- WebCache,
13
- VersionResolveError
1
+ /**
2
+ * Default implementation of a web version cache that does nothing.
3
+ */
4
+ class WebCache {
5
+ async resolve() { return null; }
6
+ async persist() { }
7
+ }
8
+
9
+ class VersionResolveError extends Error { }
10
+
11
+ module.exports = {
12
+ WebCache,
13
+ VersionResolveError
14
14
  };
@@ -1,20 +1,20 @@
1
- const RemoteWebCache = require('./RemoteWebCache');
2
- const LocalWebCache = require('./LocalWebCache');
3
- const { WebCache } = require('./WebCache');
4
-
5
- const createWebCache = (type, options) => {
6
- switch (type) {
7
- case 'remote':
8
- return new RemoteWebCache(options);
9
- case 'local':
10
- return new LocalWebCache(options);
11
- case 'none':
12
- return new WebCache();
13
- default:
14
- throw new Error(`Invalid WebCache type ${type}`);
15
- }
16
- };
17
-
18
- module.exports = {
19
- createWebCache,
1
+ const RemoteWebCache = require('./RemoteWebCache');
2
+ const LocalWebCache = require('./LocalWebCache');
3
+ const { WebCache } = require('./WebCache');
4
+
5
+ const createWebCache = (type, options) => {
6
+ switch (type) {
7
+ case 'remote':
8
+ return new RemoteWebCache(options);
9
+ case 'local':
10
+ return new LocalWebCache(options);
11
+ case 'none':
12
+ return new WebCache();
13
+ default:
14
+ throw new Error(`Invalid WebCache type ${type}`);
15
+ }
16
+ };
17
+
18
+ module.exports = {
19
+ createWebCache,
20
20
  };