@auxcode/auxta 1.3.128 → 1.3.130

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.
@@ -5,5 +5,5 @@ export declare function returnImage(code: number, screenshot: Buffer): {
5
5
  "Content-Type": string;
6
6
  "Content-Length": string;
7
7
  };
8
- body: Buffer;
8
+ body: Buffer<ArrayBufferLike>;
9
9
  };
@@ -32,4 +32,10 @@ export declare function getLastDayResults(): Promise<any>;
32
32
  export declare function compareScreenshots(key: string, screenshot?: Uint8Array | Buffer): Promise<any>;
33
33
  export declare function postNotifications(body: UploadModel): Promise<void>;
34
34
  export declare function postNotificationsOnFail(body: UploadModel): Promise<void>;
35
- export declare function getVerifyReceivedEmail(from_name: string, from_email: string, subject: string, body: string, link: boolean): Promise<import("axios").AxiosResponse<any, any, {}>>;
35
+ export declare function getVerifyReceivedEmail(from_name: string, from_email: string, subject: string, body: string, link: boolean): Promise<import("axios").AxiosResponse<any, {
36
+ from_name: string;
37
+ from_email: string;
38
+ subject: string;
39
+ body: string;
40
+ link: boolean;
41
+ }, {}, any>>;
@@ -1,3 +1,3 @@
1
1
  import { Page } from "puppeteer";
