MCPcopy Create free account
hub / github.com/desktop/desktop / fetchUser

Function fetchUser

app/src/lib/api.ts:2228–2259  ·  view source on GitHub ↗
(
  endpoint: string,
  token: string
)

Source from the content-addressed store, hash-verified

2226
2227/** Fetch the user authenticated by the token. */
2228export async function fetchUser(
2229 endpoint: string,
2230 token: string
2231): Promise<Account> {
2232 const api = new API(endpoint, token)
2233 try {
2234 const [user, emails, copilotInfo, features] = await Promise.all([
2235 api.fetchAccount(),
2236 api.fetchEmails(),
2237 api.fetchUserCopilotInfo(),
2238 api.fetchFeatureFlags(),
2239 ])
2240
2241 return new Account(
2242 user.login,
2243 endpoint,
2244 token,
2245 emails,
2246 user.avatar_url,
2247 user.id,
2248 user.name || user.login,
2249 user.plan?.name,
2250 copilotInfo?.copilotEndpoint,
2251 copilotInfo?.isCopilotDesktopEnabled,
2252 features,
2253 copilotInfo?.copilotLicenseType
2254 )
2255 } catch (e) {
2256 log.warn(`fetchUser: failed with endpoint ${endpoint}`, e)
2257 throw e
2258 }
2259}
2260
2261/**
2262 * Map a repository's URL to the endpoint associated with it. For example:

Callers 2

resolveOAuthRequestMethod · 0.90
updatedAccountFunction · 0.90

Calls 5

fetchAccountMethod · 0.95
fetchEmailsMethod · 0.95
fetchUserCopilotInfoMethod · 0.95
fetchFeatureFlagsMethod · 0.95
warnMethod · 0.80

Tested by

no test coverage detected