@wppconnect-team/wppconnect 2.3.5 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +72 -0
  2. package/README.md +87 -69
  3. package/README.pt-BR.md +119 -0
  4. package/dist/api/helpers/decrypt.js +8 -19
  5. package/dist/api/helpers/download-file.d.ts +4 -0
  6. package/dist/api/helpers/download-file.js +12 -0
  7. package/dist/api/helpers/file-to-base64.d.ts +6 -0
  8. package/dist/api/helpers/file-to-base64.js +27 -10
  9. package/dist/api/layers/catalog.layer.d.ts +3 -3
  10. package/dist/api/layers/catalog.layer.js +2 -2
  11. package/dist/api/layers/group.layer.js +3 -5
  12. package/dist/api/layers/host.layer.d.ts +10 -3
  13. package/dist/api/layers/host.layer.js +56 -25
  14. package/dist/api/layers/labels.layer.d.ts +34 -12
  15. package/dist/api/layers/labels.layer.js +36 -18
  16. package/dist/api/layers/profile.layer.d.ts +1 -1
  17. package/dist/api/layers/profile.layer.js +1 -3
  18. package/dist/api/layers/sender.layer.d.ts +4 -6
  19. package/dist/api/layers/sender.layer.js +6 -7
  20. package/dist/api/layers/status.layer.d.ts +13 -4
  21. package/dist/api/layers/status.layer.js +10 -9
  22. package/dist/api/model/index.d.ts +1 -0
  23. package/dist/api/model/index.js +1 -0
  24. package/dist/api/model/label.d.ts +16 -0
  25. package/dist/api/whatsapp.d.ts +24 -0
  26. package/dist/api/whatsapp.js +101 -52
  27. package/dist/config/create-config.d.ts +13 -1
  28. package/dist/config/create-config.js +2 -2
  29. package/dist/config/puppeteer.config.d.ts +12 -0
  30. package/dist/config/puppeteer.config.js +17 -7
  31. package/dist/controllers/auth.js +3 -1
  32. package/dist/controllers/browser.d.ts +27 -0
  33. package/dist/controllers/browser.js +128 -7
  34. package/dist/controllers/initializer.js +78 -44
  35. package/dist/lib/wapi/wapi.js +1 -1
  36. package/documentation/readme-reference.md +118 -0
  37. package/package.json +19 -19
  38. package/scripts/docs-redirects.mjs +70 -0
  39. package/scripts/typedoc-canonical.mjs +49 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wppconnect-team/wppconnect",
3
- "version": "2.3.5",
3
+ "version": "2.4.0",
4
4
  "description": "WPPConnect is an open source project developed by the JavaScript community with the aim of exporting functions from WhatsApp Web to the node, which can be used to support the creation of any interaction, such as customer service, media sending, intelligence recognition based on phrases artificial and many other things, use your imagination... 😀🤔💭",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "clean": "shx rm -rf session dist",
15
15
  "example": "node ./examples/basic/index.js",
16
16
  "commit": "cz",
17
- "docs:build": "npm run docs:clean && typedoc && npm run docs:copy-images",
17
+ "docs:build": "npm run docs:clean && typedoc && npm run docs:copy-images && node scripts/docs-redirects.mjs",
18
18
  "docs:clean": "shx rm -rf api-docs",
19
19
  "docs:copy-images": "shx cp -R ./img ./api-docs",
20
20
  "lint:js": "eslint 'src/**/*.js'",
@@ -55,49 +55,49 @@
55
55
  },
56
56
  "homepage": "https://github.com/wppconnect-team/wppconnect#readme",
