Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fileignoreconfig:
- filename: package-lock.json
checksum: 21d5e66a045c155578dc6b6d747745b94c4591c1e17f5226b94b833a46ee9bff
checksum: 7fe633822937ac8ac6153c796e02ad26f31a4cdbf28d62650fe7bc990ccabac4
- filename: pnpm-lock.yaml
checksum: a0e789a97a39aece1d637ed121bb6847d39dfb9033b71ea8bf10619eec2e246a
checksum: 096da506eea94052c82ddf88d0167be7511c4ce136d3de8cb1e6cc11c2444fd5
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
- filename: packages/contentstack-import-setup/test/config.json
Expand Down
1,263 changes: 622 additions & 641 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/contentstack-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-auth",
"description": "Contentstack CLI plugin for authentication activities",
"version": "1.7.0",
"version": "1.7.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand Down
23 changes: 12 additions & 11 deletions packages/contentstack-auth/src/utils/auth-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,25 +118,26 @@ class AuthHandler {
if (result.user) {
log.debug('Login successful, user found', { module: 'auth-handler', userEmail: result.user.email });
resolve(result.user as User);
} else if (result.error_code === 294) {
const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);

} else {
log.debug('Login failed: no user found.', { module: 'auth-handler', result });
reject(new Error(messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
}
})
.catch(async (error: any) => {
if (error.errorCode === 294) {
try {
const tfToken = await this.handleOTPFlow(tfaToken, loginPayload);
resolve(await this.login(email, password, tfToken));
} catch (error) {
log.debug('Login with TFA token failed.', { module: 'auth-handler', error });
cliux.print('CLI_AUTH_2FA_FAILED', { color: 'red' });
reject(error);
}
} else {
log.debug('Login failed: no user found.', { module: 'auth-handler', result });
reject(new Error(messageHandler.parse('CLI_AUTH_LOGIN_NO_USER')));
log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error });
cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
reject(error);
}
})
.catch((error: any) => {
log.debug('Login API call failed.', { module: 'auth-handler', error: error?.errorMessage || error });
cliux.print('CLI_AUTH_LOGIN_FAILED', { color: 'yellow' });
handleAndLogError(error, { module: 'auth-handler' });
});
} else {
const hasEmail = !!email;
Expand Down Expand Up @@ -203,7 +204,7 @@ class AuthHandler {
.catch((error: Error) => {
log.debug('Token validation failed.', { module: 'auth-handler', error: error.message });
cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' });
handleAndLogError(error, { module: 'auth-handler' });
reject(error);
});
} else {
log.debug('Token validation failed: no auth token provided.', { module: 'auth-handler' });
Expand Down
14 changes: 0 additions & 14 deletions packages/contentstack-auth/src/utils/mfa-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,6 @@ class MFAHandler {
}
}

if (!secret) {
log.debug('Checking stored MFA secret', { module: 'mfa-handler' });
const mfaConfig = configHandler.get('mfa');
if (mfaConfig?.secret) {
try {
secret = this.encrypter.decrypt(mfaConfig.secret);
source = 'stored configuration';
} catch (error) {
log.debug('Failed to decrypt stored MFA secret', { module: 'mfa-handler', error });
handleAndLogError(error, { module: 'mfa-handler' }, messageHandler.parse('CLI_AUTH_MFA_DECRYPT_FAILED'));
}
}
}

if (secret) {
try {
const code = this.generateMFACode(secret);
Expand Down
22 changes: 17 additions & 5 deletions packages/contentstack-auth/test/unit/auth-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ describe('Auth Handler', function () {
return Promise.reject(new Error('Invalid 2FA code'));
}
} else {
return Promise.resolve({ error_code: 294 });
const error: any = new Error('2FA required');
error.errorCode = 294;
return Promise.reject(error);
}
}
return Promise.resolve({ user });
Expand Down Expand Up @@ -113,13 +115,23 @@ describe('Auth Handler', function () {
it('Login with 2FA enabled invalid otp, failed to login', async function () {
this.timeout(10000);
TFAEnabled = true;
let result;
askOTPStub.restore();
askOTPStub = sinon.stub(interactive, 'askOTP').callsFake(function () {
return Promise.resolve(InvalidTFATestToken);
});
try {
result = await authHandler.login(credentials.email, credentials.password);
await authHandler.login(credentials.email, credentials.password);
expect.fail('Should have thrown an error');
} catch (error) {
result = error;
expect(error).to.be.instanceOf(Error);
expect((error as Error).message).to.include('Invalid 2FA code');
} finally {
TFAEnabled = false;
askOTPStub.restore();
askOTPStub = sinon.stub(interactive, 'askOTP').callsFake(function () {
return Promise.resolve(TFATestToken);
});
}
TFAEnabled = false;
});

it('Login with 2FA enabled with sms channel, should be logged in successfully', async function () {
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-bootstrap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli-cm-bootstrap",
"description": "Bootstrap contentstack apps",
"version": "1.18.0",
"version": "1.18.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand All @@ -16,14 +16,14 @@
"test:report": "nyc --reporter=lcov mocha \"test/**/*.test.js\""
},
"dependencies": {
"@contentstack/cli-cm-seed": "~1.14.0",
"@contentstack/cli-cm-seed": "~1.14.1",
"@contentstack/cli-command": "~1.7.1",
"@contentstack/cli-utilities": "~1.16.0",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"inquirer": "8.2.7",
"mkdirp": "^1.0.4",
"tar": "^6.2.1 "
"tar": "^7.5.6"
},
"devDependencies": {
"@oclif/test": "^4.1.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-export/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"winston": "^3.17.0"
},
"devDependencies": {
"@contentstack/cli-auth": "~1.7.0",
"@contentstack/cli-auth": "~1.7.1",
"@contentstack/cli-config": "~1.17.0",
"@contentstack/cli-dev-dependencies": "~1.3.1",
"@oclif/plugin-help": "^6.2.28",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"@contentstack/cli-audit": "~1.17.0",
"@contentstack/cli-command": "~1.7.1",
"@contentstack/cli-utilities": "~1.16.0",
"@contentstack/management": "~1.22.0",
"@contentstack/management": "~1.27.3",
"@contentstack/cli-variants": "~1.3.6",
"@oclif/core": "^4.3.0",
"big-json": "^3.2.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "@contentstack/cli-cm-seed",
"description": "create a Stack from existing content types, entries, assets, etc.",
"version": "1.14.0",
"version": "1.14.1",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.31.0",
"@contentstack/cli-command": "~1.7.1",
"@contentstack/cli-utilities": "~1.16.0",
"@contentstack/management": "~1.22.0",
"@contentstack/management": "~1.27.3",
"inquirer": "8.2.7",
"mkdirp": "^1.0.4",
"tar": "^6.2.1",
"tar": "^7.5.6",
"tmp": "^0.2.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"author": "contentstack",
"license": "MIT",
"dependencies": {
"@contentstack/management": "~1.25.1",
"@contentstack/management": "~1.27.3",
"@contentstack/marketplace-sdk": "^1.4.0",
"@oclif/core": "^4.3.0",
"axios": "^1.9.0",
Expand Down
10 changes: 5 additions & 5 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@contentstack/cli",
"description": "Command-line tool (CLI) to interact with Contentstack",
"version": "1.55.0",
"version": "1.55.1",
"author": "Contentstack",
"bin": {
"csdx": "./bin/run.js"
Expand All @@ -25,22 +25,22 @@
"@contentstack/cli-audit": "~1.17.0",
"@contentstack/cli-cm-export": "~1.23.0",
"@contentstack/cli-cm-import": "~1.31.0",
"@contentstack/cli-auth": "~1.7.0",
"@contentstack/cli-cm-bootstrap": "~1.18.0",
"@contentstack/cli-auth": "~1.7.1",
"@contentstack/cli-cm-bootstrap": "~1.18.1",
"@contentstack/cli-cm-branches": "~1.6.2",
"@contentstack/cli-cm-bulk-publish": "~1.10.5",
"@contentstack/cli-cm-clone": "~1.19.0",
"@contentstack/cli-cm-export-to-csv": "~1.10.2",
"@contentstack/cli-cm-import-setup": "~1.7.2",
"@contentstack/cli-cm-migrate-rte": "~1.6.3",
"@contentstack/cli-cm-seed": "~1.14.0",
"@contentstack/cli-cm-seed": "~1.14.1",
"@contentstack/cli-command": "~1.7.1",
"@contentstack/cli-config": "~1.17.0",
"@contentstack/cli-launch": "^1.9.2",
"@contentstack/cli-migration": "~1.10.2",
"@contentstack/cli-utilities": "~1.16.0",
"@contentstack/cli-variants": "~1.3.6",
"@contentstack/management": "~1.22.0",
"@contentstack/management": "~1.27.3",
"@oclif/core": "^4.3.0",
"@oclif/plugin-help": "^6.2.28",
"@oclif/plugin-not-found": "^3.2.53",
Expand Down
Loading
Loading