@intuned/runtime-dev 1.0.6-cli-auth.0.0.19-test → 1.0.6-cli-auth.0.1.0-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;
|
|
@@ -186,7 +189,9 @@ async function storeAuthSessionInstance(authSessionInstance, customName, authSes
|
|
|
186
189
|
const authSessionMetadata = {
|
|
187
190
|
createdAt: existingMetadata.createdAt || new Date().toISOString(),
|
|
188
191
|
updatedAt: new Date().toISOString(),
|
|
189
|
-
|
|
192
|
+
...(projectAuthConfig.type === "API" && {
|
|
193
|
+
authSessionInput: authSessionInput || existingMetadata.authSessionInput || {}
|
|
194
|
+
}),
|
|
190
195
|
authSessionId: authSessionInstanceId,
|
|
191
196
|
authSessionType: projectAuthConfig.type ?? existingMetadata.authSessionType ?? "API",
|
|
192
197
|
...(projectAuthConfig.type === "MANUAL" && {
|
|
@@ -258,13 +263,12 @@ async function getStorageState(context) {
|
|
|
258
263
|
}
|
|
259
264
|
async function recordAuthSession(startUrl, endUrl) {
|
|
260
265
|
let browser;
|
|
261
|
-
let context;
|
|
262
266
|
try {
|
|
263
267
|
browser = await playwright.chromium.launch({
|
|
264
268
|
headless: false,
|
|
265
269
|
args: ["--start-maximized", "--no-sandbox"]
|
|
266
270
|
});
|
|
267
|
-
context = await browser.newContext({
|
|
271
|
+
const context = await browser.newContext({
|
|
268
272
|
viewport: null
|
|
269
273
|
});
|
|
270
274
|
const page = await context.newPage();
|
|
@@ -272,10 +276,9 @@ async function recordAuthSession(startUrl, endUrl) {
|
|
|
272
276
|
await page.waitForURL(url => url.toString().startsWith(endUrl), {
|
|
273
277
|
timeout: 300000
|
|
274
278
|
});
|
|
275
|
-
const storageState = await context
|
|
279
|
+
const storageState = await getStorageState(context);
|
|
276
280
|
return storageState;
|
|
277
281
|
} catch (error) {
|
|
278
|
-
console.error("Failed to record authentication session:", error);
|
|
279
282
|
throw new Error(`Authentication recording failed: ${error.message}`);
|
|
280
283
|
} finally {
|
|
281
284
|
if (browser) {
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
const exclusions = ["node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo", "tsconfig.json", "parameters/**", "output/**", "README.md"];
|
|
7
|
+
const exclusions = ["node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**", ".next/**", ".cache/**", "out/**", "tmp/**", ".DS_Store", "npm-debug.log*", "yarn-debug.log*", "yarn-error.log*", ".env", ".env.*", "**/*.map", "**/*.tsbuildinfo", "tsconfig.json", "parameters/**", "output/**", "auth-sessions-instances/**", "README.md"];
|
|
8
8
|
var _default = exports.default = exclusions;
|
|
@@ -59,9 +59,9 @@ export type AuthSessionType = "API" | "MANUAL";
|
|
|
59
59
|
export type AuthSessionMetadata = {
|
|
60
60
|
createdAt: string;
|
|
61
61
|
updatedAt: string;
|
|
62
|
-
authSessionInput: Record<string, any>;
|
|
63
62
|
authSessionId: string;
|
|
64
63
|
authSessionType: AuthSessionType;
|
|
64
|
+
authSessionInput?: Record<string, any>;
|
|
65
65
|
recorderStartUrl?: string;
|
|
66
66
|
recorderEndUrl?: string;
|
|
67
67
|
};
|