@auxcode/auxta 1.3.19-beta.8 → 1.3.19
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 +23 -3
- package/build/cjs/AuxTA.d.ts +3 -1
- package/build/cjs/AuxTA.js +2 -2
- package/build/cjs/auxta/configs/config.d.ts +3 -0
- package/build/cjs/auxta/configs/config.js +2 -0
- package/build/cjs/macros/helpers/AuxGoogleAuth.d.ts +13 -0
- package/build/cjs/macros/helpers/{GoogleAuthHelper.js → AuxGoogleAuth.js} +21 -24
- package/build/cjs/macros/helpers/code.helper.d.ts +2 -0
- package/build/cjs/macros/helpers/code.helper.js +44 -0
- package/build/esm/AuxTA.d.ts +3 -1
- package/build/esm/AuxTA.js +2 -2
- package/build/esm/auxta/configs/config.d.ts +3 -0
- package/build/esm/auxta/configs/config.js +2 -0
- package/build/esm/macros/helpers/AuxGoogleAuth.d.ts +13 -0
- package/build/esm/macros/helpers/{GoogleAuthHelper.js → AuxGoogleAuth.js} +19 -22
- package/build/esm/macros/helpers/code.helper.d.ts +2 -0
- package/build/esm/macros/helpers/code.helper.js +44 -0
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/build/cjs/macros/helpers/GoogleAuthHelper.d.ts +0 -13
- package/build/esm/macros/helpers/GoogleAuthHelper.d.ts +0 -13
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AuxTA
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Implementing
|
|
4
4
|
|
|
5
5
|
The main thing is a `scenario`.
|
|
6
6
|
|
|
@@ -10,7 +10,7 @@ The main thing is a `scenario`.
|
|
|
10
10
|
|
|
11
11
|
All clicks wait for the selector by default and timeout w/ the standard timeout unless different is specified.
|
|
12
12
|
|
|
13
|
-
`timeout` It is recommended to have a standard timeout for the whole scenario and not to define spefici. `TODO`
|
|
13
|
+
`timeout` It is recommended to have a standard timeout for the whole scenario and not to define spefici. `TODO`
|
|
14
14
|
|
|
15
15
|
auxta.clickByText `TO BE FIXED BY GEORGE TO ADD THE WAIT FOR SELECTOR WHICH IS MISSING`
|
|
16
16
|
|
|
@@ -20,7 +20,27 @@ auxta.clickByClass
|
|
|
20
20
|
|
|
21
21
|
auxta.click() `THINK TO MAKE` `TODO`
|
|
22
22
|
|
|
23
|
-
waitforseelctorbytext `depreciated`
|
|
23
|
+
waitforseelctorbytext `depreciated`
|
|
24
|
+
|
|
25
|
+
### Complex Workflows
|
|
26
|
+
|
|
27
|
+
#### Email
|
|
28
|
+
|
|
29
|
+
* (AuxTA) We do some action on the website.
|
|
30
|
+
* (Website) Sends an email to the email address of the user who did the action.
|
|
31
|
+
* (AuxTA) Should check that that the email was correctly sent. So we check:
|
|
32
|
+
* `auxta.checkMail(_from_name_, _from_email_, _subject_, _body_text_)`
|
|
33
|
+
* The email login is in the main config of the test suite.
|
|
34
|
+
* email
|
|
35
|
+
* API TOKEN
|
|
36
|
+
* For the moment we do it synchroneous (AuxTA waits for the email).
|
|
37
|
+
* The email must be newser than the time of the action on the Website.
|
|
38
|
+
* Must be _from_name_ (substring)
|
|
39
|
+
* Must be _from_email_ (substring)
|
|
40
|
+
* Must have _subject_ (substring)
|
|
41
|
+
* Must cotnain _body_text_ (substring)
|
|
42
|
+
* Quality of Service, if the email does not arrive w/in eg. 5 minutes we return an error w/ timeout.
|
|
43
|
+
* * `auxta.clickInMail(_from_name_, _from_email_, _subject_, _click_on_)`
|
|
24
44
|
|
|
25
45
|
## Running
|
|
26
46
|
|
package/build/cjs/AuxTA.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ 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";
|
|
5
6
|
declare class AuxTA extends FunctionHelper {
|
|
6
7
|
puppeteer: Puppeteer;
|
|
7
8
|
aux2fa: import("./macros/helpers/Aux2faAuth").Aux2faAuth;
|
|
8
|
-
|
|
9
|
+
google: typeof AuxGoogleAuth;
|
|
9
10
|
config: {
|
|
10
11
|
auxtaURL: string;
|
|
11
12
|
baseURL: string;
|
|
@@ -18,6 +19,7 @@ declare class AuxTA extends FunctionHelper {
|
|
|
18
19
|
screenHeight: number;
|
|
19
20
|
timeout: number;
|
|
20
21
|
suitesList: never[];
|
|
22
|
+
googleEmail: string;
|
|
21
23
|
auxtaCredentials: {
|
|
22
24
|
email: string;
|
|
23
25
|
password: string;
|
package/build/cjs/AuxTA.js
CHANGED
|
@@ -47,14 +47,14 @@ 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
|
|
50
|
+
const AuxGoogleAuth_1 = require("./macros/helpers/AuxGoogleAuth");
|
|
51
51
|
dotenv.config();
|
|
52
52
|
class AuxTA extends code_helper_1.FunctionHelper {
|
|
53
53
|
constructor() {
|
|
54
54
|
super();
|
|
55
55
|
this.puppeteer = puppeteer_1.default;
|
|
56
56
|
this.aux2fa = Aux2faAuth_1.default;
|
|
57
|
-
this.
|
|
57
|
+
this.google = AuxGoogleAuth_1.AuxGoogleAuth;
|
|
58
58
|
this.config = config_1.config;
|
|
59
59
|
let file;
|
|
60
60
|
if (!process.env.RPA) {
|
|
@@ -10,6 +10,7 @@ export declare function setupConfig(jsonConfig: any): {
|
|
|
10
10
|
screenHeight: number;
|
|
11
11
|
timeout: number;
|
|
12
12
|
suitesList: never[];
|
|
13
|
+
googleEmail: string;
|
|
13
14
|
auxtaCredentials: {
|
|
14
15
|
email: string;
|
|
15
16
|
password: string;
|
|
@@ -27,6 +28,7 @@ export declare function setupOverrideConfig(overrideConfig: any): {
|
|
|
27
28
|
screenHeight: number;
|
|
28
29
|
timeout: number;
|
|
29
30
|
suitesList: never[];
|
|
31
|
+
googleEmail: string;
|
|
30
32
|
auxtaCredentials: {
|
|
31
33
|
email: string;
|
|
32
34
|
password: string;
|
|
@@ -44,6 +46,7 @@ export declare let config: {
|
|
|
44
46
|
screenHeight: number;
|
|
45
47
|
timeout: number;
|
|
46
48
|
suitesList: never[];
|
|
49
|
+
googleEmail: string;
|
|
47
50
|
auxtaCredentials: {
|
|
48
51
|
email: string;
|
|
49
52
|
password: string;
|
|
@@ -23,6 +23,7 @@ function setupConfig(jsonConfig) {
|
|
|
23
23
|
if (!jsonConfig.suitesList)
|
|
24
24
|
throw new Error("suitesList");
|
|
25
25
|
exports.config.suitesList = jsonConfig.suitesList;
|
|
26
|
+
exports.config.googleEmail = jsonConfig.googleEmail;
|
|
26
27
|
if (jsonConfig.timeout)
|
|
27
28
|
exports.config.timeout = jsonConfig.timeout;
|
|
28
29
|
if (jsonConfig.screenWidth)
|
|
@@ -56,6 +57,7 @@ exports.config = {
|
|
|
56
57
|
screenHeight: 1080,
|
|
57
58
|
timeout: 60000,
|
|
58
59
|
suitesList: [],
|
|
60
|
+
googleEmail: "",
|
|
59
61
|
auxtaCredentials: {
|
|
60
62
|
email: "",
|
|
61
63
|
password: "",
|
|
@@ -0,0 +1,13 @@
|
|
|
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 setup(): Promise<void>;
|
|
9
|
+
private static authorize;
|
|
10
|
+
private static getNewToken;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: AuxGoogleAuth;
|
|
13
|
+
export default _default;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.AuxGoogleAuth = void 0;
|
|
13
13
|
const fs = require('fs');
|
|
14
14
|
const readline = require('readline');
|
|
15
15
|
const { google } = require("googleapis");
|
|
@@ -24,39 +24,25 @@ const SCOPES = [
|
|
|
24
24
|
'https://www.googleapis.com/auth/gmail.modify',
|
|
25
25
|
'https://www.googleapis.com/auth/gmail.compose',
|
|
26
26
|
'https://www.googleapis.com/auth/gmail.readonly',
|
|
27
|
-
'https://www.googleapis.com/auth/gmail.metadata',
|
|
28
27
|
'https://www.googleapis.com/auth/gmail.insert',
|
|
29
28
|
];
|
|
30
29
|
const TOKEN_PATH = 'token.json';
|
|
31
|
-
class
|
|
32
|
-
|
|
33
|
-
this.credentialsJson = {
|
|
34
|
-
"installed": {
|
|
35
|
-
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
36
|
-
"project_id": "auxta-library",
|
|
37
|
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
38
|
-
"token_uri": "https://oauth2.googleapis.com/token",
|
|
39
|
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
40
|
-
"client_secret": "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",
|
|
41
|
-
"redirect_uris": ["https://auxcode.com"]
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
get oAuth2Client() {
|
|
30
|
+
class AuxGoogleAuth {
|
|
31
|
+
static get oAuth2Client() {
|
|
46
32
|
return this._oAuth2Client;
|
|
47
33
|
}
|
|
48
|
-
get googleClient() {
|
|
34
|
+
static get googleClient() {
|
|
49
35
|
return google;
|
|
50
36
|
}
|
|
51
|
-
get gmailClient() {
|
|
37
|
+
static get gmailClient() {
|
|
52
38
|
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
53
39
|
}
|
|
54
|
-
setup() {
|
|
40
|
+
static setup() {
|
|
55
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
42
|
yield this.authorize(this.credentialsJson);
|
|
57
43
|
});
|
|
58
44
|
}
|
|
59
|
-
authorize(credentials) {
|
|
45
|
+
static authorize(credentials) {
|
|
60
46
|
return __awaiter(this, void 0, void 0, function* () {
|
|
61
47
|
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
62
48
|
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
@@ -74,7 +60,7 @@ class GoogleAuthHelper {
|
|
|
74
60
|
}
|
|
75
61
|
});
|
|
76
62
|
}
|
|
77
|
-
getNewToken(oAuth2Client) {
|
|
63
|
+
static getNewToken(oAuth2Client) {
|
|
78
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
65
|
const authUrl = oAuth2Client.generateAuthUrl({
|
|
80
66
|
access_type: 'offline',
|
|
@@ -103,5 +89,16 @@ class GoogleAuthHelper {
|
|
|
103
89
|
});
|
|
104
90
|
}
|
|
105
91
|
}
|
|
106
|
-
exports.
|
|
107
|
-
|
|
92
|
+
exports.AuxGoogleAuth = AuxGoogleAuth;
|
|
93
|
+
AuxGoogleAuth.credentialsJson = {
|
|
94
|
+
"installed": {
|
|
95
|
+
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
96
|
+
"project_id": "auxta-library",
|
|
97
|
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
98
|
+
"token_uri": "https://oauth2.googleapis.com/token",
|
|
99
|
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
100
|
+
"client_secret": "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",
|
|
101
|
+
"redirect_uris": ["https://auxcode.com"]
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
exports.default = new AuxGoogleAuth();
|
|
@@ -16,6 +16,8 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
16
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
17
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
18
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
19
|
+
clickInMail(from_name: string, from_email: string, subject: string): Promise<boolean>;
|
|
20
|
+
private getHeader;
|
|
19
21
|
}
|
|
20
22
|
declare const _default: FunctionHelper;
|
|
21
23
|
export default _default;
|
|
@@ -19,6 +19,8 @@ const status_of_step_1 = require("../../auxta/enums/status-of.step");
|
|
|
19
19
|
const AuxTA_1 = require("../../AuxTA");
|
|
20
20
|
const extend_default_page_1 = require("./extend-default-page");
|
|
21
21
|
const puppeteer_2 = require("puppeteer");
|
|
22
|
+
const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
|
|
23
|
+
const config_1 = require("../../auxta/configs/config");
|
|
22
24
|
class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
23
25
|
log(keyword, name, status) {
|
|
24
26
|
log_service_1.default.push(keyword, name, status);
|
|
@@ -187,6 +189,48 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
187
189
|
yield loginPage.waitForNetworkIdle();
|
|
188
190
|
});
|
|
189
191
|
}
|
|
192
|
+
clickInMail(from_name, from_email, subject) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
195
|
+
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
196
|
+
userId: config_1.config.googleEmail,
|
|
197
|
+
maxResults: 3
|
|
198
|
+
});
|
|
199
|
+
const messagesIds = res.data.messages;
|
|
200
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
201
|
+
throw new Error('No messagesIds found.');
|
|
202
|
+
}
|
|
203
|
+
let timeoutCount = 12000;
|
|
204
|
+
yield this.timeout(12000);
|
|
205
|
+
while (timeoutCount <= 60000) {
|
|
206
|
+
for (const messageId of messagesIds) {
|
|
207
|
+
if (messageId.id) {
|
|
208
|
+
const message = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({ userId: config_1.config.googleEmail, id: messageId.id.toString(), format: 'FULL' });
|
|
209
|
+
if (message.data.payload) {
|
|
210
|
+
const message_sender = this.getHeader('from', message.data.payload.headers);
|
|
211
|
+
const message_subject = this.getHeader('subject', message.data.payload.headers);
|
|
212
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) && message_subject.includes(subject.toLocaleLowerCase())) {
|
|
213
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, AuxTA_1.StepStatus.PASSED);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
yield this.timeout(12000);
|
|
221
|
+
timeoutCount += 12000;
|
|
222
|
+
}
|
|
223
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, AuxTA_1.StepStatus.PASSED);
|
|
224
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} is found`);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
getHeader(value, headers) {
|
|
228
|
+
for (const header of headers) {
|
|
229
|
+
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
230
|
+
return header.value.toLocaleLowerCase();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
190
234
|
}
|
|
191
235
|
exports.FunctionHelper = FunctionHelper;
|
|
192
236
|
exports.default = new FunctionHelper();
|
package/build/esm/AuxTA.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ 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";
|
|
5
6
|
declare class AuxTA extends FunctionHelper {
|
|
6
7
|
puppeteer: Puppeteer;
|
|
7
8
|
aux2fa: import("./macros/helpers/Aux2faAuth").Aux2faAuth;
|
|
8
|
-
|
|
9
|
+
google: typeof AuxGoogleAuth;
|
|
9
10
|
config: {
|
|
10
11
|
auxtaURL: string;
|
|
11
12
|
baseURL: string;
|
|
@@ -18,6 +19,7 @@ declare class AuxTA extends FunctionHelper {
|
|
|
18
19
|
screenHeight: number;
|
|
19
20
|
timeout: number;
|
|
20
21
|
suitesList: never[];
|
|
22
|
+
googleEmail: string;
|
|
21
23
|
auxtaCredentials: {
|
|
22
24
|
email: string;
|
|
23
25
|
password: string;
|
package/build/esm/AuxTA.js
CHANGED
|
@@ -18,14 +18,14 @@ import { setupConfig, config as c, setupOverrideConfig } from "./auxta/configs/c
|
|
|
18
18
|
import { startSuite } from "./auxta/utilities/start-suite.helper";
|
|
19
19
|
import { createEmptyReport } from "./auxta/services/report.service";
|
|
20
20
|
import Aux2faAuth from "./macros/helpers/Aux2faAuth";
|
|
21
|
-
import
|
|
21
|
+
import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
|
|
22
22
|
dotenv.config();
|
|
23
23
|
class AuxTA extends FunctionHelper {
|
|
24
24
|
constructor() {
|
|
25
25
|
super();
|
|
26
26
|
this.puppeteer = puppeteer;
|
|
27
27
|
this.aux2fa = Aux2faAuth;
|
|
28
|
-
this.
|
|
28
|
+
this.google = AuxGoogleAuth;
|
|
29
29
|
this.config = c;
|
|
30
30
|
let file;
|
|
31
31
|
if (!process.env.RPA) {
|
|
@@ -10,6 +10,7 @@ export declare function setupConfig(jsonConfig: any): {
|
|
|
10
10
|
screenHeight: number;
|
|
11
11
|
timeout: number;
|
|
12
12
|
suitesList: never[];
|
|
13
|
+
googleEmail: string;
|
|
13
14
|
auxtaCredentials: {
|
|
14
15
|
email: string;
|
|
15
16
|
password: string;
|
|
@@ -27,6 +28,7 @@ export declare function setupOverrideConfig(overrideConfig: any): {
|
|
|
27
28
|
screenHeight: number;
|
|
28
29
|
timeout: number;
|
|
29
30
|
suitesList: never[];
|
|
31
|
+
googleEmail: string;
|
|
30
32
|
auxtaCredentials: {
|
|
31
33
|
email: string;
|
|
32
34
|
password: string;
|
|
@@ -44,6 +46,7 @@ export declare let config: {
|
|
|
44
46
|
screenHeight: number;
|
|
45
47
|
timeout: number;
|
|
46
48
|
suitesList: never[];
|
|
49
|
+
googleEmail: string;
|
|
47
50
|
auxtaCredentials: {
|
|
48
51
|
email: string;
|
|
49
52
|
password: string;
|
|
@@ -20,6 +20,7 @@ export function setupConfig(jsonConfig) {
|
|
|
20
20
|
if (!jsonConfig.suitesList)
|
|
21
21
|
throw new Error("suitesList");
|
|
22
22
|
config.suitesList = jsonConfig.suitesList;
|
|
23
|
+
config.googleEmail = jsonConfig.googleEmail;
|
|
23
24
|
if (jsonConfig.timeout)
|
|
24
25
|
config.timeout = jsonConfig.timeout;
|
|
25
26
|
if (jsonConfig.screenWidth)
|
|
@@ -51,6 +52,7 @@ export let config = {
|
|
|
51
52
|
screenHeight: 1080,
|
|
52
53
|
timeout: 60000,
|
|
53
54
|
suitesList: [],
|
|
55
|
+
googleEmail: "",
|
|
54
56
|
auxtaCredentials: {
|
|
55
57
|
email: "",
|
|
56
58
|
password: "",
|
|
@@ -0,0 +1,13 @@
|
|
|
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 setup(): Promise<void>;
|
|
9
|
+
private static authorize;
|
|
10
|
+
private static getNewToken;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: AuxGoogleAuth;
|
|
13
|
+
export default _default;
|
|
@@ -21,39 +21,25 @@ const SCOPES = [
|
|
|
21
21
|
'https://www.googleapis.com/auth/gmail.modify',
|
|
22
22
|
'https://www.googleapis.com/auth/gmail.compose',
|
|
23
23
|
'https://www.googleapis.com/auth/gmail.readonly',
|
|
24
|
-
'https://www.googleapis.com/auth/gmail.metadata',
|
|
25
24
|
'https://www.googleapis.com/auth/gmail.insert',
|
|
26
25
|
];
|
|
27
26
|
const TOKEN_PATH = 'token.json';
|
|
28
|
-
export class
|
|
29
|
-
|
|
30
|
-
this.credentialsJson = {
|
|
31
|
-
"installed": {
|
|
32
|
-
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
33
|
-
"project_id": "auxta-library",
|
|
34
|
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
35
|
-
"token_uri": "https://oauth2.googleapis.com/token",
|
|
36
|
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
37
|
-
"client_secret": "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",
|
|
38
|
-
"redirect_uris": ["https://auxcode.com"]
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
get oAuth2Client() {
|
|
27
|
+
export class AuxGoogleAuth {
|
|
28
|
+
static get oAuth2Client() {
|
|
43
29
|
return this._oAuth2Client;
|
|
44
30
|
}
|
|
45
|
-
get googleClient() {
|
|
31
|
+
static get googleClient() {
|
|
46
32
|
return google;
|
|
47
33
|
}
|
|
48
|
-
get gmailClient() {
|
|
34
|
+
static get gmailClient() {
|
|
49
35
|
return google.gmail({ version: 'v1', auth: this._oAuth2Client });
|
|
50
36
|
}
|
|
51
|
-
setup() {
|
|
37
|
+
static setup() {
|
|
52
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
53
39
|
yield this.authorize(this.credentialsJson);
|
|
54
40
|
});
|
|
55
41
|
}
|
|
56
|
-
authorize(credentials) {
|
|
42
|
+
static authorize(credentials) {
|
|
57
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
44
|
const { client_secret, client_id, redirect_uris } = credentials.installed;
|
|
59
45
|
const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
|
|
@@ -71,7 +57,7 @@ export class GoogleAuthHelper {
|
|
|
71
57
|
}
|
|
72
58
|
});
|
|
73
59
|
}
|
|
74
|
-
getNewToken(oAuth2Client) {
|
|
60
|
+
static getNewToken(oAuth2Client) {
|
|
75
61
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
62
|
const authUrl = oAuth2Client.generateAuthUrl({
|
|
77
63
|
access_type: 'offline',
|
|
@@ -100,4 +86,15 @@ export class GoogleAuthHelper {
|
|
|
100
86
|
});
|
|
101
87
|
}
|
|
102
88
|
}
|
|
103
|
-
|
|
89
|
+
AuxGoogleAuth.credentialsJson = {
|
|
90
|
+
"installed": {
|
|
91
|
+
"client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
|
|
92
|
+
"project_id": "auxta-library",
|
|
93
|
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
|
94
|
+
"token_uri": "https://oauth2.googleapis.com/token",
|
|
95
|
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
|
96
|
+
"client_secret": "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",
|
|
97
|
+
"redirect_uris": ["https://auxcode.com"]
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
export default new AuxGoogleAuth();
|
|
@@ -16,6 +16,8 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
16
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
17
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
18
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
19
|
+
clickInMail(from_name: string, from_email: string, subject: string): Promise<boolean>;
|
|
20
|
+
private getHeader;
|
|
19
21
|
}
|
|
20
22
|
declare const _default: FunctionHelper;
|
|
21
23
|
export default _default;
|
|
@@ -13,6 +13,8 @@ import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
|
13
13
|
import { StepStatus } from "../../AuxTA";
|
|
14
14
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
15
15
|
import { KnownDevices } from "puppeteer";
|
|
16
|
+
import { AuxGoogleAuth } from "./AuxGoogleAuth";
|
|
17
|
+
import { config } from "../../auxta/configs/config";
|
|
16
18
|
export class FunctionHelper extends ExtendDefaultPage {
|
|
17
19
|
log(keyword, name, status) {
|
|
18
20
|
log.push(keyword, name, status);
|
|
@@ -181,5 +183,47 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
181
183
|
yield loginPage.waitForNetworkIdle();
|
|
182
184
|
});
|
|
183
185
|
}
|
|
186
|
+
clickInMail(from_name, from_email, subject) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
yield AuxGoogleAuth.setup();
|
|
189
|
+
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
190
|
+
userId: config.googleEmail,
|
|
191
|
+
maxResults: 3
|
|
192
|
+
});
|
|
193
|
+
const messagesIds = res.data.messages;
|
|
194
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
195
|
+
throw new Error('No messagesIds found.');
|
|
196
|
+
}
|
|
197
|
+
let timeoutCount = 12000;
|
|
198
|
+
yield this.timeout(12000);
|
|
199
|
+
while (timeoutCount <= 60000) {
|
|
200
|
+
for (const messageId of messagesIds) {
|
|
201
|
+
if (messageId.id) {
|
|
202
|
+
const message = yield AuxGoogleAuth.gmailClient.users.messages.get({ userId: config.googleEmail, id: messageId.id.toString(), format: 'FULL' });
|
|
203
|
+
if (message.data.payload) {
|
|
204
|
+
const message_sender = this.getHeader('from', message.data.payload.headers);
|
|
205
|
+
const message_subject = this.getHeader('subject', message.data.payload.headers);
|
|
206
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) && message_subject.includes(subject.toLocaleLowerCase())) {
|
|
207
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, StepStatus.PASSED);
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
yield this.timeout(12000);
|
|
215
|
+
timeoutCount += 12000;
|
|
216
|
+
}
|
|
217
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} is found`, StepStatus.PASSED);
|
|
218
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} is found`);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
getHeader(value, headers) {
|
|
222
|
+
for (const header of headers) {
|
|
223
|
+
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
224
|
+
return header.value.toLocaleLowerCase();
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
184
228
|
}
|
|
185
229
|
export default new FunctionHelper();
|