@wppconnect-team/wppconnect 2.0.3-alpha.1 → 2.0.3-alpha.2
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.
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Browser, BrowserContext, Page } from 'puppeteer';
|
|
2
|
-
import { CreateConfig } from '../config/create-config';
|
|
3
2
|
import { Logger } from 'winston';
|
|
4
|
-
import { SessionToken } from '../token-store';
|
|
5
3
|
import { LoadingScreenCallback } from '../api/model';
|
|
4
|
+
import { CreateConfig } from '../config/create-config';
|
|
5
|
+
import { SessionToken } from '../token-store';
|
|
6
6
|
import { LogLevel } from '../utils/logger';
|
|
7
7
|
export declare function unregisterServiceWorker(page: Page): Promise<void>;
|
|
8
8
|
/**
|
|
@@ -59,15 +59,14 @@ exports.onLoadingScreen = onLoadingScreen;
|
|
|
59
59
|
exports.injectApi = injectApi;
|
|
60
60
|
exports.initBrowser = initBrowser;
|
|
61
61
|
exports.getOrCreatePage = getOrCreatePage;
|
|
62
|
+
const waVersion = __importStar(require("@wppconnect/wa-version"));
|
|
63
|
+
const axios_1 = __importDefault(require("axios"));
|
|
62
64
|
const ChromeLauncher = __importStar(require("chrome-launcher"));
|
|
63
65
|
const os = __importStar(require("os"));
|
|
64
66
|
const path = __importStar(require("path"));
|
|
67
|
+
const puppeteer_1 = __importDefault(require("puppeteer"));
|
|
65
68
|
const rimraf = __importStar(require("rimraf"));
|
|
66
|
-
const waVersion = __importStar(require("@wppconnect/wa-version"));
|
|
67
|
-
const axios_1 = __importDefault(require("axios"));
|
|
68
|
-
const puppeteer_extra_1 = __importDefault(require("puppeteer-extra"));
|
|
69
69
|
const puppeteer_config_1 = require("../config/puppeteer.config");
|
|
70
|
-
const puppeteer_extra_plugin_stealth_1 = __importDefault(require("puppeteer-extra-plugin-stealth"));
|
|
71
70
|
const WAuserAgente_1 = require("../config/WAuserAgente");
|
|
72
71
|
const websocket_1 = require("./websocket");
|
|
73
72
|
async function unregisterServiceWorker(page) {
|
|
@@ -181,22 +180,22 @@ async function onLoadingScreen(page, onLoadingScreenCallBack) {
|
|
|
181
180
|
let progressMessage = window2.getElementByXpath(selectors.PROGRESS_MESSAGE);
|
|
182
181
|
let progressMessageNewTheme = window2.getElementByXpath(selectors.PROGRESS_MESSAGE_NEW_THEME);
|
|
183
182
|
if (progressBar) {
|
|
184
|
-
if (
|
|
185
|
-
|
|
183
|
+
if (lastPercent !== progressBar.value ||
|
|
184
|
+
lastPercentMessage !== progressMessage.innerText) {
|
|
186
185
|
window2.loadingScreen(progressBar.value, progressMessage.innerText);
|
|
187
|
-
|
|
188
|
-
|
|
186
|
+
lastPercent = progressBar.value;
|
|
187
|
+
lastPercentMessage = progressMessage.innerText;
|
|
189
188
|
}
|
|
190
189
|
}
|
|
191
190
|
else if (progressBarNewTheme) {
|
|
192
|
-
if (
|
|
193
|
-
|
|
191
|
+
if (lastPercent !== progressBarNewTheme.value ||
|
|
192
|
+
lastPercentMessage !== progressMessageNewTheme.innerText) {
|
|
194
193
|
const progressMsg = progressMessageNewTheme.innerText != 'WhatsApp'
|
|
195
194
|
? progressMessageNewTheme.innerText
|
|
196
195
|
: '';
|
|
197
196
|
window2.loadingScreen(progressBarNewTheme.value, progressMsg);
|
|
198
|
-
|
|
199
|
-
|
|
197
|
+
lastPercent = progressBarNewTheme.value;
|
|
198
|
+
lastPercentMessage = progressMsg;
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
});
|
|
@@ -264,12 +263,10 @@ async function initBrowser(session, options, logger) {
|
|
|
264
263
|
});
|
|
265
264
|
}
|
|
266
265
|
}
|
|
267
|
-
// Use stealth plugin to avoid being detected as a bot
|
|
268
|
-
puppeteer_extra_1.default.use((0, puppeteer_extra_plugin_stealth_1.default)());
|
|
269
266
|
let browser = null;
|
|
270
267
|
if (options.browserWS && options.browserWS != '') {
|
|
271
268
|
const transport = await getTransport(options.browserWS);
|
|
272
|
-
browser = await
|
|
269
|
+
browser = await puppeteer_1.default.connect({ transport });
|
|
273
270
|
}
|
|
274
271
|
else {
|
|
275
272
|
/**
|
|
@@ -285,7 +282,7 @@ async function initBrowser(session, options, logger) {
|
|
|
285
282
|
if (options.proxy && options.proxy.url) {
|
|
286
283
|
args.push(`--proxy-server=${options.proxy.url}`);
|
|
287
284
|
}
|
|
288
|
-
browser = await
|
|
285
|
+
browser = await puppeteer_1.default.launch({
|
|
289
286
|
headless: options.headless,
|
|
290
287
|
devtools: options.devtools,
|
|
291
288
|
args,
|
|
@@ -295,7 +292,7 @@ async function initBrowser(session, options, logger) {
|
|
|
295
292
|
try {
|
|
296
293
|
const arg = browser
|
|
297
294
|
.process()
|
|
298
|
-
|
|
295
|
+
?.spawnargs.find((s) => s.startsWith('--user-data-dir='));
|
|
299
296
|
if (arg) {
|
|
300
297
|
const tmpUserDataDir = arg.split('=')[1];
|
|
301
298
|
// Only if path is in TMP directory
|
|
@@ -204,6 +204,12 @@ async function create(sessionOrOption, catchQR, statusFind, onLoadingScreen, cat
|
|
|
204
204
|
}
|
|
205
205
|
if (page) {
|
|
206
206
|
await page.setBypassCSP(true);
|
|
207
|
+
// Grant persistent-storage permission so WhatsApp Web's IndexedDB is never
|
|
208
|
+
// evicted by Chrome under memory pressure (prevents storage-related disconnections)
|
|
209
|
+
await page
|
|
210
|
+
.browserContext()
|
|
211
|
+
.overridePermissions('https://web.whatsapp.com', ['persistent-storage'])
|
|
212
|
+
.catch(() => null);
|
|
207
213
|
const client = new whatsapp_1.Whatsapp(page, session, mergedOptions);
|
|
208
214
|
client.catchQR = catchQR;
|
|
209
215
|
client.statusFind = statusFind;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wppconnect-team/wppconnect",
|
|
3
|
-
"version": "2.0.3-alpha.
|
|
3
|
+
"version": "2.0.3-alpha.2",
|
|
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",
|
|
@@ -63,10 +63,12 @@
|
|
|
63
63
|
"@commitlint/config-conventional": "^20.5.3",
|
|
64
64
|
"@commitlint/cz-commitlint": "^20.5.3",
|
|
65
65
|
"@eslint/js": "^10.0.1",
|
|
66
|
+
"@tony.ganchev/eslint-plugin-header": "^3.4.4",
|
|
66
67
|
"@types/atob": "^2.1.4",
|
|
67
68
|
"@types/mime-types": "^3.0.1",
|
|
68
69
|
"@types/mocha": "^10.0.10",
|
|
69
70
|
"@types/node": "^24.12.4",
|
|
71
|
+
"@types/rimraf": "^3.0.2",
|
|
70
72
|
"@types/shelljs": "^0.10.0",
|
|
71
73
|
"@types/tmp": "^0.2.6",
|
|
72
74
|
"@types/ws": "^8.18.1",
|
|
@@ -76,7 +78,6 @@
|
|
|
76
78
|
"conventional-changelog-cli": "^5.0.0",
|
|
77
79
|
"eslint": "10.3.0",
|
|
78
80
|
"eslint-config-prettier": "^10.1.8",
|
|
79
|
-
"@tony.ganchev/eslint-plugin-header": "^3.4.4",
|
|
80
81
|
"eslint-plugin-prettier": "^5.5.5",
|
|
81
82
|
"globals": "^17.6.0",
|
|
82
83
|
"husky": "^9.1.7",
|
|
@@ -94,8 +95,8 @@
|
|
|
94
95
|
"webpack-cli": "^6.0.1"
|
|
95
96
|
},
|
|
96
97
|
"dependencies": {
|
|
97
|
-
"@wppconnect/wa-js": "^4.1.
|
|
98
|
-
"@wppconnect/wa-version": "^1.5.
|
|
98
|
+
"@wppconnect/wa-js": "^4.1.3-alpha.0",
|
|
99
|
+
"@wppconnect/wa-version": "^1.5.3935",
|
|
99
100
|
"atob": "^2.1.2",
|
|
100
101
|
"axios": "^1.16.0",
|
|
101
102
|
"boxen": "^5.1.2",
|
|
@@ -109,11 +110,7 @@
|
|
|
109
110
|
"logform": "^2.7.0",
|
|
110
111
|
"lookpath": "^1.2.3",
|
|
111
112
|
"mime-types": "^3.0.2",
|
|
112
|
-
"puppeteer": "^24.
|
|
113
|
-
"puppeteer-extra": "^3.3.6",
|
|
114
|
-
"puppeteer-extra-plugin-stealth": "^2.11.2",
|
|
115
|
-
"puppeteer-extra-plugin-user-data-dir": "^2.4.1",
|
|
116
|
-
"puppeteer-extra-plugin-user-preferences": "^2.4.1",
|
|
113
|
+
"puppeteer": "^24.43.1",
|
|
117
114
|
"qrcode-terminal": "^0.12.0",
|
|
118
115
|
"reflect-metadata": "^0.2.1",
|
|
119
116
|
"rimraf": "^3.0.2",
|