@open-wa/wa-automate 4.67.0 → 4.70.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -0
- package/dist/api/Client.d.ts +3 -30
- package/dist/api/Client.js +5 -32
- package/dist/cli/cli-options.js +13 -1
- package/dist/cli/index.js +1 -1
- package/dist/cli/integrations/chatwoot.js +8 -4
- package/dist/cli/integrations/cloudflare.d.ts +6 -0
- package/dist/cli/integrations/cloudflare.js +76 -0
- package/dist/cli/server.d.ts +1 -1
- package/dist/cli/server.js +14 -12
- package/dist/controllers/auth.js +14 -8
- package/dist/controllers/initializer.js +3 -2
- package/dist/controllers/patch_manager.js +3 -9
- package/dist/lib/launch.js +10 -1
- package/dist/lib/wapi.js +384 -409
- package/dist/logging/logging.js +22 -2
- package/package.json +3 -4
package/README.md
CHANGED
@@ -10,6 +10,8 @@
|
|
10
10
|
>
|
11
11
|
>
|
12
12
|
|
13
|
+
[![Ceasefire Now](https://badge.techforpalestine.org/ceasefire-now)](https://techforpalestine.org/learn-more)
|
14
|
+
|
13
15
|
[![npm version](https://img.shields.io/npm/v/@open-wa/wa-automate.svg?color=green)](https://www.npmjs.com/package/@open-wa/wa-automate)
|
14
16
|
![node](https://img.shields.io/node/v/@open-wa/wa-automate)
|
15
17
|
[![Downloads](https://img.shields.io/npm/dm/@open-wa/wa-automate.svg)](https://www.npmjs.com/package/@open-wa/wa-automate)
|
package/dist/api/Client.d.ts
CHANGED
@@ -1883,15 +1883,7 @@ export declare class Client {
|
|
1883
1883
|
*/
|
1884
1884
|
sendGiphyAsSticker(to: ChatId, giphyMediaUrl: URL | string): Promise<MessageId | string | boolean>;
|
1885
1885
|
/**
|
1886
|
-
* @
|
1887
|
-
*
|
1888
|
-
* :::danger
|
1889
|
-
*
|
1890
|
-
* Status features are broken for now. Please join our discord community for updates.
|
1891
|
-
*
|
1892
|
-
* :::
|
1893
|
-
*
|
1894
|
-
* [REQUIRES A TEXT STORY LICENSE-KEY](https://gum.co/open-wa)
|
1886
|
+
* {@license:restricted@}
|
1895
1887
|
*
|
1896
1888
|
* Sends a formatted text story.
|
1897
1889
|
* @param text The text to be displayed in the story
|
@@ -1908,15 +1900,7 @@ export declare class Client {
|
|
1908
1900
|
*/
|
1909
1901
|
postTextStatus(text: Content, textRgba: string, backgroundRgba: string, font: number): Promise<MessageId | string | boolean>;
|
1910
1902
|
/**
|
1911
|
-
* @
|
1912
|
-
*
|
1913
|
-
* :::danger
|
1914
|
-
*
|
1915
|
-
* Status features are broken for now. Please join our discord community for updates.
|
1916
|
-
*
|
1917
|
-
* :::
|
1918
|
-
*
|
1919
|
-
* [REQUIRES AN IMAGE STORY LICENSE-KEY](https://gum.co/open-wa)
|
1903
|
+
* {@license:restricted@}
|
1920
1904
|
*
|
1921
1905
|
* Posts an image story.
|
1922
1906
|
* @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
|
@@ -1925,15 +1909,7 @@ export declare class Client {
|
|
1925
1909
|
*/
|
1926
1910
|
postImageStatus(data: DataURL, caption: Content): Promise<MessageId | string | boolean>;
|
1927
1911
|
/**
|
1928
|
-
* @
|
1929
|
-
*
|
1930
|
-
* :::danger
|
1931
|
-
*
|
1932
|
-
* Status features are broken for now. Please join our discord community for updates.
|
1933
|
-
*
|
1934
|
-
* :::
|
1935
|
-
*
|
1936
|
-
* [REQUIRES A VIDEO STORY LICENSE-KEY](https://gum.co/open-wa)
|
1912
|
+
* {@license:restricted@}
|
1937
1913
|
*
|
1938
1914
|
* Posts a video story.
|
1939
1915
|
* @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
|
@@ -1951,7 +1927,6 @@ export declare class Client {
|
|
1951
1927
|
*/
|
1952
1928
|
deleteStory(statusesToDelete: string | string[]): Promise<boolean>;
|
1953
1929
|
/**
|
1954
|
-
* @deprecated
|
1955
1930
|
* Alias for deleteStory
|
1956
1931
|
*/
|
1957
1932
|
deleteStatus(statusesToDelete: string | string[]): Promise<boolean>;
|
@@ -1963,7 +1938,6 @@ export declare class Client {
|
|
1963
1938
|
*/
|
1964
1939
|
deleteAllStories(): Promise<boolean>;
|
1965
1940
|
/**
|
1966
|
-
* @deprecated
|
1967
1941
|
* Alias for deleteStory
|
1968
1942
|
*/
|
1969
1943
|
deleteAllStatus(): Promise<boolean>;
|
@@ -1976,7 +1950,6 @@ export declare class Client {
|
|
1976
1950
|
*/
|
1977
1951
|
getMyStoryArray(): Promise<Message[]>;
|
1978
1952
|
/**
|
1979
|
-
* @deprecated
|
1980
1953
|
* Alias for deleteStory
|
1981
1954
|
*/
|
1982
1955
|
getMyStatusArray(): Promise<Message[]>;
|
package/dist/api/Client.js
CHANGED
@@ -1859,12 +1859,12 @@ class Client {
|
|
1859
1859
|
let thumb;
|
1860
1860
|
try {
|
1861
1861
|
linkData = (yield axios_1.default.get(`${((_a = this._createConfig) === null || _a === void 0 ? void 0 : _a.linkParser) || "https://link.openwa.cloud/api"}?url=${url}`)).data;
|
1862
|
-
logging_1.log.info("Got link data"
|
1862
|
+
logging_1.log.info("Got link data");
|
1863
1863
|
if (!thumbnail)
|
1864
1864
|
thumb = yield (0, tools_1.getDUrl)(linkData.image);
|
1865
1865
|
}
|
1866
1866
|
catch (error) {
|
1867
|
-
|
1867
|
+
console.error(error);
|
1868
1868
|
}
|
1869
1869
|
if (linkData && (thumbnail || thumb))
|
1870
1870
|
return yield this.sendMessageWithThumb(thumbnail || thumb, url, linkData.title, linkData.description, text, to);
|
@@ -3823,15 +3823,7 @@ class Client {
|
|
3823
3823
|
});
|
3824
3824
|
}
|
3825
3825
|
/**
|
3826
|
-
* @
|
3827
|
-
*
|
3828
|
-
* :::danger
|
3829
|
-
*
|
3830
|
-
* Status features are broken for now. Please join our discord community for updates.
|
3831
|
-
*
|
3832
|
-
* :::
|
3833
|
-
*
|
3834
|
-
* [REQUIRES A TEXT STORY LICENSE-KEY](https://gum.co/open-wa)
|
3826
|
+
* {@license:restricted@}
|
3835
3827
|
*
|
3836
3828
|
* Sends a formatted text story.
|
3837
3829
|
* @param text The text to be displayed in the story
|
@@ -3852,15 +3844,7 @@ class Client {
|
|
3852
3844
|
});
|
3853
3845
|
}
|
3854
3846
|
/**
|
3855
|
-
* @
|
3856
|
-
*
|
3857
|
-
* :::danger
|
3858
|
-
*
|
3859
|
-
* Status features are broken for now. Please join our discord community for updates.
|
3860
|
-
*
|
3861
|
-
* :::
|
3862
|
-
*
|
3863
|
-
* [REQUIRES AN IMAGE STORY LICENSE-KEY](https://gum.co/open-wa)
|
3847
|
+
* {@license:restricted@}
|
3864
3848
|
*
|
3865
3849
|
* Posts an image story.
|
3866
3850
|
* @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
|
@@ -3873,15 +3857,7 @@ class Client {
|
|
3873
3857
|
});
|
3874
3858
|
}
|
3875
3859
|
/**
|
3876
|
-
* @
|
3877
|
-
*
|
3878
|
-
* :::danger
|
3879
|
-
*
|
3880
|
-
* Status features are broken for now. Please join our discord community for updates.
|
3881
|
-
*
|
3882
|
-
* :::
|
3883
|
-
*
|
3884
|
-
* [REQUIRES A VIDEO STORY LICENSE-KEY](https://gum.co/open-wa)
|
3860
|
+
* {@license:restricted@}
|
3885
3861
|
*
|
3886
3862
|
* Posts a video story.
|
3887
3863
|
* @param data data url string `data:[<MIME-type>][;charset=<encoding>][;base64],<data>`
|
@@ -3907,7 +3883,6 @@ class Client {
|
|
3907
3883
|
});
|
3908
3884
|
}
|
3909
3885
|
/**
|
3910
|
-
* @deprecated
|
3911
3886
|
* Alias for deleteStory
|
3912
3887
|
*/
|
3913
3888
|
deleteStatus(statusesToDelete) {
|
@@ -3927,7 +3902,6 @@ class Client {
|
|
3927
3902
|
});
|
3928
3903
|
}
|
3929
3904
|
/**
|
3930
|
-
* @deprecated
|
3931
3905
|
* Alias for deleteStory
|
3932
3906
|
*/
|
3933
3907
|
deleteAllStatus() {
|
@@ -3948,7 +3922,6 @@ class Client {
|
|
3948
3922
|
});
|
3949
3923
|
}
|
3950
3924
|
/**
|
3951
|
-
* @deprecated
|
3952
3925
|
* Alias for deleteStory
|
3953
3926
|
*/
|
3954
3927
|
getMyStatusArray() {
|
package/dist/cli/cli-options.js
CHANGED
@@ -237,7 +237,19 @@ exports.optionList = [{
|
|
237
237
|
{
|
238
238
|
name: 'tunnel',
|
239
239
|
type: Boolean,
|
240
|
-
description: "Expose a tunnel to your EASY API session - this is for testing and it is unsecured."
|
240
|
+
description: "Expose a tunnel to your EASY API session - this is for testing and it is unsecured. By default it will use a random cloudflare tunnel URL. Make sure you have cloudflared installed and running."
|
241
|
+
},
|
242
|
+
{
|
243
|
+
name: 'cf-tunnel-host-domain',
|
244
|
+
type: String,
|
245
|
+
typeLabel: '{yellow {underline "mycool.site"}}',
|
246
|
+
description: "If you have a domain set up in a cloudflare account and have run cloudflared login on your machine, you can use this to expose the tunnel on your own domain. For example, if you set --cf-tunnel-host-domain mycool.site, the tunnel will be exposed on https://session_id_owa.mycool.site"
|
247
|
+
},
|
248
|
+
{
|
249
|
+
name: 'cf-tunnel-namespace',
|
250
|
+
type: String,
|
251
|
+
typeLabel: '{yellow {underline "owa"}}',
|
252
|
+
description: "You can set a sub-subdomain namespace on which the tunnel will be exposed. Needs to be set in conjunction with --tunnel & --cf-tunnel-host-domain. For example, if you set --cf-tunnel-namespace owa, the tunnel will be exposed on https://session_id.owa.mycool.site"
|
241
253
|
},
|
242
254
|
{
|
243
255
|
name: 'pm2',
|
package/dist/cli/index.js
CHANGED
@@ -201,7 +201,7 @@ function start() {
|
|
201
201
|
});
|
202
202
|
if (cliConfig.tunnel) {
|
203
203
|
spinner.info(`\n• Setting up external tunnel`);
|
204
|
-
const tunnelUrl = yield (0, server_1.setupTunnel)(cliConfig,
|
204
|
+
const tunnelUrl = yield (0, server_1.setupTunnel)(cliConfig, PORT);
|
205
205
|
spinner.succeed(`\n\t${(0, terminal_link_1.default)('External address', tunnelUrl)}`);
|
206
206
|
}
|
207
207
|
const apiDocsUrl = cliConfig.apiHost ? `${cliConfig.apiHost}/api-docs/ ` : `${cliConfig.host.includes('http') ? '' : 'http://'}${cliConfig.host}:${PORT}/api-docs/ `;
|
@@ -51,6 +51,8 @@ const chatwootMiddleware = (cliConfig, client) => {
|
|
51
51
|
var _a, _b, _c, _d;
|
52
52
|
const promises = [];
|
53
53
|
const { body } = req;
|
54
|
+
if (body.source_id)
|
55
|
+
return;
|
54
56
|
if (!body)
|
55
57
|
return;
|
56
58
|
if (body.event == "conversation_status_changed" && body.status == "resolved") {
|
@@ -407,7 +409,7 @@ class ChatwootClient {
|
|
407
409
|
try {
|
408
410
|
const { data } = yield this.cwReq('post', `contacts`, {
|
409
411
|
"identifier": contact.id,
|
410
|
-
"name": contact.formattedName || contact.id,
|
412
|
+
"name": contact.formattedName || contact.name || contact.shortName || contact.id,
|
411
413
|
"phone_number": `+${contact.id.replace('@c.us', '')}`,
|
412
414
|
"avatar_url": contact.profilePicThumbObj.eurl,
|
413
415
|
"custom_attributes": Object.assign({ "wa:number": `${contact.id.replace('@c.us', '')}` }, contact)
|
@@ -440,7 +442,9 @@ class ChatwootClient {
|
|
440
442
|
content,
|
441
443
|
"message_type": message.fromMe ? "outgoing" : "incoming",
|
442
444
|
"private": false,
|
443
|
-
echo_id: message.id
|
445
|
+
echo_id: message.id,
|
446
|
+
source_id: message.id,
|
447
|
+
"content_attributes": message
|
444
448
|
});
|
445
449
|
return data;
|
446
450
|
}
|
@@ -492,8 +496,8 @@ class ChatwootClient {
|
|
492
496
|
contactReg[message.chatId] = contact.id;
|
493
497
|
}
|
494
498
|
else {
|
495
|
-
//create the contact
|
496
|
-
contactReg[message.chatId] = (yield this.createContact(message.
|
499
|
+
//create the contact (have to use chat.contact because it may be triggered by an agent doing an outgoing message)
|
500
|
+
contactReg[message.chatId] = (yield this.createContact(message.chat.contact)).id;
|
497
501
|
}
|
498
502
|
}
|
499
503
|
if (!convoReg[message.chatId]) {
|
@@ -0,0 +1,76 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
12
|
+
exports.createCustomDomainTunnel = void 0;
|
13
|
+
const cloudflared_1 = require("cloudflared");
|
14
|
+
const __1 = require("../..");
|
15
|
+
const createCustomDomainTunnel = (cliConfig, PORT) => __awaiter(void 0, void 0, void 0, function* () {
|
16
|
+
const { cfTunnelHostDomain, sessionId, cfTunnelNamespace } = cliConfig;
|
17
|
+
const sessionName = sessionId.replace(/[^A-Z0-9]/ig, "_").toLowerCase();
|
18
|
+
const tunnelName = `_owa_${sessionName}`;
|
19
|
+
const FQDN = `${sessionName}${cfTunnelNamespace ? `.${cfTunnelNamespace}` : `_owa`}.${cfTunnelHostDomain}`;
|
20
|
+
const hostname = `https://${FQDN}`;
|
21
|
+
const target = `http://localhost:${PORT}`;
|
22
|
+
const logData = (data) => __1.log.info(`CLOUDFLARE TUNNEL: ${typeof data === "object" ? Buffer.isBuffer(data) ? data.toString() : JSON.stringify(data, null, 2) : data}`);
|
23
|
+
// simlpe helper function to convert child proc to a promise and log the output
|
24
|
+
const cfp = (child) => {
|
25
|
+
return new Promise((resolve, reject) => {
|
26
|
+
var _a, _b;
|
27
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', logData);
|
28
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', logData);
|
29
|
+
child.on('error', reject);
|
30
|
+
child.on('exit', (code) => {
|
31
|
+
if (code === 0) {
|
32
|
+
resolve(true);
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
reject(`Exit code: ${code}`);
|
36
|
+
}
|
37
|
+
});
|
38
|
+
});
|
39
|
+
};
|
40
|
+
__1.log.info(`Checking if tunnel ${tunnelName} exists...`);
|
41
|
+
const tunnelExists = yield new Promise((resolve) => {
|
42
|
+
const check = (data) => {
|
43
|
+
logData(data.toString());
|
44
|
+
return resolve(!data.toString().includes("error"));
|
45
|
+
};
|
46
|
+
const { child } = (0, cloudflared_1.tunnel)({ "info": tunnelName });
|
47
|
+
child.stdout.once('data', check);
|
48
|
+
child.stderr.once('data', check);
|
49
|
+
});
|
50
|
+
if (!tunnelExists) {
|
51
|
+
__1.log.info("Tunnel does not exist, creating...");
|
52
|
+
yield cfp((0, cloudflared_1.tunnel)({ "create": tunnelName }).child);
|
53
|
+
}
|
54
|
+
__1.log.info(`Routing traffic to the tunnel via URL ${FQDN}...`);
|
55
|
+
yield cfp((0, cloudflared_1.tunnel)({ "route": "dns", "--overwrite-dns": null, [tunnelName]: FQDN }).child);
|
56
|
+
const { connections, child, stop } = (0, cloudflared_1.tunnel)({
|
57
|
+
"--url": target,
|
58
|
+
"--hostname": hostname,
|
59
|
+
"run": tunnelName
|
60
|
+
});
|
61
|
+
child.stdout.on('data', logData);
|
62
|
+
// wait for the all 4 connections to be established
|
63
|
+
const conns = yield Promise.all(connections);
|
64
|
+
// show the connections
|
65
|
+
__1.log.info(`Connections Ready! ${JSON.stringify(conns, null, 2)}`);
|
66
|
+
return {
|
67
|
+
url: hostname,
|
68
|
+
connections,
|
69
|
+
child,
|
70
|
+
stop: () => __awaiter(void 0, void 0, void 0, function* () {
|
71
|
+
stop();
|
72
|
+
yield cfp((0, cloudflared_1.tunnel)({ "delete": tunnelName }).child);
|
73
|
+
})
|
74
|
+
};
|
75
|
+
});
|
76
|
+
exports.createCustomDomainTunnel = createCustomDomainTunnel;
|
package/dist/cli/server.d.ts
CHANGED
@@ -17,7 +17,7 @@ export declare const setupMetaProcessMiddleware: (client: Client, cliConfig: any
|
|
17
17
|
export declare const getCommands: () => any;
|
18
18
|
export declare const listListeners: () => string[];
|
19
19
|
export declare const setupMediaMiddleware: () => void;
|
20
|
-
export declare const setupTunnel: (cliConfig: any,
|
20
|
+
export declare const setupTunnel: (cliConfig: any, PORT: number) => Promise<string>;
|
21
21
|
export declare const setupTwilioCompatibleWebhook: (cliConfig: cliFlags, client: Client) => void;
|
22
22
|
export declare const setupChatwoot: (cliConfig: cliFlags, client: Client) => void;
|
23
23
|
export declare const setupBotPressHandler: (cliConfig: cliFlags, client: Client) => void;
|
package/dist/cli/server.js
CHANGED
@@ -52,11 +52,13 @@ const xmlbuilder2_1 = require("xmlbuilder2");
|
|
52
52
|
const chatwoot_1 = require("./integrations/chatwoot");
|
53
53
|
const express_ipfilter_1 = require("express-ipfilter");
|
54
54
|
const helmet_1 = __importDefault(require("helmet"));
|
55
|
-
const
|
55
|
+
const cloudflared_1 = require("cloudflared");
|
56
56
|
const child_process_1 = require("child_process");
|
57
|
+
const cloudflare_1 = require("./integrations/cloudflare");
|
57
58
|
exports.app = (0, express_1.default)();
|
58
59
|
exports.server = http_1.default.createServer(exports.app);
|
59
|
-
|
60
|
+
// will be used to clean up cloudflared tunnel
|
61
|
+
let stop;
|
60
62
|
const trimChatId = (chatId) => chatId.replace("@c.us", "").replace("@g.us", "");
|
61
63
|
const socketListenerCallbacks = {};
|
62
64
|
// const existingListeners = () => Object.keys(Object.keys(socketListenerCallbacks).flatMap(id=>Object.keys(socketListenerCallbacks[id])).reduce((acc,curr)=>{acc[curr]=true;return acc},{}))
|
@@ -262,8 +264,8 @@ const setupMetaProcessMiddleware = (client, cliConfig) => {
|
|
262
264
|
closing = true;
|
263
265
|
yield client.kill("API_KILL");
|
264
266
|
__1.log.info("Waiting for maximum ");
|
265
|
-
if (
|
266
|
-
|
267
|
+
if (stop && typeof stop === 'function')
|
268
|
+
stop();
|
267
269
|
yield Promise.race([
|
268
270
|
new Promise((resolve) => exports.server.close(() => {
|
269
271
|
console.log('Server closed');
|
@@ -319,14 +321,14 @@ const setupMediaMiddleware = () => {
|
|
319
321
|
exports.app.use("/media", express_1.default.static('media'));
|
320
322
|
};
|
321
323
|
exports.setupMediaMiddleware = setupMediaMiddleware;
|
322
|
-
const setupTunnel = (cliConfig,
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
});
|
328
|
-
cliConfig.apiHost = cliConfig.tunnel =
|
329
|
-
return
|
324
|
+
const setupTunnel = (cliConfig, PORT) => __awaiter(void 0, void 0, void 0, function* () {
|
325
|
+
const cfT = cliConfig.cfTunnelHostDomain ? yield (0, cloudflare_1.createCustomDomainTunnel)(cliConfig, PORT) : (0, cloudflared_1.tunnel)({ "--url": `localhost:${PORT}` });
|
326
|
+
stop = cfT.stop;
|
327
|
+
const url = yield cfT.url;
|
328
|
+
const conns = yield Promise.all(cfT.connections);
|
329
|
+
__1.log.info(`Connections Ready! ${JSON.stringify(conns, null, 2)}`);
|
330
|
+
cliConfig.apiHost = cliConfig.tunnel = url;
|
331
|
+
return url;
|
330
332
|
});
|
331
333
|
exports.setupTunnel = setupTunnel;
|
332
334
|
const setupTwilioCompatibleWebhook = (cliConfig, client) => {
|
package/dist/controllers/auth.js
CHANGED
@@ -56,14 +56,19 @@ exports.isAuthenticated = isAuthenticated;
|
|
56
56
|
const needsToScan = (waPage) => {
|
57
57
|
return (0, rxjs_1.from)(new Promise((resolve) => __awaiter(void 0, void 0, void 0, function* () {
|
58
58
|
try {
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
/**
|
60
|
+
* TODO: COMMENTING OUT THE BELOW LINES MAY CAUSE A REGRESSION IN RELOGIN? REVERT IF NEEDED.
|
61
|
+
*/
|
62
|
+
// const raceResult = await Promise.race([
|
63
|
+
// waPage.waitForFunction('checkQrRefresh()', { timeout: 0, polling: 1000 }).catch(() => { }),
|
64
|
+
// await waPage
|
65
|
+
// .waitForSelector('body > div > div > .landing-wrapper', {
|
66
|
+
// timeout: 0
|
67
|
+
// }).catch(() => resolve(true))
|
68
|
+
// ]).catch(() => { })
|
69
|
+
// console.log("🚀 ~ needsToScan ~ raceResult:", raceResult)
|
70
|
+
const elementResult = yield waPage.waitForSelector("canvas[aria-label='Scan me!']", { timeout: 0 }).catch(() => { });
|
71
|
+
console.log("🚀 ~ needsToScan ~ elementResult:", elementResult);
|
67
72
|
resolve(false);
|
68
73
|
}
|
69
74
|
catch (error) {
|
@@ -185,6 +190,7 @@ class QRManager {
|
|
185
190
|
}
|
186
191
|
this.hash = data;
|
187
192
|
}).catch(e => {
|
193
|
+
console.error(e);
|
188
194
|
this.hash = 'START';
|
189
195
|
});
|
190
196
|
}
|
@@ -236,7 +236,7 @@ function create(config = {}) {
|
|
236
236
|
*/
|
237
237
|
const invariantAviodanceTs = (0, tools_1.now)();
|
238
238
|
yield Promise.race([
|
239
|
-
waPage.waitForFunction(`(()=>{
|
239
|
+
waPage.waitForFunction(`(()=>{return Object.entries(require("__debug").modulesMap).length > 15})()`, { timeout: 10000 }).catch(() => { }),
|
240
240
|
waPage.waitForFunction(`[...document.getElementsByTagName('div')].filter(x=>x.dataset && x.dataset.testid)[0]?.dataset?.testid === 'qrcode'`, { timeout: 10000 }).catch(() => { }),
|
241
241
|
waPage.waitForFunction(`document.getElementsByTagName('circle').length===1`, { timeout: 10000 }).catch(() => { }) //qr spinner is present
|
242
242
|
]);
|
@@ -323,12 +323,13 @@ function create(config = {}) {
|
|
323
323
|
}
|
324
324
|
if (config.logInternalEvents)
|
325
325
|
yield waPage.evaluate("debugEvents=true");
|
326
|
+
yield waPage.evaluate("window.critlis=true");
|
326
327
|
const tI = yield (0, tools_1.timePromise)(() => (0, init_patch_1.injectInternalEventHandler)(waPage));
|
327
328
|
logging_1.log.info(`Injected internal event handler: ${tI} ms`);
|
328
329
|
if (attemptingReauth) {
|
329
330
|
yield waPage.evaluate("window.Store = undefined");
|
330
331
|
if (config === null || config === void 0 ? void 0 : config.waitForRipeSession) {
|
331
|
-
spinner.start("Waiting for ripe session
|
332
|
+
spinner.start("Waiting for ripe session....");
|
332
333
|
if (yield (0, auth_1.waitForRipeSession)(waPage, config === null || config === void 0 ? void 0 : config.waitForRipeSessionTimeout))
|
333
334
|
spinner.succeed("Session ready for injection");
|
334
335
|
else
|
@@ -181,16 +181,10 @@ exports.getLicense = getLicense;
|
|
181
181
|
function earlyInjectionCheck(page) {
|
182
182
|
return __awaiter(this, void 0, void 0, function* () {
|
183
183
|
//@ts-ignore
|
184
|
-
yield page.waitForFunction(() => Object.entries(
|
184
|
+
yield page.waitForFunction(() => Object.entries(require("__debug").modulesMap).length ? true : false, { timeout: 10, polling: 500 }).catch(() => { });
|
185
185
|
//@ts-ignore
|
186
|
-
return
|
187
|
-
|
188
|
-
}
|
189
|
-
else {
|
190
|
-
(function () { const f = Object.entries(window).filter(([, o]) => o && o.push && (o.push != [].push)); if (f[0]) {
|
191
|
-
window.webpackChunkbuild = window[f[0][0]];
|
192
|
-
} })();
|
193
|
-
} return (typeof window.webpackChunkbuild !== "undefined"); });
|
186
|
+
// return await page.evaluate(() => { if (window.webpackChunkwhatsapp_web_client) { window.webpackChunkbuild = window.webpackChunkwhatsapp_web_client; } else { (function () { const f = Object.entries(window).filter(([, o]) => o && o.push && (o.push != [].push)); if (f[0]) { window.webpackChunkbuild = window[f[0][0]]; } })(); } return (typeof window.webpackChunkbuild !== "undefined"); });
|
187
|
+
return true;
|
194
188
|
});
|
195
189
|
}
|
196
190
|
exports.earlyInjectionCheck = earlyInjectionCheck;
|