@fluid-app/fluid-cli 0.1.753 → 0.1.755

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-2J2ThJ6q.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-X-HRUprR.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-C_RzFBdF.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-5slwyRzI.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";
6
6
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -463,11 +463,17 @@ async function loginWithIdentity(context) {
463
463
  signIn = await signInWithBrowser({
464
464
  identityUrl,
465
465
  log: context.log,
466
- loginHint: context.loginHint
466
+ loginHint: context.loginHint,
467
+ org: context.org,
468
+ prompt: context.forceLogin ? "login" : void 0
467
469
  });
468
470
  } catch (error) {
469
471
  return failed("IDENTITY_SIGN_IN_FAILED", describeIdentityError(error));
470
472
  }
473
+ if (context.org && signIn.facts.companyId && signIn.facts.companyId !== context.org) {
474
+ await signOutIdentity(signIn.auth).catch(() => void 0);
475
+ return failed("IDENTITY_COMPANY_MISMATCH", "The browser signed in to a different company than the sign-in link was for. Sign out of the browser's Fluid session and try again.");
476
+ }
471
477
  if (!signIn.facts.roles.some((role) => STAFF_ROLES.has(role))) {
472
478
  await signOutIdentity(signIn.auth).catch(() => void 0);
473
479
  return failed("SHOPPER_SESSION", "This account does not sign in as an admin or rep, so it cannot sign in to the CLI.");
@@ -526,7 +532,11 @@ async function loginWithIdentityLink(token, context) {
526
532
  }
527
533
  context.onLinkSettled?.();
528
534
  spinner.succeed("Sign-in link accepted");
529
- return loginWithIdentity(context);
535
+ return loginWithIdentity({
536
+ ...context,
537
+ org: redemption.value.companyUuid,
538
+ forceLogin: true
539
+ });
530
540
  }
531
541
  //#endregion
532
542
  //#region src/commands/login.ts
@@ -754,7 +764,10 @@ async function loginWithEmail(opts, ui, deps) {
754
764
  return 1;
755
765
  }
756
766
  const linkToken = identityLinkToken(code);
757
- if (linkToken) return identityResult(await loginWithIdentityLink(linkToken, identityContext(opts, true, ui, deps)), ui, deps);
767
+ if (linkToken) return identityResult(await loginWithIdentityLink(linkToken, {
768
+ ...identityContext(opts, true, ui, deps),
769
+ loginHint: normaliseEmail(email)
770
+ }), ui, deps);
758
771
  if (!/^\d{6}$/.test(code)) {
759
772
  deps.log(chalk.red("Code must be exactly 6 digits."));
760
773
  if (attempt < MAX_CODE_ATTEMPTS) continue;
@@ -952,6 +965,7 @@ async function finishStep(opts, interactive, ui, deps) {
952
965
  if (opts.name && overwriteRule(opts.name, overwrite) === "refuse") return ui.fail(profileExists(opts.name, false));
953
966
  if (linkToken) return identityResult(await loginWithIdentityLink(linkToken, {
954
967
  ...identityContext(opts, interactive, ui, deps, record.baseUrl),
968
+ loginHint: normaliseEmail(email),
955
969
  onLinkSettled: () => deps.pending.remove(email)
956
970
  }), ui, deps);
957
971
  const spinner = ui.spinner("Verifying code...");
@@ -1063,7 +1077,7 @@ const defaultSignupDeps = {
1063
1077
  isInteractive: () => Boolean(process.stdin.isTTY),
1064
1078
  agent: {
1065
1079
  poll: pollAgentAccess,
1066
- saveProfile: async (name, input, options) => (await import("../client-B7rLAOwk.mjs")).saveClientProfile(name, input, options),
1080
+ saveProfile: async (name, input, options) => (await import("../client-BABOfZRW.mjs")).saveClientProfile(name, input, options),
1067
1081
  strictConfig: isStrictConfig,
1068
1082
  stashRecovery: writeRecoveryFile,
1069
1083
  stderrIsTty: () => Boolean(process.stderr.isTTY),