(apiBase: string, personalToken: string)
| 100 | }; |
| 101 | |
| 102 | export async function getTokenInfo(apiBase: string, personalToken: string): Promise<TokenInfo> { |
| 103 | const {headers} = await baseApiFetch({apiBase, token: personalToken, path: ''}); |
| 104 | |
| 105 | const expiration = headers.get('GitHub-Authentication-Token-Expiration'); |
| 106 | // Convert `2026-06-03 19:52:44 UTC` to `2026-06-03T19:52:44Z` |
| 107 | // So that `Date` constructor in Safari can parse it: #9043 |
| 108 | const expirationTransformed = expiration?.replace(' ', 'T').replace(' UTC', 'Z'); |
| 109 | |
| 110 | return { |
| 111 | scopes: parseTokenScopes(headers), |
| 112 | expiration: expirationTransformed, |
| 113 | }; |
| 114 | } |
| 115 | |
| 116 | export async function expectTokenScope(scope: string): Promise<void> { |
| 117 | const token = await expectToken(); |
no test coverage detected