@intuned/runtime-dev 1.0.6-cli-auth.0.0.19-test → 1.0.6-cli-auth.0.0.20-test
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.
|
@@ -9,9 +9,9 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
9
9
|
_dotenv.default.config({
|
|
10
10
|
path: `.env`
|
|
11
11
|
});
|
|
12
|
-
_commander.program.description("Check an auth session, if it is still valid or not").
|
|
12
|
+
_commander.program.description("Check an auth session, if it is still valid or not").argument("<auth-session>", "Name/id of the auth session instance to use").action(async authSession => {
|
|
13
13
|
try {
|
|
14
|
-
if (!
|
|
14
|
+
if (!authSession) {
|
|
15
15
|
throw new Error("Auth session instance is required, provide an ID/name for it");
|
|
16
16
|
}
|
|
17
17
|
const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
|
|
@@ -24,7 +24,7 @@ _commander.program.description("Check an auth session, if it is still valid or n
|
|
|
24
24
|
}
|
|
25
25
|
const {
|
|
26
26
|
authSessionInstanceStoragePath
|
|
27
|
-
} = await (0, _utils.retrieveAuthSessionInstance)(
|
|
27
|
+
} = await (0, _utils.retrieveAuthSessionInstance)(authSession, true);
|
|
28
28
|
const checkResult = await (0, _utils.runCheckApi)(authSessionInstanceStoragePath);
|
|
29
29
|
if (checkResult) {
|
|
30
30
|
console.log(_chalk.default.green("✓ Auth session checked successfully"));
|
|
@@ -10,7 +10,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
10
10
|
_dotenv.default.config({
|
|
11
11
|
path: `.env`
|
|
12
12
|
});
|
|
13
|
-
_commander.program.description("Create an auth session").
|
|
13
|
+
_commander.program.description("Create an auth session").argument("[auth-session-name]", "Name/id of the auth session instance to use (optional)").option("-i, --input <input>", "Auth session input parameters file").action(async (authSessionName, options) => {
|
|
14
14
|
try {
|
|
15
15
|
const _isAuthEnabled = await (0, _utils.isAuthEnabled)();
|
|
16
16
|
if (!_isAuthEnabled) {
|
|
@@ -26,7 +26,7 @@ _commander.program.description("Create an auth session").option("-i, --input <in
|
|
|
26
26
|
} = recorderConfig;
|
|
27
27
|
console.log(_chalk.default.blue("Starting auth session recorder..."));
|
|
28
28
|
const session = await (0, _utils.recordAuthSession)(startUrl, endUrl);
|
|
29
|
-
authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session,
|
|
29
|
+
authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, authSessionName, {});
|
|
30
30
|
} else {
|
|
31
31
|
const createApiExists = await (0, _utils.ensureAuthApi)("create");
|
|
32
32
|
if (!createApiExists) {
|
|
@@ -38,7 +38,7 @@ _commander.program.description("Create an auth session").option("-i, --input <in
|
|
|
38
38
|
console.error(_chalk.default.red("Failed to create auth session."));
|
|
39
39
|
process.exit(1);
|
|
40
40
|
}
|
|
41
|
-
authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session,
|
|
41
|
+
authSessionInstancePath = await (0, _utils.storeAuthSessionInstance)(session, authSessionName, authSessionInput);
|
|
42
42
|
}
|
|
43
43
|
console.log(_chalk.default.green("✓ Auth session created successfully!"));
|
|
44
44
|
if (authSessionInstancePath) {
|
|
@@ -153,6 +153,9 @@ async function runCheckApiViaCLI(authSessionPath) {
|
|
|
153
153
|
importFunction: _tsNodeImport.tsNodeImport
|
|
154
154
|
});
|
|
155
155
|
if (runApiResult.isErr()) {
|
|
156
|
+
if (runApiResult.error instanceof _runApi.AutomationError) {
|
|
157
|
+
throw runApiResult.error.error;
|
|
158
|
+
}
|
|
156
159
|
return false;
|
|
157
160
|
}
|
|
158
161
|
const result = runApiResult.value.result;
|
|
@@ -258,13 +261,12 @@ async function getStorageState(context) {
|
|
|
258
261
|
}
|
|
259
262
|
async function recordAuthSession(startUrl, endUrl) {
|
|
260
263
|
let browser;
|
|
261
|
-
let context;
|
|
262
264
|
try {
|
|
263
265
|
browser = await playwright.chromium.launch({
|
|
264
266
|
headless: false,
|
|
265
267
|
args: ["--start-maximized", "--no-sandbox"]
|
|
266
268
|
});
|
|
267
|
-
context = await browser.newContext({
|
|
269
|
+
const context = await browser.newContext({
|
|
268
270
|
viewport: null
|
|
269
271
|
});
|
|
270
272
|
const page = await context.newPage();
|
|
@@ -272,10 +274,9 @@ async function recordAuthSession(startUrl, endUrl) {
|
|
|
272
274
|
await page.waitForURL(url => url.toString().startsWith(endUrl), {
|
|
273
275
|
timeout: 300000
|
|
274
276
|
});
|
|
275
|
-
const storageState = await context
|
|
277
|
+
const storageState = await getStorageState(context);
|
|
276
278
|
return storageState;
|
|
277
279
|
} catch (error) {
|
|
278
|
-
console.error("Failed to record authentication session:", error);
|
|
279
280
|
throw new Error(`Authentication recording failed: ${error.message}`);
|
|
280
281
|
} finally {
|
|
281
282
|
if (browser) {
|