@fluid-app/fluid-cli 0.1.742 → 0.1.744
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/bin/fluid.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { $ as walkCommands, A as pollAgentAccess, D as fetchUserCompanies, E as confirmMfa, F as validateToken, M as sendMfa, N as signup, O as getFluidApiBase, P as switchCompany, Q as visibleSubcommands, S as resolveCredentialSource, X as rootCommand, Y as filterCatalog, Z as visibleOptions, _ as getAuthToken, c as inputsModeActive, g as getActiveProfile, j as redeemIdentityLink, k as isInsecureRemoteBase, l as registerInputsHook, s as exitOnInputsError, u as createInputsReader, w as FLUID_API_ERROR, x as readFdToken } from "../hook-
|
|
2
|
+
import { $ as walkCommands, A as pollAgentAccess, D as fetchUserCompanies, E as confirmMfa, F as validateToken, M as sendMfa, N as signup, O as getFluidApiBase, P as switchCompany, Q as visibleSubcommands, S as resolveCredentialSource, X as rootCommand, Y as filterCatalog, Z as visibleOptions, _ as getAuthToken, c as inputsModeActive, g as getActiveProfile, j as redeemIdentityLink, k as isInsecureRemoteBase, l as registerInputsHook, s as exitOnInputsError, u as createInputsReader, w as FLUID_API_ERROR, x as readFdToken } from "../hook-D0Np47MY.mjs";
|
|
3
3
|
import { A as isClientProfile, C as readStoredConfig, D as getConfigDir, E as isStrictConfig, S as readConfig, T as writeConfig, _ as primeClientProfile, c as sessionFacts, j as isIdentityProfile, l as signInWithBrowser, n as describeIdentityError, o as primeIdentityProfile, p as clientAccessToken, r as identityToken, t as endUnusedSessions, u as signOutIdentity, w as updateConfig, y as resolveIdentityUrl } from "../profiles-BRMp_Rr8.mjs";
|
|
4
4
|
import { createRequire } from "node:module";
|
|
5
5
|
import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -1529,7 +1529,37 @@ async function whoamiClient(profile) {
|
|
|
1529
1529
|
console.log(` Org: ${chalk.dim(profile.auth.org)}`);
|
|
1530
1530
|
console.log(` Stored: ${chalk.dim(profile.storedAt)}`);
|
|
1531
1531
|
}
|
|
1532
|
+
/** The prefix of a company API token, which has no user. */
|
|
1533
|
+
const COMPANY_TOKEN_PREFIX = "PT-";
|
|
1534
|
+
/**
|
|
1535
|
+
* Check a token from FLUID_TOKEN (or FLUID_TOKEN_FD), which every other
|
|
1536
|
+
* command uses before any saved login, against FLUID_API_BASE.
|
|
1537
|
+
*
|
|
1538
|
+
* token - The token the environment holds.
|
|
1539
|
+
*
|
|
1540
|
+
* Returns nothing; sets the exit code when the token is refused.
|
|
1541
|
+
*/
|
|
1542
|
+
async function whoamiEnvToken(token) {
|
|
1543
|
+
const baseUrl = process.env["FLUID_API_BASE"];
|
|
1544
|
+
const spinner = ora("Verifying the token from FLUID_TOKEN...").start();
|
|
1545
|
+
const result = await validateToken(token, baseUrl ? { baseUrl } : {});
|
|
1546
|
+
if (!result.success) {
|
|
1547
|
+
spinner.fail(chalk.red("The token in FLUID_TOKEN was refused."));
|
|
1548
|
+
console.log(chalk.dim(result.error.message));
|
|
1549
|
+
process.exitCode = 1;
|
|
1550
|
+
return;
|
|
1551
|
+
}
|
|
1552
|
+
spinner.succeed(chalk.green("Authenticated (token from FLUID_TOKEN)"));
|
|
1553
|
+
console.log(` Company: ${chalk.bold(result.value.name)}`);
|
|
1554
|
+
if (token.startsWith(COMPANY_TOKEN_PREFIX)) console.log(chalk.yellow(" A company API token has no user. It can read company sites, but publishing, sharing and site logs need a signed-in admin: run `fluid login`."));
|
|
1555
|
+
if (!baseUrl) console.log(chalk.yellow(" FLUID_API_BASE is not set. With FLUID_TOKEN and no saved login, the sites commands need it, such as https://api.fluid.app."));
|
|
1556
|
+
}
|
|
1532
1557
|
const whoamiCommand = new Command("whoami").description("Show the current authenticated profile").action(async () => {
|
|
1558
|
+
const source = resolveCredentialSource();
|
|
1559
|
+
if (source?.kind === "token") {
|
|
1560
|
+
await whoamiEnvToken(source.token);
|
|
1561
|
+
return;
|
|
1562
|
+
}
|
|
1533
1563
|
const profile = getActiveProfile();
|
|
1534
1564
|
if (!profile) {
|
|
1535
1565
|
console.log(chalk.yellow("Not logged in. Run `fluid login` to authenticate."));
|