@myvillage/cli 1.0.2 → 1.0.4
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/package.json +1 -1
- package/src/commands/login.js +4 -2
- package/src/utils/config.js +9 -3
package/package.json
CHANGED
package/src/commands/login.js
CHANGED
|
@@ -53,6 +53,7 @@ export async function loginCommand() {
|
|
|
53
53
|
|
|
54
54
|
// Create a promise that resolves when we receive the OAuth callback
|
|
55
55
|
const authResult = await new Promise((resolve, reject) => {
|
|
56
|
+
let timeout;
|
|
56
57
|
const server = createServer(async (req, res) => {
|
|
57
58
|
const url = new URL(req.url, `http://localhost:${config.callbackPort}`);
|
|
58
59
|
|
|
@@ -91,8 +92,9 @@ export async function loginCommand() {
|
|
|
91
92
|
`);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
// Close the server
|
|
95
|
+
// Close the server and clear timeout
|
|
95
96
|
server.close();
|
|
97
|
+
clearTimeout(timeout);
|
|
96
98
|
|
|
97
99
|
if (error) {
|
|
98
100
|
reject(new Error(errorDescription || error));
|
|
@@ -131,7 +133,7 @@ export async function loginCommand() {
|
|
|
131
133
|
});
|
|
132
134
|
|
|
133
135
|
// Timeout after 5 minutes
|
|
134
|
-
setTimeout(() => {
|
|
136
|
+
timeout = setTimeout(() => {
|
|
135
137
|
server.close();
|
|
136
138
|
reject(new Error('Authentication timed out. Please try again.'));
|
|
137
139
|
}, 5 * 60 * 1000);
|
package/src/utils/config.js
CHANGED
|
@@ -8,7 +8,7 @@ const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
|
8
8
|
const DEFAULT_CONFIG = {
|
|
9
9
|
apiBaseUrl: 'https://portal.myvillageproject.ai/api/v1',
|
|
10
10
|
oauthBaseUrl: 'https://portal.myvillageproject.ai/api/oauth',
|
|
11
|
-
clientId: '
|
|
11
|
+
clientId: 'mvos_aG_c729fuQxvvqYHOnkgTQ',
|
|
12
12
|
callbackPort: 3737,
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -21,14 +21,20 @@ function ensureConfigDir() {
|
|
|
21
21
|
export function getConfig() {
|
|
22
22
|
ensureConfigDir();
|
|
23
23
|
|
|
24
|
+
// Only persist user-overridable settings (not clientId/oauthBaseUrl which are app constants)
|
|
24
25
|
if (!existsSync(CONFIG_FILE)) {
|
|
25
|
-
|
|
26
|
+
const { clientId, oauthBaseUrl, ...persistable } = DEFAULT_CONFIG;
|
|
27
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(persistable, null, 2));
|
|
26
28
|
return { ...DEFAULT_CONFIG };
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
try {
|
|
30
32
|
const data = readFileSync(CONFIG_FILE, 'utf-8');
|
|
31
|
-
|
|
33
|
+
const fileConfig = JSON.parse(data);
|
|
34
|
+
// Remove stale clientId/oauthBaseUrl from file config — code defaults always win
|
|
35
|
+
delete fileConfig.clientId;
|
|
36
|
+
delete fileConfig.oauthBaseUrl;
|
|
37
|
+
return { ...DEFAULT_CONFIG, ...fileConfig };
|
|
32
38
|
} catch {
|
|
33
39
|
return { ...DEFAULT_CONFIG };
|
|
34
40
|
}
|