ag-awsauth 0.0.277 → 0.0.278
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/helpers/browser.js +84 -95
- package/package.json +1 -1
package/dist/helpers/browser.js
CHANGED
|
@@ -11,7 +11,6 @@ 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 */
|
|
15
14
|
const log_1 = require("ag-common/dist/common/helpers/log");
|
|
16
15
|
const puppeteer_1 = require("puppeteer");
|
|
17
16
|
const __1 = require("..");
|
|
@@ -136,105 +135,95 @@ function getMFA(p) {
|
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
137
|
//
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
138
|
+
(0, log_1.info)('mfa block');
|
|
139
|
+
//enter mfa
|
|
140
|
+
const { mfa } = (0, input_1.enterMFA)();
|
|
141
|
+
yield page.waitForSelector('.awsui-input-type-text', {
|
|
142
|
+
timeout: config_1.timeoutMedMs,
|
|
143
|
+
});
|
|
144
|
+
yield page.focus('.awsui-input-type-text');
|
|
145
|
+
yield page.keyboard.type(mfa);
|
|
146
|
+
yield page.$eval('.awsui-signin-button-container button', (el) => el.click());
|
|
147
|
+
//wait up to timeoutMs until url redirects, and ends up on https://d-9067b92b3b.awsapps.com/start/#/device?user_code=.*?
|
|
148
|
+
try {
|
|
149
|
+
(0, log_1.info)('waiting for redirect to device page');
|
|
150
|
+
yield page.waitForFunction(() => {
|
|
151
|
+
const url = window.location.href;
|
|
152
|
+
return url.includes('awsapps.com/start/#/device?user_code=');
|
|
153
|
+
}, { timeout: config_1.timeoutMs });
|
|
154
|
+
(0, log_1.info)('successfully redirected to device page');
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
(0, log_1.warn)('timeout waiting for device page redirect:', e);
|
|
158
|
+
// Continue anyway as the flow might still work
|
|
159
|
+
}
|
|
160
|
+
try {
|
|
161
|
+
yield waitForNetworkIdleSafe(page, {
|
|
162
|
+
idleTime: 250,
|
|
163
|
+
timeout: config_1.timeoutShortMs,
|
|
146
164
|
});
|
|
147
|
-
|
|
148
|
-
yield page.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
(0, log_1.info)('
|
|
153
|
-
yield
|
|
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
|
-
}
|
|
180
|
-
//
|
|
181
|
-
try {
|
|
182
|
-
yield waitForNetworkIdleSafe(page, {
|
|
183
|
-
idleTime: 250,
|
|
184
|
-
timeout: config_1.timeoutShortMs,
|
|
185
|
-
});
|
|
186
|
-
(0, log_1.info)('waiting for potential error');
|
|
187
|
-
const messageDiv = yield page.waitForSelector('.awsui-alert-message', {
|
|
188
|
-
timeout: config_1.timeoutShortMs,
|
|
189
|
-
});
|
|
190
|
-
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);
|
|
191
|
-
if (value) {
|
|
192
|
-
throw new Error(value);
|
|
193
|
-
}
|
|
165
|
+
(0, log_1.info)('try to click cookie decline');
|
|
166
|
+
const messageDiv = yield page.waitForSelector('[data-id="awsccc-cb-btn-decline"]', {
|
|
167
|
+
timeout: config_1.timeoutShortMs,
|
|
168
|
+
});
|
|
169
|
+
if (messageDiv) {
|
|
170
|
+
(0, log_1.info)('click decline');
|
|
171
|
+
yield messageDiv.click();
|
|
194
172
|
}
|
|
195
|
-
|
|
196
|
-
|
|
173
|
+
}
|
|
174
|
+
catch (e) {
|
|
175
|
+
(0, log_1.debug)('error clicking decline:', e);
|
|
176
|
+
}
|
|
177
|
+
//
|
|
178
|
+
try {
|
|
179
|
+
yield waitForNetworkIdleSafe(page, {
|
|
180
|
+
idleTime: 250,
|
|
181
|
+
timeout: config_1.timeoutShortMs,
|
|
182
|
+
});
|
|
183
|
+
(0, log_1.info)('waiting for potential error');
|
|
184
|
+
const messageDiv = yield page.waitForSelector('.awsui-alert-message', {
|
|
185
|
+
timeout: config_1.timeoutShortMs,
|
|
186
|
+
});
|
|
187
|
+
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);
|
|
188
|
+
if (value) {
|
|
189
|
+
throw new Error(value);
|
|
197
190
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
191
|
+
}
|
|
192
|
+
catch (e) {
|
|
193
|
+
(0, log_1.debug)('error waiting for potential error:', e);
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
(0, log_1.info)('accept-user-code');
|
|
197
|
+
const messageDiv = yield page.waitForSelector('[data-analytics="accept-user-code"]', {
|
|
198
|
+
timeout: config_1.timeoutMs,
|
|
199
|
+
});
|
|
200
|
+
if (messageDiv) {
|
|
201
|
+
(0, log_1.info)('click accept-user-code');
|
|
202
|
+
yield messageDiv.click();
|
|
210
203
|
}
|
|
211
|
-
|
|
212
|
-
|
|
204
|
+
else {
|
|
205
|
+
throw new Error('access prompt not found');
|
|
213
206
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
207
|
+
}
|
|
208
|
+
catch (e) {
|
|
209
|
+
(0, log_1.debug)('error accepting user code:', e);
|
|
210
|
+
}
|
|
211
|
+
try {
|
|
212
|
+
(0, log_1.info)('allow-access-button');
|
|
213
|
+
const messageDiv = yield page.waitForSelector('[data-testid="allow-access-button"]', {
|
|
214
|
+
timeout: config_1.timeoutMedMs,
|
|
215
|
+
});
|
|
216
|
+
if (messageDiv) {
|
|
217
|
+
(0, log_1.info)('click allow-access-button');
|
|
218
|
+
yield messageDiv.click();
|
|
226
219
|
}
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
if (!em.includes('exceeded')) {
|
|
230
|
-
const em2 = `mfa error:` + em + ' retry';
|
|
231
|
-
(0, log_1.error)(em2);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
retry = false;
|
|
235
|
-
}
|
|
220
|
+
else {
|
|
221
|
+
throw new Error('access prompt not found');
|
|
236
222
|
}
|
|
237
|
-
}
|
|
223
|
+
}
|
|
224
|
+
catch (e) {
|
|
225
|
+
(0, log_1.debug)('error clicking allow-access-button:', e);
|
|
226
|
+
}
|
|
238
227
|
try {
|
|
239
228
|
const verif = yield page.waitForSelector('#cli_verification_btn', {
|
|
240
229
|
timeout: config_1.timeoutShortMs,
|
|
@@ -244,8 +233,8 @@ function getMFA(p) {
|
|
|
244
233
|
yield verif.click();
|
|
245
234
|
}
|
|
246
235
|
}
|
|
247
|
-
catch (
|
|
248
|
-
|
|
236
|
+
catch (e) {
|
|
237
|
+
(0, log_1.debug)('error clicking auth request button:', e);
|
|
249
238
|
}
|
|
250
239
|
//
|
|
251
240
|
(0, log_1.info)('waiting for success');
|