@topolo/cli 0.9.2 → 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 +51 -45
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -2942,52 +2942,58 @@ async function refreshCredentialIfNeeded(environment = selectedEnvironment(), op
|
|
|
2942
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) {
|
|
2943
2943
|
return resolveCredential(environment);
|
|
2944
2944
|
}
|
|
2945
|
-
const
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
);
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
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
|
+
}
|
|
2983
2989
|
}
|
|
2984
|
-
}
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
}
|
|
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
|
+
});
|
|
2991
2997
|
}
|
|
2992
2998
|
async function refreshContextCredentialIfNeeded(environment, key, options = {}) {
|
|
2993
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": {
|