atxp 1.2.1 → 1.2.2
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/dist/login.d.ts.map +1 -1
- package/dist/login.js +99 -28
- package/dist/login.js.map +1 -1
- package/package.json +1 -1
package/dist/login.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAOA,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAKD,wBAAsB,KAAK,CAAC,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6BrE"}
|
package/dist/login.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import http from 'http';
|
|
1
2
|
import fs from 'fs';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
import os from 'os';
|
|
4
|
-
import inquirer from 'inquirer';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
|
+
import open from 'open';
|
|
6
7
|
const CONFIG_DIR = path.join(os.homedir(), '.atxp');
|
|
7
8
|
const CONFIG_FILE = path.join(CONFIG_DIR, 'config');
|
|
8
9
|
export async function login(options = {}) {
|
|
@@ -15,37 +16,107 @@ export async function login(options = {}) {
|
|
|
15
16
|
}
|
|
16
17
|
console.log(chalk.bold('ATXP Login'));
|
|
17
18
|
console.log();
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
19
|
+
try {
|
|
20
|
+
const connectionString = await loginWithBrowser();
|
|
21
|
+
saveConnectionString(connectionString);
|
|
22
|
+
console.log();
|
|
23
|
+
console.log(chalk.green('Login successful!'));
|
|
24
|
+
console.log();
|
|
25
|
+
console.log('To use ATXP tools in this terminal, run:');
|
|
26
|
+
console.log(chalk.cyan(` source ${CONFIG_FILE}`));
|
|
27
|
+
console.log();
|
|
28
|
+
console.log('Or add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):');
|
|
29
|
+
console.log(chalk.cyan(` source ${CONFIG_FILE}`));
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error(chalk.red('Login failed:'), error instanceof Error ? error.message : error);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async function loginWithBrowser() {
|
|
37
|
+
return new Promise((resolve, reject) => {
|
|
38
|
+
const server = http.createServer((req, res) => {
|
|
39
|
+
const url = new URL(req.url, `http://localhost`);
|
|
40
|
+
const connectionString = url.searchParams.get('connection_string');
|
|
41
|
+
if (connectionString) {
|
|
42
|
+
res.writeHead(200, { 'Content-Type': 'text/html' });
|
|
43
|
+
res.end(`
|
|
44
|
+
<!DOCTYPE html>
|
|
45
|
+
<html>
|
|
46
|
+
<head>
|
|
47
|
+
<title>ATXP Login</title>
|
|
48
|
+
<style>
|
|
49
|
+
body {
|
|
50
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
51
|
+
display: flex;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
align-items: center;
|
|
54
|
+
min-height: 100vh;
|
|
55
|
+
margin: 0;
|
|
56
|
+
background: #f5f5f5;
|
|
57
|
+
}
|
|
58
|
+
.container {
|
|
59
|
+
text-align: center;
|
|
60
|
+
padding: 40px;
|
|
61
|
+
background: white;
|
|
62
|
+
border-radius: 8px;
|
|
63
|
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
|
64
|
+
}
|
|
65
|
+
h1 { color: #10b981; margin-bottom: 16px; }
|
|
66
|
+
p { color: #666; }
|
|
67
|
+
</style>
|
|
68
|
+
</head>
|
|
69
|
+
<body>
|
|
70
|
+
<div class="container">
|
|
71
|
+
<h1>Login Successful</h1>
|
|
72
|
+
<p>You can close this tab and return to your terminal.</p>
|
|
73
|
+
</div>
|
|
74
|
+
</body>
|
|
75
|
+
</html>
|
|
76
|
+
`);
|
|
77
|
+
server.close();
|
|
78
|
+
resolve(decodeURIComponent(connectionString));
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
res.writeHead(400, { 'Content-Type': 'text/plain' });
|
|
82
|
+
res.end('Missing connection_string parameter');
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
server.on('error', (err) => {
|
|
86
|
+
reject(new Error(`Failed to start local server: ${err.message}`));
|
|
87
|
+
});
|
|
88
|
+
// Listen on random available port
|
|
89
|
+
server.listen(0, '127.0.0.1', () => {
|
|
90
|
+
const address = server.address();
|
|
91
|
+
const port = typeof address === 'object' ? address?.port : null;
|
|
92
|
+
if (!port) {
|
|
93
|
+
reject(new Error('Failed to start local server'));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const redirectUri = `http://localhost:${port}/callback`;
|
|
97
|
+
const loginUrl = `https://accounts.atxp.ai?cli_redirect=${encodeURIComponent(redirectUri)}`;
|
|
98
|
+
console.log('Opening browser to complete login...');
|
|
99
|
+
console.log(chalk.gray(`(${loginUrl})`));
|
|
100
|
+
console.log();
|
|
101
|
+
console.log('Waiting for authentication...');
|
|
102
|
+
open(loginUrl);
|
|
103
|
+
// Timeout after 5 minutes
|
|
104
|
+
const timeout = setTimeout(() => {
|
|
105
|
+
server.close();
|
|
106
|
+
reject(new Error('Login timed out. Please try again.'));
|
|
107
|
+
}, 5 * 60 * 1000);
|
|
108
|
+
server.on('close', () => {
|
|
109
|
+
clearTimeout(timeout);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function saveConnectionString(connectionString) {
|
|
35
115
|
if (!fs.existsSync(CONFIG_DIR)) {
|
|
36
116
|
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
37
117
|
}
|
|
38
|
-
|
|
39
|
-
const configContent = `export ATXP_CONNECTION="${connectionString.trim()}"
|
|
118
|
+
const configContent = `export ATXP_CONNECTION="${connectionString}"
|
|
40
119
|
`;
|
|
41
120
|
fs.writeFileSync(CONFIG_FILE, configContent, { mode: 0o600 });
|
|
42
|
-
console.log();
|
|
43
|
-
console.log(chalk.green('Login successful!'));
|
|
44
|
-
console.log();
|
|
45
|
-
console.log('To use ATXP tools in this terminal, run:');
|
|
46
|
-
console.log(chalk.cyan(` source ${CONFIG_FILE}`));
|
|
47
|
-
console.log();
|
|
48
|
-
console.log('Or add this to your shell profile (~/.bashrc, ~/.zshrc, etc.):');
|
|
49
|
-
console.log(chalk.cyan(` source ${CONFIG_FILE}`));
|
|
50
121
|
}
|
|
51
122
|
//# sourceMappingURL=login.js.map
|
package/dist/login.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../src/login.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AAMxB,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AACpD,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,QAAQ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