@open-wa/wa-automate 4.28.11 → 4.30.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.
- package/build/generate-oas-types.ts +27 -0
- package/dist/api/Client.d.ts +9 -1
- package/dist/api/Client.js +62 -25
- package/dist/cli/collections.d.ts +0 -1
- package/dist/cli/collections.js +3 -44
- package/dist/cli/index.js +6 -2
- package/dist/controllers/auth.d.ts +17 -1
- package/dist/controllers/auth.js +113 -64
- package/dist/controllers/browser.d.ts +3 -1
- package/dist/controllers/browser.js +43 -15
- package/dist/controllers/events.d.ts +2 -0
- package/dist/controllers/events.js +21 -6
- package/dist/controllers/initializer.js +7 -4
- package/dist/lib/axios.min.js +2 -2
- package/dist/lib/base64.js +1 -224
- package/dist/utils/tools.d.ts +1 -0
- package/dist/utils/tools.js +9 -1
- package/package.json +7 -4
@@ -0,0 +1,27 @@
|
|
1
|
+
import * as fs from 'fs'
|
2
|
+
import glob = require('tiny-glob');
|
3
|
+
import * as path from 'path';
|
4
|
+
|
5
|
+
import {
|
6
|
+
getTypeScriptReader,
|
7
|
+
getOpenApiWriter,
|
8
|
+
makeConverter,
|
9
|
+
} from 'typeconv'
|
10
|
+
|
11
|
+
export const getTypeSchemas : any = async () => {
|
12
|
+
const reader = getTypeScriptReader( );
|
13
|
+
const writer = getOpenApiWriter( { format: 'json', title: 'My API', version: 'v3.0.3' } );
|
14
|
+
const { convert } = makeConverter( reader, writer, {
|
15
|
+
simplify: true
|
16
|
+
});
|
17
|
+
const s = (await Promise.all([...(await glob(path.resolve(__dirname,'../**/*.d.ts'))),...(await glob(path.resolve(__dirname,'../**/message.js'))), ...(await glob(path.resolve(__dirname,'../**/chat.js')))])).filter(f=>!f.includes('node_modules'))
|
18
|
+
const res = {};
|
19
|
+
await Promise.all(s.map(async x=>{
|
20
|
+
const {data} = await convert({ data: fs.readFileSync(x, 'utf8') } );
|
21
|
+
const schemas = JSON.parse(data)?.components?.schemas;
|
22
|
+
Object.keys(schemas).forEach(k => {
|
23
|
+
res[k] = schemas[k];
|
24
|
+
})
|
25
|
+
}))
|
26
|
+
return res;
|
27
|
+
}
|
package/dist/api/Client.d.ts
CHANGED
@@ -40,7 +40,10 @@ export declare class Client {
|
|
40
40
|
private _prio;
|
41
41
|
private _pageListeners;
|
42
42
|
private _registeredPageListeners;
|
43
|
+
private _onLogoutCallbacks;
|
43
44
|
private _queues;
|
45
|
+
private _autoEmojiSet;
|
46
|
+
private _onLogoutSet;
|
44
47
|
/**
|
45
48
|
* This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
|
46
49
|
* For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
|
@@ -111,13 +114,18 @@ export declare class Client {
|
|
111
114
|
*
|
112
115
|
* @event
|
113
116
|
* @param fn callback
|
117
|
+
* @param priority A priority of -1 will mean the callback will be triggered after all the non -1 callbacks
|
114
118
|
* @fires `true`
|
115
119
|
*/
|
116
120
|
onLogout(fn: (loggedOut?: boolean) => any, priority?: number): Promise<boolean>;
|
117
121
|
/**
|
118
122
|
* Wait for the webhook queue to become idle. This is useful for ensuring webhooks are cleared before ending a process.
|
119
123
|
*/
|
120
|
-
waitWhQIdle(): Promise<
|
124
|
+
waitWhQIdle(): Promise<true | void>;
|
125
|
+
/**
|
126
|
+
* Wait for all queues to be empty
|
127
|
+
*/
|
128
|
+
waitAllQEmpty(): Promise<true | void[]>;
|
121
129
|
/**
|
122
130
|
* If you have set `onAnyMessage` or `onMessage` with the second parameter (PQueue options) then you may want to inspect their respective PQueue's.
|
123
131
|
*/
|
package/dist/api/Client.js
CHANGED
@@ -56,7 +56,6 @@ const fs = __importStar(require("fs"));
|
|
56
56
|
const datauri_1 = __importDefault(require("datauri"));
|
57
57
|
const is_url_superb_1 = __importDefault(require("is-url-superb"));
|
58
58
|
const fs_extra_1 = require("fs-extra");
|
59
|
-
const tree_kill_1 = __importDefault(require("tree-kill"));
|
60
59
|
const browser_1 = require("../controllers/browser");
|
61
60
|
const auth_1 = require("../controllers/auth");
|
62
61
|
const wa_decrypt_1 = require("@open-wa/wa-decrypt");
|
@@ -90,7 +89,10 @@ class Client {
|
|
90
89
|
this._prio = Number.MAX_SAFE_INTEGER;
|
91
90
|
this._pageListeners = [];
|
92
91
|
this._registeredPageListeners = [];
|
92
|
+
this._onLogoutCallbacks = [];
|
93
93
|
this._queues = {};
|
94
|
+
this._autoEmojiSet = false;
|
95
|
+
this._onLogoutSet = false;
|
94
96
|
/**
|
95
97
|
* This is used to track if a listener is already used via webhook. Before, webhooks used to be set once per listener. Now a listener can be set via multiple webhooks, or revoked from a specific webhook.
|
96
98
|
* For this reason, listeners assigned to a webhook are only set once and map through all possible webhooks to and fire only if the specific listener is assigned.
|
@@ -248,7 +250,7 @@ class Client {
|
|
248
250
|
logging_1.log.info('LOADED', {
|
249
251
|
PHONE_VERSION: this._sessionInfo.PHONE_VERSION
|
250
252
|
});
|
251
|
-
if (((_d = this._createConfig) === null || _d === void 0 ? void 0 : _d.autoEmoji) === undefined || ((_e = this._createConfig) === null || _e === void 0 ? void 0 : _e.autoEmoji)) {
|
253
|
+
if ((((_d = this._createConfig) === null || _d === void 0 ? void 0 : _d.autoEmoji) === undefined || ((_e = this._createConfig) === null || _e === void 0 ? void 0 : _e.autoEmoji)) && !this._autoEmojiSet) {
|
252
254
|
const ident = typeof ((_f = this._createConfig) === null || _f === void 0 ? void 0 : _f.autoEmoji) === "string" ? (_g = this._createConfig) === null || _g === void 0 ? void 0 : _g.autoEmoji : ":";
|
253
255
|
this.onMessage((message) => __awaiter(this, void 0, void 0, function* () {
|
254
256
|
if (message.body && message.body.startsWith(ident) && message.body.endsWith(ident)) {
|
@@ -258,18 +260,21 @@ class Client {
|
|
258
260
|
return yield this.sendEmoji(message.from, emojiId, message.id);
|
259
261
|
}
|
260
262
|
}));
|
263
|
+
this._autoEmojiSet = true;
|
261
264
|
}
|
262
|
-
if (((_h = this._createConfig) === null || _h === void 0 ? void 0 : _h.deleteSessionDataOnLogout) || ((_j = this._createConfig) === null || _j === void 0 ? void 0 : _j.killClientOnLogout)) {
|
263
|
-
this.onLogout(() => {
|
264
|
-
var
|
265
|
-
|
265
|
+
if ((((_h = this._createConfig) === null || _h === void 0 ? void 0 : _h.deleteSessionDataOnLogout) || ((_j = this._createConfig) === null || _j === void 0 ? void 0 : _j.killClientOnLogout)) && !this._onLogoutSet) {
|
266
|
+
this.onLogout(() => __awaiter(this, void 0, void 0, function* () {
|
267
|
+
var _k, _l;
|
268
|
+
yield this.waitAllQEmpty();
|
269
|
+
if ((_k = this._createConfig) === null || _k === void 0 ? void 0 : _k.deleteSessionDataOnLogout)
|
266
270
|
(0, browser_1.deleteSessionData)(this._createConfig);
|
267
|
-
if ((
|
271
|
+
if ((_l = this._createConfig) === null || _l === void 0 ? void 0 : _l.killClientOnLogout) {
|
268
272
|
console.log("Session logged out. Killing client");
|
269
273
|
logging_1.log.warn("Session logged out. Killing client");
|
270
274
|
this.kill("LOGGED_OUT");
|
271
275
|
}
|
272
|
-
});
|
276
|
+
}), -1);
|
277
|
+
this._onLogoutSet = true;
|
273
278
|
}
|
274
279
|
});
|
275
280
|
}
|
@@ -536,7 +541,7 @@ class Client {
|
|
536
541
|
fn = _fn;
|
537
542
|
}
|
538
543
|
if (this._registeredEvListeners && this._registeredEvListeners[funcName]) {
|
539
|
-
return events_1.ev.on(this.getEventSignature(funcName), ({ data }) => fn(data));
|
544
|
+
return events_1.ev.on(this.getEventSignature(funcName), ({ data }) => fn(data), { objectify: true });
|
540
545
|
}
|
541
546
|
/**
|
542
547
|
* If evMode is on then make the callback come from ev.
|
@@ -567,27 +572,47 @@ class Client {
|
|
567
572
|
});
|
568
573
|
if (this._registeredPageListeners.includes(event))
|
569
574
|
return true;
|
575
|
+
this._registeredPageListeners.push(event);
|
576
|
+
logging_1.log.info(`setting page listener: ${event}`, this._registeredPageListeners);
|
570
577
|
this._page.on(event, (...args) => __awaiter(this, void 0, void 0, function* () {
|
571
|
-
|
578
|
+
yield Promise.all(this._pageListeners.filter(l => l.event === event).filter(({ priority }) => priority !== -1).sort((a, b) => (b.priority || 0) - (a.priority || 0)).map(l => l.callback(...args)));
|
579
|
+
yield Promise.all(this._pageListeners.filter(l => l.event === event).filter(({ priority }) => priority == -1).sort((a, b) => (b.priority || 0) - (a.priority || 0)).map(l => l.callback(...args)));
|
580
|
+
return;
|
572
581
|
}));
|
573
|
-
this._registeredPageListeners.push(event);
|
574
582
|
}
|
575
583
|
/**
|
576
584
|
* Listens to a log out event
|
577
585
|
*
|
578
586
|
* @event
|
579
587
|
* @param fn callback
|
588
|
+
* @param priority A priority of -1 will mean the callback will be triggered after all the non -1 callbacks
|
580
589
|
* @fires `true`
|
581
590
|
*/
|
582
591
|
onLogout(fn, priority) {
|
583
592
|
return __awaiter(this, void 0, void 0, function* () {
|
584
|
-
|
593
|
+
const event = 'framenavigated';
|
594
|
+
this._onLogoutCallbacks.push({
|
595
|
+
callback: fn,
|
596
|
+
priority
|
597
|
+
});
|
598
|
+
if (!this._queues[event])
|
599
|
+
this._queues[event] = new p_queue_1.default({
|
600
|
+
concurrency: 1,
|
601
|
+
intervalCap: 1,
|
602
|
+
carryoverConcurrencyCount: true
|
603
|
+
});
|
604
|
+
if (this._registeredPageListeners.includes(event))
|
605
|
+
return true;
|
606
|
+
this.registerPageEventListener(event, (frame) => __awaiter(this, void 0, void 0, function* () {
|
585
607
|
if (frame.url().includes('post_logout=1')) {
|
586
608
|
console.log("LOGGED OUT");
|
587
609
|
logging_1.log.warn("LOGGED OUT");
|
588
|
-
yield
|
610
|
+
yield Promise.all(this._onLogoutCallbacks.filter(c => c.priority !== -1).map(({ callback }) => this._queues[event].add(() => callback(true))));
|
611
|
+
yield this._queues[event].onEmpty();
|
612
|
+
yield Promise.all(this._onLogoutCallbacks.filter(c => c.priority == -1).map(({ callback }) => this._queues[event].add(() => callback(true))));
|
613
|
+
yield this._queues[event].onEmpty();
|
589
614
|
}
|
590
|
-
}), priority);
|
615
|
+
}), priority || 1);
|
591
616
|
return true;
|
592
617
|
});
|
593
618
|
}
|
@@ -602,6 +627,18 @@ class Client {
|
|
602
627
|
return true;
|
603
628
|
});
|
604
629
|
}
|
630
|
+
/**
|
631
|
+
* Wait for all queues to be empty
|
632
|
+
*/
|
633
|
+
waitAllQEmpty() {
|
634
|
+
return __awaiter(this, void 0, void 0, function* () {
|
635
|
+
return yield Promise.all([
|
636
|
+
this._webhookQueue,
|
637
|
+
...Object.values(this._queues)
|
638
|
+
].filter(q => q).map(q => q === null || q === void 0 ? void 0 : q.onEmpty()));
|
639
|
+
return true;
|
640
|
+
});
|
641
|
+
}
|
605
642
|
/**
|
606
643
|
* If you have set `onAnyMessage` or `onMessage` with the second parameter (PQueue options) then you may want to inspect their respective PQueue's.
|
607
644
|
*/
|
@@ -1054,25 +1091,17 @@ class Client {
|
|
1054
1091
|
* @returns true
|
1055
1092
|
*/
|
1056
1093
|
kill(reason = "MANUALLY_KILLED") {
|
1057
|
-
var _a, _b
|
1094
|
+
var _a, _b;
|
1058
1095
|
return __awaiter(this, void 0, void 0, function* () {
|
1059
1096
|
if (this._currentlyBeingKilled)
|
1060
1097
|
return;
|
1061
1098
|
this._currentlyBeingKilled = true;
|
1062
1099
|
console.log('Killing client. Shutting Down');
|
1063
1100
|
logging_1.log.info('Killing client. Shutting Down');
|
1064
|
-
(0, tools_1.processSendData)({
|
1065
|
-
reason
|
1066
|
-
});
|
1067
1101
|
const browser = yield ((_a = this === null || this === void 0 ? void 0 : this._page) === null || _a === void 0 ? void 0 : _a.browser());
|
1068
1102
|
const pid = (browser === null || browser === void 0 ? void 0 : browser.process()) ? (_b = browser === null || browser === void 0 ? void 0 : browser.process()) === null || _b === void 0 ? void 0 : _b.pid : null;
|
1069
1103
|
try {
|
1070
|
-
|
1071
|
-
yield ((_d = this._page) === null || _d === void 0 ? void 0 : _d.close());
|
1072
|
-
if (this._page && ((_e = this._page) === null || _e === void 0 ? void 0 : _e.browser))
|
1073
|
-
yield ((_g = (_f = this._page) === null || _f === void 0 ? void 0 : _f.browser()) === null || _g === void 0 ? void 0 : _g.close());
|
1074
|
-
if (pid)
|
1075
|
-
(0, tree_kill_1.default)(pid, 'SIGKILL');
|
1104
|
+
yield (0, browser_1.kill)(this._page, browser, false, pid, reason);
|
1076
1105
|
}
|
1077
1106
|
catch (error) {
|
1078
1107
|
//ignore error
|
@@ -3357,7 +3386,15 @@ class Client {
|
|
3357
3386
|
return yield this._webhookQueue.add(() => __awaiter(this, void 0, void 0, function* () {
|
3358
3387
|
return yield Promise.all([
|
3359
3388
|
...Object.keys(this._registeredWebhooks).map(webhookId => this._registeredWebhooks[webhookId]).filter(webhookEntry => webhookEntry.events.includes(event))
|
3360
|
-
].map(({ id, url, requestConfig }) =>
|
3389
|
+
].map(({ id, url, requestConfig }) => {
|
3390
|
+
const whStart = performance.now();
|
3391
|
+
return (0, axios_1.default)(Object.assign({ method: 'post', url, data: this.prepEventData(_data, event, { webhook_id: id }) }, requestConfig))
|
3392
|
+
.then(({ status }) => {
|
3393
|
+
const t = (performance.now() - whStart).toFixed(0);
|
3394
|
+
logging_1.log.info("Client Webhook", event, status, t);
|
3395
|
+
})
|
3396
|
+
.catch(err => console.error(`WEBHOOK ERROR: `, url, err.message));
|
3397
|
+
}));
|
3361
3398
|
}));
|
3362
3399
|
}), 10000);
|
3363
3400
|
}
|
package/dist/cli/collections.js
CHANGED
@@ -1,23 +1,4 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
-
if (k2 === undefined) k2 = k;
|
4
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
5
|
-
}) : (function(o, m, k, k2) {
|
6
|
-
if (k2 === undefined) k2 = k;
|
7
|
-
o[k2] = m[k];
|
8
|
-
}));
|
9
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
10
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
11
|
-
}) : function(o, v) {
|
12
|
-
o["default"] = v;
|
13
|
-
});
|
14
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
15
|
-
if (mod && mod.__esModule) return mod;
|
16
|
-
var result = {};
|
17
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
18
|
-
__setModuleDefault(result, mod);
|
19
|
-
return result;
|
20
|
-
};
|
21
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
22
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
23
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
@@ -31,19 +12,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
32
13
|
};
|
33
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
|
-
exports.
|
15
|
+
exports.generateCollections = exports.collections = void 0;
|
35
16
|
const __1 = require("..");
|
36
17
|
const postman_2_swagger_1 = __importDefault(require("postman-2-swagger"));
|
37
18
|
const fs_extra_1 = require("fs-extra");
|
38
|
-
const typeconv_1 = require("typeconv");
|
39
|
-
const fs = __importStar(require("fs"));
|
40
|
-
const glob = require("tiny-glob");
|
41
|
-
const path = __importStar(require("path"));
|
42
19
|
exports.collections = {};
|
43
20
|
const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void 0, function* () {
|
44
21
|
let swCol = null;
|
45
22
|
let pmCol = null;
|
46
|
-
|
23
|
+
//TODO GENERATE TYPE SCHEMAS ON BUILD. AXIOS GET FROM GITHUB!
|
24
|
+
const _types = {};
|
47
25
|
spinner.info('Generating Swagger Spec');
|
48
26
|
pmCol = yield (0, __1.generatePostmanJson)(config);
|
49
27
|
spinner.succeed(`Postman collection generated: open-wa-${config.sessionId}.postman_collection.json`);
|
@@ -114,22 +92,3 @@ const generateCollections = (config, spinner) => __awaiter(void 0, void 0, void
|
|
114
92
|
return;
|
115
93
|
});
|
116
94
|
exports.generateCollections = generateCollections;
|
117
|
-
const getTypeSchemas = () => __awaiter(void 0, void 0, void 0, function* () {
|
118
|
-
const reader = (0, typeconv_1.getTypeScriptReader)();
|
119
|
-
const writer = (0, typeconv_1.getOpenApiWriter)({ format: 'json', title: 'My API', version: 'v3.0.3' });
|
120
|
-
const { convert } = (0, typeconv_1.makeConverter)(reader, writer, {
|
121
|
-
simplify: true
|
122
|
-
});
|
123
|
-
const s = (yield Promise.all([...(yield glob(path.resolve(__dirname, '../**/*.d.ts'))), ...(yield glob(path.resolve(__dirname, '../**/message.js'))), ...(yield glob(path.resolve(__dirname, '../**/chat.js')))])).filter(f => !f.includes('node_modules'));
|
124
|
-
const res = {};
|
125
|
-
yield Promise.all(s.map((x) => __awaiter(void 0, void 0, void 0, function* () {
|
126
|
-
var _a, _b;
|
127
|
-
const { data } = yield convert({ data: fs.readFileSync(x, 'utf8') });
|
128
|
-
const schemas = (_b = (_a = JSON.parse(data)) === null || _a === void 0 ? void 0 : _a.components) === null || _b === void 0 ? void 0 : _b.schemas;
|
129
|
-
Object.keys(schemas).forEach(k => {
|
130
|
-
res[k] = schemas[k];
|
131
|
-
});
|
132
|
-
})));
|
133
|
-
return res;
|
134
|
-
});
|
135
|
-
exports.getTypeSchemas = getTypeSchemas;
|
package/dist/cli/index.js
CHANGED
@@ -80,6 +80,7 @@ function start() {
|
|
80
80
|
}
|
81
81
|
if (!cliConfig.allowSessionDataWebhook && (namespace == "sessionData" || namespace == "sessionDataBase64"))
|
82
82
|
return;
|
83
|
+
const whStart = performance.now();
|
83
84
|
yield (0, axios_1.default)({
|
84
85
|
method: 'post',
|
85
86
|
url: cliConfig.ev,
|
@@ -89,6 +90,9 @@ function start() {
|
|
89
90
|
sessionId,
|
90
91
|
namespace
|
91
92
|
}
|
93
|
+
}).then(({ status }) => {
|
94
|
+
const t = (performance.now() - whStart).toFixed(0);
|
95
|
+
index_1.log.info("EV Webhook", namespace, status, t);
|
92
96
|
}).catch(err => console.error(`WEBHOOK ERROR: ${cliConfig.ev} ${err.message}`));
|
93
97
|
}));
|
94
98
|
}
|
@@ -109,11 +113,11 @@ function start() {
|
|
109
113
|
client.onLogout(() => __awaiter(this, void 0, void 0, function* () {
|
110
114
|
console.error('!!!! CLIENT LOGGED OUT !!!!');
|
111
115
|
if (cliConfig && !cliConfig.noKillOnLogout) {
|
112
|
-
yield client.
|
116
|
+
yield client.waitAllQEmpty();
|
113
117
|
console.error("Shutting down.");
|
114
118
|
process.exit();
|
115
119
|
}
|
116
|
-
}));
|
120
|
+
}), -1);
|
117
121
|
if (cliConfig === null || cliConfig === void 0 ? void 0 : cliConfig.botPressUrl) {
|
118
122
|
spinner.info('Setting Up Botpress handler');
|
119
123
|
(0, server_1.setupBotPressHandler)(cliConfig, client);
|
@@ -13,4 +13,20 @@ export declare const isInsideChat: (waPage: Page) => Observable<boolean>;
|
|
13
13
|
export declare const waitForRipeSession: (waPage: Page) => Promise<boolean>;
|
14
14
|
export declare const sessionDataInvalid: (waPage: Page) => Promise<string>;
|
15
15
|
export declare const phoneIsOutOfReach: (waPage: Page) => Promise<boolean>;
|
16
|
-
export declare
|
16
|
+
export declare class QRManager {
|
17
|
+
qrEv: any;
|
18
|
+
qrNum: number;
|
19
|
+
hash: string;
|
20
|
+
config: ConfigObject;
|
21
|
+
firstEmitted: boolean;
|
22
|
+
_internalQrPngLoaded: boolean;
|
23
|
+
qrCheck: string;
|
24
|
+
constructor(config?: any);
|
25
|
+
setConfig(config: any): void;
|
26
|
+
qrEvF(config?: ConfigObject): any;
|
27
|
+
grabAndEmit(qrData: any, waPage: Page, config: ConfigObject, spinner: Spin): Promise<void>;
|
28
|
+
smartQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<boolean | void | string>;
|
29
|
+
emitFirst(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
|
30
|
+
waitFirstQr(waPage: Page, config?: ConfigObject, spinner?: Spin): Promise<void>;
|
31
|
+
}
|
32
|
+
export declare const qrManager: QRManager;
|
package/dist/controllers/auth.js
CHANGED
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
32
32
|
};
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
|
-
exports.
|
34
|
+
exports.qrManager = exports.QRManager = exports.phoneIsOutOfReach = exports.sessionDataInvalid = exports.waitForRipeSession = exports.isInsideChat = exports.needsToScan = exports.isAuthenticated = void 0;
|
35
35
|
const qrcode = __importStar(require("qrcode-terminal"));
|
36
36
|
const rxjs_1 = require("rxjs");
|
37
37
|
const events_1 = require("./events");
|
@@ -100,24 +100,38 @@ const phoneIsOutOfReach = (waPage) => __awaiter(void 0, void 0, void 0, function
|
|
100
100
|
.catch(() => false);
|
101
101
|
});
|
102
102
|
exports.phoneIsOutOfReach = phoneIsOutOfReach;
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
103
|
+
class QRManager {
|
104
|
+
constructor(config = null) {
|
105
|
+
this.qrEv = null;
|
106
|
+
this.qrNum = 0;
|
107
|
+
this.hash = 'START';
|
108
|
+
this.config = null;
|
109
|
+
this.firstEmitted = false;
|
110
|
+
this._internalQrPngLoaded = false;
|
111
|
+
this.qrCheck = `document.querySelector("canvas[aria-label='Scan me!']")?document.querySelector("canvas[aria-label='Scan me!']").parentElement.getAttribute("data-ref"):false`;
|
112
|
+
this.config = config;
|
113
|
+
}
|
114
|
+
setConfig(config) {
|
115
|
+
this.config = config;
|
116
|
+
this.qrEvF(this.config);
|
117
|
+
}
|
118
|
+
qrEvF(config = this.config) {
|
119
|
+
if (!this.qrEv)
|
120
|
+
this.qrEv = new events_1.EvEmitter(config.sessionId || 'session', 'qr');
|
121
|
+
return this.qrEv;
|
122
|
+
}
|
123
|
+
grabAndEmit(qrData, waPage, config, spinner) {
|
124
|
+
return __awaiter(this, void 0, void 0, function* () {
|
125
|
+
this.qrNum++;
|
126
|
+
if (config.qrMax && this.qrNum > config.qrMax) {
|
127
|
+
spinner.info('QR Code limit reached, exiting...');
|
128
|
+
yield (0, browser_1.kill)(waPage, null, true, null, "QR_LIMIT_REACHED");
|
129
|
+
}
|
130
|
+
const qrEv = this.qrEvF(config);
|
131
|
+
if (!this.qrNum && browser_1.BROWSER_START_TS)
|
119
132
|
spinner.info(`First QR: ${Date.now() - browser_1.BROWSER_START_TS} ms`);
|
120
133
|
if (qrData) {
|
134
|
+
qrEv.emit(qrData, `qrData`);
|
121
135
|
if (!config.qrLogSkip)
|
122
136
|
qrcode.generate(qrData, { small: true });
|
123
137
|
else {
|
@@ -125,31 +139,32 @@ function smartQr(waPage, config, spinner) {
|
|
125
139
|
logging_1.log.info(`New QR Code generated. Not printing in console because qrLogSkip is set to true`);
|
126
140
|
}
|
127
141
|
}
|
142
|
+
if (!this._internalQrPngLoaded) {
|
143
|
+
logging_1.log.info("Waiting for internal QR renderer to load");
|
144
|
+
const t = yield (0, tools_1.timePromise)(() => waPage.waitForFunction(`window.getQrPng || false`, { timeout: 0, polling: 'mutation' }));
|
145
|
+
logging_1.log.info(`Internal QR renderer loaded in ${t} ms`);
|
146
|
+
this._internalQrPngLoaded = true;
|
147
|
+
}
|
128
148
|
try {
|
129
149
|
const qrPng = yield waPage.evaluate(`window.getQrPng()`);
|
130
150
|
if (qrPng) {
|
131
151
|
qrEv.emit(qrPng);
|
132
|
-
qrNum++;
|
133
152
|
(0, tools_1.processSend)('ready');
|
134
|
-
if (config.
|
135
|
-
spinner.info('QR Code limit reached, exiting...');
|
136
|
-
yield (0, browser_1.kill)(waPage, null, true, null, "QR_LIMIT_REACHED");
|
137
|
-
}
|
138
|
-
if (config.ezqr || config.inDocker) {
|
153
|
+
if (config.ezqr) {
|
139
154
|
const host = 'https://qr.openwa.cloud/';
|
140
155
|
yield axios_1.default.post(host, {
|
141
156
|
value: qrPng,
|
142
|
-
hash
|
157
|
+
hash: this.hash
|
143
158
|
}).then(({ data }) => {
|
144
|
-
if (hash === 'START') {
|
159
|
+
if (this.hash === 'START') {
|
145
160
|
const qrUrl = `${host}${data}`;
|
146
161
|
qrEv.emit(qrUrl, `qrUrl`);
|
147
162
|
console.log(`Scan the qr code at ${qrUrl}`);
|
148
163
|
logging_1.log.info(`Scan the qr code at ${qrUrl}`);
|
149
164
|
}
|
150
|
-
hash = data;
|
165
|
+
this.hash = data;
|
151
166
|
}).catch(e => {
|
152
|
-
hash = 'START';
|
167
|
+
this.hash = 'START';
|
153
168
|
});
|
154
169
|
}
|
155
170
|
}
|
@@ -165,42 +180,76 @@ function smartQr(waPage, config, spinner) {
|
|
165
180
|
spinner.info(`Something went wrong while retreiving new the QR code but it should not affect the session launch procedure: ${error.message}`);
|
166
181
|
}
|
167
182
|
});
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
const
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
183
|
+
}
|
184
|
+
smartQr(waPage, config, spinner) {
|
185
|
+
return __awaiter(this, void 0, void 0, function* () {
|
186
|
+
const evalResult = yield waPage.evaluate("window.Store && window.Store.State");
|
187
|
+
if (evalResult === false) {
|
188
|
+
console.log('Seems as though you have been TOS_BLOCKed, unable to refresh QR Code. Please see https://github.com/open-wa/wa-automate-nodejs#best-practice for information on how to prevent this from happeing. You will most likely not get a QR Code');
|
189
|
+
logging_1.log.warn('Seems as though you have been TOS_BLOCKed, unable to refresh QR Code. Please see https://github.com/open-wa/wa-automate-nodejs#best-practice for information on how to prevent this from happeing. You will most likely not get a QR Code');
|
190
|
+
if (config.throwErrorOnTosBlock)
|
191
|
+
throw new Error('TOSBLOCK');
|
192
|
+
}
|
193
|
+
const isAuthed = yield (0, exports.isAuthenticated)(waPage);
|
194
|
+
if (isAuthed)
|
195
|
+
return true;
|
196
|
+
const _hasDefaultStateYet = yield waPage.evaluate("!!(window.Store && window.Store.State && window.Store.State.Socket)");
|
197
|
+
if (!_hasDefaultStateYet) {
|
198
|
+
//expecting issue, take a screenshot then wait a few seconds before continuing
|
199
|
+
yield (0, tools_1.timeout)(2000);
|
200
|
+
}
|
201
|
+
return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
|
202
|
+
const funcName = '_smartQr';
|
203
|
+
const md = "MULTI_DEVICE_DETECTED";
|
204
|
+
let gotResult = false;
|
205
|
+
const fn = (qrData) => __awaiter(this, void 0, void 0, function* () {
|
206
|
+
if (qrData.length > 200 && !(config === null || config === void 0 ? void 0 : config.multiDevice)) {
|
207
|
+
spinner.fail(`Multi-Device detected, please set multiDevice to true in your config or add the --multi-device flag`);
|
208
|
+
return resolve(md);
|
209
|
+
}
|
210
|
+
if (!gotResult && (qrData === 'QR_CODE_SUCCESS' || qrData === md)) {
|
211
|
+
gotResult = true;
|
212
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.succeed(qrData === md ? "Multi device support for this project is EXPERIMENTAL. Some things may not work...." : "QR code scanned. Loading session...");
|
213
|
+
return resolve(yield (0, exports.isInsideChat)(waPage).toPromise());
|
214
|
+
}
|
215
|
+
if (!gotResult)
|
216
|
+
this.grabAndEmit(qrData, waPage, config, spinner);
|
217
|
+
});
|
218
|
+
const set = () => waPage.evaluate(({ funcName }) => {
|
219
|
+
//@ts-ignore
|
220
|
+
return window['smartQr'] ? window[`smartQr`](obj => window[funcName](obj)) : false;
|
221
|
+
}, { funcName });
|
222
|
+
yield waPage.exposeFunction(funcName, (obj) => fn(obj)).then(set).catch((e) => __awaiter(this, void 0, void 0, function* () {
|
223
|
+
//if an error occurs during the qr launcher then take a screenshot.
|
224
|
+
yield (0, initializer_1.screenshot)(waPage);
|
225
|
+
console.log("qr -> e", e);
|
226
|
+
logging_1.log.error("qr -> e", e);
|
227
|
+
}));
|
228
|
+
yield this.emitFirst(waPage, config, spinner);
|
200
229
|
}));
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
230
|
+
});
|
231
|
+
}
|
232
|
+
emitFirst(waPage, config, spinner) {
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
234
|
+
if (this.firstEmitted)
|
235
|
+
return;
|
236
|
+
this.firstEmitted = true;
|
237
|
+
const firstQr = yield waPage.evaluate(this.qrCheck);
|
238
|
+
yield this.grabAndEmit(firstQr, waPage, config, spinner);
|
239
|
+
});
|
240
|
+
}
|
241
|
+
waitFirstQr(waPage, config, spinner) {
|
242
|
+
return __awaiter(this, void 0, void 0, function* () {
|
243
|
+
const fqr = yield waPage.waitForFunction(`!!(${this.qrCheck})`, {
|
244
|
+
polling: 500,
|
245
|
+
timeout: 10000
|
246
|
+
})
|
247
|
+
.catch(e => false);
|
248
|
+
if (fqr)
|
249
|
+
yield this.emitFirst(waPage, config, spinner);
|
250
|
+
return;
|
251
|
+
});
|
252
|
+
}
|
205
253
|
}
|
206
|
-
exports.
|
254
|
+
exports.QRManager = QRManager;
|
255
|
+
exports.qrManager = new QRManager();
|
@@ -6,7 +6,9 @@ export declare function initPage(sessionId?: string, config?: ConfigObject, cust
|
|
6
6
|
export declare const deleteSessionData: (config: ConfigObject) => boolean;
|
7
7
|
export declare const getSessionDataFilePath: (sessionId: string, config: ConfigObject) => string | boolean;
|
8
8
|
export declare const addScript: (page: Page, js: string) => Promise<unknown>;
|
9
|
-
export declare function
|
9
|
+
export declare function injectPreApiScripts(page: Page, spinner?: Spin): Promise<Page>;
|
10
|
+
export declare function injectWapi(page: Page, spinner?: Spin): Promise<Page>;
|
11
|
+
export declare function injectApi(page: Page, spinner?: Spin): Promise<Page>;
|
10
12
|
/**
|
11
13
|
* @internal
|
12
14
|
*/
|
@@ -31,7 +31,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
31
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
32
32
|
};
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
34
|
-
exports.kill = exports.injectApi = exports.addScript = exports.getSessionDataFilePath = exports.deleteSessionData = exports.initPage = exports.BROWSER_START_TS = void 0;
|
34
|
+
exports.kill = exports.injectApi = exports.injectWapi = exports.injectPreApiScripts = exports.addScript = exports.getSessionDataFilePath = exports.deleteSessionData = exports.initPage = exports.BROWSER_START_TS = void 0;
|
35
35
|
const path = __importStar(require("path"));
|
36
36
|
const fs = __importStar(require("fs"));
|
37
37
|
const death_1 = __importDefault(require("death"));
|
@@ -41,9 +41,10 @@ const events_1 = require("./events");
|
|
41
41
|
const pico_s3_1 = require("pico-s3");
|
42
42
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
43
43
|
const puppeteer = require('puppeteer-extra');
|
44
|
-
const
|
44
|
+
const promise_1 = __importDefault(require("terminate/promise"));
|
45
45
|
const logging_1 = require("../logging/logging");
|
46
46
|
const tools_1 = require("../utils/tools");
|
47
|
+
const auth_1 = require("./auth");
|
47
48
|
let browser;
|
48
49
|
exports.BROWSER_START_TS = 0;
|
49
50
|
function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth) {
|
@@ -59,9 +60,12 @@ function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth)
|
|
59
60
|
let waPage = _page;
|
60
61
|
if (!waPage) {
|
61
62
|
spinner === null || spinner === void 0 ? void 0 : spinner.info('Launching Browser');
|
63
|
+
const startBrowser = performance.now();
|
62
64
|
browser = yield initBrowser(sessionId, config, spinner);
|
65
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Browser launched: ${(performance.now() - startBrowser).toFixed(0)}ms`);
|
63
66
|
waPage = yield getWAPage(browser);
|
64
67
|
}
|
68
|
+
const postBrowserLaunchTs = performance.now();
|
65
69
|
spinner === null || spinner === void 0 ? void 0 : spinner.info('Setting Up Page');
|
66
70
|
if (config === null || config === void 0 ? void 0 : config.proxyServerCredentials) {
|
67
71
|
yield waPage.authenticate(config.proxyServerCredentials);
|
@@ -174,11 +178,13 @@ function initPage(sessionId, config, customUserAgent, spinner, _page, skipAuth)
|
|
174
178
|
if ((_e = config === null || config === void 0 ? void 0 : config.proxyServerCredentials) === null || _e === void 0 ? void 0 : _e.address)
|
175
179
|
spinner.succeed(`Active proxy: ${config.proxyServerCredentials.address}`);
|
176
180
|
yield Promise.all(setupPromises);
|
181
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Pre page launch setup complete: ${(performance.now() - postBrowserLaunchTs).toFixed(0)}ms`);
|
177
182
|
spinner === null || spinner === void 0 ? void 0 : spinner.info('Navigating to WA');
|
178
183
|
try {
|
179
184
|
//try twice
|
180
185
|
const WEB_START_TS = new Date().getTime();
|
181
186
|
const webRes = yield waPage.goto(puppeteer_config_1.puppeteerConfig.WAUrl);
|
187
|
+
Promise.all([injectApi(waPage, spinner), auth_1.qrManager.waitFirstQr(waPage, config, spinner)]);
|
182
188
|
const WEB_END_TS = new Date().getTime();
|
183
189
|
if (webRes == null) {
|
184
190
|
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Page loaded but something may have gone wrong: ${WEB_END_TS - WEB_START_TS}ms`);
|
@@ -260,24 +266,46 @@ const addScript = (page, js) => page.addScriptTag({
|
|
260
266
|
path: require.resolve(path.join(__dirname, '../lib', js))
|
261
267
|
});
|
262
268
|
exports.addScript = addScript;
|
263
|
-
function
|
269
|
+
function injectPreApiScripts(page, spinner) {
|
264
270
|
return __awaiter(this, void 0, void 0, function* () {
|
265
|
-
yield Promise.all([
|
271
|
+
const t1 = yield (0, tools_1.timePromise)(() => Promise.all([
|
266
272
|
'axios.min.js',
|
267
273
|
'jsSha.min.js',
|
268
274
|
'qr.min.js',
|
269
275
|
'base64.js',
|
270
276
|
'hash.js'
|
271
|
-
].map(js => (0, exports.addScript)(page, js)));
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
yield (0, exports.addScript)(page, 'wapi.js');
|
280
|
-
|
277
|
+
].map(js => (0, exports.addScript)(page, js))));
|
278
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Base inject: ${t1}ms`);
|
279
|
+
return page;
|
280
|
+
});
|
281
|
+
}
|
282
|
+
exports.injectPreApiScripts = injectPreApiScripts;
|
283
|
+
function injectWapi(page, spinner) {
|
284
|
+
return __awaiter(this, void 0, void 0, function* () {
|
285
|
+
const wapi = yield (0, tools_1.timePromise)(() => (0, exports.addScript)(page, 'wapi.js'));
|
286
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`WAPI inject: ${wapi}ms`);
|
287
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info("Checking WAPI Injection");
|
288
|
+
const check = (c) => `window.${c} ? true : false`;
|
289
|
+
yield page.waitForFunction(check('WAPI'), { timeout: 0, polling: 500 });
|
290
|
+
return;
|
291
|
+
});
|
292
|
+
}
|
293
|
+
exports.injectWapi = injectWapi;
|
294
|
+
function injectApi(page, spinner) {
|
295
|
+
return __awaiter(this, void 0, void 0, function* () {
|
296
|
+
yield injectPreApiScripts(page, spinner);
|
297
|
+
yield injectWapi(page, spinner);
|
298
|
+
// const wapi = await timePromise(()=>addScript(page,'wapi.js'))
|
299
|
+
// spinner?.info(`WAPI inject: ${wapi}ms`)
|
300
|
+
// await addScript(page,'wapi.js')
|
301
|
+
// await addScript(page,'wapi.js')
|
302
|
+
// await addScript(page,'wapi.js')
|
303
|
+
// await addScript(page,'wapi.js')
|
304
|
+
// await addScript(page,'wapi.js')
|
305
|
+
// await addScript(page,'wapi.js')
|
306
|
+
// await addScript(page,'wapi.js')
|
307
|
+
const launch = yield (0, tools_1.timePromise)(() => (0, exports.addScript)(page, 'launch.js'));
|
308
|
+
spinner === null || spinner === void 0 ? void 0 : spinner.info(`Launch inject: ${launch}ms`);
|
281
309
|
return page;
|
282
310
|
});
|
283
311
|
}
|
@@ -406,7 +434,7 @@ const kill = (p, b, exit, pid, reason = "LAUNCH_KILL") => __awaiter(void 0, void
|
|
406
434
|
yield killBrowser(b);
|
407
435
|
}
|
408
436
|
if (pid)
|
409
|
-
(0,
|
437
|
+
yield (0, promise_1.default)(pid, 'SIGKILL').catch(e => console.error('Error while terminating browser PID. You can just ignore this, as the process has most likely been terminated successfully already:', e.message));
|
410
438
|
if (exit)
|
411
439
|
process.exit();
|
412
440
|
return;
|
@@ -54,8 +54,10 @@ export declare const ev: EventEmitter2;
|
|
54
54
|
export declare class EvEmitter {
|
55
55
|
sessionId: string;
|
56
56
|
eventNamespace: string;
|
57
|
+
bannedTransports: string[];
|
57
58
|
constructor(sessionId: string, eventNamespace: string);
|
58
59
|
emit(data: unknown, eventNamespaceOverride?: string): void;
|
60
|
+
emitAsync(data: unknown, eventNamespaceOverride?: string): Promise<any>;
|
59
61
|
}
|
60
62
|
/**
|
61
63
|
* @internal
|
@@ -82,6 +82,12 @@ const getGlobalSpinner = (disableSpins = false) => {
|
|
82
82
|
*/
|
83
83
|
class EvEmitter {
|
84
84
|
constructor(sessionId, eventNamespace) {
|
85
|
+
this.bannedTransports = [
|
86
|
+
//DO NOT ALLOW THESE NAMESPACES ON TRANSPORTS!!
|
87
|
+
"sessionData",
|
88
|
+
"sessionDataBase64",
|
89
|
+
"qr",
|
90
|
+
];
|
85
91
|
this.sessionId = sessionId;
|
86
92
|
this.eventNamespace = eventNamespace;
|
87
93
|
}
|
@@ -90,18 +96,27 @@ class EvEmitter {
|
|
90
96
|
const sessionId = this.sessionId;
|
91
97
|
const eventNamespace = eventNamespaceOverride || this.eventNamespace;
|
92
98
|
exports.ev.emit(eventName, data, sessionId, eventNamespace);
|
93
|
-
if (!
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
+
if (!this.bannedTransports.find(x => eventNamespace == x))
|
100
|
+
logging_1.log.info(typeof data === 'string' ? data : eventName, {
|
101
|
+
eventName,
|
102
|
+
data,
|
103
|
+
sessionId,
|
104
|
+
eventNamespace
|
105
|
+
});
|
106
|
+
// ev.emit(`${this.sessionId}.${this.eventNamespace}`,data,this.sessionId,this.eventNamespace);
|
107
|
+
}
|
108
|
+
emitAsync(data, eventNamespaceOverride) {
|
109
|
+
const eventName = `${eventNamespaceOverride || this.eventNamespace}.${this.sessionId}`;
|
110
|
+
const sessionId = this.sessionId;
|
111
|
+
const eventNamespace = eventNamespaceOverride || this.eventNamespace;
|
112
|
+
if (!this.bannedTransports.find(x => eventNamespace == x))
|
99
113
|
logging_1.log.info(typeof data === 'string' ? data : eventName, {
|
100
114
|
eventName,
|
101
115
|
data,
|
102
116
|
sessionId,
|
103
117
|
eventNamespace
|
104
118
|
});
|
119
|
+
return exports.ev.emitAsync(eventName, data, sessionId, eventNamespace);
|
105
120
|
// ev.emit(`${this.sessionId}.${this.eventNamespace}`,data,this.sessionId,this.eventNamespace);
|
106
121
|
}
|
107
122
|
}
|
@@ -145,6 +145,7 @@ function create(config = {}) {
|
|
145
145
|
if (!sessionId)
|
146
146
|
sessionId = 'session';
|
147
147
|
const spinner = new events_1.Spin(sessionId, 'STARTUP', config === null || config === void 0 ? void 0 : config.disableSpins);
|
148
|
+
auth_1.qrManager.setConfig(config);
|
148
149
|
try {
|
149
150
|
if (typeof config === 'string')
|
150
151
|
console.error("AS OF VERSION 3+ YOU CAN NO LONGER SET THE SESSION ID AS THE FIRST PARAMETER OF CREATE. CREATE CAN ONLY TAKE A CONFIG OBJECT. IF YOU STILL HAVE CONFIGS AS A SECOND PARAMETER, THEY WILL HAVE NO EFFECT! PLEASE SEE DOCS.");
|
@@ -164,7 +165,8 @@ function create(config = {}) {
|
|
164
165
|
if ((config === null || config === void 0 ? void 0 : config.multiDevice) && !(config === null || config === void 0 ? void 0 : config.useChrome))
|
165
166
|
spinner.info(`It is recommended to set useChrome: true or use the --use-chrome flag if you are experiencing issues with Multi device support`);
|
166
167
|
waPage = yield (0, browser_1.initPage)(sessionId, config, customUserAgent, spinner);
|
167
|
-
spinner.succeed('
|
168
|
+
spinner.succeed('Page loaded');
|
169
|
+
const browserLaunchedTs = performance.now();
|
168
170
|
const throwOnError = config && config.throwErrorOnTosBlock == true;
|
169
171
|
const PAGE_UA = yield waPage.evaluate('navigator.userAgent');
|
170
172
|
const BROWSER_VERSION = yield waPage.browser().version();
|
@@ -211,11 +213,12 @@ function create(config = {}) {
|
|
211
213
|
debugInfo.CLI = process.env.OWA_CLI && true || false;
|
212
214
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
213
215
|
spinner.succeed('Use this easy pre-filled link to report an issue: ' + (0, tools_1.generateGHIssueLink)(config, debugInfo));
|
216
|
+
spinner.info(`Time to injection: ${(performance.now() - browserLaunchedTs).toFixed(0)}ms`);
|
214
217
|
if (canInjectEarly) {
|
215
218
|
if (attemptingReauth)
|
216
219
|
yield waPage.evaluate(`window.Store = {"Msg": true}`);
|
217
220
|
spinner.start('Injecting api');
|
218
|
-
waPage = yield (0, browser_1.injectApi)(waPage);
|
221
|
+
waPage = yield (0, browser_1.injectApi)(waPage, spinner);
|
219
222
|
spinner.start('WAPI injected');
|
220
223
|
}
|
221
224
|
else {
|
@@ -265,7 +268,7 @@ function create(config = {}) {
|
|
265
268
|
else {
|
266
269
|
spinner.info('Authenticate to continue');
|
267
270
|
const race = [];
|
268
|
-
race.push(
|
271
|
+
race.push(auth_1.qrManager.smartQr(waPage, config, spinner));
|
269
272
|
if ((config === null || config === void 0 ? void 0 : config.qrTimeout) !== 0) {
|
270
273
|
let to = ((config === null || config === void 0 ? void 0 : config.qrTimeout) || 60) * 1000;
|
271
274
|
if (config === null || config === void 0 ? void 0 : config.multiDevice)
|
@@ -300,7 +303,7 @@ function create(config = {}) {
|
|
300
303
|
}
|
301
304
|
const pre = canInjectEarly ? 'Rei' : 'I';
|
302
305
|
spinner.start(`${pre}njecting api`);
|
303
|
-
waPage = yield (0, browser_1.injectApi)(waPage);
|
306
|
+
waPage = yield (0, browser_1.injectApi)(waPage, spinner);
|
304
307
|
spinner.succeed(`WAPI ${pre}njected`);
|
305
308
|
if (canInjectEarly) {
|
306
309
|
//check if page is valid after 5 seconds
|
package/dist/lib/axios.min.js
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
/* axios v0.
|
2
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){"use strict";function r(e){var t=new s(e),n=i(s.prototype.request,t);return o.extend(n,s.prototype,t),o.extend(n,t),n}var o=n(2),i=n(3),s=n(4),a=n(22),u=n(10),c=r(u);c.Axios=s,c.create=function(e){return r(a(c.defaults,e))},c.Cancel=n(23),c.CancelToken=n(24),c.isCancel=n(9),c.all=function(e){return Promise.all(e)},c.spread=n(25),e.exports=c,e.exports.default=c},function(e,t,n){"use strict";function r(e){return"[object Array]"===j.call(e)}function o(e){return"undefined"==typeof e}function i(e){return null!==e&&!o(e)&&null!==e.constructor&&!o(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function s(e){return"[object ArrayBuffer]"===j.call(e)}function a(e){return"undefined"!=typeof FormData&&e instanceof FormData}function u(e){var t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer}function c(e){return"string"==typeof e}function f(e){return"number"==typeof e}function p(e){return null!==e&&"object"==typeof e}function d(e){return"[object Date]"===j.call(e)}function l(e){return"[object File]"===j.call(e)}function h(e){return"[object Blob]"===j.call(e)}function m(e){return"[object Function]"===j.call(e)}function y(e){return p(e)&&m(e.pipe)}function g(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams}function v(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}function x(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)}function w(e,t){if(null!==e&&"undefined"!=typeof e)if("object"!=typeof e&&(e=[e]),r(e))for(var n=0,o=e.length;n<o;n++)t.call(null,e[n],n,e);else for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.call(null,e[i],i,e)}function b(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=b(t[n],e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)w(arguments[n],e);return t}function E(){function e(e,n){"object"==typeof t[n]&&"object"==typeof e?t[n]=E(t[n],e):"object"==typeof e?t[n]=E({},e):t[n]=e}for(var t={},n=0,r=arguments.length;n<r;n++)w(arguments[n],e);return t}function S(e,t,n){return w(t,function(t,r){n&&"function"==typeof t?e[r]=C(t,n):e[r]=t}),e}var C=n(3),j=Object.prototype.toString;e.exports={isArray:r,isArrayBuffer:s,isBuffer:i,isFormData:a,isArrayBufferView:u,isString:c,isNumber:f,isObject:p,isUndefined:o,isDate:d,isFile:l,isBlob:h,isFunction:m,isStream:y,isURLSearchParams:g,isStandardBrowserEnv:x,forEach:w,merge:b,deepMerge:E,extend:S,trim:v}},function(e,t){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";function r(e){this.defaults=e,this.interceptors={request:new s,response:new s}}var o=n(2),i=n(5),s=n(6),a=n(7),u=n(22);r.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=u(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=[a,void 0],n=Promise.resolve(e);for(this.interceptors.request.forEach(function(e){t.unshift(e.fulfilled,e.rejected)}),this.interceptors.response.forEach(function(e){t.push(e.fulfilled,e.rejected)});t.length;)n=n.then(t.shift(),t.shift());return n},r.prototype.getUri=function(e){return e=u(this.defaults,e),i(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},o.forEach(["delete","get","head","options"],function(e){r.prototype[e]=function(t,n){return this.request(o.merge(n||{},{method:e,url:t}))}}),o.forEach(["post","put","patch"],function(e){r.prototype[e]=function(t,n,r){return this.request(o.merge(r||{},{method:e,url:t,data:n}))}}),e.exports=r},function(e,t,n){"use strict";function r(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var o=n(2);e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(o.isURLSearchParams(t))i=t.toString();else{var s=[];o.forEach(t,function(e,t){null!==e&&"undefined"!=typeof e&&(o.isArray(e)?t+="[]":e=[e],o.forEach(e,function(e){o.isDate(e)?e=e.toISOString():o.isObject(e)&&(e=JSON.stringify(e)),s.push(r(t)+"="+r(e))}))}),i=s.join("&")}if(i){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}},function(e,t,n){"use strict";function r(){this.handlers=[]}var o=n(2);r.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},r.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},r.prototype.forEach=function(e){o.forEach(this.handlers,function(t){null!==t&&e(t)})},e.exports=r},function(e,t,n){"use strict";function r(e){e.cancelToken&&e.cancelToken.throwIfRequested()}var o=n(2),i=n(8),s=n(9),a=n(10);e.exports=function(e){r(e),e.headers=e.headers||{},e.data=i(e.data,e.headers,e.transformRequest),e.headers=o.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),o.forEach(["delete","get","head","post","put","patch","common"],function(t){delete e.headers[t]});var t=e.adapter||a.adapter;return t(e).then(function(t){return r(e),t.data=i(t.data,t.headers,e.transformResponse),t},function(t){return s(t)||(r(e),t&&t.response&&(t.response.data=i(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)})}},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t,n){return r.forEach(n,function(n){e=n(e,t)}),e}},function(e,t){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";function r(e,t){!i.isUndefined(e)&&i.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}function o(){var e;return"undefined"!=typeof XMLHttpRequest?e=n(12):"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process)&&(e=n(12)),e}var i=n(2),s=n(11),a={"Content-Type":"application/x-www-form-urlencoded"},u={adapter:o(),transformRequest:[function(e,t){return s(t,"Accept"),s(t,"Content-Type"),i.isFormData(e)||i.isArrayBuffer(e)||i.isBuffer(e)||i.isStream(e)||i.isFile(e)||i.isBlob(e)?e:i.isArrayBufferView(e)?e.buffer:i.isURLSearchParams(e)?(r(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):i.isObject(e)?(r(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};u.headers={common:{Accept:"application/json, text/plain, */*"}},i.forEach(["delete","get","head"],function(e){u.headers[e]={}}),i.forEach(["post","put","patch"],function(e){u.headers[e]=i.merge(a)}),e.exports=u},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){r.forEach(e,function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])})}},function(e,t,n){"use strict";var r=n(2),o=n(13),i=n(5),s=n(16),a=n(19),u=n(20),c=n(14);e.exports=function(e){return new Promise(function(t,f){var p=e.data,d=e.headers;r.isFormData(p)&&delete d["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var h=e.auth.username||"",m=e.auth.password||"";d.Authorization="Basic "+btoa(h+":"+m)}var y=s(e.baseURL,e.url);if(l.open(e.method.toUpperCase(),i(y,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l.onreadystatechange=function(){if(l&&4===l.readyState&&(0!==l.status||l.responseURL&&0===l.responseURL.indexOf("file:"))){var n="getAllResponseHeaders"in l?a(l.getAllResponseHeaders()):null,r=e.responseType&&"text"!==e.responseType?l.response:l.responseText,i={data:r,status:l.status,statusText:l.statusText,headers:n,config:e,request:l};o(t,f,i),l=null}},l.onabort=function(){l&&(f(c("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){f(c("Network Error",e,null,l)),l=null},l.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),f(c(t,e,"ECONNABORTED",l)),l=null},r.isStandardBrowserEnv()){var g=n(21),v=(e.withCredentials||u(y))&&e.xsrfCookieName?g.read(e.xsrfCookieName):void 0;v&&(d[e.xsrfHeaderName]=v)}if("setRequestHeader"in l&&r.forEach(d,function(e,t){"undefined"==typeof p&&"content-type"===t.toLowerCase()?delete d[t]:l.setRequestHeader(t,e)}),r.isUndefined(e.withCredentials)||(l.withCredentials=!!e.withCredentials),e.responseType)try{l.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&l.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(e){l&&(l.abort(),f(e),l=null)}),void 0===p&&(p=null),l.send(p)})}},function(e,t,n){"use strict";var r=n(14);e.exports=function(e,t,n){var o=n.config.validateStatus;!o||o(n.status)?e(n):t(r("Request failed with status code "+n.status,n.config,null,n.request,n))}},function(e,t,n){"use strict";var r=n(15);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},function(e,t,n){"use strict";var r=n(17),o=n(18);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(2),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;"set-cookie"===t?s[t]=(s[t]?s[t]:[]).concat([n]):s[t]=s[t]?s[t]+", "+n:n}}),s):s}},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){function e(e){var t=e;return n&&(o.setAttribute("href",t),t=o.href),o.setAttribute("href",t),{href:o.href,protocol:o.protocol?o.protocol.replace(/:$/,""):"",host:o.host,search:o.search?o.search.replace(/^\?/,""):"",hash:o.hash?o.hash.replace(/^#/,""):"",hostname:o.hostname,port:o.port,pathname:"/"===o.pathname.charAt(0)?o.pathname:"/"+o.pathname}}var t,n=/(msie|trident)/i.test(navigator.userAgent),o=document.createElement("a");return t=e(window.location.href),function(n){var o=r.isString(n)?e(n):n;return o.protocol===t.protocol&&o.host===t.host}}():function(){return function(){return!0}}()},function(e,t,n){"use strict";var r=n(2);e.exports=r.isStandardBrowserEnv()?function(){return{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),s===!0&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},function(e,t,n){"use strict";var r=n(2);e.exports=function(e,t){t=t||{};var n={},o=["url","method","params","data"],i=["headers","auth","proxy"],s=["baseURL","url","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"];r.forEach(o,function(e){"undefined"!=typeof t[e]&&(n[e]=t[e])}),r.forEach(i,function(o){r.isObject(t[o])?n[o]=r.deepMerge(e[o],t[o]):"undefined"!=typeof t[o]?n[o]=t[o]:r.isObject(e[o])?n[o]=r.deepMerge(e[o]):"undefined"!=typeof e[o]&&(n[o]=e[o])}),r.forEach(s,function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])});var a=o.concat(i).concat(s),u=Object.keys(t).filter(function(e){return a.indexOf(e)===-1});return r.forEach(u,function(r){"undefined"!=typeof t[r]?n[r]=t[r]:"undefined"!=typeof e[r]&&(n[r]=e[r])}),n}},function(e,t){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,n){"use strict";function r(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise(function(e){t=e});var n=this;e(function(e){n.reason||(n.reason=new o(e),t(n.reason))})}var o=n(23);r.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},r.source=function(){var e,t=new r(function(t){e=t});return{token:t,cancel:e}},e.exports=r},function(e,t){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}}])});
|
1
|
+
/* axios v0.25.0 | (c) 2022 by Matt Zabriskie */
|
2
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.axios=t():e.axios=t()}(this,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}([function(e,t,n){"use strict";var r=n(3),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function n(n,r){u(t[r])&&u(n)?t[r]=e(t[r],n):u(n)?t[r]=e({},n):i(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)f(arguments[r],n);return t},extend:function(e,t,n){return f(t,(function(t,o){e[o]=n&&"function"==typeof t?r(t,n):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},function(e,t,n){"use strict";var r=n(0),o=n(17),i=n(5),s={"Content-Type":"application/x-www-form-urlencoded"};function a(e,t){!r.isUndefined(e)&&r.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var u,c={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(u=n(6)),u),transformRequest:[function(e,t){return o(t,"Accept"),o(t,"Content-Type"),r.isFormData(e)||r.isArrayBuffer(e)||r.isBuffer(e)||r.isStream(e)||r.isFile(e)||r.isBlob(e)?e:r.isArrayBufferView(e)?e.buffer:r.isURLSearchParams(e)?(a(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):r.isObject(e)||t&&"application/json"===t["Content-Type"]?(a(t,"application/json"),function(e,t,n){if(r.isString(e))try{return(t||JSON.parse)(e),r.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||c.transitional,n=t&&t.silentJSONParsing,o=t&&t.forcedJSONParsing,s=!n&&"json"===this.responseType;if(s||o&&r.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(s){if("SyntaxError"===e.name)throw i(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};r.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),r.forEach(["post","put","patch"],(function(e){c.headers[e]=r.merge(s)})),e.exports=c},function(e,t,n){"use strict";function r(e){this.message=e}r.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},r.prototype.__CANCEL__=!0,e.exports=r},function(e,t,n){"use strict";e.exports=function(e,t){return function(){for(var n=new Array(arguments.length),r=0;r<n.length;r++)n[r]=arguments[r];return e.apply(t,n)}}},function(e,t,n){"use strict";var r=n(0);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,n){if(!t)return e;var i;if(n)i=n(t);else if(r.isURLSearchParams(t))i=t.toString();else{var s=[];r.forEach(t,(function(e,t){null!=e&&(r.isArray(e)?t+="[]":e=[e],r.forEach(e,(function(e){r.isDate(e)?e=e.toISOString():r.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},function(e,t,n){"use strict";e.exports=function(e,t,n,r,o){return e.config=t,n&&(e.code=n),e.request=r,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}},function(e,t,n){"use strict";var r=n(0),o=n(18),i=n(19),s=n(4),a=n(20),u=n(23),c=n(24),f=n(7),l=n(1),p=n(2);e.exports=function(e){return new Promise((function(t,n){var d,h=e.data,m=e.headers,v=e.responseType;function y(){e.cancelToken&&e.cancelToken.unsubscribe(d),e.signal&&e.signal.removeEventListener("abort",d)}r.isFormData(h)&&delete m["Content-Type"];var g=new XMLHttpRequest;if(e.auth){var b=e.auth.username||"",x=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";m.Authorization="Basic "+btoa(b+":"+x)}var w=a(e.baseURL,e.url);function E(){if(g){var r="getAllResponseHeaders"in g?u(g.getAllResponseHeaders()):null,i={data:v&&"text"!==v&&"json"!==v?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:r,config:e,request:g};o((function(e){t(e),y()}),(function(e){n(e),y()}),i),g=null}}if(g.open(e.method.toUpperCase(),s(w,e.params,e.paramsSerializer),!0),g.timeout=e.timeout,"onloadend"in g?g.onloadend=E:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(E)},g.onabort=function(){g&&(n(f("Request aborted",e,"ECONNABORTED",g)),g=null)},g.onerror=function(){n(f("Network Error",e,null,g)),g=null},g.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||l.transitional;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(f(t,e,r.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",g)),g=null},r.isStandardBrowserEnv()){var S=(e.withCredentials||c(w))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;S&&(m[e.xsrfHeaderName]=S)}"setRequestHeader"in g&&r.forEach(m,(function(e,t){void 0===h&&"content-type"===t.toLowerCase()?delete m[t]:g.setRequestHeader(t,e)})),r.isUndefined(e.withCredentials)||(g.withCredentials=!!e.withCredentials),v&&"json"!==v&&(g.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&g.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&g.upload&&g.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(d=function(e){g&&(n(!e||e&&e.type?new p("canceled"):e),g.abort(),g=null)},e.cancelToken&&e.cancelToken.subscribe(d),e.signal&&(e.signal.aborted?d():e.signal.addEventListener("abort",d))),h||(h=null),g.send(h)}))}},function(e,t,n){"use strict";var r=n(5);e.exports=function(e,t,n,o,i){var s=new Error(e);return r(s,t,n,o,i)}},function(e,t,n){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){t=t||{};var n={};function o(e,t){return r.isPlainObject(e)&&r.isPlainObject(t)?r.merge(e,t):r.isPlainObject(t)?r.merge({},t):r.isArray(t)?t.slice():t}function i(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(e[n],t[n])}function s(e){if(!r.isUndefined(t[e]))return o(void 0,t[e])}function a(n){return r.isUndefined(t[n])?r.isUndefined(e[n])?void 0:o(void 0,e[n]):o(void 0,t[n])}function u(n){return n in t?o(e[n],t[n]):n in e?o(void 0,e[n]):void 0}var c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:u};return r.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=c[e]||i,o=t(e);r.isUndefined(o)&&t!==u||(n[e]=o)})),n}},function(e,t){e.exports={version:"0.24.0"}},function(e,t,n){e.exports=n(12)},function(e,t,n){"use strict";var r=n(0),o=n(3),i=n(13),s=n(9);var a=function e(t){var n=new i(t),a=o(i.prototype.request,n);return r.extend(a,i.prototype,n),r.extend(a,n),a.create=function(n){return e(s(t,n))},a}(n(1));a.Axios=i,a.Cancel=n(2),a.CancelToken=n(26),a.isCancel=n(8),a.VERSION=n(10).version,a.all=function(e){return Promise.all(e)},a.spread=n(27),a.isAxiosError=n(28),e.exports=a,e.exports.default=a},function(e,t,n){"use strict";var r=n(0),o=n(4),i=n(14),s=n(15),a=n(9),u=n(25),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean),forcedJSONParsing:c.transitional(c.boolean),clarifyTimeoutError:c.transitional(c.boolean)},!1);var n=[],r=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(r=r&&t.synchronous,n.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!r){var f=[s,void 0];for(Array.prototype.unshift.apply(f,n),f=f.concat(i),o=Promise.resolve(e);f.length;)o=o.then(f.shift(),f.shift());return o}for(var l=e;n.length;){var p=n.shift(),d=n.shift();try{l=p(l)}catch(e){d(e);break}}try{o=s(l)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},r.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,n){return this.request(a(n||{},{method:e,url:t,data:(n||{}).data}))}})),r.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,n,r){return this.request(a(r||{},{method:e,url:t,data:n}))}})),e.exports=f},function(e,t,n){"use strict";var r=n(0);function o(){this.handlers=[]}o.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){r.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},function(e,t,n){"use strict";var r=n(0),o=n(16),i=n(8),s=n(1),a=n(2);function u(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new a("canceled")}e.exports=function(e){return u(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=r.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),r.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return u(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(u(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,n){"use strict";var r=n(0),o=n(1);e.exports=function(e,t,n){var i=this||o;return r.forEach(n,(function(n){e=n.call(i,e,t)})),e}},function(e,t,n){"use strict";var r=n(0);e.exports=function(e,t){r.forEach(e,(function(n,r){r!==t&&r.toUpperCase()===t.toUpperCase()&&(e[t]=n,delete e[r])}))}},function(e,t,n){"use strict";var r=n(7);e.exports=function(e,t,n){var o=n.config.validateStatus;n.status&&o&&!o(n.status)?t(r("Request failed with status code "+n.status,n.config,null,n.request,n)):e(n)}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?{write:function(e,t,n,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),r.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),r.isString(o)&&a.push("path="+o),r.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,n){"use strict";var r=n(21),o=n(22);e.exports=function(e,t){return e&&!r(t)?o(e,t):t}},function(e,t,n){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,n){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,n){"use strict";var r=n(0),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,n,i,s={};return e?(r.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=r.trim(e.substr(0,i)).toLowerCase(),n=r.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([n]):s[t]?s[t]+", "+n:n}})),s):s}},function(e,t,n){"use strict";var r=n(0);e.exports=r.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function o(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=o(window.location.href),function(t){var n=r.isString(t)?o(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0}},function(e,t,n){"use strict";var r=n(10).version,o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}}));var i={};o.transitional=function(e,t,n){function o(e,t){return"[Axios v"+r+"] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,r,s){if(!1===e)throw new Error(o(r," has been removed"+(t?" in "+t:"")));return t&&!i[r]&&(i[r]=!0,console.warn(o(r," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,r,s)}},e.exports={assertOptions:function(e,t,n){if("object"!=typeof e)throw new TypeError("options must be an object");for(var r=Object.keys(e),o=r.length;o-- >0;){var i=r[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==n)throw Error("Unknown option "+i)}},validators:o}},function(e,t,n){"use strict";var r=n(2);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var n=this;this.promise.then((function(e){if(n._listeners){var t,r=n._listeners.length;for(t=0;t<r;t++)n._listeners[t](e);n._listeners=null}})),this.promise.then=function(e){var t,r=new Promise((function(e){n.subscribe(e),t=e})).then(e);return r.cancel=function(){n.unsubscribe(t)},r},e((function(e){n.reason||(n.reason=new r(e),t(n.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},o.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},function(e,t,n){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,n){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}}])}));
|
3
3
|
//# sourceMappingURL=axios.min.map
|
package/dist/lib/base64.js
CHANGED
@@ -1,224 +1 @@
|
|
1
|
-
|
2
|
-
* base64.js
|
3
|
-
*
|
4
|
-
* Licensed under the BSD 3-Clause License.
|
5
|
-
* http://opensource.org/licenses/BSD-3-Clause
|
6
|
-
*
|
7
|
-
* References:
|
8
|
-
* http://en.wikipedia.org/wiki/Base64
|
9
|
-
*/
|
10
|
-
;(function (global, factory) {
|
11
|
-
typeof exports === 'object' && typeof module !== 'undefined'
|
12
|
-
? module.exports = factory(global)
|
13
|
-
: typeof define === 'function' && define.amd
|
14
|
-
? define(factory) : factory(global)
|
15
|
-
}((
|
16
|
-
typeof self !== 'undefined' ? self
|
17
|
-
: typeof window !== 'undefined' ? window
|
18
|
-
: typeof global !== 'undefined' ? global
|
19
|
-
: this
|
20
|
-
), function(global) {
|
21
|
-
'use strict';
|
22
|
-
// existing version for noConflict()
|
23
|
-
global = global || {};
|
24
|
-
var _Base64 = global.Base64;
|
25
|
-
var version = "2.5.2";
|
26
|
-
// if node.js and NOT React Native, we use Buffer
|
27
|
-
var buffer;
|
28
|
-
if (typeof module !== 'undefined' && module.exports) {
|
29
|
-
try {
|
30
|
-
buffer = eval("require('buffer').Buffer");
|
31
|
-
} catch (err) {
|
32
|
-
buffer = undefined;
|
33
|
-
}
|
34
|
-
}
|
35
|
-
// constants
|
36
|
-
var b64chars
|
37
|
-
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
38
|
-
var b64tab = function(bin) {
|
39
|
-
var t = {};
|
40
|
-
for (var i = 0, l = bin.length; i < l; i++) t[bin.charAt(i)] = i;
|
41
|
-
return t;
|
42
|
-
}(b64chars);
|
43
|
-
var fromCharCode = String.fromCharCode;
|
44
|
-
// encoder stuff
|
45
|
-
var cb_utob = function(c) {
|
46
|
-
if (c.length < 2) {
|
47
|
-
var cc = c.charCodeAt(0);
|
48
|
-
return cc < 0x80 ? c
|
49
|
-
: cc < 0x800 ? (fromCharCode(0xc0 | (cc >>> 6))
|
50
|
-
+ fromCharCode(0x80 | (cc & 0x3f)))
|
51
|
-
: (fromCharCode(0xe0 | ((cc >>> 12) & 0x0f))
|
52
|
-
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
53
|
-
+ fromCharCode(0x80 | ( cc & 0x3f)));
|
54
|
-
} else {
|
55
|
-
var cc = 0x10000
|
56
|
-
+ (c.charCodeAt(0) - 0xD800) * 0x400
|
57
|
-
+ (c.charCodeAt(1) - 0xDC00);
|
58
|
-
return (fromCharCode(0xf0 | ((cc >>> 18) & 0x07))
|
59
|
-
+ fromCharCode(0x80 | ((cc >>> 12) & 0x3f))
|
60
|
-
+ fromCharCode(0x80 | ((cc >>> 6) & 0x3f))
|
61
|
-
+ fromCharCode(0x80 | ( cc & 0x3f)));
|
62
|
-
}
|
63
|
-
};
|
64
|
-
var re_utob = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g;
|
65
|
-
var utob = function(u) {
|
66
|
-
return u.replace(re_utob, cb_utob);
|
67
|
-
};
|
68
|
-
var cb_encode = function(ccc) {
|
69
|
-
var padlen = [0, 2, 1][ccc.length % 3],
|
70
|
-
ord = ccc.charCodeAt(0) << 16
|
71
|
-
| ((ccc.length > 1 ? ccc.charCodeAt(1) : 0) << 8)
|
72
|
-
| ((ccc.length > 2 ? ccc.charCodeAt(2) : 0)),
|
73
|
-
chars = [
|
74
|
-
b64chars.charAt( ord >>> 18),
|
75
|
-
b64chars.charAt((ord >>> 12) & 63),
|
76
|
-
padlen >= 2 ? '=' : b64chars.charAt((ord >>> 6) & 63),
|
77
|
-
padlen >= 1 ? '=' : b64chars.charAt(ord & 63)
|
78
|
-
];
|
79
|
-
return chars.join('');
|
80
|
-
};
|
81
|
-
var btoa = global.btoa ? function(b) {
|
82
|
-
return global.btoa(b);
|
83
|
-
} : function(b) {
|
84
|
-
return b.replace(/[\s\S]{1,3}/g, cb_encode);
|
85
|
-
};
|
86
|
-
var _encode = function(u) {
|
87
|
-
var isUint8Array = Object.prototype.toString.call(u) === '[object Uint8Array]';
|
88
|
-
return isUint8Array ? u.toString('base64')
|
89
|
-
: btoa(utob(String(u)));
|
90
|
-
}
|
91
|
-
var encode = function(u, urisafe) {
|
92
|
-
return !urisafe
|
93
|
-
? _encode(u)
|
94
|
-
: _encode(String(u)).replace(/[+\/]/g, function(m0) {
|
95
|
-
return m0 == '+' ? '-' : '_';
|
96
|
-
}).replace(/=/g, '');
|
97
|
-
};
|
98
|
-
var encodeURI = function(u) { return encode(u, true) };
|
99
|
-
// decoder stuff
|
100
|
-
var re_btou = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g;
|
101
|
-
var cb_btou = function(cccc) {
|
102
|
-
switch(cccc.length) {
|
103
|
-
case 4:
|
104
|
-
var cp = ((0x07 & cccc.charCodeAt(0)) << 18)
|
105
|
-
| ((0x3f & cccc.charCodeAt(1)) << 12)
|
106
|
-
| ((0x3f & cccc.charCodeAt(2)) << 6)
|
107
|
-
| (0x3f & cccc.charCodeAt(3)),
|
108
|
-
offset = cp - 0x10000;
|
109
|
-
return (fromCharCode((offset >>> 10) + 0xD800)
|
110
|
-
+ fromCharCode((offset & 0x3FF) + 0xDC00));
|
111
|
-
case 3:
|
112
|
-
return fromCharCode(
|
113
|
-
((0x0f & cccc.charCodeAt(0)) << 12)
|
114
|
-
| ((0x3f & cccc.charCodeAt(1)) << 6)
|
115
|
-
| (0x3f & cccc.charCodeAt(2))
|
116
|
-
);
|
117
|
-
default:
|
118
|
-
return fromCharCode(
|
119
|
-
((0x1f & cccc.charCodeAt(0)) << 6)
|
120
|
-
| (0x3f & cccc.charCodeAt(1))
|
121
|
-
);
|
122
|
-
}
|
123
|
-
};
|
124
|
-
var btou = function(b) {
|
125
|
-
return b.replace(re_btou, cb_btou);
|
126
|
-
};
|
127
|
-
var cb_decode = function(cccc) {
|
128
|
-
var len = cccc.length,
|
129
|
-
padlen = len % 4,
|
130
|
-
n = (len > 0 ? b64tab[cccc.charAt(0)] << 18 : 0)
|
131
|
-
| (len > 1 ? b64tab[cccc.charAt(1)] << 12 : 0)
|
132
|
-
| (len > 2 ? b64tab[cccc.charAt(2)] << 6 : 0)
|
133
|
-
| (len > 3 ? b64tab[cccc.charAt(3)] : 0),
|
134
|
-
chars = [
|
135
|
-
fromCharCode( n >>> 16),
|
136
|
-
fromCharCode((n >>> 8) & 0xff),
|
137
|
-
fromCharCode( n & 0xff)
|
138
|
-
];
|
139
|
-
chars.length -= [0, 0, 2, 1][padlen];
|
140
|
-
return chars.join('');
|
141
|
-
};
|
142
|
-
var _atob = global.atob ? function(a) {
|
143
|
-
return global.atob(a);
|
144
|
-
} : function(a){
|
145
|
-
return a.replace(/\S{1,4}/g, cb_decode);
|
146
|
-
};
|
147
|
-
var atob = function(a) {
|
148
|
-
return _atob(String(a).replace(/[^A-Za-z0-9\+\/]/g, ''));
|
149
|
-
};
|
150
|
-
var _decode = buffer ?
|
151
|
-
buffer.from && Uint8Array && buffer.from !== Uint8Array.from
|
152
|
-
? function(a) {
|
153
|
-
return (a.constructor === buffer.constructor
|
154
|
-
? a : buffer.from(a, 'base64')).toString();
|
155
|
-
}
|
156
|
-
: function(a) {
|
157
|
-
return (a.constructor === buffer.constructor
|
158
|
-
? a : new buffer(a, 'base64')).toString();
|
159
|
-
}
|
160
|
-
: function(a) { return btou(_atob(a)) };
|
161
|
-
var decode = function(a){
|
162
|
-
return _decode(
|
163
|
-
String(a).replace(/[-_]/g, function(m0) { return m0 == '-' ? '+' : '/' })
|
164
|
-
.replace(/[^A-Za-z0-9\+\/]/g, '')
|
165
|
-
);
|
166
|
-
};
|
167
|
-
var noConflict = function() {
|
168
|
-
var Base64 = global.Base64;
|
169
|
-
global.Base64 = _Base64;
|
170
|
-
return Base64;
|
171
|
-
};
|
172
|
-
// export Base64
|
173
|
-
global.Base64 = {
|
174
|
-
VERSION: version,
|
175
|
-
atob: atob,
|
176
|
-
btoa: btoa,
|
177
|
-
fromBase64: decode,
|
178
|
-
toBase64: encode,
|
179
|
-
utob: utob,
|
180
|
-
encode: encode,
|
181
|
-
encodeURI: encodeURI,
|
182
|
-
btou: btou,
|
183
|
-
decode: decode,
|
184
|
-
noConflict: noConflict,
|
185
|
-
__buffer__: buffer
|
186
|
-
};
|
187
|
-
// if ES5 is available, make Base64.extendString() available
|
188
|
-
if (typeof Object.defineProperty === 'function') {
|
189
|
-
var noEnum = function(v){
|
190
|
-
return {value:v,enumerable:false,writable:true,configurable:true};
|
191
|
-
};
|
192
|
-
global.Base64.extendString = function () {
|
193
|
-
Object.defineProperty(
|
194
|
-
String.prototype, 'fromBase64', noEnum(function () {
|
195
|
-
return decode(this)
|
196
|
-
}));
|
197
|
-
Object.defineProperty(
|
198
|
-
String.prototype, 'toBase64', noEnum(function (urisafe) {
|
199
|
-
return encode(this, urisafe)
|
200
|
-
}));
|
201
|
-
Object.defineProperty(
|
202
|
-
String.prototype, 'toBase64URI', noEnum(function () {
|
203
|
-
return encode(this, true)
|
204
|
-
}));
|
205
|
-
};
|
206
|
-
}
|
207
|
-
//
|
208
|
-
// export Base64 to the namespace
|
209
|
-
//
|
210
|
-
if (global['Meteor']) { // Meteor.js
|
211
|
-
Base64 = global.Base64;
|
212
|
-
}
|
213
|
-
// module.exports and AMD are mutually exclusive.
|
214
|
-
// module.exports has precedence.
|
215
|
-
if (typeof module !== 'undefined' && module.exports) {
|
216
|
-
module.exports.Base64 = global.Base64;
|
217
|
-
}
|
218
|
-
else if (typeof define === 'function' && define.amd) {
|
219
|
-
// AMD. Register as an anonymous module.
|
220
|
-
define([], function(){ return global.Base64 });
|
221
|
-
}
|
222
|
-
// that's it!
|
223
|
-
return {Base64: global.Base64}
|
224
|
-
}));
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?module.exports=o(e):"function"==typeof define&&define.amd?define(o):o(e)}("undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this,function(global){"use strict";global=global||{};var _Base64=global.Base64,version="2.5.2",buffer;if("undefined"!=typeof module&&module.exports)try{buffer=eval("require('buffer').Buffer")}catch(e){buffer=void 0}var b64chars="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b64tab=function(e){for(var o={},r=0,t=e.length;r<t;r++)o[e.charAt(r)]=r;return o}(b64chars),fromCharCode=String.fromCharCode,cb_utob=function(e){if(e.length<2)return(o=e.charCodeAt(0))<128?e:o<2048?fromCharCode(192|o>>>6)+fromCharCode(128|63&o):fromCharCode(224|o>>>12&15)+fromCharCode(128|o>>>6&63)+fromCharCode(128|63&o);var o=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return fromCharCode(240|o>>>18&7)+fromCharCode(128|o>>>12&63)+fromCharCode(128|o>>>6&63)+fromCharCode(128|63&o)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=function(e){return e.replace(re_utob,cb_utob)},cb_encode=function(e){var o=[0,2,1][e.length%3],r=e.charCodeAt(0)<<16|(e.length>1?e.charCodeAt(1):0)<<8|(e.length>2?e.charCodeAt(2):0);return[b64chars.charAt(r>>>18),b64chars.charAt(r>>>12&63),o>=2?"=":b64chars.charAt(r>>>6&63),o>=1?"=":b64chars.charAt(63&r)].join("")},btoa=global.btoa?function(e){return global.btoa(e)}:function(e){return e.replace(/[\s\S]{1,3}/g,cb_encode)},_encode=function(e){return"[object Uint8Array]"===Object.prototype.toString.call(e)?e.toString("base64"):btoa(utob(String(e)))},encode=function(e,o){return o?_encode(String(e)).replace(/[+\/]/g,function(e){return"+"==e?"-":"_"}).replace(/=/g,""):_encode(e)},encodeURI=function(e){return encode(e,!0)},re_btou=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,cb_btou=function(e){switch(e.length){case 4:var o=((7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3))-65536;return fromCharCode(55296+(o>>>10))+fromCharCode(56320+(1023&o));case 3:return fromCharCode((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return fromCharCode((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},btou=function(e){return e.replace(re_btou,cb_btou)},cb_decode=function(e){var o=e.length,r=o%4,t=(o>0?b64tab[e.charAt(0)]<<18:0)|(o>1?b64tab[e.charAt(1)]<<12:0)|(o>2?b64tab[e.charAt(2)]<<6:0)|(o>3?b64tab[e.charAt(3)]:0),n=[fromCharCode(t>>>16),fromCharCode(t>>>8&255),fromCharCode(255&t)];return n.length-=[0,0,2,1][r],n.join("")},_atob=global.atob?function(e){return global.atob(e)}:function(e){return e.replace(/\S{1,4}/g,cb_decode)},atob=function(e){return _atob(String(e).replace(/[^A-Za-z0-9\+\/]/g,""))},_decode=buffer?buffer.from&&Uint8Array&&buffer.from!==Uint8Array.from?function(e){return(e.constructor===buffer.constructor?e:buffer.from(e,"base64")).toString()}:function(e){return(e.constructor===buffer.constructor?e:new buffer(e,"base64")).toString()}:function(e){return btou(_atob(e))},decode=function(e){return _decode(String(e).replace(/[-_]/g,function(e){return"-"==e?"+":"/"}).replace(/[^A-Za-z0-9\+\/]/g,""))},noConflict=function(){var e=global.Base64;return global.Base64=_Base64,e};if(global.Base64={VERSION:version,atob:atob,btoa:btoa,fromBase64:decode,toBase64:encode,utob:utob,encode:encode,encodeURI:encodeURI,btou:btou,decode:decode,noConflict:noConflict,__buffer__:buffer},"function"==typeof Object.defineProperty){var noEnum=function(e){return{value:e,enumerable:!1,writable:!0,configurable:!0}};global.Base64.extendString=function(){Object.defineProperty(String.prototype,"fromBase64",noEnum(function(){return decode(this)})),Object.defineProperty(String.prototype,"toBase64",noEnum(function(e){return encode(this,e)})),Object.defineProperty(String.prototype,"toBase64URI",noEnum(function(){return encode(this,!0)}))}}return global.Meteor&&(Base64=global.Base64),"undefined"!=typeof module&&module.exports?module.exports.Base64=global.Base64:"function"==typeof define&&define.amd&&define([],function(){return global.Base64}),{Base64:global.Base64}});
|
package/dist/utils/tools.d.ts
CHANGED
@@ -27,5 +27,6 @@ export declare const getDUrl: (url: string, optionsOverride?: AxiosRequestConfig
|
|
27
27
|
*/
|
28
28
|
export declare const base64MimeType: (dUrl: DataURL) => string;
|
29
29
|
export declare const processSend: (message: string) => void;
|
30
|
+
export declare function timePromise(fn: () => Promise<any>): Promise<string>;
|
30
31
|
export declare const processSendData: (data?: any) => void;
|
31
32
|
export declare const generateGHIssueLink: (config: ConfigObject, sessionInfo: SessionInfo, extras?: any) => string;
|
package/dist/utils/tools.js
CHANGED
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
24
24
|
};
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
-
exports.generateGHIssueLink = exports.processSendData = exports.processSend = exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = exports.timeout = void 0;
|
26
|
+
exports.generateGHIssueLink = exports.processSendData = exports.timePromise = exports.processSend = exports.base64MimeType = exports.getDUrl = exports.isDataURL = exports.isBase64 = exports.camelize = exports.without = exports.getConfigFromProcessEnv = exports.smartUserAgent = exports.timeout = void 0;
|
27
27
|
const axios_1 = __importDefault(require("axios"));
|
28
28
|
const child_process_1 = require("child_process");
|
29
29
|
//@ts-ignore
|
@@ -138,6 +138,14 @@ const processSend = (message) => {
|
|
138
138
|
return;
|
139
139
|
};
|
140
140
|
exports.processSend = processSend;
|
141
|
+
function timePromise(fn) {
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
143
|
+
const start = performance.now();
|
144
|
+
yield fn();
|
145
|
+
return (performance.now() - start).toFixed(0);
|
146
|
+
});
|
147
|
+
}
|
148
|
+
exports.timePromise = timePromise;
|
141
149
|
const processSendData = (data = {}) => {
|
142
150
|
process.send({
|
143
151
|
type: 'process:msg',
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@open-wa/wa-automate",
|
3
|
-
"version": "4.
|
3
|
+
"version": "4.30.0",
|
4
4
|
"licenseCheckUrl": "https://openwa.dev/license-check",
|
5
5
|
"brokenMethodReportUrl": "https://openwa.dev/report-bm",
|
6
6
|
"patches": "https://cdn.openwa.dev/patches.json",
|
@@ -60,6 +60,9 @@
|
|
60
60
|
"node": ">=12.18.3",
|
61
61
|
"npm": ">=7.9.0"
|
62
62
|
},
|
63
|
+
"resolutions": {
|
64
|
+
"colors": "1.4.0"
|
65
|
+
},
|
63
66
|
"devDependencies": {
|
64
67
|
"@types/changelog-parser": "^2.7.1",
|
65
68
|
"@types/command-line-args": "^5.0.0",
|
@@ -81,6 +84,7 @@
|
|
81
84
|
"auto-changelog": "^2.0.0",
|
82
85
|
"ava": "^3.13.0",
|
83
86
|
"changelog-parser": "^2.8.0",
|
87
|
+
"typeconv": "^1.7.0",
|
84
88
|
"command-line-args": "^5.1.1",
|
85
89
|
"eslint": "^8.1.0",
|
86
90
|
"husky": "^7.0.0",
|
@@ -94,6 +98,7 @@
|
|
94
98
|
"shelljs": "^0.8.3",
|
95
99
|
"ts-node": "^10.0.0",
|
96
100
|
"tsc-watch": "^4.0.0",
|
101
|
+
"tiny-glob": "^0.2.9",
|
97
102
|
"typedoc": "^0.21.6",
|
98
103
|
"typedoc-plugin-pages": "^1.0.1",
|
99
104
|
"typescript": "^4.2.4"
|
@@ -156,13 +161,11 @@
|
|
156
161
|
"swagger-ui-express": "^4.1.4",
|
157
162
|
"tcp-port-used": "^1.0.1",
|
158
163
|
"terminal-link": "^2.1.1",
|
159
|
-
"
|
164
|
+
"terminate": "^2.5.0",
|
160
165
|
"traverse": "^0.6.6",
|
161
|
-
"tree-kill": "^1.2.2",
|
162
166
|
"ts-json-schema-generator": "^0.95.0",
|
163
167
|
"ts-morph": "^12.0.0",
|
164
168
|
"type-fest": "^1.1.1",
|
165
|
-
"typeconv": "^1.7.0",
|
166
169
|
"update-notifier": "^5.0.0",
|
167
170
|
"uuid": "^8.3.2",
|
168
171
|
"uuid-apikey": "^1.5.3",
|