@auxcode/auxta 1.3.23-beta.4 → 1.3.23
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/cjs/AuxTA.d.ts +0 -1
- package/build/cjs/AuxTA.js +0 -2
- package/build/cjs/macros/helpers/code.helper.d.ts +6 -0
- package/build/cjs/macros/helpers/code.helper.js +69 -2
- package/build/cjs/macros/helpers/extend-default-page.d.ts +1 -1
- package/build/cjs/macros/helpers/extend-default-page.js +1 -0
- package/build/esm/AuxTA.d.ts +0 -1
- package/build/esm/AuxTA.js +0 -2
- package/build/esm/macros/helpers/code.helper.d.ts +6 -0
- package/build/esm/macros/helpers/code.helper.js +69 -2
- package/build/esm/macros/helpers/extend-default-page.d.ts +1 -1
- package/build/esm/macros/helpers/extend-default-page.js +1 -0
- package/build/tsconfig-cjs.tsbuildinfo +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -2
- package/build/cjs/macros/helpers/emailHelper.d.ts +0 -17
- package/build/cjs/macros/helpers/emailHelper.js +0 -121
- package/build/esm/macros/helpers/emailHelper.d.ts +0 -17
- package/build/esm/macros/helpers/emailHelper.js +0 -114
package/build/cjs/AuxTA.d.ts
CHANGED
package/build/cjs/AuxTA.js
CHANGED
|
@@ -48,7 +48,6 @@ 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
50
|
const AuxGoogleAuth_1 = require("./macros/helpers/AuxGoogleAuth");
|
|
51
|
-
const emailHelper_1 = __importDefault(require("./macros/helpers/emailHelper"));
|
|
52
51
|
dotenv.config();
|
|
53
52
|
class AuxTA extends code_helper_1.FunctionHelper {
|
|
54
53
|
constructor() {
|
|
@@ -57,7 +56,6 @@ class AuxTA extends code_helper_1.FunctionHelper {
|
|
|
57
56
|
this.aux2fa = Aux2faAuth_1.default;
|
|
58
57
|
this.google = AuxGoogleAuth_1.AuxGoogleAuth;
|
|
59
58
|
this.config = config_1.config;
|
|
60
|
-
this.emailHelper = emailHelper_1.default;
|
|
61
59
|
let file;
|
|
62
60
|
if (!process.env.RPA) {
|
|
63
61
|
try {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
2
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
+
import { gmail_v1 } from "googleapis";
|
|
3
4
|
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
4
5
|
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
5
6
|
suggest(name: string): void;
|
|
@@ -16,6 +17,11 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
17
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
18
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
19
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
20
|
+
clickInMail(from_name: string, from_email: string, subject: string, body: string): Promise<true | undefined>;
|
|
21
|
+
private getHeader;
|
|
22
|
+
private getBody;
|
|
23
|
+
}
|
|
24
|
+
export interface gmailResponse extends gmail_v1.Gmail {
|
|
19
25
|
}
|
|
20
26
|
declare const _default: FunctionHelper;
|
|
21
27
|
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 buffer_1 = require("buffer");
|
|
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);
|
|
@@ -89,7 +91,7 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
89
91
|
}
|
|
90
92
|
timeout(timeout = this.defaultTimeout, page = puppeteer_1.default.defaultPage) {
|
|
91
93
|
return __awaiter(this, void 0, void 0, function* () {
|
|
92
|
-
|
|
94
|
+
yield page.waitForTimeout(timeout);
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer_1.default.defaultPage, log_message = true) {
|
|
@@ -167,9 +169,18 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
167
169
|
yield this.extend_page_functions(loginPage);
|
|
168
170
|
yield loginPage.waitForNetworkIdle();
|
|
169
171
|
yield this.waitForSelector('visible', next_button, 60000, loginPage);
|
|
170
|
-
yield loginPage.type(email_input, email);
|
|
172
|
+
yield loginPage.type(email_input, email, { delay: 0 });
|
|
171
173
|
yield loginPage.keyboard.press('Enter');
|
|
172
174
|
yield loginPage.waitForNetworkIdle();
|
|
175
|
+
let isWorkOrPersonalVisible = yield puppeteer_1.default.defaultPage.$('div.table');
|
|
176
|
+
if (!!isWorkOrPersonalVisible) {
|
|
177
|
+
yield (yield puppeteer_1.default.defaultPage.$$('div.table'))[0].click();
|
|
178
|
+
console.log('Then', 'I clicked Work or school account', AuxTA_1.StepStatus.PASSED);
|
|
179
|
+
yield puppeteer_1.default.defaultPage.waitForNetworkIdle();
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
yield puppeteer_1.default.defaultPage.waitForNetworkIdle();
|
|
183
|
+
}
|
|
173
184
|
yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
|
|
174
185
|
yield this.waitForSelector('visible', password_input, 6000, loginPage);
|
|
175
186
|
try {
|
|
@@ -187,6 +198,62 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
|
|
|
187
198
|
yield loginPage.waitForNetworkIdle();
|
|
188
199
|
});
|
|
189
200
|
}
|
|
201
|
+
clickInMail(from_name, from_email, subject, body) {
|
|
202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
+
yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
|
|
204
|
+
const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
|
|
205
|
+
userId: "me",
|
|
206
|
+
maxResults: 3
|
|
207
|
+
});
|
|
208
|
+
const messagesIds = res.data.messages;
|
|
209
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
210
|
+
throw new Error('No messagesIds found.');
|
|
211
|
+
}
|
|
212
|
+
let timeoutCount = 12000;
|
|
213
|
+
yield this.timeout(12000);
|
|
214
|
+
while (timeoutCount <= 60000) {
|
|
215
|
+
for (const messageId of messagesIds) {
|
|
216
|
+
if (messageId.id) {
|
|
217
|
+
const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
|
|
218
|
+
userId: "me",
|
|
219
|
+
id: messageId.id.toString(),
|
|
220
|
+
format: 'FULL'
|
|
221
|
+
});
|
|
222
|
+
if (gmailResponse.data.payload) {
|
|
223
|
+
const message_sender = this.getHeader('from', gmailResponse.data.payload.headers);
|
|
224
|
+
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
225
|
+
const message_body = this.getBody(from_name, from_email, subject, gmailResponse);
|
|
226
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
227
|
+
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
228
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.PASSED);
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
break;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
yield this.timeout(12000);
|
|
236
|
+
timeoutCount += 12000;
|
|
237
|
+
}
|
|
238
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, AuxTA_1.StepStatus.FAILED);
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
getHeader(value, headers) {
|
|
242
|
+
for (const header of headers) {
|
|
243
|
+
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
244
|
+
return header.value.toLocaleLowerCase();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
getBody(from_name, from_email, subject, gmailResponse) {
|
|
249
|
+
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
250
|
+
if (body) {
|
|
251
|
+
return (0, buffer_1.atob)(body).toLocaleLowerCase();
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} body is empty`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
190
257
|
}
|
|
191
258
|
exports.FunctionHelper = FunctionHelper;
|
|
192
259
|
exports.default = new FunctionHelper();
|
|
@@ -22,6 +22,7 @@ class ExtendDefaultPage {
|
|
|
22
22
|
}
|
|
23
23
|
extend_page_functions(page, time = this.defaultTimeout) {
|
|
24
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
this.defaultTimeout = config_1.config.timeout;
|
|
25
26
|
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
26
27
|
page.goto = function goto(url, options) {
|
|
27
28
|
log_service_1.default.push('Then', `I go to the '${url}' page`, status_of_step_1.StatusOfStep.PASSED);
|
package/build/esm/AuxTA.d.ts
CHANGED
package/build/esm/AuxTA.js
CHANGED
|
@@ -19,7 +19,6 @@ 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
21
|
import { AuxGoogleAuth } from "./macros/helpers/AuxGoogleAuth";
|
|
22
|
-
import emailHelper from "./macros/helpers/emailHelper";
|
|
23
22
|
dotenv.config();
|
|
24
23
|
class AuxTA extends FunctionHelper {
|
|
25
24
|
constructor() {
|
|
@@ -28,7 +27,6 @@ class AuxTA extends FunctionHelper {
|
|
|
28
27
|
this.aux2fa = Aux2faAuth;
|
|
29
28
|
this.google = AuxGoogleAuth;
|
|
30
29
|
this.config = c;
|
|
31
|
-
this.emailHelper = emailHelper;
|
|
32
30
|
let file;
|
|
33
31
|
if (!process.env.RPA) {
|
|
34
32
|
try {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StatusOfStep } from "../../auxta/enums/status-of.step";
|
|
2
2
|
import { ExtendDefaultPage } from "./extend-default-page";
|
|
3
|
+
import { gmail_v1 } from "googleapis";
|
|
3
4
|
export declare class FunctionHelper extends ExtendDefaultPage {
|
|
4
5
|
log(keyword: string, name: string, status: StatusOfStep): void;
|
|
5
6
|
suggest(name: string): void;
|
|
@@ -16,6 +17,11 @@ export declare class FunctionHelper extends ExtendDefaultPage {
|
|
|
16
17
|
clickAndWaitForPageToBeCreated(selector: string, page?: import("puppeteer").Page): Promise<void>;
|
|
17
18
|
closeLastPage(page?: import("puppeteer").Page): Promise<void>;
|
|
18
19
|
microsoftLogin(button: string, email: string, password: string): Promise<void>;
|
|
20
|
+
clickInMail(from_name: string, from_email: string, subject: string, body: string): Promise<true | undefined>;
|
|
21
|
+
private getHeader;
|
|
22
|
+
private getBody;
|
|
23
|
+
}
|
|
24
|
+
export interface gmailResponse extends gmail_v1.Gmail {
|
|
19
25
|
}
|
|
20
26
|
declare const _default: FunctionHelper;
|
|
21
27
|
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 { atob } from "buffer";
|
|
16
18
|
export class FunctionHelper extends ExtendDefaultPage {
|
|
17
19
|
log(keyword, name, status) {
|
|
18
20
|
log.push(keyword, name, status);
|
|
@@ -83,7 +85,7 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
83
85
|
}
|
|
84
86
|
timeout(timeout = this.defaultTimeout, page = puppeteer.defaultPage) {
|
|
85
87
|
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
-
|
|
88
|
+
yield page.waitForTimeout(timeout);
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
91
|
waitForSelector(option, selector, time = this.defaultTimeout, page = puppeteer.defaultPage, log_message = true) {
|
|
@@ -161,9 +163,18 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
161
163
|
yield this.extend_page_functions(loginPage);
|
|
162
164
|
yield loginPage.waitForNetworkIdle();
|
|
163
165
|
yield this.waitForSelector('visible', next_button, 60000, loginPage);
|
|
164
|
-
yield loginPage.type(email_input, email);
|
|
166
|
+
yield loginPage.type(email_input, email, { delay: 0 });
|
|
165
167
|
yield loginPage.keyboard.press('Enter');
|
|
166
168
|
yield loginPage.waitForNetworkIdle();
|
|
169
|
+
let isWorkOrPersonalVisible = yield puppeteer.defaultPage.$('div.table');
|
|
170
|
+
if (!!isWorkOrPersonalVisible) {
|
|
171
|
+
yield (yield puppeteer.defaultPage.$$('div.table'))[0].click();
|
|
172
|
+
console.log('Then', 'I clicked Work or school account', StepStatus.PASSED);
|
|
173
|
+
yield puppeteer.defaultPage.waitForNetworkIdle();
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
yield puppeteer.defaultPage.waitForNetworkIdle();
|
|
177
|
+
}
|
|
167
178
|
yield this.waitForSelector('visible', sign_in_button, 60000, loginPage);
|
|
168
179
|
yield this.waitForSelector('visible', password_input, 6000, loginPage);
|
|
169
180
|
try {
|
|
@@ -181,5 +192,61 @@ export class FunctionHelper extends ExtendDefaultPage {
|
|
|
181
192
|
yield loginPage.waitForNetworkIdle();
|
|
182
193
|
});
|
|
183
194
|
}
|
|
195
|
+
clickInMail(from_name, from_email, subject, body) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
197
|
+
yield AuxGoogleAuth.setup();
|
|
198
|
+
const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
|
|
199
|
+
userId: "me",
|
|
200
|
+
maxResults: 3
|
|
201
|
+
});
|
|
202
|
+
const messagesIds = res.data.messages;
|
|
203
|
+
if (!messagesIds || messagesIds.length === 0) {
|
|
204
|
+
throw new Error('No messagesIds found.');
|
|
205
|
+
}
|
|
206
|
+
let timeoutCount = 12000;
|
|
207
|
+
yield this.timeout(12000);
|
|
208
|
+
while (timeoutCount <= 60000) {
|
|
209
|
+
for (const messageId of messagesIds) {
|
|
210
|
+
if (messageId.id) {
|
|
211
|
+
const gmailResponse = yield AuxGoogleAuth.gmailClient.users.messages.get({
|
|
212
|
+
userId: "me",
|
|
213
|
+
id: messageId.id.toString(),
|
|
214
|
+
format: 'FULL'
|
|
215
|
+
});
|
|
216
|
+
if (gmailResponse.data.payload) {
|
|
217
|
+
const message_sender = this.getHeader('from', gmailResponse.data.payload.headers);
|
|
218
|
+
const message_subject = this.getHeader('subject', gmailResponse.data.payload.headers);
|
|
219
|
+
const message_body = this.getBody(from_name, from_email, subject, gmailResponse);
|
|
220
|
+
if (message_sender.includes(from_email) && message_sender.includes(from_name.toLocaleLowerCase()) &&
|
|
221
|
+
message_subject.includes(subject.toLocaleLowerCase()) && message_body.includes(body.toLocaleLowerCase())) {
|
|
222
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.PASSED);
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
break;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
yield this.timeout(12000);
|
|
230
|
+
timeoutCount += 12000;
|
|
231
|
+
}
|
|
232
|
+
yield this.log('Then', `Email from: ${from_name} ${from_email} with subject: ${subject} and body: ${body} is found`, StepStatus.FAILED);
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
getHeader(value, headers) {
|
|
236
|
+
for (const header of headers) {
|
|
237
|
+
if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
|
|
238
|
+
return header.value.toLocaleLowerCase();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
getBody(from_name, from_email, subject, gmailResponse) {
|
|
243
|
+
const body = gmailResponse.data.payload.parts[0].body.data;
|
|
244
|
+
if (body) {
|
|
245
|
+
return atob(body).toLocaleLowerCase();
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
throw new Error(`Email from: ${from_name} ${from_email} with subject: ${subject} body is empty`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
184
251
|
}
|
|
185
252
|
export default new FunctionHelper();
|
|
@@ -16,6 +16,7 @@ export class ExtendDefaultPage {
|
|
|
16
16
|
}
|
|
17
17
|
extend_page_functions(page, time = this.defaultTimeout) {
|
|
18
18
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
this.defaultTimeout = config.timeout;
|
|
19
20
|
const { goto: original_goto, click: original_click, type: original_type, waitForNetworkIdle: original_waitForNetworkIdle } = page;
|
|
20
21
|
page.goto = function goto(url, options) {
|
|
21
22
|
log.push('Then', `I go to the '${url}' page`, StatusOfStep.PASSED);
|