MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkLoginState

Function checkLoginState

src/commands/remote-setup/remote-setup.tsx:23–61  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21 status: 'gh_not_authenticated';
22};
23async function checkLoginState(): Promise<CheckResult> {
24 if (!(await isSignedIn())) {
25 return {
26 status: 'not_signed_in'
27 };
28 }
29 const ghStatus = await getGhAuthStatus();
30 if (ghStatus === 'not_installed') {
31 return {
32 status: 'gh_not_installed'
33 };
34 }
35 if (ghStatus === 'not_authenticated') {
36 return {
37 status: 'gh_not_authenticated'
38 };
39 }
40
41 // ghStatus === 'authenticated'. getGhAuthStatus spawns with stdout:'ignore'
42 // (telemetry-safe); spawn once more with stdout:'pipe' to read the token.
43 const {
44 stdout
45 } = await execa('gh', ['auth', 'token'], {
46 stdout: 'pipe',
47 stderr: 'ignore',
48 timeout: 5000,
49 reject: false
50 });
51 const trimmed = stdout.trim();
52 if (!trimmed) {
53 return {
54 status: 'gh_not_authenticated'
55 };
56 }
57 return {
58 status: 'has_gh_token',
59 token: new RedactedGithubToken(trimmed)
60 };
61}
62function errorMessage(err: ImportTokenError, codeUrl: string): string {
63 switch (err.kind) {
64 case 'not_signed_in':

Callers 1

WebFunction · 0.85

Calls 2

isSignedInFunction · 0.85
getGhAuthStatusFunction · 0.85

Tested by

no test coverage detected