@contrail/cli 3.6.0-alpha.b1b3d9e → 3.6.0-alpha.bd1031b
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/sso.js +4 -4
- package/dist/auth/sso.spec.js +10 -0
- 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.bd1031b linux-x64 node-v24.22.1
|
|
21
21
|
$ contrail --help [COMMAND]
|
|
22
22
|
USAGE
|
|
23
23
|
$ contrail COMMAND
|
package/dist/auth/sso.js
CHANGED
|
@@ -78,7 +78,7 @@ function listenForLoopbackCode(expectedState) {
|
|
|
78
78
|
: 'Sign-in failed. Return to your terminal.';
|
|
79
79
|
response
|
|
80
80
|
.writeHead(signedIn ? 200 : 400, { 'Content-Type': 'text/plain', Connection: 'close' })
|
|
81
|
-
.end(page, () => stopListening(() => {
|
|
81
|
+
.end(page, () => stopListening(request.socket, () => {
|
|
82
82
|
if (error) {
|
|
83
83
|
rejectCode(new Error(`SSO sign-in failed: ${error}`));
|
|
84
84
|
}
|
|
@@ -95,11 +95,11 @@ function listenForLoopbackCode(expectedState) {
|
|
|
95
95
|
openSockets.add(socket);
|
|
96
96
|
socket.once('close', () => openSockets.delete(socket));
|
|
97
97
|
});
|
|
98
|
-
const timeout = setTimeout(() => stopListening(() => rejectCode(new Error('Timed out waiting for the browser sign-in.'))), BROWSER_SIGN_IN_TIMEOUT_MS);
|
|
99
|
-
function stopListening(settle) {
|
|
98
|
+
const timeout = setTimeout(() => stopListening(undefined, () => rejectCode(new Error('Timed out waiting for the browser sign-in.'))), BROWSER_SIGN_IN_TIMEOUT_MS);
|
|
99
|
+
function stopListening(respondingSocket, settle) {
|
|
100
100
|
clearTimeout(timeout);
|
|
101
101
|
server.close();
|
|
102
|
-
openSockets.forEach((socket) => socket.destroy());
|
|
102
|
+
openSockets.forEach((socket) => socket !== respondingSocket && socket.destroy());
|
|
103
103
|
settle();
|
|
104
104
|
}
|
|
105
105
|
return new Promise((resolve, reject) => {
|
package/dist/auth/sso.spec.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const node_crypto_1 = require("node:crypto");
|
|
4
|
+
const node_net_1 = require("node:net");
|
|
4
5
|
const sso_1 = require("./sso");
|
|
5
6
|
const ssoClient = {
|
|
6
7
|
domain: 'https://dev-vibeiq.auth.us-east-1.amazoncognito.com',
|
|
@@ -117,6 +118,15 @@ describe('listenForLoopbackCode', () => {
|
|
|
117
118
|
await fetch(`${sso_1.LOOPBACK_CALLBACK_URL}?error=access_denied&error_description=User%20cancelled&state=the-state`);
|
|
118
119
|
await rejection;
|
|
119
120
|
});
|
|
121
|
+
it('should close idle browser connections once the code arrives', async () => {
|
|
122
|
+
const listener = await (0, sso_1.listenForLoopbackCode)('the-state');
|
|
123
|
+
const idleConnection = (0, node_net_1.connect)(7731, 'localhost');
|
|
124
|
+
await new Promise((resolve) => idleConnection.once('connect', resolve));
|
|
125
|
+
const idleConnectionClosed = new Promise((resolve) => idleConnection.once('close', resolve));
|
|
126
|
+
await fetch(`${sso_1.LOOPBACK_CALLBACK_URL}?code=the-code&state=the-state`);
|
|
127
|
+
await expect(listener.code).resolves.toBe('the-code');
|
|
128
|
+
await expect(idleConnectionClosed).resolves.toBe(false);
|
|
129
|
+
});
|
|
120
130
|
it('should tell the user to paste a code instead when the port is taken', async () => {
|
|
121
131
|
const listener = await (0, sso_1.listenForLoopbackCode)('the-state');
|
|
122
132
|
await expect((0, sso_1.listenForLoopbackCode)('another-state')).rejects.toThrow('Port 7731 is in use. Run contrail login --no-browser instead.');
|
package/oclif.manifest.json
CHANGED