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

Function chooseLoginProfileName

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

2334// distinct profiles instead of clobbering each other (the way opencode keys
2335// accounts by email/url). A re-login to the same account reuses its profile.
2336const chooseLoginProfileName = (
2337 store: CliServerConnectionStore,
2338 account: {
2339 readonly origin: string;
2340 readonly sub?: string;
2341 readonly org?: string;
2342 readonly email?: string;
2343 },
2344): string => {
2345 const identity =
2346 account.sub && account.org ? `${account.origin}|${account.sub}|${account.org}` : null;
2347 if (identity) {
2348 const existing = store.profiles.find((p) => oauthAccountIdentity(p.connection) === identity);
2349 if (existing) return existing.name;
2350 }
2351 const base = sanitizeProfileName(account.email ?? account.sub ?? loginHostLabel(account.origin));
2352 if (!store.profiles.some((p) => p.name === base)) return base;
2353 for (let suffix = 2; ; suffix += 1) {
2354 const candidate = `${base}-${suffix}`;
2355 if (!store.profiles.some((p) => p.name === candidate)) return candidate;
2356 }
2357};
2358
2359/** Where `executor login` lands with no flags and no stored profiles. */
2360const 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