MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / chooseLoginProfileName

Function chooseLoginProfileName

apps/cli/src/main.ts:2429–2450  ·  view source on GitHub ↗
(
  store: CliServerConnectionStore,
  account: {
    readonly origin: string;
    readonly sub?: string;
    readonly org?: string;
    readonly email?: string;
  },
)

Source from the content-addressed store, hash-verified

2427// distinct profiles instead of clobbering each other (the way opencode keys
2428// accounts by email/url). A re-login to the same account reuses its profile.
2429const chooseLoginProfileName = (
2430 store: CliServerConnectionStore,
2431 account: {
2432 readonly origin: string;
2433 readonly sub?: string;
2434 readonly org?: string;
2435 readonly email?: string;
2436 },
2437): string => {
2438 const identity =
2439 account.sub && account.org ? `${account.origin}|${account.sub}|${account.org}` : null;
2440 if (identity) {
2441 const existing = store.profiles.find((p) => oauthAccountIdentity(p.connection) === identity);
2442 if (existing) return existing.name;
2443 }
2444 const base = sanitizeProfileName(account.email ?? account.sub ?? loginHostLabel(account.origin));
2445 if (!store.profiles.some((p) => p.name === base)) return base;
2446 for (let suffix = 2; ; suffix += 1) {
2447 const candidate = `${base}-${suffix}`;
2448 if (!store.profiles.some((p) => p.name === candidate)) return candidate;
2449 }
2450};
2451
2452/** Where `executor login` lands with no flags and no stored profiles. */
2453const DEFAULT_LOGIN_ORIGIN = "https://executor.sh";

Callers 1

main.tsFile · 0.85

Calls 3

oauthAccountIdentityFunction · 0.85
sanitizeProfileNameFunction · 0.85
loginHostLabelFunction · 0.85

Tested by

no test coverage detected