@intuned/runtime-dev 1.0.6-cli-auth.0.0.4-test → 1.0.6-cli-auth.0.0.5-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.
|
@@ -13,7 +13,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
13
13
|
_dotenv.default.config({
|
|
14
14
|
path: `.env`
|
|
15
15
|
});
|
|
16
|
-
_commander.program.description("Create an auth session").option("-i, --input <input>", "Auth session input parameters file").action(async options => {
|
|
16
|
+
_commander.program.description("Create an auth session").option("-i, --input <input>", "Auth session input parameters file").option("-n, --auth-session-name <output>", "Custom name for the auth session instance stored").action(async options => {
|
|
17
17
|
let authSessionInput = {};
|
|
18
18
|
if (options.input) {
|
|
19
19
|
const authSessionInputFile = options.input;
|
|
@@ -21,8 +21,14 @@ _commander.program.description("Create an auth session").option("-i, --input <in
|
|
|
21
21
|
authSessionInput = await fs.readJSON(authSessionInputPath);
|
|
22
22
|
}
|
|
23
23
|
const session = await (0, _utils.runCreateApi)(authSessionInput);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
if (!session) {
|
|
25
|
+
console.error(_chalk.default.red("Failed to create auth session."));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const authSessionInstancePath = await (0, _utils.storeAuthSessionInstace)(session, options.authSessionName);
|
|
29
|
+
console.log(_chalk.default.green("✓ Auth session created successfully!"));
|
|
30
|
+
if (authSessionInstancePath) {
|
|
31
|
+
console.log(_chalk.default.underline.green.white(`🔒 Auth session instance stored at ${authSessionInstancePath}`));
|
|
32
|
+
}
|
|
27
33
|
});
|
|
28
34
|
_commander.program.parse(process.argv);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { StorageState } from "../../common/contextStorageStateHelpers";
|
|
1
2
|
export declare function isAuthEnabled(): Promise<boolean>;
|
|
2
3
|
export declare function ensureCreateApi(): Promise<boolean>;
|
|
3
4
|
export declare function runCreateApi(authSessionInput: Record<string, any>): Promise<any>;
|
|
5
|
+
export declare function storeAuthSessionInstace(authSessionInstance: StorageState, customName?: string): Promise<string>;
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.ensureCreateApi = ensureCreateApi;
|
|
7
7
|
exports.isAuthEnabled = isAuthEnabled;
|
|
8
8
|
exports.runCreateApi = runCreateApi;
|
|
9
|
+
exports.storeAuthSessionInstace = storeAuthSessionInstace;
|
|
9
10
|
var _path = _interopRequireDefault(require("path"));
|
|
10
11
|
var _constants = require("../../common/constants");
|
|
11
12
|
var fs = _interopRequireWildcard(require("fs-extra"));
|
|
@@ -91,4 +92,18 @@ async function runCreateApiViaCLI(authSessionInput) {
|
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
return session;
|
|
95
|
+
}
|
|
96
|
+
async function storeAuthSessionInstace(authSessionInstance, customName) {
|
|
97
|
+
try {
|
|
98
|
+
const authSessionsDirectoryPath = _path.default.join(process.cwd(), _constants.AUTH_SESSIONS_INSTANCES_FOLDER_NAME);
|
|
99
|
+
await fs.ensureDir(authSessionsDirectoryPath);
|
|
100
|
+
const authSessionInstanceFileName = customName ?? `auth-session-${Date.now()}`;
|
|
101
|
+
const authSessionInstanceFilePath = _path.default.join(authSessionsDirectoryPath, `${authSessionInstanceFileName}.json`);
|
|
102
|
+
await fs.writeJSON(authSessionInstanceFilePath, authSessionInstance, {
|
|
103
|
+
spaces: 2
|
|
104
|
+
});
|
|
105
|
+
return authSessionInstanceFilePath;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
throw new Error(`Error storing auth session instance: ${error.message}`);
|
|
108
|
+
}
|
|
94
109
|
}
|
package/dist/common/constants.js
CHANGED
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
7
|
-
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
6
|
+
exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = void 0;
|
|
7
|
+
const AUTH_SESSIONS_FOLDER_NAME = exports.AUTH_SESSIONS_FOLDER_NAME = "auth-sessions";
|
|
8
|
+
const AUTH_SESSIONS_INSTANCES_FOLDER_NAME = exports.AUTH_SESSIONS_INSTANCES_FOLDER_NAME = "auth-sessions-instances";
|