MCPcopy Create free account
hub / github.com/pingdotgg/t3code / parseGitHubAuthStatus

Function parseGitHubAuthStatus

apps/server/src/sourceControl/gitHubAuthStatus.ts:38–63  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

36}
37
38export function parseGitHubAuthStatus(text: string): GitHubAuthStatus {
39 return Option.match(decodeGitHubAuthStatusJson(text), {
40 onNone: () => ({ parsed: false, accounts: [] }),
41 onSome: (status) =>
42 ({
43 parsed: true,
44 accounts: Object.values(status.hosts).flatMap((accounts) =>
45 accounts.flatMap((account) => {
46 const host = nonEmptyString(account.host);
47 const login = nonEmptyString(account.login);
48 if (host === null || login === null) return [];
49
50 return [
51 {
52 host: host.toLowerCase(),
53 account: login,
54 authenticated: account.state === "success",
55 active: account.active,
56 error: account.error?.trim() || null,
57 },
58 ];
59 }),
60 ),
61 }) satisfies GitHubAuthStatus,
62 });
63}
64
65export function findAuthenticatedGitHubAccount(
66 accounts: ReadonlyArray<GitHubAuthStatusAccount>,

Callers 2

parseGitHubAuthFunction · 0.90

Calls 1

nonEmptyStringFunction · 0.70

Tested by

no test coverage detected