@topolo/cli 0.13.24 → 0.13.25
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 +14 -12
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -6601,6 +6601,7 @@ async function runDeviceFlow(options) {
|
|
|
6601
6601
|
const config = await readConfig();
|
|
6602
6602
|
const resolved = resolvedProfileConfig(config, options.environment);
|
|
6603
6603
|
const oauth = new TopoloOAuth({
|
|
6604
|
+
environment: options.environment,
|
|
6604
6605
|
serviceUrls: resolved.serviceUrls
|
|
6605
6606
|
});
|
|
6606
6607
|
const start = await oauth.requestDeviceCode({
|
|
@@ -10130,8 +10131,9 @@ function errorMessage(error) {
|
|
|
10130
10131
|
}
|
|
10131
10132
|
|
|
10132
10133
|
// src/commands/context.ts
|
|
10133
|
-
function makeClient(credential, serviceUrls) {
|
|
10134
|
+
function makeClient(environment, credential, serviceUrls) {
|
|
10134
10135
|
return createTopolo({
|
|
10136
|
+
environment,
|
|
10135
10137
|
credential,
|
|
10136
10138
|
agent: { clientName: "topolo-cli", clientVersion: CLI_VERSION },
|
|
10137
10139
|
serviceUrls
|
|
@@ -10141,8 +10143,8 @@ function unwrap(res) {
|
|
|
10141
10143
|
const r = res ?? {};
|
|
10142
10144
|
return r.data ?? r;
|
|
10143
10145
|
}
|
|
10144
|
-
async function fetchMe(credential, serviceUrls) {
|
|
10145
|
-
const topolo = makeClient(credential, serviceUrls);
|
|
10146
|
+
async function fetchMe(environment, credential, serviceUrls) {
|
|
10147
|
+
const topolo = makeClient(environment, credential, serviceUrls);
|
|
10146
10148
|
const data = unwrap(await topolo.client.request({ service: "auth", method: "GET", path: "/api/auth/me" }));
|
|
10147
10149
|
const user = data.user ?? {};
|
|
10148
10150
|
const rawMemberships = user.organizationMemberships || data.organizations || [];
|
|
@@ -10169,8 +10171,8 @@ function credentialFromTokens(tokens) {
|
|
|
10169
10171
|
...expiresAt ? { expiresAt } : {}
|
|
10170
10172
|
};
|
|
10171
10173
|
}
|
|
10172
|
-
async function exchangeForContext(credential, serviceUrls, target) {
|
|
10173
|
-
const topolo = makeClient(credential, serviceUrls);
|
|
10174
|
+
async function exchangeForContext(environment, credential, serviceUrls, target) {
|
|
10175
|
+
const topolo = makeClient(environment, credential, serviceUrls);
|
|
10174
10176
|
const data = unwrap(
|
|
10175
10177
|
await topolo.client.request({
|
|
10176
10178
|
service: "auth",
|
|
@@ -10229,7 +10231,7 @@ function registerContextCommand(program2) {
|
|
|
10229
10231
|
let activeIdentity = null;
|
|
10230
10232
|
if (cred) {
|
|
10231
10233
|
try {
|
|
10232
|
-
activeIdentity = await fetchMe(cred, serviceUrls);
|
|
10234
|
+
activeIdentity = await fetchMe(environment, cred, serviceUrls);
|
|
10233
10235
|
} catch {
|
|
10234
10236
|
activeIdentity = null;
|
|
10235
10237
|
}
|
|
@@ -10238,7 +10240,7 @@ function registerContextCommand(program2) {
|
|
|
10238
10240
|
try {
|
|
10239
10241
|
const contextCredential = key === activeKey ? cred : await refreshContextCredentialIfNeeded(environment, key);
|
|
10240
10242
|
if (!contextCredential) return;
|
|
10241
|
-
const identity = key === activeKey && activeIdentity ? activeIdentity : await fetchMe(contextCredential, serviceUrls);
|
|
10243
|
+
const identity = key === activeKey && activeIdentity ? activeIdentity : await fetchMe(environment, contextCredential, serviceUrls);
|
|
10242
10244
|
if (!identityMatchesContext(identity, ctx)) return;
|
|
10243
10245
|
const row = rows.get(key) ?? {
|
|
10244
10246
|
key,
|
|
@@ -10334,7 +10336,7 @@ function registerContextCommand(program2) {
|
|
|
10334
10336
|
} else if (wantPersonal) {
|
|
10335
10337
|
resolved = { contextType: "personal" };
|
|
10336
10338
|
} else {
|
|
10337
|
-
const me = await fetchMe(cred, serviceUrls);
|
|
10339
|
+
const me = await fetchMe(environment, cred, serviceUrls);
|
|
10338
10340
|
const match = me.memberships.find(
|
|
10339
10341
|
(m) => m.id === target || m.slug?.toLowerCase() === needle || m.name?.toLowerCase() === needle
|
|
10340
10342
|
);
|
|
@@ -10359,7 +10361,7 @@ function registerContextCommand(program2) {
|
|
|
10359
10361
|
const storedCredential = await refreshContextCredentialIfNeeded(environment, key);
|
|
10360
10362
|
if (storedCredential) {
|
|
10361
10363
|
try {
|
|
10362
|
-
const storedIdentity = await fetchMe(storedCredential, serviceUrls);
|
|
10364
|
+
const storedIdentity = await fetchMe(environment, storedCredential, serviceUrls);
|
|
10363
10365
|
if (identityMatchesContext(storedIdentity, resolved)) {
|
|
10364
10366
|
newCredential = storedCredential;
|
|
10365
10367
|
}
|
|
@@ -10369,13 +10371,13 @@ function registerContextCommand(program2) {
|
|
|
10369
10371
|
}
|
|
10370
10372
|
if (!newCredential) {
|
|
10371
10373
|
if (resolved.contextType === "personal") {
|
|
10372
|
-
const identity = await fetchMe(cred, serviceUrls);
|
|
10374
|
+
const identity = await fetchMe(environment, cred, serviceUrls);
|
|
10373
10375
|
if (!identity.personalAvailable) {
|
|
10374
10376
|
throw new Error("Personal context is not available for this account.");
|
|
10375
10377
|
}
|
|
10376
10378
|
}
|
|
10377
10379
|
try {
|
|
10378
|
-
newCredential = await exchangeForContext(cred, serviceUrls, {
|
|
10380
|
+
newCredential = await exchangeForContext(environment, cred, serviceUrls, {
|
|
10379
10381
|
type: resolved.contextType,
|
|
10380
10382
|
id: resolved.organizationId
|
|
10381
10383
|
});
|
|
@@ -10388,7 +10390,7 @@ function registerContextCommand(program2) {
|
|
|
10388
10390
|
);
|
|
10389
10391
|
}
|
|
10390
10392
|
cred = refreshed;
|
|
10391
|
-
newCredential = await exchangeForContext(cred, serviceUrls, {
|
|
10393
|
+
newCredential = await exchangeForContext(environment, cred, serviceUrls, {
|
|
10392
10394
|
type: resolved.contextType,
|
|
10393
10395
|
id: resolved.organizationId
|
|
10394
10396
|
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/cli",
|
|
3
3
|
"packageManager": "pnpm@10.17.1",
|
|
4
|
-
"version": "0.13.
|
|
5
|
-
"topoloPublishedVersion": "0.13.
|
|
4
|
+
"version": "0.13.25",
|
|
5
|
+
"topoloPublishedVersion": "0.13.25",
|
|
6
6
|
"description": "Public command-line interface for Topolo customer organizations, developers, and agents.",
|
|
7
7
|
"license": "UNLICENSED",
|
|
8
8
|
"author": "Topolo",
|