Skip to content

Commit 75cfeaf

Browse files
committed
PR comment fix
1 parent 87b0ade commit 75cfeaf

File tree

8 files changed

+37
-34
lines changed

8 files changed

+37
-34
lines changed

.talismanrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
fileignoreconfig:
2+
- filename: pnpm-lock.yaml
3+
checksum: 14f5e6720c8596c182735dffd28e7da2e5175670ec24cd8299809fb05d6735a5
24
- filename: package-lock.json
3-
checksum: 72a462b8cacd9977871d7e5c6c15ba8be8c217930955667cb543ad93a41c1989
5+
checksum: 12cf2fe3303ea849646a97f767e720ff48847ecdcf4439140488dfd3157a0844
46
version: "1.0"

package-lock.json

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-auth/src/commands/auth/login.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ export default class LoginCommand extends BaseCommand<typeof LoginCommand> {
4242
}),
4343
'totp-secret': flags.string({
4444
description: 'TOTP secret for 2FA authentication.',
45-
multiple: false,
46-
required: false,
4745
exclusive: ['oauth'],
48-
hidden: false,
4946
}),
5047
oauth: flags.boolean({
5148
description: 'Enables single sign-on (SSO) in Contentstack CLI.',

packages/contentstack-auth/src/utils/interactive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const askOTPChannel = async (): Promise<string> => {
1717
name: 'otpChannel',
1818
message: 'CLI_AUTH_LOGIN_ASK_CHANNEL_FOR_OTP',
1919
choices: [
20-
{ name: '2FA Authenticator App', value: '2fa_authenticator_app' },
20+
{ name: 'Authenticator App', value: 'authenticator_app' },
2121
{ name: 'SMS', value: 'sms' },
2222
],
2323
});

packages/contentstack-auth/src/utils/totp-handler.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class TOTPHandler {
4141
// Validate and normalize secret
4242
const normalizedSecret = secret.toUpperCase();
4343
if (!this.isValidBase32(normalizedSecret)) {
44-
throw new Error('Invalid TOTP secret format');
44+
throw new Error('Something went wrong with your authentication setup. Please check the secret or try again');
4545
}
4646

4747
// Generate TOTP code
@@ -50,7 +50,7 @@ class TOTPHandler {
5050
return code;
5151
} catch (error) {
5252
log.debug('Failed to generate TOTP code', { module: 'totp-handler', error });
53-
throw new Error('Failed to generate TOTP code from provided secret');
53+
throw new Error('Something went wrong with your authentication setup. Please check the secret or try again');
5454
}
5555
}
5656

@@ -73,7 +73,7 @@ class TOTPHandler {
7373
source = 'stored configuration';
7474
} catch (error) {
7575
log.debug('Failed to decrypt stored TOTP secret', { module: 'totp-handler', error });
76-
throw new Error('Failed to decrypt stored TOTP secret');
76+
throw new Error('Authentication failed. Please try again.');
7777
}
7878
}
7979

@@ -84,7 +84,7 @@ class TOTPHandler {
8484
return code;
8585
} catch (error) {
8686
log.debug('Failed to generate TOTP code', { module: 'totp-handler', error, source });
87-
const message = `Failed to use TOTP secret from ${source}. Please enter the code manually.`;
87+
const message = `We couldn't retrieve your authentication code. Please enter it manually.`;
8888
cliux.print('Consider reconfiguring TOTP using config:totp:add');
8989
throw new Error(message);
9090
}
@@ -103,7 +103,7 @@ class TOTPHandler {
103103
async getManualTOTPCode(): Promise<string> {
104104
const code = await askOTP();
105105
if (!/^\d{6}$/.test(code)) {
106-
throw new Error('Invalid TOTP code format. Code must be 6 digits.');
106+
throw new Error('Invalid authentication code.');
107107
}
108108
return code;
109109
}

packages/contentstack-auth/test/unit/utils/totp-handler.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('TOTP Handler', () => {
1616
});
1717

1818
it('should throw error for invalid secret', () => {
19-
expect(() => totpHandler.generateTOTPFromSecret(invalidSecret)).to.throw('Failed to generate TOTP code from provided secret');
19+
expect(() => totpHandler.generateTOTPFromSecret(invalidSecret)).to.throw('Something went wrong with your authentication setup. Please check the secret or try again');
2020
});
2121

2222
it('should normalize secret to uppercase', () => {
@@ -74,7 +74,7 @@ describe('TOTP Handler', () => {
7474
await totpHandler.getTOTPCode();
7575
expect.fail('Should have thrown an error');
7676
} catch (error) {
77-
expect(error).to.be.an('error').with.property('message', 'Failed to decrypt stored TOTP secret');
77+
expect(error).to.be.an('error').with.property('message', 'Authentication failed. Please try again.');
7878
}
7979
});
8080
});

packages/contentstack/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"inquirer": "8.2.6",
5252
"node-machine-id": "^1.1.12",
5353
"open": "^8.4.2",
54+
"otplib": "^12.0.1",
5455
"semver": "^7.7.2",
5556
"short-uuid": "^4.2.2",
5657
"uuid": "^9.0.1",
@@ -167,4 +168,4 @@
167168
}
168169
},
169170
"repository": "https://github.com/contentstack/cli"
170-
}
171+
}

pnpm-lock.yaml

Lines changed: 10 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)