@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.
Files changed (2) hide show
  1. package/dist/index.js +65 -46
  2. 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
- return this.request({
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 config = await readConfig();
2933
- const profile = profileForEnvironment(config, environment);
2934
- const cred = profile.credential;
2935
- if (!cred || cred.kind !== "access_token") return cred ?? null;
2936
- if (!cred.refreshToken || !profile.oauthClientId) return cred;
2937
- const now = Math.floor(Date.now() / 1e3);
2938
- if (!options.force && cred.expiresAt && cred.expiresAt - REFRESH_SKEW_SECONDS > now) return cred;
2939
- const serviceUrls = resolveServiceUrls(profile.serviceUrls, environment);
2940
- if (environment === "local" && !serviceUrls?.auth) {
2941
- throw new TopoloSdkError2(
2942
- "environment_service_url_required",
2943
- "Local Topolo credential refresh requires an explicit local Auth service origin."
2944
- );
2945
- }
2946
- try {
2947
- const oauth = new TopoloOAuth2({
2948
- serviceUrls
2949
- });
2950
- const tokens = await oauth.refreshToken({
2951
- clientId: profile.oauthClientId,
2952
- refreshToken: cred.refreshToken
2953
- });
2954
- const refreshed = {
2955
- kind: "access_token",
2956
- accessToken: tokens.access_token,
2957
- ...tokens.refresh_token ? { refreshToken: tokens.refresh_token } : { refreshToken: cred.refreshToken },
2958
- expiresAt: Math.floor(Date.now() / 1e3) + tokens.expires_in
2959
- };
2960
- const activeContext = profile.activeContext;
2961
- const activeEntry = activeContext ? profile.contexts?.[activeContext] : void 0;
2962
- const updated = activeContext && activeEntry ? writeProfileConfig(config, environment, {
2963
- credential: refreshed,
2964
- contexts: {
2965
- ...profile.contexts ?? {},
2966
- [activeContext]: {
2967
- ...activeEntry,
2968
- credential: refreshed,
2969
- oauthClientId: activeEntry.oauthClientId ?? profile.oauthClientId
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
- }) : environment === "production" && !config.profiles?.production ? { ...config, credential: refreshed } : writeProfileConfig(config, environment, { credential: refreshed });
2973
- await writeConfig(updated);
2974
- return refreshed;
2975
- } catch {
2976
- return cred;
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.1",
4
- "topoloPublishedVersion": "0.9.1",
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.8",
29
- "@topolo/sdk": "0.11.8",
28
+ "@topolo/mcp": "0.11.10",
29
+ "@topolo/sdk": "0.11.10",
30
30
  "commander": "^12.1.0"
31
31
  },
32
32
  "devDependencies": {