@temps-sdk/cli 0.1.25 → 0.1.26
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/index.js +22 -13
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74681,18 +74681,24 @@ function normalizeApiUrl(url) {
|
|
|
74681
74681
|
}
|
|
74682
74682
|
return normalized;
|
|
74683
74683
|
}
|
|
74684
|
-
|
|
74684
|
+
var pinnedApiKey;
|
|
74685
|
+
var interceptorRegistered = false;
|
|
74686
|
+
async function setupClient(baseUrlOverride, apiKeyOverride) {
|
|
74685
74687
|
const apiUrl = normalizeApiUrl(baseUrlOverride ?? config.get("apiUrl"));
|
|
74688
|
+
pinnedApiKey = apiKeyOverride;
|
|
74686
74689
|
client.setConfig({
|
|
74687
74690
|
baseUrl: apiUrl
|
|
74688
74691
|
});
|
|
74689
|
-
|
|
74690
|
-
|
|
74691
|
-
|
|
74692
|
-
|
|
74693
|
-
|
|
74694
|
-
|
|
74695
|
-
|
|
74692
|
+
if (!interceptorRegistered) {
|
|
74693
|
+
interceptorRegistered = true;
|
|
74694
|
+
client.interceptors.request.use(async (request) => {
|
|
74695
|
+
const apiKey = pinnedApiKey ?? await credentials.getApiKey();
|
|
74696
|
+
if (apiKey) {
|
|
74697
|
+
request.headers.set("Authorization", `Bearer ${apiKey}`);
|
|
74698
|
+
}
|
|
74699
|
+
return request;
|
|
74700
|
+
});
|
|
74701
|
+
}
|
|
74696
74702
|
}
|
|
74697
74703
|
function getWebUrl() {
|
|
74698
74704
|
return config.get("apiUrl").replace(/\/+$/, "").replace(/\/api$/, "");
|
|
@@ -74971,8 +74977,7 @@ async function loginWithApiKey(apiKey, opts = {}) {
|
|
|
74971
74977
|
debugLog(`api-key login resolved apiUrl: ${baseUrl}`);
|
|
74972
74978
|
debugLog(`raw url arg: ${opts.url ?? "(none, using config apiUrl)"}`);
|
|
74973
74979
|
}
|
|
74974
|
-
await
|
|
74975
|
-
await setupClient(baseUrl);
|
|
74980
|
+
await setupClient(baseUrl, key);
|
|
74976
74981
|
try {
|
|
74977
74982
|
const result = await withSpinner("Validating API key...", async () => {
|
|
74978
74983
|
const { data, error: error3 } = await getCurrentUser({ client });
|
|
@@ -74999,9 +75004,13 @@ async function loginWithApiKey(apiKey, opts = {}) {
|
|
|
74999
75004
|
keyPrefix: key.slice(0, 8)
|
|
75000
75005
|
});
|
|
75001
75006
|
displayWelcome(result.email, ctxName, baseUrl);
|
|
75002
|
-
} catch {
|
|
75003
|
-
|
|
75004
|
-
|
|
75007
|
+
} catch (err) {
|
|
75008
|
+
if (debug && err instanceof Error) {
|
|
75009
|
+
debugLog(`api-key validation failed: ${err.message}`);
|
|
75010
|
+
}
|
|
75011
|
+
throw new AuthenticationError(err instanceof AuthenticationError ? err.message : `Invalid API key (validated against ${baseUrl})`);
|
|
75012
|
+
} finally {
|
|
75013
|
+
await setupClient(baseUrl);
|
|
75005
75014
|
}
|
|
75006
75015
|
}
|
|
75007
75016
|
function displayWelcome(email, contextName, baseUrl, meta) {
|