2
- export declare function captureScreenshot(): Promise<(Uint8Array<ArrayBufferLike> & Buffer) | undefined>;
3
- export declare function captureScreenshotPage(page: Page): Promise<(Uint8Array<ArrayBufferLike> & Buffer) | undefined>;
2
+ export declare function captureScreenshot(): Promise<Buffer<ArrayBufferLike> | undefined>;
3
+ export declare function captureScreenshotPage(page: Page): Promise<Buffer<ArrayBufferLike> | undefined>;
@@ -6,8 +6,8 @@ export declare class FunctionHelper extends ExtendDefaultPage {
6
6
  log(keyword: string, name: string, status: StatusOfStep, screenshot?: Uint8Array | Buffer): void;
7
7
  setTag(tag: string): void;
8
8
  clearTag(): void;
9
- callREST(method: string, url: string, headers?: object, body?: object): Promise<import("axios").AxiosResponse<any, any, {}>>;
10
- screenshot(page?: import("puppeteer-core").Page): Promise<(Uint8Array<ArrayBufferLike> & Buffer) | undefined>;
9
+ callREST(method: string, url: string, headers?: object, body?: object): Promise<import("axios").AxiosResponse<any, object, {}, any>>;
10
+ screenshot(page?: import("puppeteer-core").Page): Promise<Buffer<ArrayBufferLike> | undefined>;
11
11
  screenshotCompare(key: string, threshold?: number, page?: import("puppeteer-core").Page): Promise<void>;
12
12
  suggest(name: string): void;
13
13
  performanceFail(name: string, screenshot?: boolean, page?: import("puppeteer-core").Page): Promise<void>;
@@ -26,8 +26,9 @@ export declare class FunctionHelper extends ExtendDefaultPage {
26
26
  waitForResponse(name: string, wait?: boolean, page?: import("puppeteer-core").Page): Promise<void>;
27
27
  closeLastPage(page?: import("puppeteer-core").Page): Promise<void>;
28
28
  microsoftLogin(button: string, email: string, password: string, page?: import("puppeteer-core").Page, newPage?: boolean, staySignIn?: boolean): Promise<void>;
29
+ private failOnMicrosoftLoginError;
29
30
  private getEscapedText;
30
- callAPI(url: string, body: {}, token: string): Promise<import("axios").AxiosResponse<any, any, {}>>;
31
+ callAPI(url: string, body: {}, token: string): Promise<import("axios").AxiosResponse<any, {}, {}, any>>;
31
32
  }
32
33
  declare const _default: FunctionHelper;
33
34
  export default _default;
@@ -244,38 +244,92 @@ class FunctionHelper extends extend_default_page_1.ExtendDefaultPage {
244
244
  }
245
245
  microsoftLogin(button_1, email_1, password_1) {
246
246
  return __awaiter(this, arguments, void 0, function* (button, email, password, page = puppeteer_1.default.defaultPage, newPage = true, staySignIn = true) {
247
- var _a;
248
247
  const email_input = 'input[type="email"]';
249
- const password_input = 'input[type="password"]';
248
+ const password_input = 'input[type="password"]:not([aria-hidden="true"])';
249
+ const account_type_tile = 'div.table';
250
+ const stay_signed_in_checkbox = 'input[name="DontShowAgain"]';
251
+ const login_error = '#usernameError, #passwordError';
250
252
  yield this.clickAndWaitForPageToBeCreated(button, page, newPage);
251
253
  const pages = yield page.browser().pages();
252
254
  const loginPage = pages[pages.length - 1];
253
255
  yield this.extend_page_functions(loginPage);
254
- yield this.waitForResponse('signin-options', true, loginPage);
256
+ yield this.waitForSelector('visible', email_input, this.defaultTimeout, loginPage);
255
257
  yield loginPage.type(email_input, email, { delay: 0 });
256
258
  yield loginPage.keyboard.press('Enter');
257
- yield this.waitForResponse('arrow_left', true, loginPage);
258
- let isWorkOrPersonalVisible = yield page.$('div.table');
259
- if (!!isWorkOrPersonalVisible) {
260
- yield (yield page.$$('div.table'))[0].click();
261
- console.log('Then', 'I clicked Work or school account', AuxTA_1.StepStatus.PASSED);
262
- yield this.waitForResponse('microsoft_logo', true, loginPage);
259
+ try {
260
+ yield loginPage.waitForSelector(`${password_input}, ${account_type_tile}, ${login_error}`, {
261
+ visible: true,
262
+ timeout: this.defaultTimeout
263
+ });
264
+ }
265
+ catch (e) {
266
+ this.log('Then', `I wait for the password step of the microsoft login`, AuxTA_1.StepStatus.FAILED);
267
+ throw new Error(`I wait for the password step of the microsoft login`);
268
+ }
269
+ yield this.failOnMicrosoftLoginError(loginPage, login_error);
270
+ const accountTypeTile = yield loginPage.$(account_type_tile);
271
+ if (accountTypeTile && (yield accountTypeTile.isVisible())) {
272
+ yield accountTypeTile.click();
273
+ this.log('Then', 'I click on the Work or school account', AuxTA_1.StepStatus.PASSED);
263
274
  }
264
275
  try {
265
- yield this.timeout(1000);
266
- (_a = (yield loginPage.$(password_input))) === null || _a === void 0 ? void 0 : _a.type(password);
267
- yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.PASSED);
276
+ const passwordField = yield loginPage.waitForSelector(password_input, {
277
+ visible: true,
278
+ timeout: this.defaultTimeout
279
+ });
280
+ yield passwordField.type(password, { delay: 0 });
281
+ const typedLength = yield passwordField.evaluate((e) => e.value.length);
282
+ if (typedLength !== password.length) {
283
+ throw new Error(`Typed ${typedLength} of ${password.length} password characters`);
284
+ }
285
+ this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.PASSED);
268
286
  }
269
287
  catch (e) {
270
- yield this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.FAILED);
288
+ this.log('Then', `I type password into the ${password_input}`, AuxTA_1.StepStatus.FAILED);
271
289
  throw new Error(`I type password into the ${password_input}`);
272
290
  }
273
- yield this.timeout(1000);
274
291
  yield loginPage.keyboard.press('Enter');
275
292
  if (staySignIn) {
276
- yield this.waitForResponse('4_eae2dd7eb3a55636dc2d74f4fa4c386e', true, loginPage);
277
- yield this.timeout(1000);
278
- yield loginPage.keyboard.press('Enter');
293
+ let outcome;
294
+ try {
295
+ const handle = yield loginPage.waitForFunction((checkbox, error) => {
296
+ const errorElement = document.querySelector(error);
297
+ if (errorElement && errorElement.offsetParent !== null)
298
+ return 'error';
299
+ if (document.querySelector(checkbox))
300
+ return 'prompt';
301
+ if (!/(^|\.)(login\.microsoftonline\.com|login\.live\.com)$/.test(location.hostname))
302
+ return 'redirected';
303
+ return false;
304
+ }, { timeout: this.defaultTimeout, polling: 500 }, stay_signed_in_checkbox, login_error);
305
+ outcome = (yield handle.jsonValue());
306
+ }
307
+ catch (e) {
308
+ this.log('Then', `I wait for the Stay signed in prompt of the microsoft login`, AuxTA_1.StepStatus.FAILED);
309
+ throw new Error(`I wait for the Stay signed in prompt of the microsoft login`);
310
+ }
311
+ if (outcome === 'error') {
312
+ yield this.failOnMicrosoftLoginError(loginPage, login_error);
313
+ }
314
+ else if (outcome === 'prompt') {
315
+ yield this.waitForSelector('visible', stay_signed_in_checkbox, this.defaultTimeout, loginPage, false);
316
+ yield loginPage.keyboard.press('Enter');
317
+ this.log('Then', `I confirm the Stay signed in prompt`, AuxTA_1.StepStatus.PASSED);
318
+ }
319
+ else {
320
+ this.log('Then', `The Stay signed in prompt was not shown`, AuxTA_1.StepStatus.PASSED);
321
+ }
322
+ }
323
+ });
324
+ }
325
+ failOnMicrosoftLoginError(loginPage, login_error) {
326
+ return __awaiter(this, void 0, void 0, function* () {
327
+ const errorElement = yield loginPage.$(login_error);
328
+ if (errorElement && (yield errorElement.isVisible())) {
329
+ const errorText = yield errorElement.evaluate((e) => { var _a; return (_a = e.textContent) === null || _a === void 0 ? void 0 : _a.trim(); });
330
+ const message = `The microsoft login shows an error: ${errorText}`;
331
+ this.log('Then', message, AuxTA_1.StepStatus.FAILED);
332
+ throw new Error(message);
279
333
  }
280
334
  });
281
335
  }
