@flatkey-ai/cli 0.1.13 → 0.1.14
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/api.js +6 -2
- package/src/config.js +1 -1
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -295,11 +295,15 @@ function extractErrorMessage(body, status) {
|
|
|
295
295
|
: typeof body?.message === "string"
|
|
296
296
|
? body.message
|
|
297
297
|
: undefined;
|
|
298
|
-
if (message
|
|
298
|
+
if (isAuthTokenError(message)) return missingApiKeyMessage();
|
|
299
299
|
if (message) return message;
|
|
300
300
|
return `Flatkey API request failed with HTTP ${status}`;
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
+
function isAuthTokenError(message) {
|
|
304
|
+
return message === "Token not provided" || /^Invalid token\b/i.test(message ?? "");
|
|
305
|
+
}
|
|
306
|
+
|
|
303
307
|
function missingApiKeyMessage() {
|
|
304
|
-
return "Missing Flatkey API key.
|
|
308
|
+
return "Missing or invalid Flatkey API key. Run `flatkey login`, or create a key at https://console.flatkey.ai/keys and run `flatkey onboard --api-key <key>`.";
|
|
305
309
|
}
|
package/src/config.js
CHANGED
|
@@ -26,7 +26,7 @@ export async function resolveApiKey({
|
|
|
26
26
|
if (env.FLATKEY_API_KEY) return env.FLATKEY_API_KEY;
|
|
27
27
|
|
|
28
28
|
throw new Error(
|
|
29
|
-
"Missing Flatkey API key.
|
|
29
|
+
"Missing or invalid Flatkey API key. Run `flatkey login`, or create a key at https://console.flatkey.ai/keys and run `flatkey onboard --api-key <key>`.",
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
|