ag-awsauth 0.0.275 → 0.0.277
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 +1 -0
- package/dist/config.js +2 -2
- package/dist/helpers/browser.d.ts +2 -1
- package/dist/helpers/browser.js +86 -30
- package/dist/helpers/oidc.js +1 -0
- package/dist/helpers/version.js +0 -1
- package/dist/index.js +1 -3
- package/package.json +17 -19
package/dist/config.d.ts
CHANGED
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.timeoutShortMs = 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;
|
|
6
|
+
exports.timeoutMedMs = exports.timeoutShortMs = 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"));
|
|
@@ -48,9 +48,9 @@ const runConfig = () => {
|
|
|
48
48
|
c.identityCenterRegion = ' //eg us-east-1';
|
|
49
49
|
}
|
|
50
50
|
fs_1.default.writeFileSync(pn, (0, envfile_1.stringify)(c));
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
52
51
|
require('child_process').exec(`start "" "${pn}"`);
|
|
53
52
|
};
|
|
54
53
|
exports.runConfig = runConfig;
|
|
55
54
|
exports.timeoutMs = 30000;
|
|
56
55
|
exports.timeoutShortMs = 3000;
|
|
56
|
+
exports.timeoutMedMs = 6000;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Page } from 'puppeteer';
|
|
1
2
|
export declare const closeBrowser: () => Promise<void>;
|
|
2
3
|
export declare const launchBrowser: () => Promise<void>;
|
|
3
|
-
export declare const goToPage: (url: string) => Promise<
|
|
4
|
+
export declare const goToPage: (url: string) => Promise<Page>;
|
|
4
5
|
export declare function getMFA(p: {
|
|
5
6
|
verificationUriComplete: string;
|
|
6
7
|
creds: {
|
package/dist/helpers/browser.js
CHANGED
|
@@ -11,13 +11,24 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.goToPage = exports.launchBrowser = exports.closeBrowser = void 0;
|
|
13
13
|
exports.getMFA = getMFA;
|
|
14
|
+
/* eslint-disable no-await-in-loop */
|
|
14
15
|
const log_1 = require("ag-common/dist/common/helpers/log");
|
|
15
|
-
const sleep_1 = require("ag-common/dist/common/helpers/sleep");
|
|
16
16
|
const puppeteer_1 = require("puppeteer");
|
|
17
17
|
const __1 = require("..");
|
|
18
18
|
const config_1 = require("../config");
|
|
19
19
|
const input_1 = require("./input");
|
|
20
20
|
let browser;
|
|
21
|
+
/**
|
|
22
|
+
* Helper to wait for network idle, ignoring timeout errors
|
|
23
|
+
*/
|
|
24
|
+
const waitForNetworkIdleSafe = (page_1, ...args_1) => __awaiter(void 0, [page_1, ...args_1], void 0, function* (page, options = {}) {
|
|
25
|
+
try {
|
|
26
|
+
yield page.waitForNetworkIdle(options);
|
|
27
|
+
}
|
|
28
|
+
catch (_a) {
|
|
29
|
+
// Ignore timeout errors
|
|
30
|
+
}
|
|
31
|
+
});
|
|
21
32
|
const closeBrowser = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
33
|
try {
|
|
23
34
|
if (!browser) {
|
|
@@ -35,17 +46,15 @@ const launchBrowser = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
35
46
|
const opt = {
|
|
36
47
|
defaultViewport: { height: 1000, width: 500 },
|
|
37
48
|
headless: (__1.globalargs === null || __1.globalargs === void 0 ? void 0 : __1.globalargs.verbose) ? false : true,
|
|
38
|
-
ignoreHTTPSErrors: true,
|
|
39
49
|
devtools: false,
|
|
50
|
+
args: [
|
|
51
|
+
'--disable-features=AudioServiceOutOfProcess',
|
|
52
|
+
'--disable-features=AudioServiceOutOfProcessKillAtHang',
|
|
53
|
+
'--disable-software-rasterizer',
|
|
54
|
+
'--disable-gpu',
|
|
55
|
+
'--disable-dev-shm-usage',
|
|
56
|
+
],
|
|
40
57
|
};
|
|
41
|
-
if (!opt.args) {
|
|
42
|
-
opt.args = [];
|
|
43
|
-
}
|
|
44
|
-
opt.args.push('--disable-features=AudioServiceOutOfProcess');
|
|
45
|
-
opt.args.push('--disable-features=AudioServiceOutOfProcessKillAtHang');
|
|
46
|
-
opt.args.push('--disable-software-rasterizer');
|
|
47
|
-
opt.args.push('--disable-gpu');
|
|
48
|
-
opt.args.push('--disable-dev-shm-usage');
|
|
49
58
|
yield (0, exports.closeBrowser)();
|
|
50
59
|
(0, log_1.debug)('launch browser, opt=', opt);
|
|
51
60
|
browser = (yield (0, puppeteer_1.launch)(opt));
|
|
@@ -92,7 +101,7 @@ function getMFA(p) {
|
|
|
92
101
|
yield verif.click();
|
|
93
102
|
}
|
|
94
103
|
}
|
|
95
|
-
catch (
|
|
104
|
+
catch (_b) {
|
|
96
105
|
//
|
|
97
106
|
}
|
|
98
107
|
//
|
|
@@ -107,14 +116,8 @@ function getMFA(p) {
|
|
|
107
116
|
yield page.focus('#password-input input');
|
|
108
117
|
yield page.keyboard.type(p.creds.password);
|
|
109
118
|
yield page.$eval('#password-submit-button button', (el) => el.click());
|
|
110
|
-
yield (0, sleep_1.sleep)(250);
|
|
111
|
-
try {
|
|
112
|
-
yield page.waitForNetworkIdle({ idleTime: 250, timeout: 3000 });
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
//
|
|
116
|
-
}
|
|
117
119
|
try {
|
|
120
|
+
yield waitForNetworkIdleSafe(page, { idleTime: 250, timeout: 3000 });
|
|
118
121
|
(0, log_1.info)('wait optional alert message');
|
|
119
122
|
const messageDiv = yield page.waitForSelector('.awsui-alert-message', {
|
|
120
123
|
timeout: config_1.timeoutShortMs,
|
|
@@ -136,17 +139,50 @@ function getMFA(p) {
|
|
|
136
139
|
let retry = true;
|
|
137
140
|
do {
|
|
138
141
|
(0, log_1.info)('mfa block');
|
|
142
|
+
//enter mfa
|
|
139
143
|
const { mfa } = (0, input_1.enterMFA)();
|
|
140
144
|
yield page.waitForSelector('.awsui-input-type-text', {
|
|
141
|
-
timeout: config_1.
|
|
145
|
+
timeout: config_1.timeoutMedMs,
|
|
142
146
|
});
|
|
143
147
|
yield page.focus('.awsui-input-type-text');
|
|
144
148
|
yield page.keyboard.type(mfa);
|
|
145
149
|
yield page.$eval('.awsui-signin-button-container button', (el) => el.click());
|
|
150
|
+
//wait up to timeoutMs until url redirects, and ends up on https://d-9067b92b3b.awsapps.com/start/#/device?user_code=.*?
|
|
151
|
+
try {
|
|
152
|
+
(0, log_1.info)('waiting for redirect to device page');
|
|
153
|
+
yield page.waitForFunction(() => {
|
|
154
|
+
const url = window.location.href;
|
|
155
|
+
return url.includes('awsapps.com/start/#/device?user_code=');
|
|
156
|
+
}, { timeout: config_1.timeoutMs });
|
|
157
|
+
(0, log_1.info)('successfully redirected to device page');
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
(0, log_1.warn)('timeout waiting for device page redirect:', e);
|
|
161
|
+
// Continue anyway as the flow might still work
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
yield waitForNetworkIdleSafe(page, {
|
|
165
|
+
idleTime: 250,
|
|
166
|
+
timeout: config_1.timeoutShortMs,
|
|
167
|
+
});
|
|
168
|
+
(0, log_1.info)('try to click cookie decline');
|
|
169
|
+
const messageDiv = yield page.waitForSelector('[data-id="awsccc-cb-btn-decline"]', {
|
|
170
|
+
timeout: config_1.timeoutShortMs,
|
|
171
|
+
});
|
|
172
|
+
if (messageDiv) {
|
|
173
|
+
(0, log_1.info)('click decline');
|
|
174
|
+
yield messageDiv.click();
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (_c) {
|
|
178
|
+
//
|
|
179
|
+
}
|
|
146
180
|
//
|
|
147
181
|
try {
|
|
148
|
-
yield (
|
|
149
|
-
|
|
182
|
+
yield waitForNetworkIdleSafe(page, {
|
|
183
|
+
idleTime: 250,
|
|
184
|
+
timeout: config_1.timeoutShortMs,
|
|
185
|
+
});
|
|
150
186
|
(0, log_1.info)('waiting for potential error');
|
|
151
187
|
const messageDiv = yield page.waitForSelector('.awsui-alert-message', {
|
|
152
188
|
timeout: config_1.timeoutShortMs,
|
|
@@ -155,22 +191,30 @@ function getMFA(p) {
|
|
|
155
191
|
if (value) {
|
|
156
192
|
throw new Error(value);
|
|
157
193
|
}
|
|
158
|
-
retry = false;
|
|
159
194
|
}
|
|
160
|
-
catch (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
195
|
+
catch (_d) {
|
|
196
|
+
//
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
(0, log_1.info)('accept-user-code');
|
|
200
|
+
const messageDiv = yield page.waitForSelector('[data-analytics="accept-user-code"]', {
|
|
201
|
+
timeout: config_1.timeoutMs,
|
|
202
|
+
});
|
|
203
|
+
if (messageDiv) {
|
|
204
|
+
(0, log_1.info)('click access prompt');
|
|
205
|
+
yield messageDiv.click();
|
|
165
206
|
}
|
|
166
207
|
else {
|
|
167
|
-
|
|
208
|
+
throw new Error('access prompt not found');
|
|
168
209
|
}
|
|
169
210
|
}
|
|
211
|
+
catch (_e) {
|
|
212
|
+
//
|
|
213
|
+
}
|
|
170
214
|
try {
|
|
171
|
-
(0, log_1.info)('
|
|
215
|
+
(0, log_1.info)('allow-access-button');
|
|
172
216
|
const messageDiv = yield page.waitForSelector('[data-testid="allow-access-button"]', {
|
|
173
|
-
timeout: config_1.
|
|
217
|
+
timeout: config_1.timeoutMedMs,
|
|
174
218
|
});
|
|
175
219
|
if (messageDiv) {
|
|
176
220
|
(0, log_1.info)('click access prompt');
|
|
@@ -191,6 +235,18 @@ function getMFA(p) {
|
|
|
191
235
|
}
|
|
192
236
|
}
|
|
193
237
|
} while (retry);
|
|
238
|
+
try {
|
|
239
|
+
const verif = yield page.waitForSelector('#cli_verification_btn', {
|
|
240
|
+
timeout: config_1.timeoutShortMs,
|
|
241
|
+
});
|
|
242
|
+
if (verif) {
|
|
243
|
+
(0, log_1.info)('clicking auth request button');
|
|
244
|
+
yield verif.click();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (_f) {
|
|
248
|
+
//
|
|
249
|
+
}
|
|
194
250
|
//
|
|
195
251
|
(0, log_1.info)('waiting for success');
|
|
196
252
|
yield page.waitForSelector('[data-analytics-alert="success"]', {
|
package/dist/helpers/oidc.js
CHANGED
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.requestMFA = requestMFA;
|
|
13
|
+
/* eslint-disable no-await-in-loop */
|
|
13
14
|
const client_sso_oidc_1 = require("@aws-sdk/client-sso-oidc");
|
|
14
15
|
const log_1 = require("ag-common/dist/common/helpers/log");
|
|
15
16
|
const sleep_1 = require("ag-common/dist/common/helpers/sleep");
|
package/dist/helpers/version.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.globalargs = void 0;
|
|
16
16
|
exports.main = main;
|
|
17
17
|
exports.run = run;
|
|
18
|
-
/* eslint-disable padding-line-between-statements */
|
|
19
18
|
const log_1 = require("ag-common/dist/common/helpers/log");
|
|
20
19
|
const dotenv_1 = require("dotenv");
|
|
21
20
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -44,7 +43,7 @@ function main(args) {
|
|
|
44
43
|
try {
|
|
45
44
|
fs_1.default.appendFileSync(config_1.logPath, JSON.stringify(a1, null, 2));
|
|
46
45
|
}
|
|
47
|
-
catch (
|
|
46
|
+
catch (_a) {
|
|
48
47
|
//
|
|
49
48
|
}
|
|
50
49
|
});
|
|
@@ -59,7 +58,6 @@ function main(args) {
|
|
|
59
58
|
}
|
|
60
59
|
if (args.wipe) {
|
|
61
60
|
(0, log_1.info)('wiping args');
|
|
62
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
63
61
|
yield (0, awsconfig_1.updateAwsCredentials)(undefined);
|
|
64
62
|
return;
|
|
65
63
|
}
|
package/package.json
CHANGED
|
@@ -5,13 +5,11 @@
|
|
|
5
5
|
"author": "andrei gec (andreigec@hotmail.com)",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"private": false,
|
|
8
|
-
"version": "0.0.
|
|
8
|
+
"version": "0.0.277",
|
|
9
9
|
"preferGlobal": true,
|
|
10
10
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"lint:eslint": "eslint --ext .ts,.tsx src",
|
|
14
|
-
"lint": "pnpm run /^lint:/",
|
|
11
|
+
"lint": "next lint",
|
|
12
|
+
"format": "eslint src --fix",
|
|
15
13
|
"start": "tsc && node bin/awsauth.js",
|
|
16
14
|
"build": "tsc"
|
|
17
15
|
},
|
|
@@ -25,26 +23,26 @@
|
|
|
25
23
|
"LICENSE.md"
|
|
26
24
|
],
|
|
27
25
|
"dependencies": {
|
|
28
|
-
"@aws-sdk/client-sso": "3.
|
|
29
|
-
"@aws-sdk/client-sso-oidc": "3.
|
|
30
|
-
"@aws-sdk/client-sts": "3.
|
|
31
|
-
"@aws-sdk/shared-ini-file-loader": "
|
|
32
|
-
"ag-common": "0.0.
|
|
26
|
+
"@aws-sdk/client-sso": "3.848.0",
|
|
27
|
+
"@aws-sdk/client-sso-oidc": "3.848.0",
|
|
28
|
+
"@aws-sdk/client-sts": "3.848.0",
|
|
29
|
+
"@aws-sdk/shared-ini-file-loader": "3.374.0",
|
|
30
|
+
"ag-common": "0.0.755",
|
|
33
31
|
"cli-select": "1.1.2",
|
|
34
|
-
"dotenv": "
|
|
32
|
+
"dotenv": "17.2.1",
|
|
35
33
|
"envfile": "7.1.0",
|
|
36
|
-
"eslint-config-e7npm": "0.
|
|
37
|
-
"ini": "
|
|
38
|
-
"node-fetch": "
|
|
39
|
-
"puppeteer": "
|
|
34
|
+
"eslint-config-e7npm": "0.1.23",
|
|
35
|
+
"ini": "5.0.0",
|
|
36
|
+
"node-fetch": "3.3.2",
|
|
37
|
+
"puppeteer": "24.15.0",
|
|
40
38
|
"readline-sync": "1.4.10",
|
|
41
|
-
"typescript": "5.
|
|
42
|
-
"yargs": "
|
|
39
|
+
"typescript": "5.8.3",
|
|
40
|
+
"yargs": "18.0.0"
|
|
43
41
|
},
|
|
44
42
|
"devDependencies": {
|
|
45
43
|
"@types/ini": "4.1.1",
|
|
46
|
-
"@types/node": "
|
|
47
|
-
"@types/node-fetch": "2.6.
|
|
44
|
+
"@types/node": "24.1.0",
|
|
45
|
+
"@types/node-fetch": "2.6.12",
|
|
48
46
|
"@types/readline-sync": "1.4.8",
|
|
49
47
|
"@types/yargs": "17.0.33"
|
|
50
48
|
},
|