57
57
  "devDependencies": {
58
- "@babel/core": "^7.29.7",
59
- "@babel/eslint-parser": "^7.29.9",
58
+ "@babel/core": "^7.29.13",
59
+ "@babel/eslint-parser": "^7.29.13",
60
60
  "@babel/eslint-plugin": "^7.29.7",
61
61
  "@babel/preset-env": "^7.29.7",
62
- "@commitlint/cli": "^21.2.3",
63
- "@commitlint/config-conventional": "^21.2.3",
64
- "@commitlint/cz-commitlint": "^21.2.3",
62
+ "@commitlint/cli": "^21.2.4",
63
+ "@commitlint/config-conventional": "^21.2.4",
64
+ "@commitlint/cz-commitlint": "^21.2.4",
65
65
  "@eslint/js": "^10.0.1",
66
66
  "@tony.ganchev/eslint-plugin-header": "^3.4.4",
67
67
  "@types/atob": "^2.1.4",
68
68
  "@types/mime-types": "^3.0.1",
69
69
  "@types/mocha": "^10.0.10",
70
- "@types/node": "^24.13.3",
70
+ "@types/node": "^24.19.2",
71
71
  "@types/shelljs": "^0.10.0",
72
72
  "@types/tmp": "^0.2.6",
73
73
  "@types/ws": "^8.18.1",
74
74
  "babel-loader": "^10.1.1",
75
75
  "commitizen": "^4.3.2",
76
- "concurrently": "^10.0.6",
76
+ "concurrently": "^10.0.7",
77
77
  "conventional-changelog-cli": "^5.0.0",
78
- "eslint": "10.12.0",
78
+ "eslint": "10.14.0",
79
79
  "eslint-config-prettier": "^10.1.8",
80
- "eslint-plugin-prettier": "^5.5.6",
81
- "globals": "^17.13.0",
80
+ "eslint-plugin-prettier": "^5.5.7",
81
+ "globals": "^17.14.0",
82
82
  "husky": "^9.1.7",
83
83
  "mocha": "^12.0.3",
84
84
  "prettier": "^2.8.8",
85
85
  "pretty-quick": "^4.2.2",
86
86
  "regenerator-runtime": "^0.14.1",
87
- "release-it": "^21.1.1",
87
+ "release-it": "^21.1.2",
88
88
  "shx": "^0.4.0",
89
89
  "ts-node": "^10.9.2",
90
90
  "typedoc": "^0.28.20",
91
91
  "typescript": "^5.9.3",
92
- "typescript-eslint": "^8.71.2",
93
- "webpack": "^5.110.3",
92
+ "typescript-eslint": "^8.72.2",
93
+ "webpack": "^5.112.2",
94
94
  "webpack-cli": "^6.0.1"
95
95
  },
96
96
  "dependencies": {
97
- "@wppconnect/wa-js": "^4.7.1",
97
+ "@wppconnect/wa-js": "^4.8.0",
98
98
  "@wppconnect/wa-version": "^1.5.4472",
99
99
  "atob": "^2.1.2",
100
- "axios": "^1.20.0",
100
+ "axios": "^1.21.0",
101
101
  "boxen": "^5.1.2",
102
102
  "catch-exit": "^2.0.0",
103
103
  "chalk": "~4.1.2",
@@ -107,7 +107,7 @@
107
107
  "logform": "^2.7.0",
108
108
  "lookpath": "^1.2.3",
109
109
  "mime-types": "^3.0.2",
110
- "puppeteer": "^24.43.1",
110
+ "puppeteer": "^25.16.0",
111
111
  "puppeteer-extra": "^3.3.6",
112
112
  "puppeteer-extra-plugin-stealth": "^2.11.2",
113
113
  "puppeteer-extra-plugin-user-data-dir": "^2.4.1",
@@ -123,7 +123,7 @@
123
123
  "ws": "^8.21.3"
124
124
  },
125
125
  "overrides": {
126
- "serialize-javascript": "7.1.2"
126
+ "serialize-javascript": "7.1.4"
127
127
  },
