@auxcode/auxta 1.3.19-beta.8 → 1.3.19-beta.9

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.
@@ -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
- googleAuth: import("./macros/helpers/GoogleAuthHelper").GoogleAuthHelper;
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;
@@ -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 GoogleAuthHelper_1 = __importDefault(require("./macros/helpers/GoogleAuthHelper"));
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.googleAuth = GoogleAuthHelper_1.default;
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.GoogleAuthHelper = void 0;
12
+ exports.AuxGoogleAuth = void 0;
13
13
  const fs = require('fs');
14
14
  const readline = require('readline');
15
15
  const { google } = require("googleapis");
@@ -28,35 +28,22 @@ const SCOPES = [
28
28
  'https://www.googleapis.com/auth/gmail.insert',
29
29
  ];
30
30
  const TOKEN_PATH = 'token.json';
31
- class GoogleAuthHelper {
32
- constructor() {
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() {
31
+ class AuxGoogleAuth {
32
+ static get oAuth2Client() {
46
33
  return this._oAuth2Client;
47
34
  }
48
- get googleClient() {
35
+ static get googleClient() {
49
36
  return google;
50
37
  }
51
- get gmailClient() {
38
+ static get gmailClient() {
52
39
  return google.gmail({ version: 'v1', auth: this._oAuth2Client });
53
40
  }
54
- setup() {
41
+ static setup() {
55
42
  return __awaiter(this, void 0, void 0, function* () {
56
43
  yield this.authorize(this.credentialsJson);
57
44
  });
58
45
  }
59
- authorize(credentials) {
46
+ static authorize(credentials) {
60
47
  return __awaiter(this, void 0, void 0, function* () {
61
48
  const { client_secret, client_id, redirect_uris } = credentials.installed;
62
49
  const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
@@ -74,7 +61,7 @@ class GoogleAuthHelper {
74
61
  }
75
62
  });
76
63
  }
77
- getNewToken(oAuth2Client) {
64
+ static getNewToken(oAuth2Client) {
78
65
  return __awaiter(this, void 0, void 0, function* () {
79
66
  const authUrl = oAuth2Client.generateAuthUrl({
80
67
  access_type: 'offline',
@@ -103,5 +90,16 @@ class GoogleAuthHelper {
103
90
  });
104
91
  }
105
92
  }
106
- exports.GoogleAuthHelper = GoogleAuthHelper;
107
- exports.default = new GoogleAuthHelper();
93
+ exports.AuxGoogleAuth = AuxGoogleAuth;
94
+ AuxGoogleAuth.credentialsJson = {
95
+ "installed": {
96
+ "client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
97
+ "project_id": "auxta-library",
98
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
99
+ "token_uri": "https://oauth2.googleapis.com/token",
100
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
101
+ "client_secret": "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",
102
+ "redirect_uris": ["https://auxcode.com"]
103
+ }
104
+ };
105
+ exports.default = new AuxGoogleAuth();
@@ -0,0 +1,7 @@
1
+ import { FunctionHelper } from "./code.helper";
2
+ export declare class GoogleCodeHelper extends FunctionHelper {
3
+ clickInMail(from_email: string): Promise<boolean | undefined>;
4
+ private getHeader;
5
+ }
6
+ declare const _default: GoogleCodeHelper;
7
+ export default _default;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.GoogleCodeHelper = void 0;
13
+ const AuxGoogleAuth_1 = require("./AuxGoogleAuth");
14
+ const config_1 = require("../../auxta/configs/config");
15
+ const code_helper_1 = require("./code.helper");
16
+ class GoogleCodeHelper extends code_helper_1.FunctionHelper {
17
+ clickInMail(from_email) {
18
+ return __awaiter(this, void 0, void 0, function* () {
19
+ const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
20
+ userId: config_1.config.googleEmail,
21
+ maxResults: 3
22
+ });
23
+ const messagesIds = res.data.messages;
24
+ if (!messagesIds || messagesIds.length === 0) {
25
+ console.log('No messagesIds found.');
26
+ return;
27
+ }
28
+ let timeoutCount = 12000;
29
+ yield this.timeout(12000);
30
+ while (timeoutCount <= 60000) {
31
+ for (const messageId of messagesIds) {
32
+ if (messageId.id) {
33
+ const message = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({ userId: config_1.config.googleEmail, id: messageId.id.toString(), format: 'FULL' });
34
+ if (message.data.payload) {
35
+ const sender = this.getHeader('sender', message.data.payload.headers);
36
+ if (sender.toLocaleLowerCase().includes(from_email.toLocaleLowerCase())) {
37
+ return true;
38
+ }
39
+ }
40
+ break;
41
+ }
42
+ }
43
+ yield this.timeout(12000);
44
+ timeoutCount += 12000;
45
+ }
46
+ return false;
47
+ });
48
+ }
49
+ getHeader(value, headers) {
50
+ for (const header of headers) {
51
+ if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
52
+ return header.value;
53
+ }
54
+ }
55
+ }
56
+ }
57
+ exports.GoogleCodeHelper = GoogleCodeHelper;
58
+ exports.default = new GoogleCodeHelper();
@@ -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
- googleAuth: import("./macros/helpers/GoogleAuthHelper").GoogleAuthHelper;
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;
@@ -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 GoogleAuthHelper from "./macros/helpers/GoogleAuthHelper";
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.googleAuth = GoogleAuthHelper;
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;
@@ -25,35 +25,22 @@ const SCOPES = [
25
25
  'https://www.googleapis.com/auth/gmail.insert',
26
26
  ];
27
27
  const TOKEN_PATH = 'token.json';
28
- export class GoogleAuthHelper {
29
- constructor() {
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() {
28
+ export class AuxGoogleAuth {
29
+ static get oAuth2Client() {
43
30
  return this._oAuth2Client;
44
31
  }
45
- get googleClient() {
32
+ static get googleClient() {
46
33
  return google;
47
34
  }
48
- get gmailClient() {
35
+ static get gmailClient() {
49
36
  return google.gmail({ version: 'v1', auth: this._oAuth2Client });
50
37
  }
51
- setup() {
38
+ static setup() {
52
39
  return __awaiter(this, void 0, void 0, function* () {
53
40
  yield this.authorize(this.credentialsJson);
54
41
  });
55
42
  }
56
- authorize(credentials) {
43
+ static authorize(credentials) {
57
44
  return __awaiter(this, void 0, void 0, function* () {
58
45
  const { client_secret, client_id, redirect_uris } = credentials.installed;
59
46
  const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
@@ -71,7 +58,7 @@ export class GoogleAuthHelper {
71
58
  }
72
59
  });
73
60
  }
74
- getNewToken(oAuth2Client) {
61
+ static getNewToken(oAuth2Client) {
75
62
  return __awaiter(this, void 0, void 0, function* () {
76
63
  const authUrl = oAuth2Client.generateAuthUrl({
77
64
  access_type: 'offline',
@@ -100,4 +87,15 @@ export class GoogleAuthHelper {
100
87
  });
101
88
  }
102
89
  }
103
- export default new GoogleAuthHelper();
90
+ AuxGoogleAuth.credentialsJson = {
91
+ "installed": {
92
+ "client_id": "120362272213-usevfijf76jj5nsr502i2lai6nu71oq8.apps.googleusercontent.com",
93
+ "project_id": "auxta-library",
94
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
95
+ "token_uri": "https://oauth2.googleapis.com/token",
96
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
97
+ "client_secret": "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",
98
+ "redirect_uris": ["https://auxcode.com"]
99
+ }
100
+ };
101
+ export default new AuxGoogleAuth();
@@ -0,0 +1,7 @@
1
+ import { FunctionHelper } from "./code.helper";
2
+ export declare class GoogleCodeHelper extends FunctionHelper {
3
+ clickInMail(from_email: string): Promise<boolean | undefined>;
4
+ private getHeader;
5
+ }
6
+ declare const _default: GoogleCodeHelper;
7
+ export default _default;
@@ -0,0 +1,54 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { AuxGoogleAuth } from "./AuxGoogleAuth";
11
+ import { config } from "../../auxta/configs/config";
12
+ import { FunctionHelper } from "./code.helper";
13
+ export class GoogleCodeHelper extends FunctionHelper {
14
+ clickInMail(from_email) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
17
+ userId: config.googleEmail,
18
+ maxResults: 3
19
+ });
20
+ const messagesIds = res.data.messages;
21
+ if (!messagesIds || messagesIds.length === 0) {
22
+ console.log('No messagesIds found.');
23
+ return;
24
+ }
25
+ let timeoutCount = 12000;
26
+ yield this.timeout(12000);
27
+ while (timeoutCount <= 60000) {
28
+ for (const messageId of messagesIds) {
29
+ if (messageId.id) {
30
+ const message = yield AuxGoogleAuth.gmailClient.users.messages.get({ userId: config.googleEmail, id: messageId.id.toString(), format: 'FULL' });
31
+ if (message.data.payload) {
32
+ const sender = this.getHeader('sender', message.data.payload.headers);
33
+ if (sender.toLocaleLowerCase().includes(from_email.toLocaleLowerCase())) {
34
+ return true;
35
+ }
36
+ }
37
+ break;
38
+ }
39
+ }
40
+ yield this.timeout(12000);
41
+ timeoutCount += 12000;
42
+ }
43
+ return false;
44
+ });
45
+ }
46
+ getHeader(value, headers) {
47
+ for (const header of headers) {
48
+ if (header.name.toLocaleLowerCase() === value.toLocaleLowerCase()) {
49
+ return header.value;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ export default new GoogleCodeHelper();