@contentstack/cli-auth 1.6.1 → 1.6.3
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/LICENSE +1 -1
- package/README.md +2 -2
- package/lib/base-command.js +3 -1
- package/lib/commands/auth/login.js +11 -11
- package/lib/commands/auth/logout.js +7 -7
- package/lib/commands/auth/tokens/add.js +15 -15
- package/lib/commands/auth/tokens/index.js +10 -10
- package/lib/commands/auth/tokens/remove.js +14 -14
- package/lib/commands/auth/whoami.js +4 -4
- package/lib/utils/auth-handler.js +19 -19
- package/lib/utils/tokens-validation.js +14 -14
- package/oclif.manifest.json +1 -1
- package/package.json +3 -3
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ $ npm install -g @contentstack/cli-auth
|
|
|
18
18
|
$ csdx COMMAND
|
|
19
19
|
running command...
|
|
20
20
|
$ csdx (--version)
|
|
21
|
-
@contentstack/cli-auth/1.6.
|
|
21
|
+
@contentstack/cli-auth/1.6.3 linux-x64 node-v22.21.1
|
|
22
22
|
$ csdx --help [COMMAND]
|
|
23
23
|
USAGE
|
|
24
24
|
$ csdx COMMAND
|
|
@@ -145,7 +145,7 @@ FLAGS
|
|
|
145
145
|
-e, --environment=<value> Environment name for delivery token
|
|
146
146
|
-k, --stack-api-key=<value> Stack API Key
|
|
147
147
|
-m, --management Set this flag to save management token
|
|
148
|
-
-t, --token=<value> Add the token name
|
|
148
|
+
-t, --token=<value> [env: TOKEN] Add the token name
|
|
149
149
|
-y, --yes Use this flag to skip confirmation
|
|
150
150
|
|
|
151
151
|
DESCRIPTION
|
package/lib/base-command.js
CHANGED
|
@@ -9,8 +9,10 @@ class BaseCommand extends cli_command_1.Command {
|
|
|
9
9
|
* plugins, registering the configuration, and initializing the logger.
|
|
10
10
|
*/
|
|
11
11
|
async init() {
|
|
12
|
+
var _a, _b;
|
|
12
13
|
await super.init();
|
|
13
|
-
this.contextDetails =
|
|
14
|
+
// this.contextDetails = { ...this.createExportContext() };
|
|
15
|
+
this.contextDetails = Object.assign({}, (0, cli_utilities_1.createLogContext)(((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'auth', ''));
|
|
14
16
|
}
|
|
15
17
|
/**
|
|
16
18
|
* The catch function is used to handle errors from a command, either by adding custom logic or
|
|
@@ -7,11 +7,11 @@ class LoginCommand extends base_command_1.BaseCommand {
|
|
|
7
7
|
async run() {
|
|
8
8
|
cli_utilities_1.log.debug('LoginCommand run method started', this.contextDetails);
|
|
9
9
|
try {
|
|
10
|
-
cli_utilities_1.log.debug('Initializing
|
|
10
|
+
cli_utilities_1.log.debug('Initializing the Management API client.', this.contextDetails);
|
|
11
11
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.cmaHost, skipTokenValidity: true });
|
|
12
|
-
cli_utilities_1.log.debug('Management API client initialized successfully', this.contextDetails);
|
|
12
|
+
cli_utilities_1.log.debug('Management API client initialized successfully.', this.contextDetails);
|
|
13
13
|
const { flags: loginFlags } = await this.parse(LoginCommand);
|
|
14
|
-
cli_utilities_1.log.debug('Token add flags parsed', Object.assign(Object.assign({}, this.contextDetails), { flags: loginFlags }));
|
|
14
|
+
cli_utilities_1.log.debug('Token add flags parsed.', Object.assign(Object.assign({}, this.contextDetails), { flags: loginFlags }));
|
|
15
15
|
utils_1.authHandler.client = managementAPIClient;
|
|
16
16
|
cli_utilities_1.log.debug('Auth handler client set', this.contextDetails);
|
|
17
17
|
const oauth = loginFlags === null || loginFlags === void 0 ? void 0 : loginFlags.oauth;
|
|
@@ -31,7 +31,7 @@ class LoginCommand extends base_command_1.BaseCommand {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
catch (error) {
|
|
34
|
-
cli_utilities_1.log.debug('Login
|
|
34
|
+
cli_utilities_1.log.debug('Login failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
|
|
35
35
|
if (((error === null || error === void 0 ? void 0 : error.message) && (error === null || error === void 0 ? void 0 : error.message.includes('2FA'))) || (error === null || error === void 0 ? void 0 : error.message.includes('MFA'))) {
|
|
36
36
|
error.message = `${error.message}\nFor more information about MFA, visit: https://www.contentstack.com/docs/developers/security/multi-factor-authentication`;
|
|
37
37
|
}
|
|
@@ -55,19 +55,19 @@ class LoginCommand extends base_command_1.BaseCommand {
|
|
|
55
55
|
tfaToken = undefined;
|
|
56
56
|
}
|
|
57
57
|
const user = await utils_1.authHandler.login(username, password, tfaToken);
|
|
58
|
-
cli_utilities_1.log.debug('Auth handler login completed', Object.assign(Object.assign({}, this.contextDetails), { hasUser: !!user, hasAuthToken: !!(user === null || user === void 0 ? void 0 : user.authtoken), userEmail: user === null || user === void 0 ? void 0 : user.email }));
|
|
58
|
+
cli_utilities_1.log.debug('Auth handler login completed.', Object.assign(Object.assign({}, this.contextDetails), { hasUser: !!user, hasAuthToken: !!(user === null || user === void 0 ? void 0 : user.authtoken), userEmail: user === null || user === void 0 ? void 0 : user.email }));
|
|
59
59
|
if (typeof user !== 'object' || !user.authtoken || !user.email) {
|
|
60
|
-
cli_utilities_1.log.debug('Login failed
|
|
61
|
-
throw new cli_utilities_1.CLIError('
|
|
60
|
+
cli_utilities_1.log.debug('Login failed: Invalid user response', Object.assign(Object.assign({}, this.contextDetails), { user }));
|
|
61
|
+
throw new cli_utilities_1.CLIError('Login failed: Invalid response.');
|
|
62
62
|
}
|
|
63
|
-
cli_utilities_1.log.debug('Setting
|
|
63
|
+
cli_utilities_1.log.debug('Setting configuration data for basic authentication.', this.contextDetails);
|
|
64
64
|
await cli_utilities_1.authHandler.setConfigData('basicAuth', user);
|
|
65
|
-
cli_utilities_1.log.debug('
|
|
65
|
+
cli_utilities_1.log.debug('Configuration data set successfully.', this.contextDetails);
|
|
66
66
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('CLI_AUTH_LOGIN_SUCCESS'), this.contextDetails);
|
|
67
|
-
cli_utilities_1.log.debug('Login
|
|
67
|
+
cli_utilities_1.log.debug('Login completed successfully.', this.contextDetails);
|
|
68
68
|
}
|
|
69
69
|
catch (error) {
|
|
70
|
-
cli_utilities_1.log.debug('Login
|
|
70
|
+
cli_utilities_1.log.debug('Login failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
|
|
71
71
|
throw error;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -20,7 +20,7 @@ class LogoutCommand extends base_command_1.BaseCommand {
|
|
|
20
20
|
cli_utilities_1.log.debug(`User confirmation received: ${confirm}`, this.contextDetails);
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
-
cli_utilities_1.log.debug('Initializing
|
|
23
|
+
cli_utilities_1.log.debug('Initializing the Management API client for logout.', this.contextDetails);
|
|
24
24
|
const managementAPIClient = await (0, cli_utilities_1.managementSDKClient)({ host: this.cmaHost, skipTokenValidity: true });
|
|
25
25
|
cli_utilities_1.log.debug('Management API client initialized successfully', this.contextDetails);
|
|
26
26
|
utils_1.authHandler.client = managementAPIClient;
|
|
@@ -31,9 +31,9 @@ class LogoutCommand extends base_command_1.BaseCommand {
|
|
|
31
31
|
if (await cli_utilities_1.authHandler.isAuthorisationTypeBasic()) {
|
|
32
32
|
cli_utilities_1.log.debug('Using basic authentication for logout', this.contextDetails);
|
|
33
33
|
const authToken = cli_utilities_1.configHandler.get('authtoken');
|
|
34
|
-
cli_utilities_1.log.debug('
|
|
34
|
+
cli_utilities_1.log.debug('Authentication token retrieved for logout.', Object.assign(Object.assign({}, this.contextDetails), { hasAuthToken: !!authToken }));
|
|
35
35
|
await utils_1.authHandler.logout(authToken);
|
|
36
|
-
cli_utilities_1.log.debug('Basic
|
|
36
|
+
cli_utilities_1.log.debug('Basic authentication logout completed.', this.contextDetails);
|
|
37
37
|
}
|
|
38
38
|
else if (await cli_utilities_1.authHandler.isAuthorisationTypeOAuth()) {
|
|
39
39
|
cli_utilities_1.log.debug('Using OAuth authentication for logout', this.contextDetails);
|
|
@@ -42,7 +42,7 @@ class LogoutCommand extends base_command_1.BaseCommand {
|
|
|
42
42
|
}
|
|
43
43
|
cli_utilities_1.cliux.loader('');
|
|
44
44
|
cli_utilities_1.log.success(cli_utilities_1.messageHandler.parse('CLI_AUTH_LOGOUT_SUCCESS'), this.contextDetails);
|
|
45
|
-
cli_utilities_1.log.debug('Logout
|
|
45
|
+
cli_utilities_1.log.debug('Logout completed successfully.', this.contextDetails);
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
cli_utilities_1.log.debug('User not confirmed or not authenticated, skipping logout', Object.assign(Object.assign({}, this.contextDetails), { confirm, isAuthenticated: cli_utilities_1.authHandler.isAuthenticated() }));
|
|
@@ -50,15 +50,15 @@ class LogoutCommand extends base_command_1.BaseCommand {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
catch (error) {
|
|
53
|
-
cli_utilities_1.log.debug('Logout
|
|
53
|
+
cli_utilities_1.log.debug('Logout failed.', Object.assign(Object.assign({}, this.contextDetails), { error: error.message }));
|
|
54
54
|
cli_utilities_1.cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' });
|
|
55
55
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
|
|
56
56
|
}
|
|
57
57
|
finally {
|
|
58
58
|
if (confirm === true) {
|
|
59
|
-
cli_utilities_1.log.debug('Setting
|
|
59
|
+
cli_utilities_1.log.debug('Setting configuration data for logout.', this.contextDetails);
|
|
60
60
|
await cli_utilities_1.authHandler.setConfigData('logout');
|
|
61
|
-
cli_utilities_1.log.debug('
|
|
61
|
+
cli_utilities_1.log.debug('Configuration data set for logout.', this.contextDetails);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -5,10 +5,10 @@ const base_command_1 = require("../../../base-command");
|
|
|
5
5
|
const interactive_1 = require("../../../utils/interactive");
|
|
6
6
|
class TokensAddCommand extends base_command_1.BaseCommand {
|
|
7
7
|
async run() {
|
|
8
|
-
cli_utilities_1.log.debug('TokensAddCommand run method started', this.contextDetails);
|
|
8
|
+
cli_utilities_1.log.debug('TokensAddCommand run method started.', this.contextDetails);
|
|
9
9
|
this.contextDetails.module = 'tokens-add';
|
|
10
10
|
const { flags: addTokenFlags } = await this.parse(TokensAddCommand);
|
|
11
|
-
cli_utilities_1.log.debug('Token add flags parsed', Object.assign(Object.assign({}, this.contextDetails), { flags: addTokenFlags }));
|
|
11
|
+
cli_utilities_1.log.debug('Token add flags parsed.', Object.assign(Object.assign({}, this.contextDetails), { flags: addTokenFlags }));
|
|
12
12
|
let isAliasExist = false;
|
|
13
13
|
const skipAliasReplaceConfirmation = addTokenFlags.force || addTokenFlags.yes;
|
|
14
14
|
let alias = addTokenFlags.alias;
|
|
@@ -49,7 +49,7 @@ class TokensAddCommand extends base_command_1.BaseCommand {
|
|
|
49
49
|
cli_utilities_1.log.debug(`Alias replace confirmation: ${shouldAliasReplace}`, this.contextDetails);
|
|
50
50
|
if (!shouldAliasReplace) {
|
|
51
51
|
cli_utilities_1.log.debug('User declined alias replacement, exiting', this.contextDetails);
|
|
52
|
-
cli_utilities_1.log.info('Exiting
|
|
52
|
+
cli_utilities_1.log.info('Exiting the token replacement process.', this.contextDetails);
|
|
53
53
|
cli_utilities_1.cliux.print('CLI_AUTH_EXIT_PROCESS');
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
@@ -57,12 +57,12 @@ class TokensAddCommand extends base_command_1.BaseCommand {
|
|
|
57
57
|
if (!apiKey) {
|
|
58
58
|
cli_utilities_1.log.debug('No API key provided, requesting user input', this.contextDetails);
|
|
59
59
|
apiKey = await cli_utilities_1.cliux.inquire({ type: 'input', message: 'CLI_AUTH_TOKENS_ADD_ENTER_API_KEY', name: 'apiKey' });
|
|
60
|
-
cli_utilities_1.log.debug('API key obtained', Object.assign(Object.assign({}, this.contextDetails), { hasApiKey: !!apiKey }));
|
|
60
|
+
cli_utilities_1.log.debug('API key obtained.', Object.assign(Object.assign({}, this.contextDetails), { hasApiKey: !!apiKey }));
|
|
61
61
|
}
|
|
62
62
|
if (!token) {
|
|
63
63
|
cli_utilities_1.log.debug('No token provided, requesting user input', this.contextDetails);
|
|
64
64
|
token = await cli_utilities_1.cliux.inquire({ type: 'input', message: 'CLI_AUTH_TOKENS_ADD_ENTER_TOKEN', name: 'token' });
|
|
65
|
-
cli_utilities_1.log.debug('Token obtained', Object.assign(Object.assign({}, this.contextDetails), { hasToken: !!token }));
|
|
65
|
+
cli_utilities_1.log.debug('Token obtained.', Object.assign(Object.assign({}, this.contextDetails), { hasToken: !!token }));
|
|
66
66
|
}
|
|
67
67
|
if (isDelivery && !environment) {
|
|
68
68
|
cli_utilities_1.log.debug('Delivery token requires environment, requesting user input', this.contextDetails);
|
|
@@ -82,41 +82,41 @@ class TokensAddCommand extends base_command_1.BaseCommand {
|
|
|
82
82
|
cli_utilities_1.log.debug('Validating management token', Object.assign(Object.assign({}, this.contextDetails), { apiKeyStatus: apiKey ? 'provided' : 'not-provided' }));
|
|
83
83
|
// FIXME - Once the SDK refresh token issue is resolved, need to revert this back to SDK call
|
|
84
84
|
const httpClient = new cli_utilities_1.HttpClient({ headers: { api_key: apiKey, authorization: token } });
|
|
85
|
-
cli_utilities_1.log.debug('Making management token validation API call', this.contextDetails);
|
|
85
|
+
cli_utilities_1.log.debug('Making management token validation API call.', this.contextDetails);
|
|
86
86
|
const response = (await httpClient.get(`https://${this.cmaHost}/v3/environments?limit=1`)).data;
|
|
87
|
-
cli_utilities_1.log.debug('Management token validation response received', Object.assign(Object.assign({}, this.contextDetails), { response }));
|
|
87
|
+
cli_utilities_1.log.debug('Management token validation response received.', Object.assign(Object.assign({}, this.contextDetails), { response }));
|
|
88
88
|
if ((response === null || response === void 0 ? void 0 : response.error_code) === 105) {
|
|
89
|
-
cli_utilities_1.log.debug('Management token validation failed
|
|
89
|
+
cli_utilities_1.log.debug('Management token validation failed: invalid token.', this.contextDetails);
|
|
90
90
|
throw new Error(cli_utilities_1.messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_MANAGEMENT_TOKEN'));
|
|
91
91
|
}
|
|
92
92
|
else if (response === null || response === void 0 ? void 0 : response.error_message) {
|
|
93
93
|
cli_utilities_1.log.debug('Management token validation failed with error message', Object.assign(Object.assign({}, this.contextDetails), { errorMessage: response.error_message }));
|
|
94
94
|
throw new Error(response.error_message);
|
|
95
95
|
}
|
|
96
|
-
cli_utilities_1.log.debug('Management token validation successful', this.contextDetails);
|
|
96
|
+
cli_utilities_1.log.debug('Management token validation successful.', this.contextDetails);
|
|
97
97
|
}
|
|
98
98
|
cli_utilities_1.log.debug('Saving token to configuration', Object.assign(Object.assign({}, this.contextDetails), { alias,
|
|
99
99
|
type, hasEnvironment: !!environment }));
|
|
100
100
|
if (isManagement) {
|
|
101
101
|
cli_utilities_1.configHandler.set(`${configKeyTokens}.${alias}`, { token, apiKey, type });
|
|
102
|
-
cli_utilities_1.log.debug('Management token saved to configuration', this.contextDetails);
|
|
102
|
+
cli_utilities_1.log.debug('Management token saved to configuration.', this.contextDetails);
|
|
103
103
|
}
|
|
104
104
|
else {
|
|
105
105
|
cli_utilities_1.configHandler.set(`${configKeyTokens}.${alias}`, { token, apiKey, environment, type });
|
|
106
|
-
cli_utilities_1.log.debug('Delivery token saved to configuration', this.contextDetails);
|
|
106
|
+
cli_utilities_1.log.debug('Delivery token saved to configuration.', this.contextDetails);
|
|
107
107
|
}
|
|
108
108
|
if (isAliasExist) {
|
|
109
|
-
cli_utilities_1.log.debug('Token replaced successfully', this.contextDetails);
|
|
109
|
+
cli_utilities_1.log.debug('Token replaced successfully.', this.contextDetails);
|
|
110
110
|
cli_utilities_1.cliux.success('CLI_AUTH_TOKENS_ADD_REPLACE_SUCCESS');
|
|
111
111
|
}
|
|
112
112
|
else {
|
|
113
|
-
cli_utilities_1.log.debug('Token added successfully', this.contextDetails);
|
|
113
|
+
cli_utilities_1.log.debug('Token added successfully.', this.contextDetails);
|
|
114
114
|
cli_utilities_1.cliux.success('CLI_AUTH_TOKENS_ADD_SUCCESS');
|
|
115
115
|
}
|
|
116
|
-
cli_utilities_1.log.debug('Token
|
|
116
|
+
cli_utilities_1.log.debug('Token addition process completed successfully.', this.contextDetails);
|
|
117
117
|
}
|
|
118
118
|
catch (error) {
|
|
119
|
-
cli_utilities_1.log.debug('Token
|
|
119
|
+
cli_utilities_1.log.debug('Token addition process failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
|
|
120
120
|
cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_ADD_FAILED', { color: 'yellow' });
|
|
121
121
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
|
|
122
122
|
}
|
|
@@ -4,15 +4,15 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
|
4
4
|
const base_command_1 = require("../../../base-command");
|
|
5
5
|
class TokensListCommand extends base_command_1.BaseCommand {
|
|
6
6
|
async run() {
|
|
7
|
-
cli_utilities_1.log.debug('TokensListCommand run method started', this.contextDetails);
|
|
7
|
+
cli_utilities_1.log.debug('TokensListCommand run method started.', this.contextDetails);
|
|
8
8
|
this.contextDetails.module = 'tokens-list';
|
|
9
9
|
try {
|
|
10
|
-
cli_utilities_1.log.debug('Retrieving tokens from configuration', this.contextDetails);
|
|
10
|
+
cli_utilities_1.log.debug('Retrieving tokens from configuration.', this.contextDetails);
|
|
11
11
|
const managementTokens = cli_utilities_1.configHandler.get('tokens');
|
|
12
|
-
cli_utilities_1.log.debug('Tokens retrieved from configuration', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 }));
|
|
12
|
+
cli_utilities_1.log.debug('Tokens retrieved from configuration.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: managementTokens ? Object.keys(managementTokens).length : 0 }));
|
|
13
13
|
const tokens = [];
|
|
14
14
|
if (managementTokens && Object.keys(managementTokens).length > 0) {
|
|
15
|
-
cli_utilities_1.log.debug('Processing tokens for display', this.contextDetails);
|
|
15
|
+
cli_utilities_1.log.debug('Processing tokens for display.', this.contextDetails);
|
|
16
16
|
Object.keys(managementTokens).forEach(function (item) {
|
|
17
17
|
tokens.push({
|
|
18
18
|
alias: item,
|
|
@@ -24,7 +24,7 @@ class TokensListCommand extends base_command_1.BaseCommand {
|
|
|
24
24
|
cli_utilities_1.log.debug(`Token processed: ${item}`, { tokenType: managementTokens[item].type });
|
|
25
25
|
});
|
|
26
26
|
const { flags } = await this.parse(TokensListCommand);
|
|
27
|
-
cli_utilities_1.log.debug('
|
|
27
|
+
cli_utilities_1.log.debug('Token list flags parsed.', Object.assign(Object.assign({}, this.contextDetails), { flags }));
|
|
28
28
|
const headers = [
|
|
29
29
|
{
|
|
30
30
|
value: 'alias',
|
|
@@ -42,18 +42,18 @@ class TokensListCommand extends base_command_1.BaseCommand {
|
|
|
42
42
|
value: 'type',
|
|
43
43
|
},
|
|
44
44
|
];
|
|
45
|
-
cli_utilities_1.log.debug('Displaying
|
|
45
|
+
cli_utilities_1.log.debug('Displaying token table.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: tokens.length }));
|
|
46
46
|
cli_utilities_1.cliux.table(headers, tokens, flags);
|
|
47
|
-
cli_utilities_1.log.debug('
|
|
47
|
+
cli_utilities_1.log.debug('Token table displayed successfully.', this.contextDetails);
|
|
48
48
|
}
|
|
49
49
|
else {
|
|
50
|
-
cli_utilities_1.log.debug('No tokens found in configuration', this.contextDetails);
|
|
50
|
+
cli_utilities_1.log.debug('No tokens found in configuration.', this.contextDetails);
|
|
51
51
|
cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_LIST_NO_TOKENS');
|
|
52
52
|
}
|
|
53
|
-
cli_utilities_1.log.debug('
|
|
53
|
+
cli_utilities_1.log.debug('Token list command completed successfully.', this.contextDetails);
|
|
54
54
|
}
|
|
55
55
|
catch (error) {
|
|
56
|
-
cli_utilities_1.log.debug('
|
|
56
|
+
cli_utilities_1.log.debug('Token list command failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
|
|
57
57
|
cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_LIST_FAILED', { color: 'yellow' });
|
|
58
58
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
|
|
59
59
|
}
|
|
@@ -7,25 +7,25 @@ class TokensRemoveCommand extends base_command_1.BaseCommand {
|
|
|
7
7
|
cli_utilities_1.log.debug('TokensRemoveCommand run method started', this.contextDetails);
|
|
8
8
|
this.contextDetails.module = 'tokens-remove';
|
|
9
9
|
const { flags: removeTokenFlags } = await this.parse(TokensRemoveCommand);
|
|
10
|
-
cli_utilities_1.log.debug('Token
|
|
10
|
+
cli_utilities_1.log.debug('Token removal flags parsed.', Object.assign(Object.assign({}, this.contextDetails), { flags: removeTokenFlags }));
|
|
11
11
|
const alias = removeTokenFlags.alias;
|
|
12
12
|
const ignore = removeTokenFlags.ignore;
|
|
13
|
-
cli_utilities_1.log.debug('Token removal parameters', Object.assign(Object.assign({}, this.contextDetails), { alias, ignore }));
|
|
13
|
+
cli_utilities_1.log.debug('Token removal parameters set.', Object.assign(Object.assign({}, this.contextDetails), { alias, ignore }));
|
|
14
14
|
try {
|
|
15
|
-
cli_utilities_1.log.debug('Retrieving token from configuration', Object.assign(Object.assign({}, this.contextDetails), { alias }));
|
|
15
|
+
cli_utilities_1.log.debug('Retrieving token from configuration.', Object.assign(Object.assign({}, this.contextDetails), { alias }));
|
|
16
16
|
const token = cli_utilities_1.configHandler.get(`tokens.${alias}`);
|
|
17
|
-
cli_utilities_1.log.debug('Token retrieved from configuration', Object.assign(Object.assign({}, this.contextDetails), { hasToken: !!token, tokenType: token === null || token === void 0 ? void 0 : token.type }));
|
|
17
|
+
cli_utilities_1.log.debug('Token retrieved from configuration.', Object.assign(Object.assign({}, this.contextDetails), { hasToken: !!token, tokenType: token === null || token === void 0 ? void 0 : token.type }));
|
|
18
18
|
const tokens = cli_utilities_1.configHandler.get('tokens');
|
|
19
|
-
cli_utilities_1.log.debug('All tokens retrieved from configuration', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: tokens ? Object.keys(tokens).length : 0 }));
|
|
19
|
+
cli_utilities_1.log.debug('All tokens retrieved from configuration.', Object.assign(Object.assign({}, this.contextDetails), { tokenCount: tokens ? Object.keys(tokens).length : 0 }));
|
|
20
20
|
const tokenOptions = [];
|
|
21
21
|
if (token || ignore) {
|
|
22
|
-
cli_utilities_1.log.debug('Token found or ignore flag set
|
|
22
|
+
cli_utilities_1.log.debug('Token found, or ignore flag set.', Object.assign(Object.assign({}, this.contextDetails), { hasToken: !!token, ignore }));
|
|
23
23
|
cli_utilities_1.configHandler.delete(`tokens.${alias}`);
|
|
24
|
-
cli_utilities_1.log.debug('Token removed from configuration', Object.assign(Object.assign({}, this.contextDetails), { alias }));
|
|
24
|
+
cli_utilities_1.log.debug('Token removed from configuration.', Object.assign(Object.assign({}, this.contextDetails), { alias }));
|
|
25
25
|
return cli_utilities_1.cliux.success(`CLI_AUTH_TOKENS_REMOVE_SUCCESS`);
|
|
26
26
|
}
|
|
27
27
|
if (tokens && Object.keys(tokens).length > 0) {
|
|
28
|
-
cli_utilities_1.log.debug('Building token options for user selection', this.contextDetails);
|
|
28
|
+
cli_utilities_1.log.debug('Building token options for user selection.', this.contextDetails);
|
|
29
29
|
Object.keys(tokens).forEach(function (item) {
|
|
30
30
|
const tokenOption = `${item}: ${tokens[item].token} : ${tokens[item].apiKey}${tokens[item].environment ? ' : ' + tokens[item].environment + ' ' : ''}: ${tokens[item].type}`;
|
|
31
31
|
tokenOptions.push(tokenOption);
|
|
@@ -34,10 +34,10 @@ class TokensRemoveCommand extends base_command_1.BaseCommand {
|
|
|
34
34
|
cli_utilities_1.log.debug(`Token options built: ${tokenOptions.length} options`, this.contextDetails);
|
|
35
35
|
}
|
|
36
36
|
else {
|
|
37
|
-
cli_utilities_1.log.debug('No tokens found in configuration', this.contextDetails);
|
|
37
|
+
cli_utilities_1.log.debug('No tokens found in configuration.', this.contextDetails);
|
|
38
38
|
return cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_NOT_FOUND');
|
|
39
39
|
}
|
|
40
|
-
cli_utilities_1.log.debug('Requesting user to select tokens for removal', this.contextDetails);
|
|
40
|
+
cli_utilities_1.log.debug('Requesting user to select tokens for removal.', this.contextDetails);
|
|
41
41
|
const selectedTokens = await cli_utilities_1.cliux.inquire({
|
|
42
42
|
name: 'selectedTokens',
|
|
43
43
|
message: 'CLI_AUTH_TOKENS_REMOVE_SELECT_TOKEN',
|
|
@@ -46,13 +46,13 @@ class TokensRemoveCommand extends base_command_1.BaseCommand {
|
|
|
46
46
|
});
|
|
47
47
|
cli_utilities_1.log.debug(`User selected ${selectedTokens.length} tokens for removal`, Object.assign(Object.assign({}, this.contextDetails), { selectedTokens }));
|
|
48
48
|
if (selectedTokens.length === 0) {
|
|
49
|
-
cli_utilities_1.log.debug('No tokens selected for removal
|
|
49
|
+
cli_utilities_1.log.debug('No tokens selected for removal.', this.contextDetails);
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
selectedTokens.forEach((ele) => {
|
|
53
53
|
cli_utilities_1.log.info(`Selected token: ${ele}`, this.contextDetails);
|
|
54
54
|
});
|
|
55
|
-
cli_utilities_1.log.debug('Removing selected tokens from configuration', this.contextDetails);
|
|
55
|
+
cli_utilities_1.log.debug('Removing selected tokens from configuration.', this.contextDetails);
|
|
56
56
|
selectedTokens.forEach((element) => {
|
|
57
57
|
const selectedToken = element.split(':')[0];
|
|
58
58
|
cli_utilities_1.log.debug(`Removing token: ${selectedToken}`, this.contextDetails);
|
|
@@ -60,10 +60,10 @@ class TokensRemoveCommand extends base_command_1.BaseCommand {
|
|
|
60
60
|
cli_utilities_1.cliux.success('CLI_AUTH_TOKENS_REMOVE_SUCCESS');
|
|
61
61
|
cli_utilities_1.log.info(`Token removed: ${selectedToken}`, this.contextDetails);
|
|
62
62
|
});
|
|
63
|
-
cli_utilities_1.log.debug('Token removal
|
|
63
|
+
cli_utilities_1.log.debug('Token removal completed successfully.', this.contextDetails);
|
|
64
64
|
}
|
|
65
65
|
catch (error) {
|
|
66
|
-
cli_utilities_1.log.debug('Token removal
|
|
66
|
+
cli_utilities_1.log.debug('Token removal failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
|
|
67
67
|
cli_utilities_1.cliux.print('CLI_AUTH_TOKENS_REMOVE_FAILED', { color: 'yellow' });
|
|
68
68
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
|
|
69
69
|
}
|
|
@@ -6,20 +6,20 @@ class WhoamiCommand extends base_command_1.BaseCommand {
|
|
|
6
6
|
async run() {
|
|
7
7
|
cli_utilities_1.log.debug('WhoamiCommand run method started', this.contextDetails);
|
|
8
8
|
try {
|
|
9
|
-
cli_utilities_1.log.debug('Checking user email from context', Object.assign(Object.assign({}, this.contextDetails), { hasEmail: !!this.email }));
|
|
9
|
+
cli_utilities_1.log.debug('Checking user email from context.', Object.assign(Object.assign({}, this.contextDetails), { hasEmail: !!this.email }));
|
|
10
10
|
if (this.email) {
|
|
11
11
|
cli_utilities_1.log.debug('User email found, displaying user information', Object.assign(Object.assign({}, this.contextDetails), { email: this.email }));
|
|
12
12
|
cli_utilities_1.cliux.print('CLI_AUTH_WHOAMI_LOGGED_IN_AS', { color: 'white' });
|
|
13
13
|
cli_utilities_1.cliux.print(this.email, { color: 'green' });
|
|
14
|
-
cli_utilities_1.log.debug('
|
|
14
|
+
cli_utilities_1.log.debug('whoami command completed successfully.', this.contextDetails);
|
|
15
15
|
}
|
|
16
16
|
else {
|
|
17
|
-
cli_utilities_1.log.debug('No user email found in context', this.contextDetails);
|
|
17
|
+
cli_utilities_1.log.debug('No user email found in context.', this.contextDetails);
|
|
18
18
|
cli_utilities_1.log.error(cli_utilities_1.messageHandler.parse('CLI_AUTH_WHOAMI_FAILED'), this.contextDetails);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
|
22
|
-
cli_utilities_1.log.debug('
|
|
22
|
+
cli_utilities_1.log.debug('whoami command failed.', Object.assign(Object.assign({}, this.contextDetails), { error }));
|
|
23
23
|
cli_utilities_1.cliux.print('CLI_AUTH_WHOAMI_FAILED', { color: 'yellow' });
|
|
24
24
|
(0, cli_utilities_1.handleAndLogError)(error, Object.assign({}, this.contextDetails));
|
|
25
25
|
}
|
|
@@ -8,11 +8,11 @@ const interactive_1 = require("./interactive");
|
|
|
8
8
|
*/
|
|
9
9
|
class AuthHandler {
|
|
10
10
|
set client(contentStackClient) {
|
|
11
|
-
cli_utilities_1.log.debug('Setting
|
|
11
|
+
cli_utilities_1.log.debug('Setting Contentstack client.', { module: 'auth-handler' });
|
|
12
12
|
this._client = contentStackClient;
|
|
13
13
|
}
|
|
14
14
|
set host(contentStackHost) {
|
|
15
|
-
cli_utilities_1.log.debug(`Setting
|
|
15
|
+
cli_utilities_1.log.debug(`Setting Contentstack host: ${contentStackHost}`, { module: 'auth-handler' });
|
|
16
16
|
this._host = contentStackHost;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
@@ -63,14 +63,14 @@ class AuthHandler {
|
|
|
63
63
|
* @throws CLIError if SMS request fails
|
|
64
64
|
*/
|
|
65
65
|
async requestSMSOTP(loginPayload) {
|
|
66
|
-
cli_utilities_1.log.debug('Sending SMS OTP request', { module: 'auth-handler' });
|
|
66
|
+
cli_utilities_1.log.debug('Sending SMS OTP request.', { module: 'auth-handler' });
|
|
67
67
|
try {
|
|
68
68
|
await this._client.axiosInstance.post('/user/request_token_sms', { user: loginPayload });
|
|
69
|
-
cli_utilities_1.log.debug('SMS OTP request successful', { module: 'auth-handler' });
|
|
69
|
+
cli_utilities_1.log.debug('SMS OTP request successful.', { module: 'auth-handler' });
|
|
70
70
|
cli_utilities_1.cliux.print('CLI_AUTH_LOGIN_SECURITY_CODE_SEND_SUCCESS');
|
|
71
71
|
}
|
|
72
72
|
catch (error) {
|
|
73
|
-
cli_utilities_1.log.debug('SMS OTP request failed', { module: 'auth-handler', error });
|
|
73
|
+
cli_utilities_1.log.debug('SMS OTP request failed.', { module: 'auth-handler', error });
|
|
74
74
|
throw error;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -88,7 +88,7 @@ class AuthHandler {
|
|
|
88
88
|
const loginPayload = { email, password };
|
|
89
89
|
if (tfaToken) {
|
|
90
90
|
loginPayload.tfa_token = tfaToken;
|
|
91
|
-
cli_utilities_1.log.debug('Adding TFA token to login payload', { module: 'auth-handler' });
|
|
91
|
+
cli_utilities_1.log.debug('Adding TFA token to login payload.', { module: 'auth-handler' });
|
|
92
92
|
}
|
|
93
93
|
cli_utilities_1.log.debug('Making login API call', {
|
|
94
94
|
module: 'auth-handler',
|
|
@@ -112,18 +112,18 @@ class AuthHandler {
|
|
|
112
112
|
resolve(await this.login(email, password, tfToken));
|
|
113
113
|
}
|
|
114
114
|
catch (error) {
|
|
115
|
-
cli_utilities_1.log.debug('Login with TFA token failed', { module: 'auth-handler', error });
|
|
115
|
+
cli_utilities_1.log.debug('Login with TFA token failed.', { module: 'auth-handler', error });
|
|
116
116
|
cli_utilities_1.cliux.print('CLI_AUTH_2FA_FAILED', { color: 'red' });
|
|
117
117
|
reject(error);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
else {
|
|
121
|
-
cli_utilities_1.log.debug('Login failed
|
|
121
|
+
cli_utilities_1.log.debug('Login failed: no user found.', { module: 'auth-handler', result });
|
|
122
122
|
reject(new Error(cli_utilities_1.messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
|
|
123
123
|
}
|
|
124
124
|
})
|
|
125
125
|
.catch((error) => {
|
|
126
|
-
cli_utilities_1.log.debug('Login API call failed', { module: 'auth-handler', error: (error === null || error === void 0 ? void 0 : error.errorMessage) || error });
|
|
126
|
+
cli_utilities_1.log.debug('Login API call failed.', { module: 'auth-handler', error: (error === null || error === void 0 ? void 0 : error.errorMessage) || error });
|
|
127
127
|
cli_utilities_1.cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
|
|
128
128
|
(0, cli_utilities_1.handleAndLogError)(error, { module: 'auth-handler' });
|
|
129
129
|
});
|
|
@@ -147,24 +147,24 @@ class AuthHandler {
|
|
|
147
147
|
* @returns {Promise} Promise object returns response object from Contentstack
|
|
148
148
|
*/
|
|
149
149
|
async logout(authtoken) {
|
|
150
|
-
cli_utilities_1.log.debug('Starting logout process', { module: 'auth-handler', hasAuthToken: !!authtoken });
|
|
150
|
+
cli_utilities_1.log.debug('Starting logout process.', { module: 'auth-handler', hasAuthToken: !!authtoken });
|
|
151
151
|
return new Promise((resolve, reject) => {
|
|
152
152
|
if (authtoken) {
|
|
153
|
-
cli_utilities_1.log.debug('Making logout API call', { module: 'auth-handler' });
|
|
153
|
+
cli_utilities_1.log.debug('Making logout API call.', { module: 'auth-handler' });
|
|
154
154
|
this._client
|
|
155
155
|
.logout(authtoken)
|
|
156
156
|
.then(function (response) {
|
|
157
|
-
cli_utilities_1.log.debug('Logout API call successful', { module: 'auth-handler', response });
|
|
157
|
+
cli_utilities_1.log.debug('Logout API call successful.', { module: 'auth-handler', response });
|
|
158
158
|
return resolve(response);
|
|
159
159
|
})
|
|
160
160
|
.catch((error) => {
|
|
161
|
-
cli_utilities_1.log.debug('Logout API call failed', { module: 'auth-handler', error: error.message });
|
|
161
|
+
cli_utilities_1.log.debug('Logout API call failed.', { module: 'auth-handler', error: error.message });
|
|
162
162
|
cli_utilities_1.cliux.print('CLI_AUTH_LOGOUT_FAILED', { color: 'yellow' });
|
|
163
163
|
reject(error);
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
else {
|
|
167
|
-
cli_utilities_1.log.debug('Logout failed
|
|
167
|
+
cli_utilities_1.log.debug('Logout failed: no auth token provided.', { module: 'auth-handler' });
|
|
168
168
|
reject(new Error(cli_utilities_1.messageHandler.parse('CLI_AUTH_LOGOUT_NO_TOKEN')));
|
|
169
169
|
}
|
|
170
170
|
});
|
|
@@ -175,24 +175,24 @@ class AuthHandler {
|
|
|
175
175
|
* @returns {Promise} Promise object returns response object from Contentstack
|
|
176
176
|
*/
|
|
177
177
|
async validateAuthtoken(authtoken) {
|
|
178
|
-
cli_utilities_1.log.debug('Starting token validation', { module: 'auth-handler', hasAuthToken: !!authtoken });
|
|
178
|
+
cli_utilities_1.log.debug('Starting token validation.', { module: 'auth-handler', hasAuthToken: !!authtoken });
|
|
179
179
|
return new Promise((resolve, reject) => {
|
|
180
180
|
if (authtoken) {
|
|
181
|
-
cli_utilities_1.log.debug('Making token validation API call', { module: 'auth-handler' });
|
|
181
|
+
cli_utilities_1.log.debug('Making token validation API call.', { module: 'auth-handler' });
|
|
182
182
|
this._client
|
|
183
183
|
.getUser()
|
|
184
184
|
.then((user) => {
|
|
185
|
-
cli_utilities_1.log.debug('Token validation successful', { module: 'auth-handler', user });
|
|
185
|
+
cli_utilities_1.log.debug('Token validation successful.', { module: 'auth-handler', user });
|
|
186
186
|
resolve(user);
|
|
187
187
|
})
|
|
188
188
|
.catch((error) => {
|
|
189
|
-
cli_utilities_1.log.debug('Token validation failed', { module: 'auth-handler', error: error.message });
|
|
189
|
+
cli_utilities_1.log.debug('Token validation failed.', { module: 'auth-handler', error: error.message });
|
|
190
190
|
cli_utilities_1.cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' });
|
|
191
191
|
(0, cli_utilities_1.handleAndLogError)(error, { module: 'auth-handler' });
|
|
192
192
|
});
|
|
193
193
|
}
|
|
194
194
|
else {
|
|
195
|
-
cli_utilities_1.log.debug('Token validation failed
|
|
195
|
+
cli_utilities_1.log.debug('Token validation failed: no auth token provided.', { module: 'auth-handler' });
|
|
196
196
|
reject(new Error(cli_utilities_1.messageHandler.parse('CLI_AUTH_TOKEN_VALIDATION_NO_TOKEN')));
|
|
197
197
|
}
|
|
198
198
|
});
|
|
@@ -10,27 +10,27 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
|
10
10
|
* @returns
|
|
11
11
|
*/
|
|
12
12
|
const validateEnvironment = async (contentStackClient, apiKey, environment) => {
|
|
13
|
-
cli_utilities_1.log.debug('Starting environment validation', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided', environment });
|
|
13
|
+
cli_utilities_1.log.debug('Starting environment validation.', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided', environment });
|
|
14
14
|
let result;
|
|
15
15
|
try {
|
|
16
|
-
cli_utilities_1.log.debug('Making environment validation API call', { module: 'tokens-validation', environment });
|
|
16
|
+
cli_utilities_1.log.debug('Making environment validation API call.', { module: 'tokens-validation', environment });
|
|
17
17
|
const validationResult = await contentStackClient.Stack({ api_key: apiKey }).environment(environment).fetch();
|
|
18
|
-
cli_utilities_1.log.debug('Environment validation API response received', { module: 'tokens-validation', validationResult });
|
|
18
|
+
cli_utilities_1.log.debug('Environment validation API response received.', { module: 'tokens-validation', validationResult });
|
|
19
19
|
if (validationResult.name === environment) {
|
|
20
|
-
cli_utilities_1.log.debug('Environment validation successful', { module: 'tokens-validation', environment, validationResult });
|
|
20
|
+
cli_utilities_1.log.debug('Environment validation successful.', { module: 'tokens-validation', environment, validationResult });
|
|
21
21
|
result = { valid: true, message: validationResult };
|
|
22
22
|
}
|
|
23
23
|
else {
|
|
24
|
-
cli_utilities_1.log.debug('Environment validation failed
|
|
24
|
+
cli_utilities_1.log.debug('Environment validation failed: name mismatch.', { module: 'tokens-validation', expected: environment, actual: validationResult.name });
|
|
25
25
|
result = { valid: false, message: cli_utilities_1.messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_ENVIRONMENT_NAME') };
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
catch (error) {
|
|
29
|
-
cli_utilities_1.log.debug('Environment validation API call failed', { module: 'tokens-validation', error: error.message, environment });
|
|
29
|
+
cli_utilities_1.log.debug('Environment validation API call failed.', { module: 'tokens-validation', error: error.message, environment });
|
|
30
30
|
(0, cli_utilities_1.handleAndLogError)(error, { apiKey, environment });
|
|
31
31
|
result = { valid: false, message: 'CLI_AUTH_TOKENS_VALIDATION_INVALID_ENVIRONMENT_NAME' };
|
|
32
32
|
}
|
|
33
|
-
cli_utilities_1.log.debug('Environment validation completed', { module: 'tokens-validation', result });
|
|
33
|
+
cli_utilities_1.log.debug('Environment validation completed.', { module: 'tokens-validation', result });
|
|
34
34
|
return result;
|
|
35
35
|
};
|
|
36
36
|
exports.validateEnvironment = validateEnvironment;
|
|
@@ -41,27 +41,27 @@ exports.validateEnvironment = validateEnvironment;
|
|
|
41
41
|
* @returns
|
|
42
42
|
*/
|
|
43
43
|
const validateAPIKey = async (contentStackClient, apiKey) => {
|
|
44
|
-
cli_utilities_1.log.debug('Starting API key validation', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided' });
|
|
44
|
+
cli_utilities_1.log.debug('Starting API key validation.', { module: 'tokens-validation', apiKeyStatus: apiKey ? 'provided' : 'not-provided' });
|
|
45
45
|
let result;
|
|
46
46
|
try {
|
|
47
|
-
cli_utilities_1.log.debug('Making API key validation API call', { module: 'tokens-validation' });
|
|
47
|
+
cli_utilities_1.log.debug('Making API key validation API call.', { module: 'tokens-validation' });
|
|
48
48
|
const validateAPIKeyResult = await contentStackClient.stack({ api_key: apiKey }).fetch();
|
|
49
|
-
cli_utilities_1.log.debug('API key validation API response received', { module: 'tokens-validation', validateAPIKeyResult });
|
|
49
|
+
cli_utilities_1.log.debug('API key validation API response received.', { module: 'tokens-validation', validateAPIKeyResult });
|
|
50
50
|
if (validateAPIKeyResult.api_key === apiKey) {
|
|
51
|
-
cli_utilities_1.log.debug('API key validation successful', { module: 'tokens-validation', apiKey: validateAPIKeyResult.api_key });
|
|
51
|
+
cli_utilities_1.log.debug('API key validation successful.', { module: 'tokens-validation', apiKey: validateAPIKeyResult.api_key });
|
|
52
52
|
result = { valid: true, message: validateAPIKeyResult };
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
cli_utilities_1.log.debug('API key validation failed
|
|
55
|
+
cli_utilities_1.log.debug('API key validation failed: key mismatch.', { module: 'tokens-validation', expected: apiKey, actual: validateAPIKeyResult.api_key });
|
|
56
56
|
result = { valid: false, message: cli_utilities_1.messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_API_KEY') };
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
catch (error) {
|
|
60
|
-
cli_utilities_1.log.debug('API key validation API call failed', { module: 'tokens-validation', error: error.message });
|
|
60
|
+
cli_utilities_1.log.debug('API key validation API call failed.', { module: 'tokens-validation', error: error.message });
|
|
61
61
|
(0, cli_utilities_1.handleAndLogError)(error, { apiKey });
|
|
62
62
|
result = { valid: false, message: cli_utilities_1.messageHandler.parse('CLI_AUTH_TOKENS_VALIDATION_INVALID_API_KEY') };
|
|
63
63
|
}
|
|
64
|
-
cli_utilities_1.log.debug('API key validation completed', { module: 'tokens-validation', result });
|
|
64
|
+
cli_utilities_1.log.debug('API key validation completed.', { module: 'tokens-validation', result });
|
|
65
65
|
return result;
|
|
66
66
|
};
|
|
67
67
|
exports.validateAPIKey = validateAPIKey;
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-auth",
|
|
3
3
|
"description": "Contentstack CLI plugin for authentication activities",
|
|
4
|
-
"version": "1.6.
|
|
4
|
+
"version": "1.6.3",
|
|
5
5
|
"author": "Contentstack",
|
|
6
6
|
"bugs": "https://github.com/contentstack/cli/issues",
|
|
7
7
|
"scripts": {
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"test:unit:report": "nyc --extension .ts mocha --forbid-only \"test/unit/**/*.test.ts\""
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@contentstack/cli-command": "~1.
|
|
26
|
-
"@contentstack/cli-utilities": "~1.
|
|
25
|
+
"@contentstack/cli-command": "~1.7.1",
|
|
26
|
+
"@contentstack/cli-utilities": "~1.16.0",
|
|
27
27
|
"@oclif/core": "^4.3.0",
|
|
28
28
|
"@oclif/plugin-help": "^6.2.28",
|
|
29
29
|
"otplib": "^12.0.1"
|