MCPcopy
hub / github.com/refined-github/refined-github / expectTokenScope

Function expectTokenScope

source/github-helpers/github-token.ts:116–130  ·  view source on GitHub ↗
(scope: string)

Source from the content-addressed store, hash-verified

114}
115
116export async function expectTokenScope(scope: string): Promise<void> {
117 const token = await expectToken();
118 const api = pageDetect.isEnterprise()
119 ? `${location.origin}/api/v3/`
120 : 'https://api.github.com/';
121
122 const {scopes: tokenScopes} = await getTokenInfo(api, token);
123 if (!tokenScopes.includes(scope)) {
124 throw new Error(
125 'The token you provided does not have ' + (tokenScopes.length > 0
126 ? `the \`${scope}\` scope. It only includes \`${tokenScopes.join(', ')}\`.`
127 : 'any scope. You can change the scope of your token at https://github.com/settings/tokens'),
128 );
129 }
130}

Callers 2

deleteRepositoryFunction · 0.85
updaterFunction · 0.85

Calls 3

expectTokenFunction · 0.85
getTokenInfoFunction · 0.85
includesMethod · 0.80

Tested by

no test coverage detected