imagemcp-cli 1.0.2 → 1.0.3
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/config.js +7 -4
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -89,7 +89,8 @@ function loadConfig() {
|
|
|
89
89
|
if (!config.apiKey && fs.existsSync(LOCAL_CONFIG_FILE)) {
|
|
90
90
|
try {
|
|
91
91
|
const data = JSON.parse(fs.readFileSync(LOCAL_CONFIG_FILE, 'utf8'));
|
|
92
|
-
|
|
92
|
+
const rawToken = data.token || data.apiKey;
|
|
93
|
+
if (rawToken) config.apiKey = typeof rawToken === 'string' ? rawToken : decrypt(rawToken);
|
|
93
94
|
if (data.apiUrl) config.apiUrl = data.apiUrl;
|
|
94
95
|
if (data.user) config.user = data.user;
|
|
95
96
|
config.savedTo = LOCAL_CONFIG_FILE;
|
|
@@ -100,7 +101,8 @@ function loadConfig() {
|
|
|
100
101
|
if (!config.apiKey && fs.existsSync(GLOBAL_CONFIG_FILE)) {
|
|
101
102
|
try {
|
|
102
103
|
const data = JSON.parse(fs.readFileSync(GLOBAL_CONFIG_FILE, 'utf8'));
|
|
103
|
-
|
|
104
|
+
const rawToken = data.token || data.apiKey;
|
|
105
|
+
if (rawToken) config.apiKey = typeof rawToken === 'string' ? rawToken : decrypt(rawToken);
|
|
104
106
|
if (data.apiUrl) config.apiUrl = data.apiUrl;
|
|
105
107
|
if (data.user) config.user = data.user;
|
|
106
108
|
config.savedTo = GLOBAL_CONFIG_FILE;
|
|
@@ -129,11 +131,12 @@ function saveConfig({ apiKey, apiUrl, user }, isLocal = false) {
|
|
|
129
131
|
} catch (_) {}
|
|
130
132
|
}
|
|
131
133
|
|
|
132
|
-
const
|
|
134
|
+
const tokenString = typeof apiKey === 'string' ? apiKey : (apiKey?.raw || apiKey?.token || '');
|
|
133
135
|
|
|
134
136
|
const updated = {
|
|
135
137
|
...existing,
|
|
136
|
-
token:
|
|
138
|
+
token: tokenString,
|
|
139
|
+
apiKey: tokenString,
|
|
137
140
|
apiUrl: apiUrl || existing.apiUrl || DEFAULT_API_URL,
|
|
138
141
|
user: user || existing.user || null,
|
|
139
142
|
updatedAt: new Date().toISOString()
|