@contentstack/cli-auth 2.0.0-beta.2 → 2.0.0-beta.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/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/2.0.0-beta.2 linux-x64 node-v22.22.0
21
+ @contentstack/cli-auth/2.0.0-beta.3 linux-x64 node-v22.22.0
22
22
  $ csdx --help [COMMAND]
23
23
  USAGE
24
24
  $ csdx COMMAND
@@ -106,9 +106,15 @@ class AuthHandler {
106
106
  cli_utilities_1.log.debug('Login successful, user found', { module: 'auth-handler', userEmail: result.user.email });
107
107
  resolve(result.user);
108
108
  }
109
- else if (result.error_code === 294) {
110
- const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);
109
+ else {
110
+ cli_utilities_1.log.debug('Login failed: no user found.', { module: 'auth-handler', result });
111
+ reject(new Error(cli_utilities_1.messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
112
+ }
113
+ })
114
+ .catch(async (error) => {
115
+ if (error.errorCode === 294) {
111
116
  try {
117
+ const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);
112
118
  resolve(await this.login(email, password, tfToken));
113
119
  }
114
120
  catch (error) {
@@ -118,14 +124,10 @@ class AuthHandler {
118
124
  }
119
125
  }
120
126
  else {
121
- cli_utilities_1.log.debug('Login failed: no user found.', { module: 'auth-handler', result });
122
- reject(new Error(cli_utilities_1.messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
127
+ cli_utilities_1.log.debug('Login API call failed.', { module: 'auth-handler', error: (error === null || error === void 0 ? void 0 : error.errorMessage) || error });
128
+ cli_utilities_1.cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
129
+ reject(error);
123
130
  }
124
- })
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 });
127
- cli_utilities_1.cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
128
- (0, cli_utilities_1.handleAndLogError)(error, { module: 'auth-handler' });
129
131
  });
130
132
  }
131
133
  else {
@@ -188,7 +190,7 @@ class AuthHandler {
188
190
  .catch((error) => {
189
191
  cli_utilities_1.log.debug('Token validation failed.', { module: 'auth-handler', error: error.message });
190
192
  cli_utilities_1.cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' });
191
- (0, cli_utilities_1.handleAndLogError)(error, { module: 'auth-handler' });
193
+ reject(error);
192
194
  });
193
195
  }
194
196
  else {
@@ -75,20 +75,6 @@ class MFAHandler {
75
75
  source = 'environment variable';
76
76
  }
77
77
  }
78
- if (!secret) {
79
- cli_utilities_1.log.debug('Checking stored MFA secret', { module: 'mfa-handler' });
80
- const mfaConfig = cli_utilities_1.configHandler.get('mfa');
81
- if (mfaConfig === null || mfaConfig === void 0 ? void 0 : mfaConfig.secret) {
82
- try {
83
- secret = this.encrypter.decrypt(mfaConfig.secret);
84
- source = 'stored configuration';
85
- }
86
- catch (error) {
87
- cli_utilities_1.log.debug('Failed to decrypt stored MFA secret', { module: 'mfa-handler', error });
88
- (0, cli_utilities_1.handleAndLogError)(error, { module: 'mfa-handler' }, cli_utilities_1.messageHandler.parse('CLI_AUTH_MFA_DECRYPT_FAILED'));
89
- }
90
- }
91
- }
92
78
  if (secret) {
93
79
  try {
94
80
  const code = this.generateMFACode(secret);
@@ -359,5 +359,5 @@
359
359
  ]
360
360
  }
361
361
  },
362
- "version": "2.0.0-beta.2"
362
+ "version": "2.0.0-beta.3"
363
363
  }
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": "2.0.0-beta.2",
4
+ "version": "2.0.0-beta.3",
5
5
  "author": "Contentstack",
6
6
  "bugs": "https://github.com/contentstack/cli/issues",
7
7
  "scripts": {