@contrail/cli 3.6.0-alpha.bd1031b → 3.6.0-alpha.de0c110
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 +1 -1
- package/dist/auth/login.js +4 -4
- package/dist/auth/login.spec.js +5 -3
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ $ npm install -g @contrail/cli
|
|
|
17
17
|
$ contrail COMMAND
|
|
18
18
|
running command...
|
|
19
19
|
$ contrail (--version)
|
|
20
|
-
@contrail/cli/3.6.0-alpha.
|
|
20
|
+
@contrail/cli/3.6.0-alpha.de0c110 linux-x64 node-v24.22.1
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
package/dist/auth/login.js
CHANGED
|
@@ -90,7 +90,7 @@ async function signIn(options) {
|
|
|
90
90
|
return signInWithSso(params, domainCheck.identityProvider, options);
|
|
91
91
|
}
|
|
92
92
|
if (domainCheck.kind === 'legacy') {
|
|
93
|
-
|
|
93
|
+
console.log('The CLI does not support your SSO provider yet. Sign in with your VibeIQ password, or set CONTRAIL_CLI_API_KEY.');
|
|
94
94
|
}
|
|
95
95
|
return authenticateWithUsernamePassword(params);
|
|
96
96
|
}
|
|
@@ -110,12 +110,12 @@ async function signInWithSso(params, identityProvider, options) {
|
|
|
110
110
|
let code;
|
|
111
111
|
if (usesLoopback) {
|
|
112
112
|
const loopbackListener = await (0, sso_1.listenForLoopbackCode)(pkce.state);
|
|
113
|
-
|
|
114
|
-
await (0, sso_1.openBrowser)(authorizeUrl).catch(() =>
|
|
113
|
+
console.log(`Opening your browser to sign in. If it does not open, visit:\n${authorizeUrl}`);
|
|
114
|
+
await (0, sso_1.openBrowser)(authorizeUrl).catch(() => console.log('Could not open a browser. Open the URL above to sign in.'));
|
|
115
115
|
code = await loopbackListener.code;
|
|
116
116
|
}
|
|
117
117
|
else {
|
|
118
|
-
|
|
118
|
+
console.log(`Open this URL in any browser to sign in:\n${authorizeUrl}`);
|
|
119
119
|
const answers = await inquirer_1.default.prompt([
|
|
120
120
|
{ type: 'input', name: 'signInCode', validate: (val) => !!val, message: 'Sign-in code' },
|
|
121
121
|
]);
|
package/dist/auth/login.spec.js
CHANGED
|
@@ -5,7 +5,6 @@ const amazon_cognito_identity_js_1 = require("amazon-cognito-identity-js");
|
|
|
5
5
|
const sdk_1 = require("@contrail/sdk");
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
7
7
|
const config_1 = require("../helpers/config/config");
|
|
8
|
-
const logger_1 = tslib_1.__importDefault(require("../logger"));
|
|
9
8
|
const login_1 = require("./login");
|
|
10
9
|
const mockAuthenticateUser = jest.fn();
|
|
11
10
|
jest.mock('amazon-cognito-identity-js', () => ({
|
|
@@ -219,9 +218,10 @@ describe('signIn with SSO', () => {
|
|
|
219
218
|
const DEV_COGNITO_DOMAIN = 'https://dev-vibeiq.auth.us-east-1.amazoncognito.com';
|
|
220
219
|
let fetchMock;
|
|
221
220
|
let promptSpy;
|
|
221
|
+
let consoleLogSpy;
|
|
222
222
|
function pasteCodeFromPrintedSignInUrl() {
|
|
223
223
|
promptSpy.mockImplementation(async () => {
|
|
224
|
-
const printed =
|
|
224
|
+
const printed = consoleLogSpy.mock.calls.map(([message]) => message).join('\n');
|
|
225
225
|
const signInUrl = new URL(printed.match(/https:\/\/\S+oauth2\/authorize\S+/)[0]);
|
|
226
226
|
return { signInCode: `pasted-code#${signInUrl.searchParams.get('state')}` };
|
|
227
227
|
});
|
|
@@ -233,6 +233,7 @@ describe('signIn with SSO', () => {
|
|
|
233
233
|
config_1.getConfig.mockResolvedValue({ apiGateway: DEV_GATEWAY, orgSlug: 'adam-zone-1' });
|
|
234
234
|
sdk_1.getCurrentUser.mockResolvedValue({ id: 'user-1' });
|
|
235
235
|
mockAuthenticateUser.mockImplementation((_details, callbacks) => callbacks.onSuccess({ idToken: { jwtToken: 'cognito-id-token' } }));
|
|
236
|
+
consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => undefined);
|
|
236
237
|
promptSpy = jest.spyOn(inquirer_1.default, 'prompt');
|
|
237
238
|
pasteCodeFromPrintedSignInUrl();
|
|
238
239
|
fetchMock = jest.fn();
|
|
@@ -240,6 +241,7 @@ describe('signIn with SSO', () => {
|
|
|
240
241
|
});
|
|
241
242
|
afterEach(() => {
|
|
242
243
|
promptSpy.mockRestore();
|
|
244
|
+
consoleLogSpy.mockRestore();
|
|
243
245
|
global.fetch = originalFetch;
|
|
244
246
|
restoreEnv('CONTRAIL_CLI_EMAIL', originalEmail);
|
|
245
247
|
restoreEnv('CONTRAIL_CLI_PASSWORD', originalPassword);
|
|
@@ -286,7 +288,7 @@ describe('signIn with SSO', () => {
|
|
|
286
288
|
promptSpy.mockResolvedValue({ password: 'secret' });
|
|
287
289
|
const context = await (0, login_1.signIn)({ openBrowser: false });
|
|
288
290
|
expect(context.apiUserToken).toBe('vibe-access');
|
|
289
|
-
expect(
|
|
291
|
+
expect(consoleLogSpy).toHaveBeenCalledWith(expect.stringContaining('The CLI does not support your SSO provider yet.'));
|
|
290
292
|
});
|
|
291
293
|
it('should refresh a stored SSO token through Cognito instead of the VibeIQ refresh endpoint', async () => {
|
|
292
294
|
config_1.getConfig.mockResolvedValue({
|
package/oclif.manifest.json
CHANGED