@auxcode/auxta 1.3.80 → 1.3.82
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/README.md +18 -14
- package/build/AuxTA.d.ts +1 -3
- package/build/AuxTA.js +15 -17
- package/build/auxta/models/upload.model.d.ts +18 -18
- package/build/auxta/models/upload.model.js +21 -21
- package/build/auxta/services/log.service.d.ts +2 -2
- package/build/auxta/services/log.service.js +8 -3
- package/build/auxta/services/runtime.service.d.ts +1 -1
- package/build/auxta/services/runtime.service.js +8 -9
- package/build/auxta/utilities/runtime.helper.d.ts +1 -1
- package/build/macros/helpers/code.helper.d.ts +2 -2
- package/build/macros/helpers/code.helper.js +16 -12
- package/build/macros/helpers/emailHelper.js +3 -5
- package/build/puppeteer/puppeteer.d.ts +1 -1
- package/build/puppeteer/puppeteer.js +21 -22
- package/package.json +4 -6
- package/build/macros/helpers/AuxGoogleAuth.d.ts +0 -21
- package/build/macros/helpers/AuxGoogleAuth.js +0 -182
- package/build/puppeteer/puppeteer-extra.d.ts +0 -9
- package/build/puppeteer/puppeteer-extra.js +0 -63
package/README.md
CHANGED
|
@@ -33,23 +33,25 @@ waitforseelctorbytext `depreciated`
|
|
|
33
33
|
* (AuxTA) We do some action on the website.
|
|
34
34
|
* (Website) Sends an email to the email address of the user who did the action.
|
|
35
35
|
* (AuxTA) Should check that that the email was correctly sent. So we check:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*
|
|
36
|
+
* `auxta.checkMail(_from_name_, _from_email_, _subject_, _body_text_)`
|
|
37
|
+
* The email login is in the main config of the test suite.
|
|
38
|
+
* email
|
|
39
|
+
* API TOKEN
|
|
40
|
+
* For the moment we do it synchroneous (AuxTA waits for the email).
|
|
41
|
+
* The email must be newser than the time of the action on the Website.
|
|
42
|
+
* Must be _from_name_ (substring)
|
|
43
|
+
* Must be _from_email_ (substring)
|
|
44
|
+
* Must have _subject_ (substring)
|
|
45
|
+
* Must cotnain _body_text_ (substring)
|
|
46
|
+
* Quality of Service, if the email does not arrive w/in eg. 5 minutes we return an error w/ timeout.
|
|
47
|
+
*
|
|
48
|
+
* `auxta.clickInMail(_from_name_, _from_email_, _subject_, _click_on_)`
|
|
48
49
|
|
|
49
50
|
## Running
|
|
50
51
|
|
|
51
52
|
* Create a main function that calls the run() function which starts all tests
|
|
52
|
-
* Create a function for each test that calls the `auxtaPuppeteer.run(event, callback, featureName, scenarioName)`
|
|
53
|
+
* Create a function for each test that calls the `auxtaPuppeteer.run(event, callback, featureName, scenarioName)`
|
|
54
|
+
function
|
|
53
55
|
|
|
54
56
|
## Puppeteer
|
|
55
57
|
|
|
@@ -96,10 +98,12 @@ npm i
|
|
|
96
98
|
Implement a way to scout the skipped steps w/ $failed=true, $skipped=++
|
|
97
99
|
control click go to source directory
|
|
98
100
|
|
|
99
|
-
|
|
100
101
|
##Improvements
|
|
102
|
+
|
|
101
103
|
* introduce the new headless mode, by Puppeteer.
|
|
102
104
|
|
|
103
105
|
### platform improvements
|
|
106
|
+
|
|
104
107
|
Also some improvements to the platform in general:
|
|
108
|
+
|
|
105
109
|
* get the console state after a fail, this would increase the value of each failed report.
|
package/build/AuxTA.d.ts
CHANGED
|
@@ -2,11 +2,9 @@ import { Puppeteer } from "./puppeteer/puppeteer";
|
|
|
2
2
|
import { FunctionHelper } from "./macros/helpers/code.helper";
|
|
3
3
|
import StatusOfStep from "./auxta/enums/status-of.step";
|
|
4
4
|
import { UploadModel } from "./auxta/models/upload.model";
|
|
5
|
-
import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
|
|
6
5
|
declare class AuxTA extends FunctionHelper {
|
|
7
6
|
puppeteer: Puppeteer;
|
|
8
7
|
aux2fa: import("./macros/helpers/Aux2faAuth").Aux2faAuth;
|
|
9
|
-
google: typeof AuxGoogleAuth;
|
|
10
8
|
config: {
|
|
11
9
|
auxtaURL: string;
|
|
12
10
|
baseURL: string;
|
|
@@ -40,7 +38,6 @@ declare class AuxTA extends FunctionHelper {
|
|
|
40
38
|
currentSuite: string | undefined;
|
|
41
39
|
retries: string;
|
|
42
40
|
}>;
|
|
43
|
-
private changeModelData;
|
|
44
41
|
startBrowser(event: any, callback: any, feature: string, scenario: string, overrideConfig?: any, singleFeature?: boolean, fileName?: string): Promise<{
|
|
45
42
|
nextSuites?: undefined;
|
|
46
43
|
reportId?: undefined;
|
|
@@ -56,6 +53,7 @@ declare class AuxTA extends FunctionHelper {
|
|
|
56
53
|
} | undefined>;
|
|
57
54
|
startBrowserRPA(event: any, callback: any, baseURL: string, fileName?: string): Promise<any>;
|
|
58
55
|
getUploadModel(): UploadModel;
|
|
56
|
+
private changeModelData;
|
|
59
57
|
}
|
|
60
58
|
export declare const StepStatus: typeof StatusOfStep;
|
|
61
59
|
declare const auxta: AuxTA;
|
package/build/AuxTA.js
CHANGED
|
@@ -47,7 +47,6 @@ const config_1 = require("./auxta/configs/config");
|
|
|
47
47
|
const start_suite_helper_1 = require("./auxta/utilities/start-suite.helper");
|
|
48
48
|
const report_service_1 = require("./auxta/services/report.service");
|
|
49
49
|
const Aux2faAuth_1 = __importDefault(require("./macros/helpers/Aux2faAuth"));
|
|
50
|
-
const AuxGoogleAuth_1 = require("./macros/helpers/AuxGoogleAuth");
|
|
51
50
|
const emailHelper_1 = __importDefault(require("./macros/helpers/emailHelper"));
|
|
52
51
|
dotenv.config();
|
|
53
52
|
class AuxTA extends code_helper_1.FunctionHelper {
|
|
@@ -55,7 +54,6 @@ class AuxTA extends code_helper_1.FunctionHelper {
|
|
|
55
54
|
super();
|
|
56
55
|
this.puppeteer = puppeteer_1.default;
|
|
57
56
|
this.aux2fa = Aux2faAuth_1.default;
|
|
58
|
-
this.google = AuxGoogleAuth_1.AuxGoogleAuth;
|
|
59
57
|
this.config = config_1.config;
|
|
60
58
|
this.email = emailHelper_1.default;
|
|
61
59
|
let file;
|
|
@@ -110,21 +108,6 @@ class AuxTA extends code_helper_1.FunctionHelper {
|
|
|
110
108
|
return (0, start_suite_helper_1.startSuite)(suites, reportId || (yield (0, report_service_1.createEmptyReport)(this.uploadModel)));
|
|
111
109
|
});
|
|
112
110
|
}
|
|
113
|
-
changeModelData(overrideConfig) {
|
|
114
|
-
if (overrideConfig) {
|
|
115
|
-
if (overrideConfig.digitalProduct)
|
|
116
|
-
this.uploadModel.digitalProduct = overrideConfig.digitalProduct;
|
|
117
|
-
if (overrideConfig.environment)
|
|
118
|
-
this.uploadModel.environment = overrideConfig.environment;
|
|
119
|
-
if (overrideConfig.baseURL)
|
|
120
|
-
this.uploadModel.baseUrl = overrideConfig.baseURL;
|
|
121
|
-
if (overrideConfig.bucket)
|
|
122
|
-
this.uploadModel.bucket = overrideConfig.bucket;
|
|
123
|
-
if (overrideConfig.isOfficial !== undefined)
|
|
124
|
-
this.uploadModel.isOfficial = overrideConfig.isOfficial;
|
|
125
|
-
this.config = (0, config_1.setupOverrideConfig)(overrideConfig);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
111
|
startBrowser(event, callback, feature, scenario, overrideConfig, singleFeature = false, fileName = '') {
|
|
129
112
|
return __awaiter(this, void 0, void 0, function* () {
|
|
130
113
|
this.changeModelData(overrideConfig);
|
|
@@ -150,6 +133,21 @@ class AuxTA extends code_helper_1.FunctionHelper {
|
|
|
150
133
|
getUploadModel() {
|
|
151
134
|
return this.uploadModel;
|
|
152
135
|
}
|
|
136
|
+
changeModelData(overrideConfig) {
|
|
137
|
+
if (overrideConfig) {
|
|
138
|
+
if (overrideConfig.digitalProduct)
|
|
139
|
+
this.uploadModel.digitalProduct = overrideConfig.digitalProduct;
|
|
140
|
+
if (overrideConfig.environment)
|
|
141
|
+
this.uploadModel.environment = overrideConfig.environment;
|
|
142
|
+
if (overrideConfig.baseURL)
|
|
143
|
+
this.uploadModel.baseUrl = overrideConfig.baseURL;
|
|
144
|
+
if (overrideConfig.bucket)
|
|
145
|
+
this.uploadModel.bucket = overrideConfig.bucket;
|
|
146
|
+
if (overrideConfig.isOfficial !== undefined)
|
|
147
|
+
this.uploadModel.isOfficial = overrideConfig.isOfficial;
|
|
148
|
+
this.config = (0, config_1.setupOverrideConfig)(overrideConfig);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
153
151
|
}
|
|
154
152
|
exports.StepStatus = status_of_step_1.default;
|
|
155
153
|
const auxta = new AuxTA();
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
export declare class UploadModel {
|
|
2
|
-
private _reportId;
|
|
3
|
-
private _nextSuites;
|
|
4
|
-
private _digitalProduct;
|
|
5
|
-
private _baseUrl;
|
|
6
2
|
private readonly _organization;
|
|
7
|
-
private _bucket;
|
|
8
|
-
private _environment;
|
|
9
|
-
private _currentSuite;
|
|
10
|
-
private _retries;
|
|
11
|
-
private _featureName;
|
|
12
|
-
private _scenarioName;
|
|
13
|
-
private _isOfficial;
|
|
14
3
|
constructor(org: string, baseUrl: string, digitalProduct: string, environment: string, bucket: string, isOfficial: boolean);
|
|
15
|
-
|
|
16
|
-
set retries(value: number);
|
|
17
|
-
get currentSuite(): string;
|
|
18
|
-
get bucket(): string;
|
|
19
|
-
set bucket(value: string);
|
|
20
|
-
get retries(): number;
|
|
4
|
+
private _reportId;
|
|
21
5
|
get reportId(): string;
|
|
22
6
|
set reportId(value: string);
|
|
7
|
+
private _nextSuites;
|
|
23
8
|
get nextSuites(): [];
|
|
24
9
|
set nextSuites(value: []);
|
|
10
|
+
private _digitalProduct;
|
|
25
11
|
get digitalProduct(): string;
|
|
26
12
|
set digitalProduct(value: string);
|
|
27
|
-
|
|
13
|
+
private _baseUrl;
|
|
28
14
|
get baseUrl(): string;
|
|
29
15
|
set baseUrl(value: string);
|
|
16
|
+
private _bucket;
|
|
17
|
+
get bucket(): string;
|
|
18
|
+
set bucket(value: string);
|
|
19
|
+
private _environment;
|
|
30
20
|
get environment(): string;
|
|
31
21
|
set environment(value: string);
|
|
22
|
+
private _currentSuite;
|
|
23
|
+
get currentSuite(): string;
|
|
24
|
+
set currentSuite(value: string);
|
|
25
|
+
private _retries;
|
|
26
|
+
get retries(): number;
|
|
27
|
+
set retries(value: number);
|
|
28
|
+
private _featureName;
|
|
32
29
|
get featureName(): string;
|
|
33
30
|
set featureName(value: string);
|
|
31
|
+
private _scenarioName;
|
|
34
32
|
get scenarioName(): string;
|
|
35
33
|
set scenarioName(value: string);
|
|
34
|
+
private _isOfficial;
|
|
36
35
|
get isOfficial(): boolean;
|
|
37
36
|
set isOfficial(value: boolean);
|
|
37
|
+
get organization(): string;
|
|
38
38
|
}
|
|
@@ -16,24 +16,6 @@ class UploadModel {
|
|
|
16
16
|
this._scenarioName = '';
|
|
17
17
|
this._isOfficial = isOfficial;
|
|
18
18
|
}
|
|
19
|
-
set currentSuite(value) {
|
|
20
|
-
this._currentSuite = value;
|
|
21
|
-
}
|
|
22
|
-
set retries(value) {
|
|
23
|
-
this._retries = value;
|
|
24
|
-
}
|
|
25
|
-
get currentSuite() {
|
|
26
|
-
return this._currentSuite;
|
|
27
|
-
}
|
|
28
|
-
get bucket() {
|
|
29
|
-
return this._bucket;
|
|
30
|
-
}
|
|
31
|
-
set bucket(value) {
|
|
32
|
-
this._bucket = value;
|
|
33
|
-
}
|
|
34
|
-
get retries() {
|
|
35
|
-
return this._retries;
|
|
36
|
-
}
|
|
37
19
|
get reportId() {
|
|
38
20
|
return this._reportId;
|
|
39
21
|
}
|
|
@@ -52,21 +34,36 @@ class UploadModel {
|
|
|
52
34
|
set digitalProduct(value) {
|
|
53
35
|
this._digitalProduct = value;
|
|
54
36
|
}
|
|
55
|
-
get organization() {
|
|
56
|
-
return this._organization;
|
|
57
|
-
}
|
|
58
37
|
get baseUrl() {
|
|
59
38
|
return this._baseUrl;
|
|
60
39
|
}
|
|
61
40
|
set baseUrl(value) {
|
|
62
41
|
this._baseUrl = value;
|
|
63
42
|
}
|
|
43
|
+
get bucket() {
|
|
44
|
+
return this._bucket;
|
|
45
|
+
}
|
|
46
|
+
set bucket(value) {
|
|
47
|
+
this._bucket = value;
|
|
48
|
+
}
|
|
64
49
|
get environment() {
|
|
65
50
|
return this._environment;
|
|
66
51
|
}
|
|
67
52
|
set environment(value) {
|
|
68
53
|
this._environment = value;
|
|
69
54
|
}
|
|
55
|
+
get currentSuite() {
|
|
56
|
+
return this._currentSuite;
|
|
57
|
+
}
|
|
58
|
+
set currentSuite(value) {
|
|
59
|
+
this._currentSuite = value;
|
|
60
|
+
}
|
|
61
|
+
get retries() {
|
|
62
|
+
return this._retries;
|
|
63
|
+
}
|
|
64
|
+
set retries(value) {
|
|
65
|
+
this._retries = value;
|
|
66
|
+
}
|
|
70
67
|
get featureName() {
|
|
71
68
|
return this._featureName;
|
|
72
69
|
}
|
|
@@ -85,5 +82,8 @@ class UploadModel {
|
|
|
85
82
|
set isOfficial(value) {
|
|
86
83
|
this._isOfficial = value;
|
|
87
84
|
}
|
|
85
|
+
get organization() {
|
|
86
|
+
return this._organization;
|
|
87
|
+
}
|
|
88
88
|
}
|
|
89
89
|
exports.UploadModel = UploadModel;
|
|
@@ -13,14 +13,14 @@ export interface Step {
|
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
export declare class LogSteps {
|
|
16
|
-
private stepLog;
|
|
17
|
-
private lastStepTime;
|
|
18
16
|
statusCounter: {
|
|
19
17
|
passed: number;
|
|
20
18
|
failed: number;
|
|
21
19
|
skipped: number;
|
|
22
20
|
suggestion: number;
|
|
23
21
|
};
|
|
22
|
+
private stepLog;
|
|
23
|
+
private lastStepTime;
|
|
24
24
|
addSuggestion(text: string): void;
|
|
25
25
|
clear(): void;
|
|
26
26
|
push(keyword: string, name: string, status: StatusOfStep, screenshot?: string, imageCompareKey?: string): void;
|
|
@@ -4,14 +4,14 @@ exports.LogSteps = void 0;
|
|
|
4
4
|
const status_of_step_1 = require("../enums/status-of.step");
|
|
5
5
|
class LogSteps {
|
|
6
6
|
constructor() {
|
|
7
|
-
this.stepLog = [];
|
|
8
|
-
this.lastStepTime = new Date().getTime();
|
|
9
7
|
this.statusCounter = {
|
|
10
8
|
[status_of_step_1.StatusOfStep.PASSED]: 0,
|
|
11
9
|
[status_of_step_1.StatusOfStep.FAILED]: 0,
|
|
12
10
|
[status_of_step_1.StatusOfStep.SKIPPED]: 0,
|
|
13
11
|
[status_of_step_1.StatusOfStep.SUGGESTION]: 0,
|
|
14
12
|
};
|
|
13
|
+
this.stepLog = [];
|
|
14
|
+
this.lastStepTime = new Date().getTime();
|
|
15
15
|
}
|
|
16
16
|
addSuggestion(text) {
|
|
17
17
|
this.statusCounter[status_of_step_1.StatusOfStep.SUGGESTION]++;
|
|
@@ -45,7 +45,12 @@ class LogSteps {
|
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
|
-
this.stepLog.push({
|
|
48
|
+
this.stepLog.push({
|
|
49
|
+
keyword,
|
|
50
|
+
name,
|
|
51
|
+
imageCompareKey,
|
|
52
|
+
result: { status, duration: currentStep - this.lastStepTime }
|
|
53
|
+
});
|
|
49
54
|
}
|
|
50
55
|
this.lastStepTime = currentStep;
|
|
51
56
|
}
|
|
@@ -8,9 +8,9 @@ export declare class Runtime {
|
|
|
8
8
|
private end;
|
|
9
9
|
private runtime;
|
|
10
10
|
constructor(s: Date, e: Date);
|
|
11
|
+
returnRuntime(): RunTime;
|
|
11
12
|
private calculateDuration;
|
|
12
13
|
private splitAtDecimanlMinutes;
|
|
13
14
|
private splitAtDecimanlHours;
|
|
14
15
|
private formatRuntime;
|
|
15
|
-
returnRuntime(): RunTime;
|
|
16
16
|
}
|
|
@@ -6,10 +6,16 @@ class Runtime {
|
|
|
6
6
|
this.start = s;
|
|
7
7
|
this.end = e;
|
|
8
8
|
}
|
|
9
|
+
returnRuntime() {
|
|
10
|
+
let duration = this.formatRuntime(this.calculateDuration());
|
|
11
|
+
let startTime = this.start;
|
|
12
|
+
let endTime = this.end;
|
|
13
|
+
this.runtime = { duration, startTime, endTime };
|
|
14
|
+
return this.runtime;
|
|
15
|
+
}
|
|
9
16
|
calculateDuration() {
|
|
10
17
|
let currentTime = new Date;
|
|
11
|
-
|
|
12
|
-
return duration;
|
|
18
|
+
return currentTime.getTime() - this.start.getTime();
|
|
13
19
|
}
|
|
14
20
|
splitAtDecimanlMinutes(time) {
|
|
15
21
|
let minutes = time.toFixed(2).toString().split('.');
|
|
@@ -30,12 +36,5 @@ class Runtime {
|
|
|
30
36
|
return this.splitAtDecimanlHours(duration / 3600000);
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
|
-
returnRuntime() {
|
|
34
|
-
let duration = this.formatRuntime(this.calculateDuration());
|
|
35
|
-
let startTime = this.start;
|
|
36
|
-
let endTime = this.end;
|
|
37
|
-
this.runtime = { duration, startTime, endTime };
|
|
38
|
-
return this.runtime;
|
|
39
|
-
}
|
|
40
39
|
}
|
|
41
40
|
exports.Runtime = Runtime;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { RunTime } from "../services/runtime.service";
|
|
2
2
|
export declare class CalculateRuntime {
|
|
3
|
-
private runtime;
|
|
4
3
|
startTimeSeconds: string;
|
|
5
4
|
startTimeMinutes: string;
|
|
6
5
|
startTimeHours: string;
|
|
@@ -11,5 +10,6 @@ export declare class CalculateRuntime {
|
|
|
11
10
|
endTimeHours: string;
|
|
12
11
|
endTimeDay: string;
|
|
13
12
|
endTimeMonth: string;
|
|
13
|
+
private runtime;
|
|
14
14
|
constructor(r: RunTime);
|
|
15
15
|
}
|
|
@@ -5,11 +5,10 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
5
5
|
screenshot(page?: import("puppeteer").Page): Promise<string | undefined>;
|
|
6
6
|
screenshotCompare(key: string, threshold?: number, page?: import("puppeteer").Page): Promise<void>;
|
|
7
7
|
suggest(name: string): void;
|
|
8
|
-
private getEscapedText;
|
|
9
8
|
clickByText(selector: string, text: string, dotOrText?: string, options?: {}, page?: import("puppeteer").Page, time?: number, log_message?: boolean): Promise<void>;
|
|
10
9
|
clickByTextWithClass(class_selector: string, class_name: string, selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<void>;
|
|
11
10
|
waitForSelectorWithText(selector: string, text: string, dotOrText?: string, page?: import("puppeteer").Page): Promise<boolean>;
|
|
12
|
-
timeout(timeout?: number
|
|
11
|
+
timeout(timeout?: number): Promise<void>;
|
|
13
12
|
waitForSelector(option: string, selector: string, time?: number, page?: import("puppeteer").Page, log_message?: boolean): Promise<void>;
|
|
14
13
|
urlContains(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
15
14
|
pressEnter(page?: import("puppeteer").Page): Promise<void>;
|
|
@@ -18,6 +17,7 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
18
17
|
clickAndWaitForPageToBeCreated(selector: string, page: import("puppeteer").Page | undefined, newPage: boolean): Promise<void>;
|
|
19
18
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
20
19
|
microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer").Page, newPage?: boolean): Promise<void>;
|
|
20
|
+
private getEscapedText;
|
|
21
21
|
}
|
|
22
22
|
declare const _default: FunctionHelper;
|
|
23
23
|
export default _default;
|
|
@@ -56,15 +56,11 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
56
56
|
suggest(name) {
|
|
57
57
|
log_service_1.default.addSuggestion(name);
|
|
58
58
|
}
|
|
59
|
-
getEscapedText(text) {
|
|
60
|
-
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
61
|
-
return `concat('${splitedQuotes}', '')`;
|
|
62
|
-
}
|
|
63
59
|
clickByText(selector, text, dotOrText = '.', options = {}, page = puppeteer_1.default.defaultPage, time = this.defaultTimeout, log_message = true) {
|
|
64
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
65
61
|
const message = `I clicked on the '${text}' '${selector}'`;
|
|
66
62
|
try {
|
|
67
|
-
const [linkHandlers] = yield page
|
|
63
|
+
const [linkHandlers] = yield page.$$(`xpath/.//${selector}[contains(${dotOrText},"${text}")]`);
|
|
68
64
|
if (linkHandlers) {
|
|
69
65
|
yield linkHandlers.click(options);
|
|
70
66
|
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
@@ -85,7 +81,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
85
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
82
|
const message = `I click on the '${text}' '${selector}'`;
|
|
87
83
|
try {
|
|
88
|
-
const [linkHandlers] = yield page
|
|
84
|
+
const [linkHandlers] = yield page.$$(`xpath/.//${class_selector}[contains(@class,${this.getEscapedText(class_name)})]//${selector}[contains(${dotOrText},"${text}")]`);
|
|
89
85
|
if (linkHandlers) {
|
|
90
86
|
yield linkHandlers.click();
|
|
91
87
|
log_service_1.default.push('Then', message, status_of_step_1.StatusOfStep.PASSED);
|
|
@@ -105,7 +101,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
105
101
|
yield page.waitForSelector(selector, {
|
|
106
102
|
timeout: this.defaultTimeout
|
|
107
103
|
});
|
|
108
|
-
const linkHandlers = yield page
|
|
104
|
+
const linkHandlers = yield page.$$(`xpath/.//${selector}[contains(${dotOrText},"${text}")]`);
|
|
109
105
|
if (linkHandlers.length > 0) {
|
|
110
106
|
log_service_1.default.push('And', message, status_of_step_1.StatusOfStep.PASSED);
|
|
111
107
|
return true;
|
|
@@ -117,7 +113,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
117
113
|
throw new Error(message);
|
|
118
114
|
});
|
|
119
115
|
}
|
|
120
|
-
timeout(timeout = this.defaultTimeout
|
|
116
|
+
timeout(timeout = this.defaultTimeout) {
|
|
121
117
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
118
|
yield new Promise(r => setTimeout(r, timeout));
|
|
123
119
|
});
|
|
@@ -204,7 +200,8 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
204
200
|
try {
|
|
205
201
|
yield loginPage.waitForSelector(next_button, { visible: true, timeout: 60000 });
|
|
206
202
|
}
|
|
207
|
-
catch (e) {
|
|
203
|
+
catch (e) {
|
|
204
|
+
}
|
|
208
205
|
this.log('Then', `I checked for the '${next_button}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
209
206
|
yield loginPage.type(email_input, email, { delay: 0 });
|
|
210
207
|
yield loginPage.keyboard.press('Enter');
|
|
@@ -221,12 +218,14 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
221
218
|
try {
|
|
222
219
|
yield loginPage.waitForSelector(sign_in_button, { visible: true, timeout: 60000 });
|
|
223
220
|
}
|
|
224
|
-
catch (e) {
|
|
221
|
+
catch (e) {
|
|
222
|
+
}
|
|
225
223
|
this.log('Then', `I checked for the '${sign_in_button}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
226
224
|
try {
|
|
227
225
|
yield loginPage.waitForSelector(password_input, { visible: true, timeout: 60000 });
|
|
228
226
|
}
|
|
229
|
-
catch (e) {
|
|
227
|
+
catch (e) {
|
|
228
|
+
}
|
|
230
229
|
this.log('Then', `I checked for the '${password_input}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
231
230
|
try {
|
|
232
231
|
(_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
|
|
@@ -241,11 +240,16 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
241
240
|
try {
|
|
242
241
|
yield loginPage.waitForSelector(no_button, { visible: true, timeout: 60000 });
|
|
243
242
|
}
|
|
244
|
-
catch (e) {
|
|
243
|
+
catch (e) {
|
|
244
|
+
}
|
|
245
245
|
this.log('Then', `I checked for the '${no_button}' element to be visible`, AuxTA_1.StepStatus.PASSED);
|
|
246
246
|
yield loginPage.keyboard.press('Enter');
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
+
getEscapedText(text) {
|
|
250
|
+
const splitedQuotes = text.replace(/'/g, `', "'", '`);
|
|
251
|
+
return `concat('${splitedQuotes}', '')`;
|
|
252
|
+
}
|
|
249
253
|
}
|
|
250
254
|
exports.FunctionHelper = FunctionHelper;
|
|
251
255
|
exports.default = new FunctionHelper();
|
|
@@ -14,16 +14,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EmailHelper = void 0;
|
|
16
16
|
const log_service_1 = __importDefault(require("../../auxta/services/log.service"));
|
|
17
|
-
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
18
17
|
const AuxTA_1 = require("../../AuxTA");
|
|
19
18
|
const report_service_1 = require("../../auxta/services/report.service");
|
|
20
19
|
class EmailHelper {
|
|
21
20
|
verifyEmail(from_name, from_email, subject, body, link = false) {
|
|
22
21
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
22
|
try {
|
|
24
|
-
log_service_1.default.push('Then', `
|
|
25
|
-
yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
|
|
26
|
-
log_service_1.default.push('Then', `Done logging in and waiting 35 seconds`, AuxTA_1.StepStatus.PASSED);
|
|
23
|
+
log_service_1.default.push('Then', `waiting 35 seconds`, AuxTA_1.StepStatus.PASSED);
|
|
27
24
|
yield new Promise(r => setTimeout(r, 35000));
|
|
28
25
|
let timeoutCount = 12000;
|
|
29
26
|
while (timeoutCount <= 60000) {
|
|
@@ -39,7 +36,8 @@ class EmailHelper {
|
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
38
|
}
|
|
42
|
-
catch (e) {
|
|
39
|
+
catch (e) {
|
|
40
|
+
}
|
|
43
41
|
log_service_1.default.push('Then', `Failed two get the email with the given criteria and waiting 12 seconds`, AuxTA_1.StepStatus.PASSED);
|
|
44
42
|
yield new Promise(r => setTimeout(r, timeoutCount));
|
|
45
43
|
timeoutCount += 12000;
|
|
@@ -3,6 +3,7 @@ import puppeteer = require("puppeteer");
|
|
|
3
3
|
export declare class Puppeteer {
|
|
4
4
|
defaultPage: puppeteer.Page;
|
|
5
5
|
private browser;
|
|
6
|
+
private static setupHeader;
|
|
6
7
|
startBrowser(): Promise<void>;
|
|
7
8
|
close(): Promise<void>;
|
|
8
9
|
run(event: any, callback: any, featureName?: string, scenarioName?: string, uploadModel?: UploadModel): Promise<{
|
|
@@ -19,7 +20,6 @@ export declare class Puppeteer {
|
|
|
19
20
|
statusCode: number;
|
|
20
21
|
} | undefined>;
|
|
21
22
|
runRPA(event: any, callback: any, uploadModel?: UploadModel, close?: boolean): Promise<any>;
|
|
22
|
-
private static setupHeader;
|
|
23
23
|
}
|
|
24
24
|
declare const _default: Puppeteer;
|
|
25
25
|
export default _default;
|
|
@@ -23,17 +23,34 @@ const start_suite_helper_1 = require("../auxta/utilities/start-suite.helper");
|
|
|
23
23
|
const report_service_1 = require("../auxta/services/report.service");
|
|
24
24
|
const puppeteer = require("puppeteer");
|
|
25
25
|
class Puppeteer {
|
|
26
|
+
static setupHeader(event, uploadModel) {
|
|
27
|
+
let close = true;
|
|
28
|
+
if (process.env.ENVIRONMENT !== 'LOCAL' && event) {
|
|
29
|
+
uploadModel.reportId = event.reportId;
|
|
30
|
+
uploadModel.nextSuites = event.nextSuites;
|
|
31
|
+
uploadModel.currentSuite = event.currentSuite;
|
|
32
|
+
uploadModel.retries = Number(event.retries);
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
if (event.close) {
|
|
36
|
+
close = event.close === "true";
|
|
37
|
+
}
|
|
38
|
+
return close;
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
26
44
|
startBrowser() {
|
|
27
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
46
|
let args = [];
|
|
29
|
-
let env = {};
|
|
30
47
|
if (process.env.ENVIRONMENT === 'LOCAL') {
|
|
31
48
|
args.push('--start-maximized');
|
|
32
49
|
}
|
|
33
|
-
args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth :
|
|
50
|
+
args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth : 1920},${config_1.config.screenHeight ? config_1.config.screenHeight : 1080}`);
|
|
34
51
|
args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
|
|
35
52
|
args.push('--enable-automation=false');
|
|
36
|
-
env = {
|
|
53
|
+
let env = {
|
|
37
54
|
DISPLAY: ":10.0"
|
|
38
55
|
};
|
|
39
56
|
this.browser = yield puppeteer.default.launch({
|
|
@@ -46,7 +63,7 @@ class Puppeteer {
|
|
|
46
63
|
width: config_1.config.screenWidth,
|
|
47
64
|
height: config_1.config.screenHeight
|
|
48
65
|
},
|
|
49
|
-
headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true'
|
|
66
|
+
headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true') : true
|
|
50
67
|
});
|
|
51
68
|
this.defaultPage = (yield this.browser.pages())[0];
|
|
52
69
|
yield AuxTA_1.default.extend_page_functions(this.defaultPage);
|
|
@@ -187,24 +204,6 @@ class Puppeteer {
|
|
|
187
204
|
return { statusCode: 200 };
|
|
188
205
|
});
|
|
189
206
|
}
|
|
190
|
-
static setupHeader(event, uploadModel) {
|
|
191
|
-
let close = true;
|
|
192
|
-
if (process.env.ENVIRONMENT !== 'LOCAL' && event) {
|
|
193
|
-
uploadModel.reportId = event.reportId;
|
|
194
|
-
uploadModel.nextSuites = event.nextSuites;
|
|
195
|
-
uploadModel.currentSuite = event.currentSuite;
|
|
196
|
-
uploadModel.retries = Number(event.retries);
|
|
197
|
-
}
|
|
198
|
-
try {
|
|
199
|
-
if (event.close) {
|
|
200
|
-
close = event.close === "true";
|
|
201
|
-
}
|
|
202
|
-
return close;
|
|
203
|
-
}
|
|
204
|
-
catch (e) {
|
|
205
|
-
return true;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
207
|
}
|
|
209
208
|
exports.Puppeteer = Puppeteer;
|
|
210
209
|
exports.default = new Puppeteer();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auxcode/auxta",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.82",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/AuxTA.js",
|
|
6
6
|
"types": "./build/AuxTA.d.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@types/node": "^17.0.9",
|
|
19
|
-
"axios": "
|
|
19
|
+
"axios": "1.6.5",
|
|
20
20
|
"dotenv": "^10.0.0",
|
|
21
21
|
"dotenv-extended": "^2.9.0",
|
|
22
22
|
"fs": "^0.0.1-security",
|
|
@@ -24,11 +24,9 @@
|
|
|
24
24
|
"js-base64": "^3.7.5",
|
|
25
25
|
"node-2fa": "^2.0.3",
|
|
26
26
|
"nodemailer": "^6.9.2",
|
|
27
|
-
"puppeteer": "^
|
|
27
|
+
"puppeteer": "^22.0.0",
|
|
28
28
|
"readline": "^1.3.0",
|
|
29
|
-
"typescript": "^5.2.2"
|
|
30
|
-
"puppeteer-extra": "^3.3.6",
|
|
31
|
-
"puppeteer-extra-plugin-stealth": "^2.11.2"
|
|
29
|
+
"typescript": "^5.2.2"
|
|
32
30
|
},
|
|
33
31
|
"devDependencies": {
|
|
34
32
|
"@babel/preset-typescript": "^7.16.0"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import googleType = require("googleapis");
|
|
2
|
-
export declare class AuxGoogleAuth {
|
|
3
|
-
private static _oAuth2Client;
|
|
4
|
-
private static credentialsJson;
|
|
5
|
-
static get oAuth2Client(): googleType.Auth.OAuth2Client;
|
|
6
|
-
static get googleClient(): googleType.GoogleApis;
|
|
7
|
-
static get gmailClient(): googleType.gmail_v1.Gmail;
|
|
8
|
-
static setupBrowser(): Promise<void>;
|
|
9
|
-
static setEmailPassword(email: string, password: string): Promise<void>;
|
|
10
|
-
static setupHeadless(): Promise<void>;
|
|
11
|
-
private static authorize;
|
|
12
|
-
private static authorizeHeadless;
|
|
13
|
-
private static getNewToken;
|
|
14
|
-
private static getNewTokenHeadless;
|
|
15
|
-
}
|
|
16
|
-
declare const _default: AuxGoogleAuth;
|
|
17
|
-
export default _default;
|
|
18
|
-
export interface currentUser {
|
|
19
|
-
name: string;
|
|
20
|
-
email: string;
|
|
21
|
-
}
|
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.AuxGoogleAuth = void 0;
|
|
39
|
-
const code_helper_1 = __importDefault(require("../helpers/code.helper"));
|
|
40
|
-
const status_of_step_1 = __importDefault(require("../../auxta/enums/status-of.step"));
|
|
41
|
-
const fs = require('fs');
|
|
42
|
-
const readline = require('readline');
|
|
43
|
-
const process = __importStar(require("process"));
|
|
44
|
-
const { google } = require("googleapis");
|
|
45
|
-
const SCOPES = [
|
|
46
|
-
'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
|
|
47
|
-
'https://www.googleapis.com/auth/gmail.addons.current.message.action',
|
|
48
|
-
'https://www.googleapis.com/auth/gmail.labels',
|
|
49
|
-
'https://www.googleapis.com/auth/gmail.addons.current.message.metadata',
|
|
50
|
-
'https://www.googleapis.com/auth/gmail.addons.current.message.readonly',
|
|
51
|
-
'https://www.googleapis.com/auth/gmail.send',
|
|
52
|
-
'https://mail.google.com/',
|
|
53
|
-
'https://www.googleapis.com/auth/gmail.modify',
|
|
54
|
-
'https://www.googleapis.com/auth/gmail.compose',
|
|
55
|
-
'https://www.googleapis.com/auth/gmail.readonly',
|
|
56
|
-
'https://www.googleapis.com/auth/gmail.insert',
|
|
57
|
-
];
|
|
58
|
-
const TOKEN_PATH = 'token.json';
|
|
59
|
-
let TOKEN;
|
|
60
|
-
let TOKENS = [
|
|
61
|
-
{ "access_token": "ya29.a0AfB_byBxWTRPqnu3nL6bUzCCGdJl9skLupcJH8q0GSEAkimkkvQaKSkXimshAzJWQz4nmyYQ_cW7p9iYNDnT2zlJYk4j1eeVDI7YT80uhxPmLOw3Dcn7IY9cbhZK0_lgRBm8CCrBVVRPzkfVSnAF3D3wuW3-sLr22qt4aCgYKAcYSARASFQHGX2Mi1lEgWolMYxlejnZD-kjcDQ0171", "refresh_token": "1//09YdEzFTKqqYxCgYIARAAGAkSNwF-L9IrL8CtoJKFamnKWiHs-kTBaZXfSWY15jTLMeLSJzT-St1OVpHfCCumEkJorO8hg29wGXI", "scope": "https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.insert https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.labels https://mail.google.com/ https://www.googleapis.com/auth/gmail.addons.current.message.readonly https://www.googleapis.com/auth/gmail.readonly", "token_type": "Bearer", "expiry_date": 1702994988534 },
|
|
62
|
-
{ "access_token": "ya29.a0AfB_byB-QxjIsHwSU7lbD2FpCMz2rK7p1Tzohl9BjeQUK_nFsEzqww4uQK086INqwTLENLXYVVq09hW7nRuhEg15MYtWo9xbU-nRtAMvzG5aLGPKOXl9mkWBR1cCsgtBPoxl7Klc_jnvH0PnC0TYwISoUqm9W-5c6fFraCgYKAQgSARASFQHGX2Minj2IKMCYkue3rCSMmM_h8g0171", "refresh_token": "1//09YMAAKDjzZ3VCgYIARAAGAkSNwF-L9Ir62E-caPL0S0qKj1phMtHSk3nQWFBW7YAyl7Nh8oSJ6WSXd2NvzHt0Hwf-i85GLF6grE", "scope": "https://mail.google.com/ https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.insert https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.addons.current.message.readonly https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.labels", "token_type": "Bearer", "expiry_date": 1702995163803 },
|
|
63
|
-
{ "access_token": "ya29.a0AfB_byDVVHpB9LKHhdmD5nInQJHTGU8Ky0JHf2wRNtZB1HJHqod7Pme_0CHSy6vO5pNNaVPpyO8H3vNQ9jA6AGJLc82AKI3mGTsGmaIQFRQr02nhPTFuTY7Gl-_iR5lgZM6BmB5koWccOT6Xe9pl5ND5T8FVlRSRLvitaCgYKAdUSARASFQHGX2Mi2iH-ZeiaxFELglikw-okOw0171", "refresh_token": "1//09YD8dwZN5F1RCgYIARAAGAkSNwF-L9Irfie38zhzgw1ue4oEgR5Xc89BgiZHs1vcm8Tf6ROJfuCrnhsWLhr4oFkNlQ6UbJgU7GA", "scope": "https://www.googleapis.com/auth/gmail.insert https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.labels https://mail.google.com/ https://www.googleapis.com/auth/gmail.addons.current.message.readonly", "token_type": "Bearer", "expiry_date": 1702995310295 },
|
|
64
|
-
{ "access_token": "ya29.a0AfB_byBKWIknMT7E8yzyFjfNIzl_y_I73sP71YadO-yoKjphk6mvdSwOaYooLYYuZrHit8bYt0ERrX8mhkE1WGdiNcWGpBliS0s1Ved2DWJqkMlYsgnzz-4uAByodSHaxoqbnI0L1vCsqkJvvO4AJYUAIcSjf4z162gRaCgYKAT8SARASFQHGX2Mib4ndKaU92xuMBjUVD990GQ0171", "refresh_token": "1//09BZILsMOzERdCgYIARAAGAkSNwF-L9IryuSQRewZs9LSuCSdXdmfimL18Edof34Mo5UrC-FGuGHED7519THwrYLFoOFJe18TgRk", "scope": "https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.addons.current.message.readonly https://mail.google.com/ https://www.googleapis.com/auth/gmail.labels https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://www.googleapis.com/auth/gmail.insert https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.send", "token_type": "Bearer", "expiry_date": 1702995376462 },
|
|
65
|
-
{ "access_token": "ya29.a0AfB_byABK1ECnRhzxM2_5FzN4XdwBG2q-qWDZlCJ2oZ2g7-k_QFgdyyICP99rQJuOyIU5t6NU9wSRsxL-hrk6kf2BmC2rW7ltdRw14h_n-nFPSk9Gg8979iuqvvfEokd9dIkY_MwhOYGiz7rP6aUwqjEAXDjg6FAieL1aCgYKAdsSARASFQHGX2Mim1Y5ousgcVP835Epj10Xww0171", "refresh_token": "1//09yqHMectr6qjCgYIARAAGAkSNwF-L9IrITv60RhPCDiL8POjD0Uy8CvxPDc7hmWrvL7zLCOcxNACUWDpTnQyqkOYRGWyF3pyNaI", "scope": "https://www.googleapis.com/auth/gmail.addons.current.message.action https://www.googleapis.com/auth/gmail.send https://www.googleapis.com/auth/gmail.addons.current.action.compose https://www.googleapis.com/auth/gmail.compose https://www.googleapis.com/auth/gmail.insert https://www.googleapis.com/auth/gmail.addons.current.message.metadata https://mail.google.com/ https://www.googleapis.com/auth/gmail.labels https://www.googleapis.com/auth/gmail.addons.current.message.readonly https://www.googleapis.com/auth/gmail.modify https://www.googleapis.com/auth/gmail.readonly", "token_type": "Bearer", "expiry_date": 1702995426413 }
|
|
66
|
-
];
|
|
67
|
-
let EMAIL;
|
|
68
|
-
let PASSWORD;
|
|
69
|
-
class AuxGoogleAuth {
|
|
70
|
-
static get oAuth2Client() {
|
|
71
|
-
return this._oAuth2Client;
|
|
72
|
-
}
|
|
73
|
-
static get googleClient() {
|
|
74
|
-
return google;
|
|
75
|
-
}
|
|
76
|
-
static get gmailClient() {
|
|
77
|
-
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
78
|
-
}
|
|
79
|
-
static setupBrowser() {
|
|
80
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
-
yield this.authorize(this.credentialsJson);
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
static setEmailPassword(email, password) {
|
|
85
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
EMAIL = email;
|
|
87
|
-
PASSWORD = password;
|
|
88
|
-
console.log(EMAIL, PASSWORD);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
static setupHeadless() {
|
|
92
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
-
yield this.authorizeHeadless(this.credentialsJson);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
static authorize(credentials) {
|
|
97
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
-
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
99
|
-
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
100
|
-
try {
|
|
101
|
-
let token = fs.readFileSync(TOKEN_PATH);
|
|
102
|
-
if (token.length > 0 && token !== undefined) {
|
|
103
|
-
oAuth2Client.setCredentials(JSON.parse(token));
|
|
104
|
-
this._oAuth2Client = oAuth2Client;
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
yield this.getNewToken(oAuth2Client);
|
|
108
|
-
}
|
|
109
|
-
catch (e) {
|
|
110
|
-
yield this.getNewToken(oAuth2Client);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
static authorizeHeadless(credentials) {
|
|
115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
-
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
117
|
-
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
118
|
-
try {
|
|
119
|
-
if (TOKEN) {
|
|
120
|
-
oAuth2Client.setCredentials(TOKEN);
|
|
121
|
-
this._oAuth2Client = oAuth2Client;
|
|
122
|
-
code_helper_1.default.log('Then', 'Getting the existing token', status_of_step_1.default.PASSED);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
yield this.getNewTokenHeadless(oAuth2Client);
|
|
126
|
-
}
|
|
127
|
-
catch (e) {
|
|
128
|
-
code_helper_1.default.log('Then', 'Getting the existing token', status_of_step_1.default.FAILED);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
static getNewToken(oAuth2Client) {
|
|
133
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
-
const authUrl = oAuth2Client.generateAuthUrl({
|
|
135
|
-
access_type: 'offline',
|
|
136
|
-
prompt: 'consent',
|
|
137
|
-
scope: SCOPES,
|
|
138
|
-
});
|
|
139
|
-
console.log('Authorize this app by visiting this url:', authUrl);
|
|
140
|
-
const rl = readline.createInterface({
|
|
141
|
-
input: process.stdin,
|
|
142
|
-
output: process.stdout,
|
|
143
|
-
});
|
|
144
|
-
rl.question('Enter the code from that page here: ', (code) => {
|
|
145
|
-
rl.close();
|
|
146
|
-
oAuth2Client.getToken(code, (err, token) => {
|
|
147
|
-
if (err)
|
|
148
|
-
return console.error('Error retrieving access token', err);
|
|
149
|
-
oAuth2Client.setCredentials(token);
|
|
150
|
-
fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
|
|
151
|
-
if (err)
|
|
152
|
-
return console.error(err);
|
|
153
|
-
console.log('Token stored to', TOKEN_PATH);
|
|
154
|
-
});
|
|
155
|
-
this._oAuth2Client = oAuth2Client;
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
static getNewTokenHeadless(oAuth2Client) {
|
|
161
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
-
const position = Math.floor(Math.random() * 6);
|
|
163
|
-
const token = TOKENS[position];
|
|
164
|
-
oAuth2Client.setCredentials(token);
|
|
165
|
-
this._oAuth2Client = oAuth2Client;
|
|
166
|
-
code_helper_1.default.log('Then', 'I login with the google account', status_of_step_1.default.PASSED);
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
exports.AuxGoogleAuth = AuxGoogleAuth;
|
|
171
|
-
AuxGoogleAuth.credentialsJson = {
|
|
172
|
-
"installed": {
|
|
173
|
-
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
174
|
-
"project_id": "auxta-library",
|
|
175
|
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
176
|
-
"token_uri": "https://oauth2.googleapis.com/token",
|
|
177
|
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
178
|
-
"client_secret": "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",
|
|
179
|
-
"redirect_uris": ["https://auxcode.com"]
|
|
180
|
-
}
|
|
181
|
-
};
|
|
182
|
-
exports.default = new AuxGoogleAuth();
|
|
@@ -1,63 +0,0 @@
|
|
|
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
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.PuppeteerExtra = void 0;
|
|
16
|
-
const AuxTA_1 = __importDefault(require("../AuxTA"));
|
|
17
|
-
const config_1 = require("../auxta/configs/config");
|
|
18
|
-
const puppeteer_extra = require("puppeteer-extra");
|
|
19
|
-
class PuppeteerExtra {
|
|
20
|
-
startBrowser() {
|
|
21
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
22
|
-
let args = [];
|
|
23
|
-
let env = {};
|
|
24
|
-
if (process.env.ENVIRONMENT === 'LOCAL') {
|
|
25
|
-
args.push('--start-maximized');
|
|
26
|
-
}
|
|
27
|
-
if (process.env.ENVIRONMENT != 'LOCAL') {
|
|
28
|
-
args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth : 1920},${config_1.config.screenHeight ? config_1.config.screenHeight : 1080}`);
|
|
29
|
-
args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
|
|
30
|
-
env = {
|
|
31
|
-
DISPLAY: ":10.0"
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
|
|
35
|
-
puppeteer_extra.default.use(StealthPlugin());
|
|
36
|
-
this.browser = yield puppeteer_extra.default.launch({
|
|
37
|
-
slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
|
|
38
|
-
executablePath: puppeteer_extra.default.executablePath(),
|
|
39
|
-
args,
|
|
40
|
-
env,
|
|
41
|
-
ignoreDefaultArgs: ["--enable-automation"],
|
|
42
|
-
defaultViewport: process.env.ENVIRONMENT === 'LOCAL' ? null : {
|
|
43
|
-
width: config_1.config.screenWidth,
|
|
44
|
-
height: config_1.config.screenHeight
|
|
45
|
-
},
|
|
46
|
-
headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true' ? 'new' : false) : 'new'
|
|
47
|
-
});
|
|
48
|
-
this.defaultPage = (yield this.browser.pages())[0];
|
|
49
|
-
yield AuxTA_1.default.extend_page_functions(this.defaultPage);
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
close() {
|
|
53
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
if (this.browser) {
|
|
55
|
-
let pages = yield this.browser.pages();
|
|
56
|
-
yield Promise.all(pages.map((page) => page.close()));
|
|
57
|
-
yield this.browser.close();
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
exports.PuppeteerExtra = PuppeteerExtra;
|
|
63
|
-
exports.default = new PuppeteerExtra();
|