diff --git a/extensions/github-authentication/src/extension.ts b/extensions/github-authentication/src/extension.ts index bd41ea45535..c9b76d81670 100644 --- a/extensions/github-authentication/src/extension.ts +++ b/extensions/github-authentication/src/extension.ts @@ -26,14 +26,14 @@ export async function activate(context: vscode.ExtensionContext) { onDidChangeSessions: onDidChangeSessions.event, getAllSessions: () => Promise.resolve(loginService.sessions), getSessions: (scopes: string[]) => loginService.getSessions(scopes), - login: async (scopeList: string[]) => { + createSession: async (scopeList: string[]) => { try { /* __GDPR__ "login" : { } */ telemetryReporter.sendTelemetryEvent('login'); - const session = await loginService.login(scopeList.sort().join(' ')); + const session = await loginService.createSession(scopeList.sort().join(' ')); Logger.info('Login success!'); onDidChangeSessions.fire({ added: [session], removed: [], changed: [] }); return session; @@ -57,14 +57,14 @@ export async function activate(context: vscode.ExtensionContext) { throw e; } }, - logout: async (id: string) => { + removeSession: async (id: string) => { try { /* __GDPR__ "logout" : { } */ telemetryReporter.sendTelemetryEvent('logout'); - const session = await loginService.logout(id); + const session = await loginService.removeSession(id); if (session) { onDidChangeSessions.fire({ added: [], removed: [session], changed: [] }); } diff --git a/extensions/github-authentication/src/github.ts b/extensions/github-authentication/src/github.ts index f3ef508cd5c..89893c94ccd 100644 --- a/extensions/github-authentication/src/github.ts +++ b/extensions/github-authentication/src/github.ts @@ -158,7 +158,7 @@ export class GitHubAuthenticationProvider { return this._sessions; } - public async login(scopes: string): Promise { + public async createSession(scopes: string): Promise { const token = await this._githubServer.login(scopes); const session = await this.tokenToSession(token, scopes.split(' ')); await this.setToken(session); @@ -190,7 +190,7 @@ export class GitHubAuthenticationProvider { await this.storeSessions(); } - public async logout(id: string): Promise { + public async removeSession(id: string): Promise { Logger.info(`Logging out of ${id}`); const sessionIndex = this._sessions.findIndex(session => session.id === id); let session: vscode.AuthenticationSession | undefined; diff --git a/extensions/microsoft-authentication/src/AADHelper.ts b/extensions/microsoft-authentication/src/AADHelper.ts index 17ff85a6db9..cd8b66075fc 100644 --- a/extensions/microsoft-authentication/src/AADHelper.ts +++ b/extensions/microsoft-authentication/src/AADHelper.ts @@ -144,7 +144,7 @@ export class AzureActiveDirectoryService { this.pollForReconnect(session.id, session.refreshToken, session.scope); } } else { - await this.logout(session.id); + await this.removeSession(session.id); } } }); @@ -193,7 +193,7 @@ export class AzureActiveDirectoryService { if (e.message === REFRESH_NETWORK_FAILURE) { // Ignore, will automatically retry on next poll. } else { - await this.logout(session.id); + await this.removeSession(session.id); } } } @@ -202,7 +202,7 @@ export class AzureActiveDirectoryService { promises = promises.concat(this._tokens.map(async token => { const matchesExisting = sessions.some(session => token.scope === session.scope && token.sessionId === session.id); if (!matchesExisting) { - await this.logout(token.sessionId); + await this.removeSession(token.sessionId); removed.push(this.convertToSessionSync(token)); } })); @@ -306,7 +306,7 @@ export class AzureActiveDirectoryService { return Promise.all(this._tokens.map(token => this.convertToSession(token))); } - public async login(scope: string): Promise { + public async createSession(scope: string): Promise { Logger.info('Logging in...'); if (!scope.includes('offline_access')) { Logger.info('Warning: The \'offline_access\' scope was not included, so the generated token will not be able to be refreshed.'); @@ -507,7 +507,7 @@ export class AzureActiveDirectoryService { this.pollForReconnect(token.sessionId, token.refreshToken, token.scope); } } else { - await this.logout(token.sessionId); + await this.removeSession(token.sessionId); onDidChangeSessions.fire({ added: [], removed: [this.convertToSessionSync(token)], changed: [] }); } } @@ -687,7 +687,7 @@ export class AzureActiveDirectoryService { }); } - public async logout(sessionId: string): Promise { + public async removeSession(sessionId: string): Promise { Logger.info(`Logging out of session '${sessionId}'`); const token = this.removeInMemorySessionData(sessionId); let session: vscode.AuthenticationSession | undefined; diff --git a/extensions/microsoft-authentication/src/extension.ts b/extensions/microsoft-authentication/src/extension.ts index f949ec1ec2d..584a4027b64 100644 --- a/extensions/microsoft-authentication/src/extension.ts +++ b/extensions/microsoft-authentication/src/extension.ts @@ -22,14 +22,14 @@ export async function activate(context: vscode.ExtensionContext) { onDidChangeSessions: onDidChangeSessions.event, getAllSessions: () => Promise.resolve(loginService.sessions), getSessions: (scopes: string[]) => loginService.getSessions(scopes), - login: async (scopes: string[]) => { + createSession: async (scopes: string[]) => { try { /* __GDPR__ "login" : { } */ telemetryReporter.sendTelemetryEvent('login'); - const session = await loginService.login(scopes.sort().join(' ')); + const session = await loginService.createSession(scopes.sort().join(' ')); onDidChangeSessions.fire({ added: [session], removed: [], changed: [] }); return session; } catch (e) { @@ -41,14 +41,14 @@ export async function activate(context: vscode.ExtensionContext) { throw e; } }, - logout: async (id: string) => { + removeSession: async (id: string) => { try { /* __GDPR__ "logout" : { } */ telemetryReporter.sendTelemetryEvent('logout'); - const session = await loginService.logout(id); + const session = await loginService.removeSession(id); if (session) { onDidChangeSessions.fire({ added: [], removed: [session], changed: [] }); } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 8cd964987cb..9cf63216b00 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -82,14 +82,14 @@ declare module 'vscode' { * Prompts a user to login. */ // eslint-disable-next-line vscode-dts-provider-naming - login(scopes: string[]): Thenable; + createSession(scopes: string[]): Thenable; /** * Removes the session corresponding to session id. * @param sessionId The session id to log out of */ // eslint-disable-next-line vscode-dts-provider-naming - logout(sessionId: string): Thenable; + removeSession(sessionId: string): Thenable; } /** diff --git a/src/vs/workbench/api/browser/mainThreadAuthentication.ts b/src/vs/workbench/api/browser/mainThreadAuthentication.ts index c0e48209936..dfad0388642 100644 --- a/src/vs/workbench/api/browser/mainThreadAuthentication.ts +++ b/src/vs/workbench/api/browser/mainThreadAuthentication.ts @@ -71,7 +71,7 @@ export class MainThreadAuthenticationProvider extends Disposable { quickPick.show(); } - async signOut(accountName: string, sessions: modes.AuthenticationSession[]): Promise { + async removeAccountSessions(accountName: string, sessions: modes.AuthenticationSession[]): Promise { const accountUsages = readAccountUsages(this.storageService, this.id, accountName); const result = await this.dialogService.confirm({ @@ -82,8 +82,8 @@ export class MainThreadAuthenticationProvider extends Disposable { }); if (result.confirmed) { - const logoutPromises = sessions.map(session => this.logout(session.id)); - await Promise.all(logoutPromises); + const removeSessionPromises = sessions.map(session => this.removeSession(session.id)); + await Promise.all(removeSessionPromises); removeAccountUsage(this.storageService, this.id, accountName); this.storageService.remove(`${this.id}-${accountName}`, StorageScope.GLOBAL); } @@ -97,12 +97,12 @@ export class MainThreadAuthenticationProvider extends Disposable { return this._proxy.$getAllSessions(this.id); } - login(scopes: string[]): Promise { - return this._proxy.$login(this.id, scopes); + createSession(scopes: string[]): Promise { + return this._proxy.$createSession(this.id, scopes); } - async logout(sessionId: string): Promise { - await this._proxy.$logout(this.id, sessionId); + async removeSession(sessionId: string): Promise { + await this._proxy.$removeSession(this.id, sessionId); this.notificationService.info(nls.localize('signedOut', "Successfully signed out.")); } } @@ -159,8 +159,8 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu this.authenticationService.sessionsUpdate(id, event); } - $logout(providerId: string, sessionId: string): Promise { - return this.authenticationService.logout(providerId, sessionId); + $removeSession(providerId: string, sessionId: string): Promise { + return this.authenticationService.removeSession(providerId, sessionId); } private async loginPrompt(providerName: string, extensionName: string): Promise { const { choice } = await this.dialogService.show( @@ -247,7 +247,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu throw new Error('User did not consent to login.'); } - session = await this.authenticationService.login(providerId, scopes, true); + session = await this.authenticationService.createSession(providerId, scopes, true); await this.setTrustedExtensionAndAccountPreference(providerId, session.account.label, extensionId, extensionName, session.id); } else { await this.authenticationService.requestNewSession(providerId, scopes, extensionId, extensionName); diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 865ded63659..51c3ad42cfa 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -230,7 +230,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I }, logout(providerId: string, sessionId: string): Thenable { checkProposedApiEnabled(extension); - return extHostAuthentication.logout(providerId, sessionId); + return extHostAuthentication.removeSession(providerId, sessionId); } }; diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index 37ed3830c68..47387b9d266 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -168,7 +168,7 @@ export interface MainThreadAuthenticationShape extends IDisposable { $ensureProvider(id: string): Promise; $sendDidChangeSessions(providerId: string, event: modes.AuthenticationSessionsChangeEvent): void; $getSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: { createIfNone?: boolean, clearSessionPreference?: boolean }): Promise; - $logout(providerId: string, sessionId: string): Promise; + $removeSession(providerId: string, sessionId: string): Promise; } export interface MainThreadSecretStateShape extends IDisposable { @@ -1128,8 +1128,8 @@ export interface ExtHostLabelServiceShape { export interface ExtHostAuthenticationShape { $getAllSessions(id: string): Promise>; $getSessions(id: string, scopes: string[]): Promise>; - $login(id: string, scopes: string[]): Promise; - $logout(id: string, sessionId: string): Promise; + $createSession(id: string, scopes: string[]): Promise; + $removeSession(id: string, sessionId: string): Promise; $onDidChangeAuthenticationSessions(id: string, label: string, event: modes.AuthenticationSessionsChangeEvent): Promise; $onDidChangeAuthenticationProviders(added: modes.AuthenticationProviderInformation[], removed: modes.AuthenticationProviderInformation[]): Promise; $setProviders(providers: modes.AuthenticationProviderInformation[]): Promise; diff --git a/src/vs/workbench/api/common/extHostAuthentication.ts b/src/vs/workbench/api/common/extHostAuthentication.ts index 8a170d227ac..988f93a5c9f 100644 --- a/src/vs/workbench/api/common/extHostAuthentication.ts +++ b/src/vs/workbench/api/common/extHostAuthentication.ts @@ -87,13 +87,13 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape { return this._proxy.$getSession(providerId, scopes, extensionId, extensionName, options); } - async logout(providerId: string, sessionId: string): Promise { + async removeSession(providerId: string, sessionId: string): Promise { const providerData = this._authenticationProviders.get(providerId); if (!providerData) { - return this._proxy.$logout(providerId, sessionId); + return this._proxy.$removeSession(providerId, sessionId); } - return providerData.provider.logout(sessionId); + return providerData.provider.removeSession(sessionId); } registerAuthenticationProvider(id: string, label: string, provider: vscode.AuthenticationProvider, options?: vscode.AuthenticationProviderOptions): vscode.Disposable { @@ -129,19 +129,19 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape { }); } - $login(providerId: string, scopes: string[]): Promise { + $createSession(providerId: string, scopes: string[]): Promise { const providerData = this._authenticationProviders.get(providerId); if (providerData) { - return Promise.resolve(providerData.provider.login(scopes)); + return Promise.resolve(providerData.provider.createSession(scopes)); } throw new Error(`Unable to find authentication provider with handle: ${providerId}`); } - $logout(providerId: string, sessionId: string): Promise { + $removeSession(providerId: string, sessionId: string): Promise { const providerData = this._authenticationProviders.get(providerId); if (providerData) { - return Promise.resolve(providerData.provider.logout(sessionId)); + return Promise.resolve(providerData.provider.removeSession(sessionId)); } throw new Error(`Unable to find authentication provider with handle: ${providerId}`); diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts index f443898f7b2..c3f7817a47f 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts @@ -240,7 +240,7 @@ export class AccountsActivityActionViewItem extends MenuActivityActionViewItem { })); const signOutAction = disposables.add(new Action('signOut', localize('signOut', "Sign Out"), '', true, () => { - return this.authenticationService.signOutOfAccount(sessionInfo.providerId, accountName, sessionInfo.sessions[accountName]); + return this.authenticationService.removeAccountSessions(sessionInfo.providerId, accountName, sessionInfo.sessions[accountName]); })); const providerSubMenuActions = [manageExtensionsAction]; diff --git a/src/vs/workbench/services/authentication/browser/authenticationService.ts b/src/vs/workbench/services/authentication/browser/authenticationService.ts index ec4005a5e78..5d6de318988 100644 --- a/src/vs/workbench/services/authentication/browser/authenticationService.ts +++ b/src/vs/workbench/services/authentication/browser/authenticationService.ts @@ -128,11 +128,11 @@ export interface IAuthenticationService { getAllSessions(providerId: string, activateImmediate?: boolean): Promise>; getLabel(providerId: string): string; supportsMultipleAccounts(providerId: string): boolean; - login(providerId: string, scopes: string[], activateImmediate?: boolean): Promise; - logout(providerId: string, sessionId: string): Promise; + createSession(providerId: string, scopes: string[], activateImmediate?: boolean): Promise; + removeSession(providerId: string, sessionId: string): Promise; manageTrustedExtensionsForAccount(providerId: string, accountName: string): Promise; - signOutOfAccount(providerId: string, accountName: string, sessions: AuthenticationSession[]): Promise; + removeAccountSessions(providerId: string, accountName: string, sessions: AuthenticationSession[]): Promise; } export interface AllowedExtension { @@ -473,7 +473,7 @@ export class AuthenticationService extends Disposable implements IAuthentication quickPick.placeholder = nls.localize('getSessionPlateholder', "Select an account for '{0}' to use or Esc to cancel", extensionName); quickPick.onDidAccept(async _ => { - const session = quickPick.selectedItems[0].session ?? await this.login(providerId, availableSessions[0].scopes as string[]); + const session = quickPick.selectedItems[0].session ?? await this.createSession(providerId, availableSessions[0].scopes as string[]); const accountName = session.account.label; const allowList = readAllowedExtensions(this.storageService, providerId, accountName); @@ -610,7 +610,7 @@ export class AuthenticationService extends Disposable implements IAuthentication handler: async (accessor) => { const authenticationService = accessor.get(IAuthenticationService); const storageService = accessor.get(IStorageService); - const session = await authenticationService.login(providerId, scopes); + const session = await authenticationService.createSession(providerId, scopes); // Add extension to allow list since user explicitly signed in on behalf of it const allowList = readAllowedExtensions(storageService, providerId, session.account.label); @@ -712,19 +712,19 @@ export class AuthenticationService extends Disposable implements IAuthentication } } - async login(id: string, scopes: string[], activateImmediate: boolean = false): Promise { + async createSession(id: string, scopes: string[], activateImmediate: boolean = false): Promise { try { const authProvider = this._authenticationProviders.get(id) || await this.tryActivateProvider(id, activateImmediate); - return await authProvider.login(scopes); + return await authProvider.createSession(scopes); } catch (_) { throw new Error(`No authentication provider '${id}' is currently registered.`); } } - async logout(id: string, sessionId: string): Promise { + async removeSession(id: string, sessionId: string): Promise { const authProvider = this._authenticationProviders.get(id); if (authProvider) { - return authProvider.logout(sessionId); + return authProvider.removeSession(sessionId); } else { throw new Error(`No authentication provider '${id}' is currently registered.`); } @@ -739,10 +739,10 @@ export class AuthenticationService extends Disposable implements IAuthentication } } - async signOutOfAccount(id: string, accountName: string, sessions: AuthenticationSession[]): Promise { + async removeAccountSessions(id: string, accountName: string, sessions: AuthenticationSession[]): Promise { const authProvider = this._authenticationProviders.get(id); if (authProvider) { - return authProvider.signOut(accountName, sessions); + return authProvider.removeAccountSessions(accountName, sessions); } else { throw new Error(`No authentication provider '${id}' is currently registered.`); } diff --git a/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts b/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts index ec7bc09735a..32228c4c3b0 100644 --- a/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts +++ b/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts @@ -471,7 +471,7 @@ export class UserDataSyncWorkbenchService extends Disposable implements IUserDat } let sessionId: string, accountName: string, accountId: string; if (isAuthenticationProvider(result)) { - const session = await this.authenticationService.login(result.id, result.scopes); + const session = await this.authenticationService.createSession(result.id, result.scopes); sessionId = session.id; accountName = session.account.label; accountId = session.account.id;