@topolo/cli 0.4.1 → 0.4.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 +16 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3970,7 +3970,7 @@ var CLI_VERSION = readCliVersion();
|
|
|
3970
3970
|
// src/commands/auth.ts
|
|
3971
3971
|
function registerAuthCommands(program2) {
|
|
3972
3972
|
const auth = program2.command("auth").description("Manage Topolo credentials");
|
|
3973
|
-
auth.command("login").description("Authenticate with Topolo via OAuth device flow (default) or store an API key").option("--api-key <key>", "Store an API key directly, skipping the OAuth flow").option("--client-id <id>", "OAuth client_id (or set TOPOLO_CLI_CLIENT_ID)").option("--scope <scope>", "Scopes to request (space-separated)").option("--json", "Output JSON").option("--no-json", "Output human-readable text").action(
|
|
3973
|
+
auth.command("login").description("Authenticate with Topolo via OAuth device flow (default) or store an API key").option("--api-key <key>", "Store an API key directly, skipping the OAuth flow").option("--client-id <id>", "OAuth client_id (or set TOPOLO_CLI_CLIENT_ID)").option("--scope <scope>", "Scopes to request (space-separated)").option("--no-browser", "Print the approval URL without opening a browser").option("--json", "Output JSON").option("--no-json", "Output human-readable text").action(
|
|
3974
3974
|
async (opts) => {
|
|
3975
3975
|
const mode = resolveOutputMode(opts.json);
|
|
3976
3976
|
const environment = selectedEnvironment();
|
|
@@ -3999,7 +3999,13 @@ Visit ${apiKeyIssuanceUrl(environment)} to mint one, or configure an OAuth clien
|
|
|
3999
3999
|
await storeApiKey(apiKey, environment, mode);
|
|
4000
4000
|
return;
|
|
4001
4001
|
}
|
|
4002
|
-
await runDeviceFlow({
|
|
4002
|
+
await runDeviceFlow({
|
|
4003
|
+
clientId,
|
|
4004
|
+
environment,
|
|
4005
|
+
scope: opts.scope,
|
|
4006
|
+
mode,
|
|
4007
|
+
openBrowser: opts.browser !== false
|
|
4008
|
+
});
|
|
4003
4009
|
} catch (err) {
|
|
4004
4010
|
fail(err, mode);
|
|
4005
4011
|
}
|
|
@@ -4073,7 +4079,7 @@ async function runDeviceFlow(options) {
|
|
|
4073
4079
|
});
|
|
4074
4080
|
const verifyUrl = start.verification_uri_complete ?? start.verification_uri;
|
|
4075
4081
|
const expiresMin = Math.round(start.expires_in / 60);
|
|
4076
|
-
const opened = options.mode === "pretty" ? tryOpenBrowser(verifyUrl) : false;
|
|
4082
|
+
const opened = options.mode === "pretty" && options.openBrowser ? tryOpenBrowser(verifyUrl) : false;
|
|
4077
4083
|
if (options.mode === "pretty") {
|
|
4078
4084
|
process.stderr.write(
|
|
4079
4085
|
`
|
|
@@ -11222,10 +11228,16 @@ function registerContextCommand(program2) {
|
|
|
11222
11228
|
const config = await readConfig();
|
|
11223
11229
|
const profile = profileForEnvironment(config, environment);
|
|
11224
11230
|
const serviceUrls = resolvedProfileConfig(config, environment).serviceUrls;
|
|
11225
|
-
const
|
|
11231
|
+
const priorCredential = profile.credential ?? (profile.activeContext ? profile.contexts?.[profile.activeContext]?.credential : void 0);
|
|
11232
|
+
const cred = await refreshCredentialIfNeeded(environment, { force: true });
|
|
11226
11233
|
if (!cred) {
|
|
11227
11234
|
throw new Error("Not signed in. Run `topolo auth login` first.");
|
|
11228
11235
|
}
|
|
11236
|
+
if (priorCredential?.kind === "access_token" && priorCredential.refreshToken && cred.kind === "access_token" && cred.accessToken === priorCredential.accessToken) {
|
|
11237
|
+
throw new Error(
|
|
11238
|
+
`The active credential could not be refreshed. Run \`topolo --env ${environment} auth login\` to sign in again.`
|
|
11239
|
+
);
|
|
11240
|
+
}
|
|
11229
11241
|
const wantPersonal = /^(personal|me)$/i.test(target.trim());
|
|
11230
11242
|
let resolved;
|
|
11231
11243
|
const needle = target.trim().toLowerCase();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "Command-line interface for Topolo developers, operators, and agents, with internal first-party scaffolding available under the topolo platform namespace.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|