@auxcode/auxta 1.3.51-beta.0 → 1.3.51-beta.10

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.
@@ -145,7 +145,7 @@ function compareScreenshots(key, screenshot) {
145
145
  data: screenshot,
146
146
  mime_type: "image/png"
147
147
  };
148
- yield axios_1.default.post(`${config_1.config.auxtaURL}save-compared-screenshot`, {
148
+ return yield axios_1.default.post(`${config_1.config.auxtaURL}save-compared-screenshot`, {
149
149
  organization: config_1.config.organization,
150
150
  key: key,
151
151
  embedding: embedding,
@@ -43,6 +43,7 @@ function captureScreenshotPage(page) {
43
43
  try {
44
44
  const screenshotBuffer = yield page.screenshot({
45
45
  fullPage: true,
46
+ captureBeyondViewport: false,
46
47
  encoding: 'binary'
47
48
  });
48
49
  if (Buffer.isBuffer(screenshotBuffer))
@@ -5,9 +5,14 @@ export declare class AuxGoogleAuth {
5
5
  static get oAuth2Client(): googleType.Auth.OAuth2Client;
6
6
  static get googleClient(): googleType.GoogleApis;
7
7
  static get gmailClient(): googleType.gmail_v1.Gmail;
8
- static setup(): Promise<void>;
8
+ static setupBrowser(): Promise<void>;
9
+ static setEmailPassword(email: string, password: string): Promise<void>;
10
+ static setupHeadless(): Promise<void>;
9
11
  private static authorize;
12
+ private static authorizeHeadless;
10
13
  private static getNewToken;
14
+ private static getNewTokenHeadless;
15
+ private static LogIn;
11
16
  }
12
17
  declare const _default: AuxGoogleAuth;
13
18
  export default _default;
@@ -8,10 +8,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.AuxGoogleAuth = void 0;
16
+ const config_1 = require("../../auxta/configs/config");
13
17
  const fs = require('fs');
14
18
  const readline = require('readline');
19
+ const puppeteer_1 = __importDefault(require("../../puppeteer/puppeteer"));
20
+ const code_helper_1 = __importDefault(require("../helpers/code.helper"));
15
21
  const { google } = require("googleapis");
16
22
  const SCOPES = [
17
23
  'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
@@ -27,6 +33,9 @@ const SCOPES = [
27
33
  'https://www.googleapis.com/auth/gmail.insert',
28
34
  ];
29
35
  const TOKEN_PATH = 'token.json';
36
+ let TOKEN = '';
37
+ let EMAIL = '';
38
+ let PASSWORD = '';
30
39
  class AuxGoogleAuth {
31
40
  static get oAuth2Client() {
32
41
  return this._oAuth2Client;
@@ -37,11 +46,22 @@ class AuxGoogleAuth {
37
46
  static get gmailClient() {
38
47
  return google.gmail({ version: 'v1', auth: this._oAuth2Client });
39
48
  }
40
- static setup() {
49
+ static setupBrowser() {
41
50
  return __awaiter(this, void 0, void 0, function* () {
42
51
  yield this.authorize(this.credentialsJson);
43
52
  });
44
53
  }
54
+ static setEmailPassword(email, password) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ EMAIL = email;
57
+ PASSWORD = password;
58
+ });
59
+ }
60
+ static setupHeadless() {
61
+ return __awaiter(this, void 0, void 0, function* () {
62
+ yield this.authorizeHeadless(this.credentialsJson);
63
+ });
64
+ }
45
65
  static authorize(credentials) {
46
66
  return __awaiter(this, void 0, void 0, function* () {
47
67
  const { client_secret, client_id, redirect_uris } = credentials.installed;
@@ -60,6 +80,23 @@ class AuxGoogleAuth {
60
80
  }
61
81
  });
62
82
  }
83
+ static authorizeHeadless(credentials) {
84
+ return __awaiter(this, void 0, void 0, function* () {
85
+ const { client_secret, client_id, redirect_uris } = credentials.installed;
86
+ const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
87
+ try {
88
+ if (TOKEN.length > 0) {
89
+ oAuth2Client.setCredentials(JSON.parse(TOKEN));
90
+ this._oAuth2Client = oAuth2Client;
91
+ return;
92
+ }
93
+ yield this.getNewTokenHeadless(oAuth2Client);
94
+ }
95
+ catch (e) {
96
+ yield this.getNewTokenHeadless(oAuth2Client);
97
+ }
98
+ });
99
+ }
63
100
  static getNewToken(oAuth2Client) {
64
101
  return __awaiter(this, void 0, void 0, function* () {
65
102
  const authUrl = oAuth2Client.generateAuthUrl({
@@ -88,6 +125,50 @@ class AuxGoogleAuth {
88
125
  });
89
126
  });
90
127
  }
128
+ static getNewTokenHeadless(oAuth2Client) {
129
+ return __awaiter(this, void 0, void 0, function* () {
130
+ const authUrl = oAuth2Client.generateAuthUrl({
131
+ access_type: 'offline',
132
+ prompt: 'consent',
133
+ scope: SCOPES,
134
+ });
135
+ const code = yield this.LogIn(authUrl);
136
+ oAuth2Client.getToken(code, (err, token) => {
137
+ if (err)
138
+ return console.error('Error retrieving access token', err);
139
+ oAuth2Client.setCredentials(token);
140
+ TOKEN = token;
141
+ this._oAuth2Client = oAuth2Client;
142
+ });
143
+ });
144
+ }
145
+ static LogIn(authUrl) {
146
+ var _a, _b, _c;
147
+ return __awaiter(this, void 0, void 0, function* () {
148
+ const context = yield puppeteer_1.default.defaultPage.browser().createIncognitoBrowserContext();
149
+ const page = yield context.newPage();
150
+ yield page.goto(authUrl);
151
+ yield page.waitForNetworkIdle();
152
+ yield code_helper_1.default.waitForSelector('visible', '#identifierId', config_1.config.timeout, page);
153
+ yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(EMAIL));
154
+ yield (yield page.$$('button'))[3].click();
155
+ yield page.waitForNetworkIdle();
156
+ yield code_helper_1.default.waitForSelector('visible', 'input[type="password"]', config_1.config.timeout, page);
157
+ yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(PASSWORD));
158
+ yield (yield page.$$('button'))[1].click();
159
+ yield page.waitForNetworkIdle();
160
+ yield code_helper_1.default.waitForSelector('visible', '#headingText', config_1.config.timeout, page);
161
+ yield (yield page.$$('button'))[2].click();
162
+ yield page.waitForNetworkIdle();
163
+ yield code_helper_1.default.waitForSelector('visible', 'input[type="checkbox"]', config_1.config.timeout, page);
164
+ yield ((_c = (yield page.$('input[type="checkbox"]'))) === null || _c === void 0 ? void 0 : _c.click());
165
+ yield (yield page.$$('button'))[2].click();
166
+ yield page.waitForNetworkIdle();
167
+ const currentUrl = page.url();
168
+ const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
169
+ return decodeURIComponent(code);
170
+ });
171
+ }
91
172
  }
92
173
  exports.AuxGoogleAuth = AuxGoogleAuth;
93
174
  AuxGoogleAuth.credentialsJson = {
@@ -35,11 +35,16 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
35
35
  }
36
36
  screenshotCompare(key, page = puppeteer_1.default.defaultPage) {
37
37
  return __awaiter(this, void 0, void 0, function* () {
38
- const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
39
- if (screenshotBuffer) {
40
- const screenshot = screenshotBuffer.toString('base64');
41
- log_service_1.default.push('Then', `compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, undefined, key);
42
- yield (0, report_service_1.compareScreenshots)(key, screenshot);
38
+ if (process.env.ENVIRONMENT !== 'LOCAL') {
39
+ const screenshotBuffer = yield (0, screenshot_helper_1.captureScreenshotPage)(page);
40
+ if (screenshotBuffer) {
41
+ const screenshot = screenshotBuffer.toString('base64');
42
+ yield (0, report_service_1.compareScreenshots)(key, screenshot);
43
+ log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, screenshot, key);
44
+ }
45
+ }
46
+ else {
47
+ log_service_1.default.push('Then', `I compare screenshots with key ${key}`, status_of_step_1.StatusOfStep.PASSED, undefined, key);
43
48
  }
44
49
  });
45
50
  }
@@ -21,7 +21,7 @@ const MailComposer = require('nodemailer/lib/mail-composer');
21
21
  class EmailHelper {
22
22
  verifyEmail(from_name, from_email, subject, body, link = false) {
23
23
  return __awaiter(this, void 0, void 0, function* () {
24
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
24
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
25
25
  let timeoutCount = 12000;
26
26
  while (timeoutCount <= 60000) {
27
27
  const res = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.list({
@@ -76,7 +76,7 @@ class EmailHelper {
76
76
  }
77
77
  sendEmail(to, subject, body) {
78
78
  return __awaiter(this, void 0, void 0, function* () {
79
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
79
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
80
80
  const options = {
81
81
  to: to,
82
82
  from: this.getCurrentUserEmail(),
@@ -88,7 +88,7 @@ class EmailHelper {
88
88
  }
89
89
  replyEmail(id, threadId, body) {
90
90
  return __awaiter(this, void 0, void 0, function* () {
91
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
91
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
92
92
  const gmailResponse = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.messages.get({
93
93
  userId: "me",
94
94
  id: id,
@@ -148,7 +148,7 @@ class EmailHelper {
148
148
  }
149
149
  getCurrentUserEmail() {
150
150
  return __awaiter(this, void 0, void 0, function* () {
151
- yield AuxGoogleAuth_1.AuxGoogleAuth.setup();
151
+ yield AuxGoogleAuth_1.AuxGoogleAuth.setupHeadless();
152
152
  const profile = yield AuxGoogleAuth_1.AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
153
153
  return profile.data.emailAddress;
154
154
  });
@@ -1,7 +1,7 @@
1
1
  import { UploadModel } from "../auxta/models/upload.model";
2
- import puppeteer = require("puppeteer");
2
+ import puppeteerN = require("puppeteer");
3
3
  export declare class Puppeteer {
4
- defaultPage: puppeteer.Page;
4
+ defaultPage: puppeteerN.Page;
5
5
  private browser;
6
6
  startBrowser(): Promise<void>;
7
7
  close(): Promise<void>;
@@ -21,24 +21,27 @@ const status_of_step_1 = require("../auxta/enums/status-of.step");
21
21
  const config_1 = require("../auxta/configs/config");
22
22
  const start_suite_helper_1 = require("../auxta/utilities/start-suite.helper");
23
23
  const report_service_1 = require("../auxta/services/report.service");
24
- const puppeteer = require("puppeteer");
24
+ const puppeteer = require("puppeteer-extra");
25
25
  class Puppeteer {
26
26
  startBrowser() {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- let args = [
29
- '--start-maximized'
30
- ];
28
+ let args = [];
31
29
  let env = {};
30
+ if (process.env.ENVIRONMENT === 'LOCAL') {
31
+ args.push('--start-maximized');
32
+ }
32
33
  if (process.env.ENVIRONMENT != 'LOCAL') {
33
- args.push(`--window-size=${config_1.config.screenWidth},${config_1.config.screenHeight}`);
34
+ args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth : 1920},${config_1.config.screenHeight ? config_1.config.screenHeight : 1080}`);
34
35
  args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
35
36
  env = {
36
37
  DISPLAY: ":10.0"
37
38
  };
38
39
  }
39
- this.browser = yield puppeteer.launch({
40
+ const StealthPlugin = require('puppeteer-extra-plugin-stealth');
41
+ puppeteer.default.use(StealthPlugin());
42
+ this.browser = yield puppeteer.default.launch({
40
43
  slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
41
- executablePath: puppeteer.executablePath(),
44
+ executablePath: puppeteer.default.executablePath(),
42
45
  args,
43
46
  env,
44
47
  ignoreDefaultArgs: ["--enable-automation"],
@@ -46,7 +49,7 @@ class Puppeteer {
46
49
  width: config_1.config.screenWidth,
47
50
  height: config_1.config.screenHeight
48
51
  },
49
- headless: process.env.ENVIRONMENT === 'LOCAL' ? process.env.headless === 'true' : true
52
+ headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true' ? 'new' : false) : 'new'
50
53
  });
51
54
  this.defaultPage = (yield this.browser.pages())[0];
52
55
  yield AuxTA_1.default.extend_page_functions(this.defaultPage);
@@ -133,7 +133,7 @@ export function compareScreenshots(key, screenshot) {
133
133
  data: screenshot,
134
134
  mime_type: "image/png"
135
135
  };
136
- yield axios.post(`${config.auxtaURL}save-compared-screenshot`, {
136
+ return yield axios.post(`${config.auxtaURL}save-compared-screenshot`, {
137
137
  organization: config.organization,
138
138
  key: key,
139
139
  embedding: embedding,
@@ -36,6 +36,7 @@ export function captureScreenshotPage(page) {
36
36
  try {
37
37
  const screenshotBuffer = yield page.screenshot({
38
38
  fullPage: true,
39
+ captureBeyondViewport: false,
39
40
  encoding: 'binary'
40
41
  });
41
42
  if (Buffer.isBuffer(screenshotBuffer))
@@ -5,9 +5,14 @@ export declare class AuxGoogleAuth {
5
5
  static get oAuth2Client(): googleType.Auth.OAuth2Client;
6
6
  static get googleClient(): googleType.GoogleApis;
7
7
  static get gmailClient(): googleType.gmail_v1.Gmail;
8
- static setup(): Promise<void>;
8
+ static setupBrowser(): Promise<void>;
9
+ static setEmailPassword(email: string, password: string): Promise<void>;
10
+ static setupHeadless(): Promise<void>;
9
11
  private static authorize;
12
+ private static authorizeHeadless;
10
13
  private static getNewToken;
14
+ private static getNewTokenHeadless;
15
+ private static LogIn;
11
16
  }
12
17
  declare const _default: AuxGoogleAuth;
13
18
  export default _default;
@@ -7,8 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { config } from "../../auxta/configs/config";
10
11
  const fs = require('fs');
11
12
  const readline = require('readline');
13
+ import puppeteer from "../../puppeteer/puppeteer";
14
+ import FunctionHelper from "../helpers/code.helper";
12
15
  const { google } = require("googleapis");
13
16
  const SCOPES = [
14
17
  'https://www.googleapis.com/auth/gmail.addons.current.action.compose',
@@ -24,6 +27,9 @@ const SCOPES = [
24
27
  'https://www.googleapis.com/auth/gmail.insert',
25
28
  ];
26
29
  const TOKEN_PATH = 'token.json';
30
+ let TOKEN = '';
31
+ let EMAIL = '';
32
+ let PASSWORD = '';
27
33
  export class AuxGoogleAuth {
28
34
  static get oAuth2Client() {
29
35
  return this._oAuth2Client;
@@ -34,11 +40,22 @@ export class AuxGoogleAuth {
34
40
  static get gmailClient() {
35
41
  return google.gmail({ version: 'v1', auth: this._oAuth2Client });
36
42
  }
37
- static setup() {
43
+ static setupBrowser() {
38
44
  return __awaiter(this, void 0, void 0, function* () {
39
45
  yield this.authorize(this.credentialsJson);
40
46
  });
41
47
  }
48
+ static setEmailPassword(email, password) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ EMAIL = email;
51
+ PASSWORD = password;
52
+ });
53
+ }
54
+ static setupHeadless() {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ yield this.authorizeHeadless(this.credentialsJson);
57
+ });
58
+ }
42
59
  static authorize(credentials) {
43
60
  return __awaiter(this, void 0, void 0, function* () {
44
61
  const { client_secret, client_id, redirect_uris } = credentials.installed;
@@ -57,6 +74,23 @@ export class AuxGoogleAuth {
57
74
  }
58
75
  });
59
76
  }
77
+ static authorizeHeadless(credentials) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const { client_secret, client_id, redirect_uris } = credentials.installed;
80
+ const oAuth2Client = new google.auth.OAuth2(client_id, client_secret, redirect_uris[0]);
81
+ try {
82
+ if (TOKEN.length > 0) {
83
+ oAuth2Client.setCredentials(JSON.parse(TOKEN));
84
+ this._oAuth2Client = oAuth2Client;
85
+ return;
86
+ }
87
+ yield this.getNewTokenHeadless(oAuth2Client);
88
+ }
89
+ catch (e) {
90
+ yield this.getNewTokenHeadless(oAuth2Client);
91
+ }
92
+ });
93
+ }
60
94
  static getNewToken(oAuth2Client) {
61
95
  return __awaiter(this, void 0, void 0, function* () {
62
96
  const authUrl = oAuth2Client.generateAuthUrl({
@@ -85,6 +119,50 @@ export class AuxGoogleAuth {
85
119
  });
86
120
  });
87
121
  }
122
+ static getNewTokenHeadless(oAuth2Client) {
123
+ return __awaiter(this, void 0, void 0, function* () {
124
+ const authUrl = oAuth2Client.generateAuthUrl({
125
+ access_type: 'offline',
126
+ prompt: 'consent',
127
+ scope: SCOPES,
128
+ });
129
+ const code = yield this.LogIn(authUrl);
130
+ oAuth2Client.getToken(code, (err, token) => {
131
+ if (err)
132
+ return console.error('Error retrieving access token', err);
133
+ oAuth2Client.setCredentials(token);
134
+ TOKEN = token;
135
+ this._oAuth2Client = oAuth2Client;
136
+ });
137
+ });
138
+ }
139
+ static LogIn(authUrl) {
140
+ var _a, _b, _c;
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ const context = yield puppeteer.defaultPage.browser().createIncognitoBrowserContext();
143
+ const page = yield context.newPage();
144
+ yield page.goto(authUrl);
145
+ yield page.waitForNetworkIdle();
146
+ yield FunctionHelper.waitForSelector('visible', '#identifierId', config.timeout, page);
147
+ yield ((_a = (yield page.$('#identifierId'))) === null || _a === void 0 ? void 0 : _a.type(EMAIL));
148
+ yield (yield page.$$('button'))[3].click();
149
+ yield page.waitForNetworkIdle();
150
+ yield FunctionHelper.waitForSelector('visible', 'input[type="password"]', config.timeout, page);
151
+ yield ((_b = (yield page.$('input[type="password"]'))) === null || _b === void 0 ? void 0 : _b.type(PASSWORD));
152
+ yield (yield page.$$('button'))[1].click();
153
+ yield page.waitForNetworkIdle();
154
+ yield FunctionHelper.waitForSelector('visible', '#headingText', config.timeout, page);
155
+ yield (yield page.$$('button'))[2].click();
156
+ yield page.waitForNetworkIdle();
157
+ yield FunctionHelper.waitForSelector('visible', 'input[type="checkbox"]', config.timeout, page);
158
+ yield ((_c = (yield page.$('input[type="checkbox"]'))) === null || _c === void 0 ? void 0 : _c.click());
159
+ yield (yield page.$$('button'))[2].click();
160
+ yield page.waitForNetworkIdle();
161
+ const currentUrl = page.url();
162
+ const code = currentUrl.substring(currentUrl.indexOf("code=") + 5, currentUrl.lastIndexOf("&"));
163
+ return decodeURIComponent(code);
164
+ });
165
+ }
88
166
  }
89
167
  AuxGoogleAuth.credentialsJson = {
90
168
  "installed": {
@@ -29,11 +29,16 @@ export class FunctionHelper extends ExtendDefaultPage {
29
29
  }
30
30
  screenshotCompare(key, page = puppeteer.defaultPage) {
31
31
  return __awaiter(this, void 0, void 0, function* () {
32
- const screenshotBuffer = yield captureScreenshotPage(page);
33
- if (screenshotBuffer) {
34
- const screenshot = screenshotBuffer.toString('base64');
35
- log.push('Then', `compare screenshots with key ${key}`, StatusOfStep.PASSED, undefined, key);
36
- yield compareScreenshots(key, screenshot);
32
+ if (process.env.ENVIRONMENT !== 'LOCAL') {
33
+ const screenshotBuffer = yield captureScreenshotPage(page);
34
+ if (screenshotBuffer) {
35
+ const screenshot = screenshotBuffer.toString('base64');
36
+ yield compareScreenshots(key, screenshot);
37
+ log.push('Then', `I compare screenshots with key ${key}`, StatusOfStep.PASSED, screenshot, key);
38
+ }
39
+ }
40
+ else {
41
+ log.push('Then', `I compare screenshots with key ${key}`, StatusOfStep.PASSED, undefined, key);
37
42
  }
38
43
  });
39
44
  }
@@ -15,7 +15,7 @@ const MailComposer = require('nodemailer/lib/mail-composer');
15
15
  export class EmailHelper {
16
16
  verifyEmail(from_name, from_email, subject, body, link = false) {
17
17
  return __awaiter(this, void 0, void 0, function* () {
18
- yield AuxGoogleAuth.setup();
18
+ yield AuxGoogleAuth.setupHeadless();
19
19
  let timeoutCount = 12000;
20
20
  while (timeoutCount <= 60000) {
21
21
  const res = yield AuxGoogleAuth.gmailClient.users.messages.list({
@@ -70,7 +70,7 @@ export class EmailHelper {
70
70
  }
71
71
  sendEmail(to, subject, body) {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
- yield AuxGoogleAuth.setup();
73
+ yield AuxGoogleAuth.setupHeadless();
74
74
  const options = {
75
75
  to: to,
76
76
  from: this.getCurrentUserEmail(),
@@ -82,7 +82,7 @@ export class EmailHelper {
82
82
  }
83
83
  replyEmail(id, threadId, body) {
84
84
  return __awaiter(this, void 0, void 0, function* () {
85
- yield AuxGoogleAuth.setup();
85
+ yield AuxGoogleAuth.setupHeadless();
86
86
  const gmailResponse = yield AuxGoogleAuth.gmailClient.users.messages.get({
87
87
  userId: "me",
88
88
  id: id,
@@ -142,7 +142,7 @@ export class EmailHelper {
142
142
  }
143
143
  getCurrentUserEmail() {
144
144
  return __awaiter(this, void 0, void 0, function* () {
145
- yield AuxGoogleAuth.setup();
145
+ yield AuxGoogleAuth.setupHeadless();
146
146
  const profile = yield AuxGoogleAuth.gmailClient.users.getProfile({ userId: "me" });
147
147
  return profile.data.emailAddress;
148
148
  });
@@ -1,7 +1,7 @@
1
1
  import { UploadModel } from "../auxta/models/upload.model";
2
- import puppeteer = require("puppeteer");
2
+ import puppeteerN = require("puppeteer");
3
3
  export declare class Puppeteer {
4
- defaultPage: puppeteer.Page;
4
+ defaultPage: puppeteerN.Page;
5
5
  private browser;
6
6
  startBrowser(): Promise<void>;
7
7
  close(): Promise<void>;
@@ -18,20 +18,23 @@ import { postNotificationsOnFail } from "../auxta/services/report.service";
18
18
  export class Puppeteer {
19
19
  startBrowser() {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
- let args = [
22
- '--start-maximized'
23
- ];
21
+ let args = [];
24
22
  let env = {};
23
+ if (process.env.ENVIRONMENT === 'LOCAL') {
24
+ args.push('--start-maximized');
25
+ }
25
26
  if (process.env.ENVIRONMENT != 'LOCAL') {
26
- args.push(`--window-size=${config.screenWidth},${config.screenHeight}`);
27
+ args.push(`--window-size=${config.screenWidth ? config.screenWidth : 1920},${config.screenHeight ? config.screenHeight : 1080}`);
27
28
  args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
28
29
  env = {
29
30
  DISPLAY: ":10.0"
30
31
  };
31
32
  }
32
- this.browser = yield puppeteer.launch({
33
+ const StealthPlugin = require('puppeteer-extra-plugin-stealth');
34
+ puppeteer.default.use(StealthPlugin());
35
+ this.browser = yield puppeteer.default.launch({
33
36
  slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
34
- executablePath: puppeteer.executablePath(),
37
+ executablePath: puppeteer.default.executablePath(),
35
38
  args,
36
39
  env,
37
40
  ignoreDefaultArgs: ["--enable-automation"],
@@ -39,7 +42,7 @@ export class Puppeteer {
39
42
  width: config.screenWidth,
40
43
  height: config.screenHeight
41
44
  },
42
- headless: process.env.ENVIRONMENT === 'LOCAL' ? process.env.headless === 'true' : true
45
+ headless: process.env.ENVIRONMENT === 'LOCAL' ? (process.env.headless === 'true' ? 'new' : false) : 'new'
43
46
  });
44
47
  this.defaultPage = (yield this.browser.pages())[0];
45
48
  yield auxta.extend_page_functions(this.defaultPage);