@topolo/cli 0.9.1 → 0.9.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/dist/index.js +65 -46
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1607,7 +1607,7 @@ var TopoloClient = class _TopoloClient {
|
|
|
1607
1607
|
}
|
|
1608
1608
|
const mapped = mapActionInput(entry, input2);
|
|
1609
1609
|
const service = entry.appSlug || entry.appId;
|
|
1610
|
-
|
|
1610
|
+
const result = await this.request({
|
|
1611
1611
|
service,
|
|
1612
1612
|
...entry.apiBaseUrl ? { baseUrl: entry.apiBaseUrl } : {},
|
|
1613
1613
|
method: entry.method,
|
|
@@ -1621,6 +1621,7 @@ var TopoloClient = class _TopoloClient {
|
|
|
1621
1621
|
},
|
|
1622
1622
|
confirm: options.confirm === true || entry.readOnly && !entry.destructive && !entry.requiresConfirmation
|
|
1623
1623
|
});
|
|
1624
|
+
return redactActionResult(result);
|
|
1624
1625
|
}
|
|
1625
1626
|
/**
|
|
1626
1627
|
* Introspect the current credential. Returns the caller's resolved identity,
|
|
@@ -1744,6 +1745,18 @@ function readOptionalString(value) {
|
|
|
1744
1745
|
function isRecord3(value) {
|
|
1745
1746
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
1746
1747
|
}
|
|
1748
|
+
function redactActionResult(value) {
|
|
1749
|
+
if (Array.isArray(value)) return value.map(redactActionResult);
|
|
1750
|
+
if (!isRecord3(value)) return value;
|
|
1751
|
+
return Object.fromEntries(Object.entries(value).map(([key, item]) => [
|
|
1752
|
+
key,
|
|
1753
|
+
isSensitiveActionResultKey(key) ? "[REDACTED]" : redactActionResult(item)
|
|
1754
|
+
]));
|
|
1755
|
+
}
|
|
1756
|
+
function isSensitiveActionResultKey(key) {
|
|
1757
|
+
const normalized = key.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
1758
|
+
return ["authorization", "cookie", "setcookie", "proxyauthorization", "capability"].includes(normalized) || /(token|secret|password|privatekey|apikey)$/.test(normalized);
|
|
1759
|
+
}
|
|
1747
1760
|
function resolveConfiguredServiceUrl(slug, serviceUrls) {
|
|
1748
1761
|
for (const serviceKey of serviceKeyCandidates2(slug)) {
|
|
1749
1762
|
const configured = serviceUrls?.[serviceKey];
|
|
@@ -2929,52 +2942,58 @@ async function refreshCredentialIfNeeded(environment = selectedEnvironment(), op
|
|
|
2929
2942
|
if (process.env[`${prefix}_API_KEY`] || process.env[`${prefix}_ACCESS_TOKEN`] || environment === "production" && process.env.TOPOLO_API_KEY || environment === "production" && process.env.TOPOLO_ACCESS_TOKEN) {
|
|
2930
2943
|
return resolveCredential(environment);
|
|
2931
2944
|
}
|
|
2932
|
-
const
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
);
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2945
|
+
const observed = profileForEnvironment(await readConfig(), environment).credential;
|
|
2946
|
+
return withConfigWriteLock(async () => {
|
|
2947
|
+
const config = await readConfig();
|
|
2948
|
+
const profile = profileForEnvironment(config, environment);
|
|
2949
|
+
const cred = profile.credential;
|
|
2950
|
+
if (!cred || cred.kind !== "access_token") return cred ?? null;
|
|
2951
|
+
if (!cred.refreshToken || !profile.oauthClientId) return cred;
|
|
2952
|
+
if (options.force && observed?.kind === "access_token" && observed.accessToken !== cred.accessToken) {
|
|
2953
|
+
return cred;
|
|
2954
|
+
}
|
|
2955
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
2956
|
+
if (!options.force && cred.expiresAt && cred.expiresAt - REFRESH_SKEW_SECONDS > now) return cred;
|
|
2957
|
+
const serviceUrls = resolveServiceUrls(profile.serviceUrls, environment);
|
|
2958
|
+
if (environment === "local" && !serviceUrls?.auth) {
|
|
2959
|
+
throw new TopoloSdkError2(
|
|
2960
|
+
"environment_service_url_required",
|
|
2961
|
+
"Local Topolo credential refresh requires an explicit local Auth service origin."
|
|
2962
|
+
);
|
|
2963
|
+
}
|
|
2964
|
+
try {
|
|
2965
|
+
const oauth = new TopoloOAuth2({
|
|
2966
|
+
serviceUrls
|
|
2967
|
+
});
|
|
2968
|
+
const tokens = await oauth.refreshToken({
|
|
2969
|
+
clientId: profile.oauthClientId,
|
|
2970
|
+
refreshToken: cred.refreshToken
|
|
2971
|
+
});
|
|
2972
|
+
const refreshed = {
|
|
2973
|
+
kind: "access_token",
|
|
2974
|
+
accessToken: tokens.access_token,
|
|
2975
|
+
...tokens.refresh_token ? { refreshToken: tokens.refresh_token } : { refreshToken: cred.refreshToken },
|
|
2976
|
+
expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
|
|
2977
|
+
};
|
|
2978
|
+
const activeContext = profile.activeContext;
|
|
2979
|
+
const activeEntry = activeContext ? profile.contexts?.[activeContext] : void 0;
|
|
2980
|
+
const updated = activeContext && activeEntry ? writeProfileConfig(config, environment, {
|
|
2981
|
+
credential: refreshed,
|
|
2982
|
+
contexts: {
|
|
2983
|
+
...profile.contexts ?? {},
|
|
2984
|
+
[activeContext]: {
|
|
2985
|
+
...activeEntry,
|
|
2986
|
+
credential: refreshed,
|
|
2987
|
+
oauthClientId: activeEntry.oauthClientId ?? profile.oauthClientId
|
|
2988
|
+
}
|
|
2970
2989
|
}
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
}
|
|
2990
|
+
}) : environment === "production" && !config.profiles?.production ? { ...config, credential: refreshed } : writeProfileConfig(config, environment, { credential: refreshed });
|
|
2991
|
+
await writeConfig(updated);
|
|
2992
|
+
return refreshed;
|
|
2993
|
+
} catch {
|
|
2994
|
+
return cred;
|
|
2995
|
+
}
|
|
2996
|
+
});
|
|
2978
2997
|
}
|
|
2979
2998
|
async function refreshContextCredentialIfNeeded(environment, key, options = {}) {
|
|
2980
2999
|
return withConfigWriteLock(async () => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
|
-
"version": "0.9.
|
|
4
|
-
"topoloPublishedVersion": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
|
+
"topoloPublishedVersion": "0.9.3",
|
|
5
5
|
"description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
28
|
-
"@topolo/mcp": "0.11.
|
|
29
|
-
"@topolo/sdk": "0.11.
|
|
28
|
+
"@topolo/mcp": "0.11.10",
|
|
29
|
+
"@topolo/sdk": "0.11.10",
|
|
30
30
|
"commander": "^12.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|