MCPcopy Index your code
hub / github.com/refined-github/refined-github / parseTokenScopes

Function parseTokenScopes

source/github-helpers/github-token.ts:75–95  ·  view source on GitHub ↗
(headers: Headers)

Source from the content-addressed store, hash-verified

73}
74
75function parseTokenScopes(headers: Headers): string[] {
76 // If `X-OAuth-Scopes` is not present, the token may be not a classic token.
77 const scopesHeader = headers.get('X-OAuth-Scopes');
78 if (!scopesHeader) {
79 // If the request succeeded but lacked this header, it's likely a fine-grained token
80 // https://github.com/orgs/community/discussions/25259#discussioncomment-3247158
81 return ['valid_token', 'unknown'];
82 }
83
84 const scopes = scopesHeader.split(', ');
85 scopes.push('valid_token');
86 if (scopes.includes('repo')) {
87 scopes.push('public_repo');
88 }
89
90 if (scopes.includes('project')) {
91 scopes.push('read:project');
92 }
93
94 return scopes;
95}
96
97type TokenInfo = {
98 scopes: string[];

Callers 1

getTokenInfoFunction · 0.85

Calls 2

getMethod · 0.80
includesMethod · 0.80

Tested by

no test coverage detected