Skip to content
Open
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
10 changes: 8 additions & 2 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
fileignoreconfig:
- filename: package-lock.json
checksum: 7fe633822937ac8ac6153c796e02ad26f31a4cdbf28d62650fe7bc990ccabac4
checksum: 771f4558f516890a059eddf1aa6adaf6e0d809e6e9fd7c1e4f18899caf867a69
- filename: pnpm-lock.yaml
checksum: 096da506eea94052c82ddf88d0167be7511c4ce136d3de8cb1e6cc11c2444fd5
checksum: 1765026d6fa58955c39681a1c5a7bd15118f0e099efe1ea533ca162fd1e945f4
- filename: packages/contentstack-import-setup/test/unit/backup-handler.test.ts
checksum: 0582d62b88834554cf12951c8690a73ef3ddbb78b82d2804d994cf4148e1ef93
- filename: packages/contentstack-import-setup/test/config.json
Expand Down Expand Up @@ -277,4 +277,10 @@ fileignoreconfig:
checksum: 1e6c1fba1172512401038d5454c8d218201ec62262449c5c878609592e0124c4
- filename: packages/contentstack-audit/src/modules/composable-studio.ts
checksum: 4fc97ff582d6dff9a54b3a50dfa3cbb5febd38a55aeb8737034b97188ad543ba
- filename: packages/contentstack-utilities/src/proxy-helper.ts
checksum: 2a8379d7a34acb3c14093599fb4ba7307c94b0f280ea70d6d862ecb2448fe924
- filename: packages/contentstack-config/src/utils/interactive.ts
checksum: 09ebc9918e5161e423238df8879b782daf673e52a5ca97e000a9618517a40b96
- filename: packages/contentstack-config/src/commands/config/set/proxy.ts
checksum: 058c98f96a2de7e75a65536933e5fcd88f0fb7e8a487d9c172f4daacd0d05bea
version: '1.0'
601 changes: 354 additions & 247 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.1",
"version": "1.7.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"scripts": {
Expand Down
30 changes: 0 additions & 30 deletions packages/contentstack-auth/src/utils/auth-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,36 +182,6 @@ class AuthHandler {
}
});
}

/**
* Validate token
* @param {string} authtoken
* @returns {Promise} Promise object returns response object from Contentstack
*/
async validateAuthtoken(authtoken: string): Promise<object> {
log.debug('Starting token validation.', { module: 'auth-handler', hasAuthToken: !!authtoken });

return new Promise((resolve, reject) => {
if (authtoken) {
log.debug('Making token validation API call.', { module: 'auth-handler' });

this._client
.getUser()
.then((user: object) => {
log.debug('Token validation successful.', { module: 'auth-handler', user });
resolve(user);
})
.catch((error: Error) => {
log.debug('Token validation failed.', { module: 'auth-handler', error: error.message });
cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' });
reject(error);
});
} else {
log.debug('Token validation failed: no auth token provided.', { module: 'auth-handler' });
reject(new Error(messageHandler.parse('CLI_AUTH_TOKEN_VALIDATION_NO_TOKEN')));
}
});
}
}

export default new AuthHandler();
1 change: 0 additions & 1 deletion packages/contentstack-auth/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { default as authHandler } from './auth-handler';
export { default as mfaHandler } from './mfa-handler';
export * as interactive from './interactive';
export * as tokenValidation from './tokens-validation';
26 changes: 0 additions & 26 deletions packages/contentstack-auth/src/utils/mfa-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,6 @@ class MFAHandler {
}
}

/**
* Gets MFA code through manual user input
* @returns Promise<string> The MFA code
* @throws Error if code format is invalid
*/
async getManualMFACode(): Promise<string> {
try {
const code = await askOTP();
if (!/^\d{6}$/.test(code)) {
throw new Error(messageHandler.parse('CLI_AUTH_MFA_INVALID_CODE'));
}
return code;
} catch (error) {
log.debug('Failed to get MFA code', { module: 'mfa-handler', error });
throw error;
}
}

/**
* Validates an MFA code format
* @param code The MFA code to validate
* @returns boolean True if valid, false otherwise
*/
isValidMFACode(code: string): boolean {
return /^\d{6}$/.test(code);
}
}

export default new MFAHandler();
69 changes: 0 additions & 69 deletions packages/contentstack-auth/src/utils/tokens-validation.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { expect } from 'chai';
import * as sinon from 'sinon';
import { configHandler, cliux } from '@contentstack/cli-utilities';
import TokensAddCommand from '../../../src/commands/auth/tokens/add';
import { tokenValidation } from '../../../src/utils';
import { stub, assert } from 'sinon';
import { config as dotenvConfig } from 'dotenv';
import nock from 'nock';
Expand Down Expand Up @@ -31,8 +30,6 @@ function resetConfig() {
config.delete(`${configKeyTokens}.newToken`);
}
describe('Tokens Add Command', () => {
let apiKeyValidationStub: sinon.SinonStub;
let environmentTokenValidationStub: sinon.SinonStub;
let printStub: sinon.SinonStub;
const validAPIKey = conf.validAPIKey;
const validDeliveryToken = '***REMOVED***';
Expand All @@ -43,28 +40,9 @@ describe('Tokens Add Command', () => {
resetConfig();
if ((cliux.print as any).restore) (cliux.print as any).restore();
printStub = stub(cliux, 'print');
apiKeyValidationStub = sinon
.stub(tokenValidation, 'validateAPIKey')
.callsFake(function (client: any, apiKey: string): Promise<any> {
if (apiKey === validAPIKey) {
return Promise.resolve({ valid: true, message: 'success' });
}
return Promise.resolve({ valid: false, message: 'failed' });
});

environmentTokenValidationStub = sinon
.stub(tokenValidation, 'validateEnvironment')
.callsFake(function (client: any, apiKey: string, environment): Promise<any> {
if (environment === validEnvironment) {
return Promise.resolve({ valid: true, message: 'success' });
}
return Promise.resolve({ valid: false, message: 'failed' });
});
});

after(() => {
apiKeyValidationStub.restore();
environmentTokenValidationStub.restore();
printStub.restore();
resetConfig();
});
Expand Down
92 changes: 0 additions & 92 deletions packages/contentstack-auth/test/unit/tokens-validation.test.ts

This file was deleted.

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.1",
"@contentstack/cli-auth": "~1.7.2",
"@contentstack/cli-config": "~1.17.0",
"@contentstack/cli-dev-dependencies": "~1.3.1",
"@oclif/plugin-help": "^6.2.28",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"@contentstack/cli-audit": "~1.17.0",
"@contentstack/cli-cm-export": "~1.23.0",
"@contentstack/cli-cm-import": "~1.31.1",
"@contentstack/cli-auth": "~1.7.1",
"@contentstack/cli-cm-bootstrap": "~1.18.0",
"@contentstack/cli-auth": "~1.7.2",
"@contentstack/cli-cm-bootstrap": "~1.18.1",
"@contentstack/cli-cm-branches": "~1.6.3",
"@contentstack/cli-cm-bulk-publish": "~1.10.5",
"@contentstack/cli-cm-clone": "~1.19.0",
Expand Down
Loading
Loading