MCPcopy Index your code
hub / github.com/sourcebot-dev/sourcebot / detectGitHubTokenType

Function detectGitHubTokenType

packages/backend/src/github.ts:38–45  ·  view source on GitHub ↗
(token: string)

Source from the content-addressed store, hash-verified

36 * @see https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/
37 */
38export const detectGitHubTokenType = (token: string): GitHubTokenType => {
39 if (token.startsWith('ghp_')) return 'classic_pat';
40 if (token.startsWith('gho_')) return 'oauth_user';
41 if (token.startsWith('ghu_')) return 'app_user';
42 if (token.startsWith('ghs_')) return 'app_installation';
43 if (token.startsWith('github_pat_')) return 'fine_grained_pat';
44 return 'unknown';
45};
46
47/**
48 * Checks if a token type supports OAuth scope introspection via x-oauth-scopes header.

Callers 2

github.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected