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

Function chooseLoginProfileName

apps/cli/src/main.ts:2305–2326  ·  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

2303// distinct profiles instead of clobbering each other (the way opencode keys
2304// accounts by email/url). A re-login to the same account reuses its profile.
2305const chooseLoginProfileName = (
2306 store: CliServerConnectionStore,
2307 account: {
2308 readonly origin: string;
2309 readonly sub?: string;
2310 readonly org?: string;
2311 readonly email?: string;
2312 },
2313): string => {
2314 const identity =
2315 account.sub && account.org ? `${account.origin}|${account.sub}|${account.org}` : null;
2316 if (identity) {
2317 const existing = store.profiles.find((p) => oauthAccountIdentity(p.connection) === identity);
2318 if (existing) return existing.name;
2319 }
2320 const base = sanitizeProfileName(account.email ?? account.sub ?? loginHostLabel(account.origin));
2321 if (!store.profiles.some((p) => p.name === base)) return base;
2322 for (let suffix = 2; ; suffix += 1) {
2323 const candidate = `${base}-${suffix}`;
2324 if (!store.profiles.some((p) => p.name === candidate)) return candidate;
2325 }
2326};
2327
2328/** Where `executor login` lands with no flags and no stored profiles. */
2329const 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