(token: string)
| 36 | * @see https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats/ |
| 37 | */ |
| 38 | export 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. |
no outgoing calls
no test coverage detected