Skip to content

Commit a15ddf6

Browse files
Merge branch 'development' into enh/dx-3902-Refactor-Endpoints-Integrations
2 parents 0334553 + e7314a3 commit a15ddf6

11 files changed

Lines changed: 578 additions & 832 deletions

File tree

package-lock.json

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

packages/contentstack-auth/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@contentstack/cli-auth",
33
"description": "Contentstack CLI plugin for authentication activities",
4-
"version": "1.7.2",
4+
"version": "1.7.3",
55
"author": "Contentstack",
66
"bugs": "https://github.com/contentstack/cli/issues",
77
"scripts": {

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

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -182,36 +182,6 @@ class AuthHandler {
182182
}
183183
});
184184
}
185-
186-
/**
187-
* Validate token
188-
* @param {string} authtoken
189-
* @returns {Promise} Promise object returns response object from Contentstack
190-
*/
191-
async validateAuthtoken(authtoken: string): Promise<object> {
192-
log.debug('Starting token validation.', { module: 'auth-handler', hasAuthToken: !!authtoken });
193-
194-
return new Promise((resolve, reject) => {
195-
if (authtoken) {
196-
log.debug('Making token validation API call.', { module: 'auth-handler' });
197-
198-
this._client
199-
.getUser()
200-
.then((user: object) => {
201-
log.debug('Token validation successful.', { module: 'auth-handler', user });
202-
resolve(user);
203-
})
204-
.catch((error: Error) => {
205-
log.debug('Token validation failed.', { module: 'auth-handler', error: error.message });
206-
cliux.print('CLI_AUTH_TOKEN_VALIDATION_FAILED', { color: 'yellow' });
207-
reject(error);
208-
});
209-
} else {
210-
log.debug('Token validation failed: no auth token provided.', { module: 'auth-handler' });
211-
reject(new Error(messageHandler.parse('CLI_AUTH_TOKEN_VALIDATION_NO_TOKEN')));
212-
}
213-
});
214-
}
215185
}
216186

217187
export default new AuthHandler();
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
export { default as authHandler } from './auth-handler';
22
export { default as mfaHandler } from './mfa-handler';
33
export * as interactive from './interactive';
4-
export * as tokenValidation from './tokens-validation';

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -104,32 +104,6 @@ class MFAHandler {
104104
}
105105
}
106106

107-
/**
108-
* Gets MFA code through manual user input
109-
* @returns Promise<string> The MFA code
110-
* @throws Error if code format is invalid
111-
*/
112-
async getManualMFACode(): Promise<string> {
113-
try {
114-
const code = await askOTP();
115-
if (!/^\d{6}$/.test(code)) {
116-
throw new Error(messageHandler.parse('CLI_AUTH_MFA_INVALID_CODE'));
117-
}
118-
return code;
119-
} catch (error) {
120-
log.debug('Failed to get MFA code', { module: 'mfa-handler', error });
121-
throw error;
122-
}
123-
}
124-
125-
/**
126-
* Validates an MFA code format
127-
* @param code The MFA code to validate
128-
* @returns boolean True if valid, false otherwise
129-
*/
130-
isValidMFACode(code: string): boolean {
131-
return /^\d{6}$/.test(code);
132-
}
133107
}
134108

135109
export default new MFAHandler();

packages/contentstack-auth/src/utils/tokens-validation.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.

packages/contentstack-auth/test/unit/commands/tokens-add.test.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { expect } from 'chai';
22
import * as sinon from 'sinon';
33
import { configHandler, cliux } from '@contentstack/cli-utilities';
44
import TokensAddCommand from '../../../src/commands/auth/tokens/add';
5-
import { tokenValidation } from '../../../src/utils';
65
import { stub, assert } from 'sinon';
76
import { config as dotenvConfig } from 'dotenv';
87
import nock from 'nock';
@@ -31,8 +30,6 @@ function resetConfig() {
3130
config.delete(`${configKeyTokens}.newToken`);
3231
}
3332
describe('Tokens Add Command', () => {
34-
let apiKeyValidationStub: sinon.SinonStub;
35-
let environmentTokenValidationStub: sinon.SinonStub;
3633
let printStub: sinon.SinonStub;
3734
const validAPIKey = conf.validAPIKey;
3835
const validDeliveryToken = '***REMOVED***';
@@ -43,28 +40,9 @@ describe('Tokens Add Command', () => {
4340
resetConfig();
4441
if ((cliux.print as any).restore) (cliux.print as any).restore();
4542
printStub = stub(cliux, 'print');
46-
apiKeyValidationStub = sinon
47-
.stub(tokenValidation, 'validateAPIKey')
48-
.callsFake(function (client: any, apiKey: string): Promise<any> {
49-
if (apiKey === validAPIKey) {
50-
return Promise.resolve({ valid: true, message: 'success' });
51-
}
52-
return Promise.resolve({ valid: false, message: 'failed' });
53-
});
54-
55-
environmentTokenValidationStub = sinon
56-
.stub(tokenValidation, 'validateEnvironment')
57-
.callsFake(function (client: any, apiKey: string, environment): Promise<any> {
58-
if (environment === validEnvironment) {
59-
return Promise.resolve({ valid: true, message: 'success' });
60-
}
61-
return Promise.resolve({ valid: false, message: 'failed' });
62-
});
6343
});
6444

6545
after(() => {
66-
apiKeyValidationStub.restore();
67-
environmentTokenValidationStub.restore();
6846
printStub.restore();
6947
resetConfig();
7048
});

packages/contentstack-auth/test/unit/tokens-validation.test.ts

Lines changed: 0 additions & 92 deletions
This file was deleted.

packages/contentstack-export/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"winston": "^3.17.0"
2222
},
2323
"devDependencies": {
24-
"@contentstack/cli-auth": "~1.7.2",
24+
"@contentstack/cli-auth": "~1.7.3",
2525
"@contentstack/cli-config": "~1.18.0",
2626
"@contentstack/cli-dev-dependencies": "~1.3.1",
2727
"@oclif/plugin-help": "^6.2.28",

packages/contentstack/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"@contentstack/cli-audit": "~1.17.1",
2626
"@contentstack/cli-cm-export": "~1.23.1",
2727
"@contentstack/cli-cm-import": "~1.31.2",
28-
"@contentstack/cli-auth": "~1.7.2",
28+
"@contentstack/cli-auth": "~1.7.3",
2929
"@contentstack/cli-cm-bootstrap": "~1.18.2",
3030
"@contentstack/cli-cm-branches": "~1.6.3",
3131
"@contentstack/cli-cm-bulk-publish": "~1.10.6",

0 commit comments

Comments
 (0)