@fluid-app/fluid-cli 0.1.796 → 0.1.798

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.
@@ -1,6 +1,6 @@
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-Dc3vVUfk.mjs";
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-DqDZHbAv.mjs";
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-O0j_i9gX.mjs";
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-Sitg25-8.mjs";
4
4
  import { createRequire } from "node:module";
5
5
  import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -1307,6 +1307,9 @@ async function overwriteDecision(profileName, opts, deps) {
1307
1307
  initial: false
1308
1308
  }))["overwrite"] ? "replace" : "keep";
1309
1309
  }
1310
+ function isLegacyProfile(profile) {
1311
+ return profile !== void 0 && !profile.auth && typeof profile.token === "string" && profile.token !== "";
1312
+ }
1310
1313
  function profileExists(profileName, codeUsed) {
1311
1314
  return {
1312
1315
  code: "PROFILE_EXISTS",
@@ -1359,10 +1362,18 @@ function identityContext(opts, interactive, ui, deps, apiBase) {
1359
1362
  ...options
1360
1363
  }),
1361
1364
  redeemIdentityLink: deps.api.redeemIdentityLink,
1362
- decideOverwrite: (profileName) => overwriteDecision(profileName, {
1363
- yes: Boolean(opts.yes),
1364
- interactive
1365
- }, deps)
1365
+ decideOverwrite: (profileName) => {
1366
+ if (isLegacyProfile(readConfig().profiles[profileName])) {
1367
+ const notice = `Replaced legacy profile "${profileName}" with a One Auth sign-in.`;
1368
+ if (ui.json) deps.err(notice);
1369
+ else deps.log(chalk.dim(notice));
1370
+ return Promise.resolve("replace");
1371
+ }
1372
+ return overwriteDecision(profileName, {
1373
+ yes: Boolean(opts.yes),
1374
+ interactive
1375
+ }, deps);
1376
+ }
1366
1377
  };
1367
1378
  }
1368
1379
  function identityResult(outcome, ui, deps) {
@@ -1403,12 +1414,20 @@ async function loginWithEmail(opts, ui, deps) {
1403
1414
  }
1404
1415
  }
1405
1416
  const sendSpinner = ui.spinner("Sending verification code...");
1406
- const sendResult = await deps.api.sendMfa(email, opts.shop ? { fluidShop: opts.shop } : { identityHint: true });
1417
+ const sendResult = await deps.api.sendMfa(email, opts.shop ? {
1418
+ fluidShop: opts.shop,
1419
+ identityHint: true
1420
+ } : { identityHint: true });
1407
1421
  if (!sendResult.success) return ui.fail(sendResult.error, sendSpinner);
1408
1422
  if (sendResult.value.signInPath === "identity") {
1423
+ if (opts.shop && !sendResult.value.companyUuid) return ui.fail({
1424
+ code: "SHOP_NOT_RESOLVED",
1425
+ message: `Could not resolve ${opts.shop} for browser sign-in. Run "fluid login" without --shop and pick the shop in the browser.`
1426
+ }, sendSpinner);
1409
1427
  sendSpinner.succeed("Opening your browser to sign in");
1410
1428
  return identityResult(await loginWithIdentity({
1411
1429
  ...identityContext(opts, true, ui, deps),
1430
+ ...opts.shop ? pinnedIdentity(sendResult.value.companyUuid) : {},
1412
1431
  loginHint: normaliseEmail(email)
1413
1432
  }), ui, deps);
1414
1433
  }
@@ -1629,7 +1648,7 @@ async function finishStep(opts, interactive, ui, deps) {
1629
1648
  yes: Boolean(opts.yes),
1630
1649
  interactive
1631
1650
  };
1632
- if (opts.name && overwriteRule(opts.name, overwrite) === "refuse") return ui.fail(profileExists(opts.name, false));
1651
+ if (opts.name && !(linkToken && isLegacyProfile(readConfig().profiles[opts.name])) && overwriteRule(opts.name, overwrite) === "refuse") return ui.fail(profileExists(opts.name, false));
1633
1652
  if (linkToken) return identityResult(await loginWithIdentityLink(linkToken, {
1634
1653
  ...identityContext(opts, interactive, ui, deps, record.baseUrl),
1635
1654
  loginHint: normaliseEmail(email),
@@ -1748,7 +1767,7 @@ const defaultSignupDeps = {
1748
1767
  isInteractive: () => Boolean(process.stdin.isTTY),
1749
1768
  agent: {
1750
1769
  poll: pollAgentAccess,
1751
- saveProfile: async (name, input, options) => (await import("../client-CFmMhNvn.mjs")).saveClientProfile(name, input, options),
1770
+ saveProfile: async (name, input, options) => (await import("../client-8ZkZdMPP.mjs")).saveClientProfile(name, input, options),
1752
1771
  strictConfig: isStrictConfig,
1753
1772
  stashRecovery: writeRecoveryFile,
1754
1773
  stderrIsTty: () => Boolean(process.stderr.isTTY),