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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/config.js +7 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imagemcp-cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "ImageMCP CLI & Authentication SDK — Seamless browser login, token encryption, and multi-model AI image generation.",
5
5
  "main": "src/index.js",
6
6
  "bin": {
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
- if (data.token) config.apiKey = decrypt(data.token);
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
- if (data.token) config.apiKey = decrypt(data.token);
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 encryptedToken = encrypt(apiKey);
134
+ const tokenString = typeof apiKey === 'string' ? apiKey : (apiKey?.raw || apiKey?.token || '');
133
135
 
134
136
  const updated = {
135
137
  ...existing,
136
- token: encryptedToken,
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()