@@ -145,6 +145,7 @@ class Puppeteer {
145
145
  }
146
146
  startBrowser() {
147
147
  return __awaiter(this, void 0, void 0, function* () {
148
+ var _a;
148
149
  let args = [];
149
150
  if (process.env.ENVIRONMENT === 'LOCAL') {
150
151
  args.push('--start-maximized');
@@ -152,12 +153,11 @@ class Puppeteer {
152
153
  args.push(`--window-size=${config_1.config.screenWidth ? config_1.config.screenWidth : 1920},${config_1.config.screenHeight ? config_1.config.screenHeight : 1080}`);
153
154
  args.push("--no-sandbox", "--disable-setuid-sandbox", "--disable-gpu");
154
155
  args.push('--enable-automation=false');
155
- let env = {
156
- DISPLAY: ":10.0"
157
- };
156
+ args.push('--disable-dev-shm-usage');
157
+ let env = Object.assign(Object.assign({}, process.env), { DISPLAY: (_a = process.env.DISPLAY) !== null && _a !== void 0 ? _a : ":10.0" });
158
158
  this.browser = yield puppeteer.default.launch({
159
159
  slowMo: process.env.slowMo ? Number(process.env.slowMo) : 0,
160
- executablePath: puppeteer.default.executablePath(),
160
+ executablePath: yield puppeteer.default.executablePath(),
161
161
  args,
162
162
  env,
163
163
  ignoreDefaultArgs: ["--enable-automation"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auxcode/auxta",
3
- "version": "1.3.128",
3
+ "version": "1.3.130",
4
4
  "description": "",
5
5
  "main": "./build/AuxTA.js",
6
6
  "types": "./build/AuxTA.d.ts",
@@ -15,21 +15,21 @@
15
15
  "author": "auxcode",
16
16
  "license": "ISC",
17
17
  "dependencies": {
18
- "@types/node": "^17.0.9",
18
+ "@types/node": "^26.0.0",
19
19
  "axios": "^1.13.5",
20
- "dotenv": "^10.0.0",
21
- "dotenv-extended": "^2.9.0",
20
+ "dotenv": "^17.4.2",
21
+ "dotenv-extended": "^3.1.0",
22
22
  "fs": "^0.0.1-security",
23
23
  "js-base64": "^3.7.5",
24
- "moment-timezone": "^0.5.45",
24
+ "moment-timezone": "^0.6.1",
25
25
  "node-2fa": "^2.0.3",
26
- "nodemailer": "^8.0.4",
27
- "puppeteer": "^24.39.0",
26
+ "nodemailer": "^9.0.1",
27
+ "puppeteer": "^25.1.0",
28
28
  "readline": "^1.3.0",
29
- "typescript": "^5.9.2"
29
+ "typescript": "^6.0.3"
30
30
  },
31
31
  "devDependencies": {
32
- "@babel/preset-typescript": "^7.23.3"
32
+ "@babel/preset-typescript": "^8.0.1"
33
33
  },
34
34
  "overrides": {
35
35
  "js-yaml": "4.1.1"