@@ -38,6 +38,7 @@ export interface GitHub {
3838 octokit : LoggingOctokit ;
3939 graphql : LoggingApolloClient ;
4040 currentUser ?: Promise < IAccount > ;
41+ isEmu ?: Promise < boolean > ;
4142}
4243
4344interface AuthResult {
@@ -347,18 +348,33 @@ export class CredentialStore implements vscode.Disposable {
347348 return ( await this . _githubAPI ?. currentUser ) ?. login === username || ( await this . _githubEnterpriseAPI ?. currentUser ) ?. login == username ;
348349 }
349350
351+ public async getIsEmu ( authProviderId : AuthProvider ) : Promise < boolean > {
352+ const github = this . getHub ( authProviderId ) ;
353+ return ! ! ( await github ?. isEmu ) ;
354+ }
355+
350356 public getCurrentUser ( authProviderId : AuthProvider ) : Promise < IAccount > {
351357 const github = this . getHub ( authProviderId ) ;
352358 const octokit = github ?. octokit ;
353359 return ( octokit && github ?. currentUser ) ! ;
354360 }
355361
356362 private setCurrentUser ( github : GitHub ) : void {
357- github . currentUser = new Promise ( resolve => {
363+ const getUser : ReturnType < typeof github . octokit . api . users . getAuthenticated > = new Promise ( resolve => {
358364 github . octokit . call ( github . octokit . api . users . getAuthenticated , { } ) . then ( result => {
365+ resolve ( result ) ;
366+ } ) ;
367+ } ) ;
368+ github . currentUser = new Promise ( resolve => {
369+ getUser . then ( result => {
359370 resolve ( convertRESTUserToAccount ( result . data ) ) ;
360371 } ) ;
361372 } ) ;
373+ github . isEmu = new Promise ( resolve => {
374+ getUser . then ( result => {
375+ resolve ( result . data . plan ?. name === 'emu_user' ) ;
376+ } ) ;
377+ } ) ;
362378 }
363379
364380 private async getSession ( authProviderId : AuthProvider , getAuthSessionOptions : vscode . AuthenticationGetSessionOptions , scopes : string [ ] , requireScopes : boolean ) : Promise < { session : vscode . AuthenticationSession | undefined , isNew : boolean , scopes : string [ ] } > {
0 commit comments