file import { Octokit } from "@octokit/rest" ; import { User } from "../../common/Objects/User" ; param { string } token param { Octokit } initiated returns export async function getUserInfo ( token , octokit ) { const data = await octokit . request ( "HEAD /" ) ; const scopes = data . headers [ "x-oauth-scopes" ] . split ( ", " ) ; if ( scopes . lastIndexOf ( "repo" ) === - 1 ) { throw new Error ( "wrong scope" ) ; } const result = await octokit . users . getAuthenticated ( { } ) ; const userName = result . data . login ; const avatar_url = result . data . avatar_url ; const newUser = new User ( token , userName , avatar_url ) ; return newUser ; }