128
128
  "optionalDependencies": {
129
129
  "@img/sharp-win32-x64": "^0.35.5",
@@ -0,0 +1,70 @@
1
+ import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { dirname, resolve } from 'node:path';
3
+
4
+ const output = resolve('api-docs');
5
+ const base = 'https://wppconnect.io/wppconnect/';
6
+ const redirects = {
7
+ 'variables/WAJS.webpack.isInjected.html': 'variables/WAJS.isInjected.html',
8
+ 'variables/WAJS.webpack.__debug.html': 'variables/WAJS.loader.__debug.html',
9
+ 'variables/WAJS.webpack.webpackRequire.html':
10
+ 'variables/WAJS.loader.moduleRequire.html',
11
+ 'modules/WAJS.webpack.html': 'modules/WAJS.loader.html',
12
+ 'functions/WAJS.webpack.onReady.html': 'functions/WAJS.loader.onReady.html',
13
+ 'interfaces/WAJS.ev.WebpackEvents.html':
14
+ 'interfaces/WAJS.ev.LoaderEvents.html',
15
+ 'pages/getting-started/installation.html':
16
+ 'https://wppconnect.io/docs/tutorial/basics/installation/',
17
+ };
18
+
19
+ for (const [oldPath, target] of Object.entries(redirects)) {
20
+ const destination = new URL(target, base);
21
+ if (destination.href.startsWith(base)) {
22
+ await access(resolve(output, target));
23
+ }
24
+
25
+ const file = resolve(output, oldPath);
26
+ await mkdir(dirname(file), { recursive: true });
27
+ const html = [
28
+ '<!doctype html><html lang="en"><meta charset="utf-8">',
29
+ '<title>Documentation moved</title>',
30
+ '<link rel="canonical" href="' + destination.href + '">',
31
+ '<meta http-equiv="refresh" content="0; url=' + destination.href + '">',
32
+ '<p>Documentation moved. <a href="' +
33
+ destination.href +
34
+ '">Open the current reference</a>.</p></html>',
35
+ ].join('\n');
36
+ await writeFile(file, html, { flag: 'wx' });
37
+ }
38
+
39
+ // TypeDoc uses the directory URL in the home page's canonical link.
40
+ const sitemap = resolve(output, 'sitemap.xml');
41
+ const xml = await readFile(sitemap, 'utf8');
42
+ const canonicalXml = xml.replace(
43
+ '<loc>' + base + 'index.html</loc>',
44
+ '<loc>' + base + '</loc>'
45
+ );
46
+ const locations = Array.from(
47
+ canonicalXml.matchAll(/<loc>([^<]+)<\/loc>/g),
48
+ (match) => match[1]
49
+ );
50
+ if (!locations.some((location) => location === base))
51
+ throw new Error('Missing API reference home in sitemap');
52
+ for (const url of locations) {
53
+ const { origin, pathname } = new URL(url);
54
+ const root = new URL(base);
55
+ if (origin !== root.origin || !pathname.startsWith(root.pathname)) {
56
+ throw new Error('Unexpected sitemap URL: ' + url);
57
+ }
58
+ const path = pathname.slice(root.pathname.length) || 'index.html';
59
+ const html = await readFile(resolve(output, path), 'utf8');
60
+ const canonicals =
61
+ html.split('</head>', 1)[0].match(/<link\b[^>]*\brel="canonical"[^>]*>/g) ??
62
+ [];
63
+ if (
64
+ canonicals.length !== 1 ||
65
+ !canonicals[0].includes('href="' + url + '"')
66
+ ) {
67
+ throw new Error('Invalid canonical on ' + url);
68
+ }
69
+ }
70
+ await writeFile(sitemap, canonicalXml);
@@ -0,0 +1,49 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { JSX } from 'typedoc';
3
+
4
+ export function load(app) {
5
+ const base = app.options.getValue('hostedBaseUrl');
6
+ app.renderer.hooks.on('head.end', ({ page }) => {
7
+ // TypeDoc supplies the home page canonical through its sitemap plugin.
8
+ if (page.url === 'index.html') return;
9
+ return JSX.createElement('link', {
10
+ rel: 'canonical',
11
+ href: new URL(page.url, base).href,
12
+ });
13
+ });
14
+
15
+ const manifest = new URL(
16
+ '../node_modules/@wppconnect/wa-js/package.json',
17
+ import.meta.url
18
+ );
19
+ const { version } = JSON.parse(readFileSync(manifest, 'utf8'));
20
+ app.renderer.hooks.on('content.begin', ({ page }) => {
21
+ if (!/\/WAJS\./.test(page.url)) return;
22
+ return JSX.createElement(
23
+ 'p',
24
+ null,
25
+ 'The Node.js SDK re-exports the WAJS namespace for TypeScript. This reference describes types from ',
26
+ JSX.createElement(
27
+ 'a',
28
+ {
29
+ href:
30
+ 'https://github.com/wppconnect-team/wa-js/releases/tag/v' + version,
31
+ },
32
+ 'WA-JS ' + version
33
+ ),
34
+ '. For operations available on a connected Node.js client, see ',
35
+ JSX.createElement(
36
+ 'a',
37
+ { href: new URL('classes/Whatsapp.html', base).href },
38
+ 'Whatsapp'
39
+ ),
40
+ '. For functions running inside WhatsApp Web, see the ',
41
+ JSX.createElement(
42
+ 'a',
43
+ { href: 'https://wppconnect.io/wa-js/' },
44
+ 'WA-JS browser API'
45
+ ),
46
+ '.'
47
+ );
48
+ });
49
+ }