ag-awsauth 0.0.4 → 0.0.6

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/dist/config.d.ts CHANGED
@@ -9,3 +9,4 @@ export declare let targetRegion: string;
9
9
  export declare const validateConfig: () => boolean;
10
10
  export declare const setConfig: () => void;
11
11
  export declare const runConfig: () => void;
12
+ export declare const timeoutMs = 10000;
package/dist/config.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.runConfig = exports.setConfig = exports.validateConfig = exports.targetRegion = exports.ssoStartUrl = exports.identityCenterRegion = exports.setBasePath = exports.basePath = exports.nativeStsDurationSeconds = exports.stsDurationSeconds = exports.logPath = void 0;
6
+ exports.timeoutMs = exports.runConfig = exports.setConfig = exports.validateConfig = exports.targetRegion = exports.ssoStartUrl = exports.identityCenterRegion = exports.setBasePath = exports.basePath = exports.nativeStsDurationSeconds = exports.stsDurationSeconds = exports.logPath = void 0;
7
7
  const envfile_1 = require("envfile");
8
8
  const fs_1 = __importDefault(require("fs"));
9
9
  const path_1 = __importDefault(require("path"));
@@ -52,3 +52,4 @@ const runConfig = () => {
52
52
  require('child_process').exec(`start "" "${pn}"`);
53
53
  };
54
54
  exports.runConfig = runConfig;
55
+ exports.timeoutMs = 10000;
@@ -14,6 +14,7 @@ const log_1 = require("ag-common/dist/common/helpers/log");
14
14
  const sleep_1 = require("ag-common/dist/common/helpers/sleep");
15
15
  const puppeteer_1 = require("puppeteer");
16
16
  const __1 = require("..");
17
+ const config_1 = require("../config");
17
18
  const input_1 = require("./input");
18
19
  let browser;
19
20
  const closeBrowser = () => __awaiter(void 0, void 0, void 0, function* () {
@@ -62,7 +63,7 @@ const goToPage = (url) => __awaiter(void 0, void 0, void 0, function* () {
62
63
  const page = yield browser.newPage();
63
64
  yield page.goto(url, {
64
65
  waitUntil: ['networkidle2'],
65
- timeout: 10000,
66
+ timeout: config_1.timeoutMs,
66
67
  });
67
68
  return page;
68
69
  }
@@ -80,13 +81,13 @@ function getMFA(p) {
80
81
  (0, log_1.info)('start mfa');
81
82
  const page = yield (0, exports.goToPage)(p.verificationUriComplete);
82
83
  (0, log_1.info)('username block');
83
- yield page.waitForSelector('#username-input');
84
+ yield page.waitForSelector('#username-input', { timeout: config_1.timeoutMs });
84
85
  yield page.focus('#username-input input');
85
86
  yield page.keyboard.type(p.creds.username);
86
87
  yield page.$eval('#username-submit-button button', (el) => el.click());
87
88
  //
88
89
  (0, log_1.info)('password block');
89
- yield page.waitForSelector('#password-input');
90
+ yield page.waitForSelector('#password-input', { timeout: config_1.timeoutMs });
90
91
  yield page.focus('#password-input input');
91
92
  yield page.keyboard.type(p.creds.password);
92
93
  yield page.$eval('#password-submit-button button', (el) => el.click());
@@ -95,7 +96,7 @@ function getMFA(p) {
95
96
  //
96
97
  try {
97
98
  const messageDiv = yield page.waitForSelector('.awsui-alert-message', {
98
- timeout: 2000,
99
+ timeout: 2000, //can be short
99
100
  });
100
101
  const value = yield page.evaluate((el) => { var _a; return (_a = el === null || el === void 0 ? void 0 : el.textContent) !== null && _a !== void 0 ? _a : ''; }, messageDiv);
101
102
  if (value) {
@@ -115,7 +116,7 @@ function getMFA(p) {
115
116
  do {
116
117
  (0, log_1.info)('mfa block');
117
118
  const { mfa } = (0, input_1.enterMFA)();
118
- yield page.waitForSelector('#input-0');
119
+ yield page.waitForSelector('#input-0', { timeout: config_1.timeoutMs });
119
120
  yield page.focus('#input-0 input');
120
121
  yield page.keyboard.type(mfa);
121
122
  yield page.$eval('.awsui-signin-button-container button', (el) => el.click());
@@ -124,7 +125,7 @@ function getMFA(p) {
124
125
  yield (0, sleep_1.sleep)(250);
125
126
  yield page.waitForNetworkIdle({ idleTime: 250 });
126
127
  const messageDiv = yield page.waitForSelector('.awsui-alert-message', {
127
- timeout: 2000,
128
+ timeout: 2000, // can be short
128
129
  });
129
130
  const value = yield page.evaluate((el) => { var _a; return (_a = el === null || el === void 0 ? void 0 : el.textContent) !== null && _a !== void 0 ? _a : ''; }, messageDiv);
130
131
  if (value) {
@@ -146,11 +147,13 @@ function getMFA(p) {
146
147
  //
147
148
  yield (0, sleep_1.sleep)(3000);
148
149
  yield page.waitForNetworkIdle({ idleTime: 250 });
149
- yield page.waitForSelector('#cli_login_button', { timeout: 5000 });
150
+ yield page.waitForSelector('#cli_login_button', { timeout: config_1.timeoutMs });
150
151
  yield page.$eval('#cli_login_button', (el) => el.click());
151
152
  yield (0, sleep_1.sleep)(250);
152
153
  yield page.waitForNetworkIdle({ idleTime: 250 });
153
- yield page.waitForSelector('.awsui-icon-variant-success', { timeout: 5000 });
154
+ yield page.waitForSelector('.awsui-icon-variant-success', {
155
+ timeout: config_1.timeoutMs,
156
+ });
154
157
  (0, log_1.warn)('mfa success');
155
158
  const cookies = yield (page === null || page === void 0 ? void 0 : page.cookies());
156
159
  const ssoAuthn = (_a = cookies === null || cookies === void 0 ? void 0 : cookies.find((c) => c.name === 'x-amz-sso_authn')) === null || _a === void 0 ? void 0 : _a.value;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "author": "andrei gec (andreigec@hotmail.com)",
6
6
  "license": "ISC",
7
7
  "private": false,
8
- "version": "0.0.4",
8
+ "version": "0.0.6",
9
9
  "preferGlobal": true,
10
10
  "bin": {
11
11
  "ag-awsauth": "./bin/awsauth.js"
@@ -21,7 +21,7 @@
21
21
  "@aws-sdk/client-sso-oidc": "3.272.0",
22
22
  "@aws-sdk/client-sts": "3.272.0",
23
23
  "@aws-sdk/shared-ini-file-loader": "3.272.0",
24
- "ag-common": "0.0.412",
24
+ "ag-common": "0.0.414",
25
25
  "cli-select": "1.1.2",
26
26
  "dotenv": "16.0.3",
27
27
  "envfile": "6.18.0",