From 757b70873ecff24b138b3d0c9c5bc8896c5ecc89 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Fri, 4 Feb 2022 16:53:28 -0800 Subject: [PATCH] move Auth types to a better location --- src/vs/editor/common/languages.ts | 31 -------- .../api/browser/mainThreadAuthentication.ts | 14 ++-- .../workbench/api/common/extHost.protocol.ts | 11 +-- .../api/common/extHostAuthentication.ts | 5 +- .../browser/extHostAuthentication.test.ts | 3 +- .../parts/activitybar/activitybarActions.ts | 4 +- .../electron-sandbox/remoteExtensionsInit.ts | 2 +- .../contrib/url/browser/trustedDomains.ts | 2 +- .../url/browser/trustedDomainsValidator.ts | 2 +- .../userDataSync/browser/userDataSync.ts | 2 +- .../browser/authenticationService.ts | 54 +------------ .../authentication/common/authentication.ts | 77 +++++++++++++++++++ .../issue/electron-sandbox/issueService.ts | 2 +- .../browser/userDataSyncWorkbenchService.ts | 4 +- 14 files changed, 105 insertions(+), 108 deletions(-) create mode 100644 src/vs/workbench/services/authentication/common/authentication.ts diff --git a/src/vs/editor/common/languages.ts b/src/vs/editor/common/languages.ts index e61187cd542..68fb919c5a5 100644 --- a/src/vs/editor/common/languages.ts +++ b/src/vs/editor/common/languages.ts @@ -1586,37 +1586,6 @@ export interface RenameProvider { resolveRenameLocation?(model: model.ITextModel, position: Position, token: CancellationToken): ProviderResult; } -/** - * @internal - */ -export interface AuthenticationSession { - id: string; - accessToken: string; - account: { - label: string; - id: string; - }; - scopes: ReadonlyArray; - idToken?: string; -} - -/** - * @internal - */ -export interface AuthenticationSessionsChangeEvent { - added: ReadonlyArray; - removed: ReadonlyArray; - changed: ReadonlyArray; -} - -/** - * @internal - */ -export interface AuthenticationProviderInformation { - id: string; - label: string; -} - export interface Command { id: string; title: string; diff --git a/src/vs/workbench/api/browser/mainThreadAuthentication.ts b/src/vs/workbench/api/browser/mainThreadAuthentication.ts index 511d30528db..77c903cdf0c 100644 --- a/src/vs/workbench/api/browser/mainThreadAuthentication.ts +++ b/src/vs/workbench/api/browser/mainThreadAuthentication.ts @@ -4,10 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import { Disposable } from 'vs/base/common/lifecycle'; -import * as languages from 'vs/editor/common/languages'; import * as nls from 'vs/nls'; import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers'; -import { IAuthenticationService, AllowedExtension, readAllowedExtensions, getAuthenticationProviderActivationEvent, addAccountUsage, readAccountUsages, removeAccountUsage, IAuthenticationProvider } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { AllowedExtension, readAllowedExtensions, getAuthenticationProviderActivationEvent, addAccountUsage, readAccountUsages, removeAccountUsage } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { AuthenticationSession, AuthenticationSessionsChangeEvent, IAuthenticationProvider, IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { ExtHostAuthenticationShape, ExtHostContext, MainContext, MainThreadAuthenticationShape } from '../common/extHost.protocol'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; @@ -96,7 +96,7 @@ export class MainThreadAuthenticationProvider extends Disposable implements IAut quickPick.show(); } - async removeAccountSessions(accountName: string, sessions: languages.AuthenticationSession[]): Promise { + async removeAccountSessions(accountName: string, sessions: AuthenticationSession[]): Promise { const accountUsages = readAccountUsages(this.storageService, this.id, accountName); const result = await this.dialogService.show( @@ -124,7 +124,7 @@ export class MainThreadAuthenticationProvider extends Disposable implements IAut return this._proxy.$getSessions(this.id, scopes); } - createSession(scopes: string[]): Promise { + createSession(scopes: string[]): Promise { return this._proxy.$createSession(this.id, scopes); } @@ -175,7 +175,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu return this.extensionService.activateByEvent(getAuthenticationProviderActivationEvent(id), ActivationKind.Immediate); } - $sendDidChangeSessions(id: string, event: languages.AuthenticationSessionsChangeEvent): void { + $sendDidChangeSessions(id: string, event: AuthenticationSessionsChangeEvent): void { this.authenticationService.sessionsUpdate(id, event); } @@ -205,7 +205,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu } - private async doGetSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: AuthenticationGetSessionOptions): Promise { + private async doGetSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: AuthenticationGetSessionOptions): Promise { const sessions = await this.authenticationService.getSessions(providerId, scopes, true); const supportsMultipleAccounts = this.authenticationService.supportsMultipleAccounts(providerId); @@ -268,7 +268,7 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu return validSession; } - async $getSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: AuthenticationGetSessionOptions): Promise { + async $getSession(providerId: string, scopes: string[], extensionId: string, extensionName: string, options: AuthenticationGetSessionOptions): Promise { const session = await this.doGetSession(providerId, scopes, extensionId, extensionName, options); if (session) { diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts index eae2a8dcd0e..d39b0c41810 100644 --- a/src/vs/workbench/api/common/extHost.protocol.ts +++ b/src/vs/workbench/api/common/extHost.protocol.ts @@ -69,6 +69,7 @@ import { IWorkspaceSymbol } from 'vs/workbench/contrib/search/common/search'; import { ILineChange } from 'vs/editor/common/diff/diffComputer'; import { IStaticWorkspaceData } from 'vs/workbench/services/extensions/common/extensionHostProtocol'; import { IResolveAuthorityResult } from 'vs/workbench/services/extensions/common/extensionHostProxy'; +import { AuthenticationProviderInformation, AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/workbench/services/authentication/common/authentication'; export interface IWorkspaceData extends IStaticWorkspaceData { folders: { uri: UriComponents; name: string; index: number }[]; @@ -139,8 +140,8 @@ export interface MainThreadAuthenticationShape extends IDisposable { $registerAuthenticationProvider(id: string, label: string, supportsMultipleAccounts: boolean): void; $unregisterAuthenticationProvider(id: string): void; $ensureProvider(id: string): Promise; - $sendDidChangeSessions(providerId: string, event: languages.AuthenticationSessionsChangeEvent): void; - $getSession(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string, options: { createIfNone?: boolean; forceNewSession?: boolean | { detail: string }; clearSessionPreference?: boolean }): Promise; + $sendDidChangeSessions(providerId: string, event: AuthenticationSessionsChangeEvent): void; + $getSession(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string, options: { createIfNone?: boolean; forceNewSession?: boolean | { detail: string }; clearSessionPreference?: boolean }): Promise; $removeSession(providerId: string, sessionId: string): Promise; } @@ -1298,11 +1299,11 @@ export interface ExtHostLabelServiceShape { } export interface ExtHostAuthenticationShape { - $getSessions(id: string, scopes?: string[]): Promise>; - $createSession(id: string, scopes: string[]): Promise; + $getSessions(id: string, scopes?: string[]): Promise>; + $createSession(id: string, scopes: string[]): Promise; $removeSession(id: string, sessionId: string): Promise; $onDidChangeAuthenticationSessions(id: string, label: string): Promise; - $setProviders(providers: languages.AuthenticationProviderInformation[]): Promise; + $setProviders(providers: AuthenticationProviderInformation[]): Promise; } export interface ExtHostSecretStateShape { diff --git a/src/vs/workbench/api/common/extHostAuthentication.ts b/src/vs/workbench/api/common/extHostAuthentication.ts index 2fb6c4103ca..afc9355c25a 100644 --- a/src/vs/workbench/api/common/extHostAuthentication.ts +++ b/src/vs/workbench/api/common/extHostAuthentication.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import type * as vscode from 'vscode'; -import * as languages from 'vs/editor/common/languages'; import { Emitter, Event } from 'vs/base/common/event'; import { IMainContext, MainContext, MainThreadAuthenticationShape, ExtHostAuthenticationShape } from 'vs/workbench/api/common/extHost.protocol'; import { Disposable } from 'vs/workbench/api/common/extHostTypes'; @@ -129,7 +128,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape { }); } - $createSession(providerId: string, scopes: string[]): Promise { + $createSession(providerId: string, scopes: string[]): Promise { const providerData = this._authenticationProviders.get(providerId); if (providerData) { return Promise.resolve(providerData.provider.createSession(scopes)); @@ -147,7 +146,7 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape { throw new Error(`Unable to find authentication provider with handle: ${providerId}`); } - $getSessions(providerId: string, scopes?: string[]): Promise> { + $getSessions(providerId: string, scopes?: string[]): Promise> { const providerData = this._authenticationProviders.get(providerId); if (providerData) { return Promise.resolve(providerData.provider.getSessions(scopes)); diff --git a/src/vs/workbench/api/test/browser/extHostAuthentication.test.ts b/src/vs/workbench/api/test/browser/extHostAuthentication.test.ts index 038b1b19435..0a9919154a3 100644 --- a/src/vs/workbench/api/test/browser/extHostAuthentication.test.ts +++ b/src/vs/workbench/api/test/browser/extHostAuthentication.test.ts @@ -18,7 +18,8 @@ import { MainThreadAuthentication } from 'vs/workbench/api/browser/mainThreadAut import { ExtHostContext, MainContext } from 'vs/workbench/api/common/extHost.protocol'; import { ExtHostAuthentication } from 'vs/workbench/api/common/extHostAuthentication'; import { IActivityService } from 'vs/workbench/services/activity/common/activity'; -import { AuthenticationService, IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { AuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IExtensionService, nullExtensionDescription as extensionDescription } from 'vs/workbench/services/extensions/common/extensions'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; import { TestRemoteAgentService } from 'vs/workbench/services/remote/test/common/testServices'; diff --git a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts index 51b15159903..87699c28b96 100644 --- a/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts +++ b/src/vs/workbench/browser/parts/activitybar/activitybarActions.ts @@ -24,8 +24,8 @@ import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/bro import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { createAndFillInActionBarActions } from 'vs/platform/actions/browser/menuEntryActionViewItem'; import { isMacintosh, isWeb } from 'vs/base/common/platform'; -import { getCurrentAuthenticationSessionInfo, IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; -import { AuthenticationSession } from 'vs/editor/common/languages'; +import { getCurrentAuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { AuthenticationSession, IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IProductService } from 'vs/platform/product/common/productService'; diff --git a/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts b/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts index aba98e02655..13380b3aaf5 100644 --- a/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts +++ b/src/vs/workbench/contrib/extensions/electron-sandbox/remoteExtensionsInit.ts @@ -19,7 +19,7 @@ import { IIgnoredExtensionsManagementService } from 'vs/platform/userDataSync/co import { IRemoteUserData, IUserDataSyncStoreManagementService, SyncResource } from 'vs/platform/userDataSync/common/userDataSync'; import { UserDataSyncStoreClient } from 'vs/platform/userDataSync/common/userDataSyncStoreService'; import { IWorkbenchContribution } from 'vs/workbench/common/contributions'; -import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IExtensionManagementServerService } from 'vs/workbench/services/extensionManagement/common/extensionManagement'; import { IExtensionManifestPropertiesService } from 'vs/workbench/services/extensions/common/extensionManifestPropertiesService'; import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService'; diff --git a/src/vs/workbench/contrib/url/browser/trustedDomains.ts b/src/vs/workbench/contrib/url/browser/trustedDomains.ts index de6034a9b89..613047e7a97 100644 --- a/src/vs/workbench/contrib/url/browser/trustedDomains.ts +++ b/src/vs/workbench/contrib/url/browser/trustedDomains.ts @@ -11,7 +11,7 @@ import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/commo import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IFileService } from 'vs/platform/files/common/files'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; diff --git a/src/vs/workbench/contrib/url/browser/trustedDomainsValidator.ts b/src/vs/workbench/contrib/url/browser/trustedDomainsValidator.ts index 0c7070402a0..dbaf96b6c27 100644 --- a/src/vs/workbench/contrib/url/browser/trustedDomainsValidator.ts +++ b/src/vs/workbench/contrib/url/browser/trustedDomainsValidator.ts @@ -19,7 +19,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IdleValue } from 'vs/base/common/async'; -import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { testUrlMatchesGlob } from 'vs/workbench/contrib/url/common/urlGlob'; import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust'; diff --git a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts index bcd8241a22b..07d50613857 100644 --- a/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts +++ b/src/vs/workbench/contrib/userDataSync/browser/userDataSync.ts @@ -47,7 +47,7 @@ import { fromNow } from 'vs/base/common/date'; import { IProductService } from 'vs/platform/product/common/productService'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { IOpenerService } from 'vs/platform/opener/common/opener'; -import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { Registry } from 'vs/platform/registry/common/platform'; import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'; import { ViewContainerLocation, IViewContainersRegistry, Extensions, ViewContainer } from 'vs/workbench/common/views'; diff --git a/src/vs/workbench/services/authentication/browser/authenticationService.ts b/src/vs/workbench/services/authentication/browser/authenticationService.ts index 695c0f793dd..42505773acc 100644 --- a/src/vs/workbench/services/authentication/browser/authenticationService.ts +++ b/src/vs/workbench/services/authentication/browser/authenticationService.ts @@ -10,7 +10,6 @@ import { Disposable, dispose, IDisposable, MutableDisposable } from 'vs/base/com import { isWeb } from 'vs/base/common/platform'; import { isFalsyOrWhitespace } from 'vs/base/common/strings'; import { isString } from 'vs/base/common/types'; -import { AuthenticationProviderInformation, AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/editor/common/languages'; import * as nls from 'vs/nls'; import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; import { CommandsRegistry } from 'vs/platform/commands/common/commands'; @@ -18,12 +17,12 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey'; import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { Severity } from 'vs/platform/notification/common/notification'; import { IProductService } from 'vs/platform/product/common/productService'; import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage'; import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity'; +import { AuthenticationProviderInformation, AuthenticationSession, AuthenticationSessionsChangeEvent, IAuthenticationProvider, IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService'; import { ActivationKind, IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { ExtensionsRegistry } from 'vs/workbench/services/extensions/common/extensionsRegistry'; @@ -31,7 +30,7 @@ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteA export function getAuthenticationProviderActivationEvent(id: string): string { return `onAuthenticationRequest:${id}`; } -export interface IAccountUsage { +interface IAccountUsage { extensionId: string; extensionName: string; lastUsed: number; @@ -106,55 +105,6 @@ export async function getCurrentAuthenticationSessionInfo(credentialsService: IC return undefined; } -export const IAuthenticationService = createDecorator('IAuthenticationService'); - -export interface IAuthenticationService { - readonly _serviceBrand: undefined; - - isAuthenticationProviderRegistered(id: string): boolean; - getProviderIds(): string[]; - registerAuthenticationProvider(id: string, provider: IAuthenticationProvider): void; - unregisterAuthenticationProvider(id: string): void; - isAccessAllowed(providerId: string, accountName: string, extensionId: string): boolean | undefined; - updatedAllowedExtension(providerId: string, accountName: string, extensionId: string, extensionName: string, isAllowed: boolean): Promise; - showGetSessionPrompt(providerId: string, accountName: string, extensionId: string, extensionName: string): Promise; - selectSession(providerId: string, extensionId: string, extensionName: string, scopes: string[], possibleSessions: readonly AuthenticationSession[]): Promise; - requestSessionAccess(providerId: string, extensionId: string, extensionName: string, scopes: string[], possibleSessions: readonly AuthenticationSession[]): void; - completeSessionAccessRequest(providerId: string, extensionId: string, extensionName: string, scopes: string[]): Promise; - requestNewSession(providerId: string, scopes: string[], extensionId: string, extensionName: string): Promise; - sessionsUpdate(providerId: string, event: AuthenticationSessionsChangeEvent): void; - - readonly onDidRegisterAuthenticationProvider: Event; - readonly onDidUnregisterAuthenticationProvider: Event; - - readonly onDidChangeSessions: Event<{ providerId: string; label: string; event: AuthenticationSessionsChangeEvent }>; - - // TODO @RMacfarlane completely remove this property - declaredProviders: AuthenticationProviderInformation[]; - readonly onDidChangeDeclaredProviders: Event; - - getSessions(id: string, scopes?: string[], activateImmediate?: boolean): Promise>; - getLabel(providerId: string): string; - supportsMultipleAccounts(providerId: string): boolean; - createSession(providerId: string, scopes: string[], activateImmediate?: boolean): Promise; - removeSession(providerId: string, sessionId: string): Promise; - - manageTrustedExtensionsForAccount(providerId: string, accountName: string): Promise; - removeAccountSessions(providerId: string, accountName: string, sessions: AuthenticationSession[]): Promise; -} - -export interface IAuthenticationProvider { - readonly id: string; - readonly label: string; - readonly supportsMultipleAccounts: boolean; - dispose(): void; - manageTrustedExtensions(accountName: string): void; - removeAccountSessions(accountName: string, sessions: AuthenticationSession[]): Promise; - getSessions(scopes?: string[]): Promise; - createSession(scopes: string[]): Promise; - removeSession(sessionId: string): Promise; -} - export interface AllowedExtension { id: string; name: string; diff --git a/src/vs/workbench/services/authentication/common/authentication.ts b/src/vs/workbench/services/authentication/common/authentication.ts new file mode 100644 index 00000000000..d5bd102712e --- /dev/null +++ b/src/vs/workbench/services/authentication/common/authentication.ts @@ -0,0 +1,77 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import { Event } from 'vs/base/common/event'; +import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; + +export interface AuthenticationSession { + id: string; + accessToken: string; + account: { + label: string; + id: string; + }; + scopes: ReadonlyArray; + idToken?: string; +} + +export interface AuthenticationSessionsChangeEvent { + added: ReadonlyArray; + removed: ReadonlyArray; + changed: ReadonlyArray; +} + +export interface AuthenticationProviderInformation { + id: string; + label: string; +} + +export const IAuthenticationService = createDecorator('IAuthenticationService'); + +export interface IAuthenticationService { + readonly _serviceBrand: undefined; + + isAuthenticationProviderRegistered(id: string): boolean; + getProviderIds(): string[]; + registerAuthenticationProvider(id: string, provider: IAuthenticationProvider): void; + unregisterAuthenticationProvider(id: string): void; + isAccessAllowed(providerId: string, accountName: string, extensionId: string): boolean | undefined; + updatedAllowedExtension(providerId: string, accountName: string, extensionId: string, extensionName: string, isAllowed: boolean): Promise; + showGetSessionPrompt(providerId: string, accountName: string, extensionId: string, extensionName: string): Promise; + selectSession(providerId: string, extensionId: string, extensionName: string, scopes: string[], possibleSessions: readonly AuthenticationSession[]): Promise; + requestSessionAccess(providerId: string, extensionId: string, extensionName: string, scopes: string[], possibleSessions: readonly AuthenticationSession[]): void; + completeSessionAccessRequest(providerId: string, extensionId: string, extensionName: string, scopes: string[]): Promise; + requestNewSession(providerId: string, scopes: string[], extensionId: string, extensionName: string): Promise; + sessionsUpdate(providerId: string, event: AuthenticationSessionsChangeEvent): void; + + readonly onDidRegisterAuthenticationProvider: Event; + readonly onDidUnregisterAuthenticationProvider: Event; + + readonly onDidChangeSessions: Event<{ providerId: string; label: string; event: AuthenticationSessionsChangeEvent }>; + + // TODO @RMacfarlane completely remove this property + declaredProviders: AuthenticationProviderInformation[]; + readonly onDidChangeDeclaredProviders: Event; + + getSessions(id: string, scopes?: string[], activateImmediate?: boolean): Promise>; + getLabel(providerId: string): string; + supportsMultipleAccounts(providerId: string): boolean; + createSession(providerId: string, scopes: string[], activateImmediate?: boolean): Promise; + removeSession(providerId: string, sessionId: string): Promise; + + manageTrustedExtensionsForAccount(providerId: string, accountName: string): Promise; + removeAccountSessions(providerId: string, accountName: string, sessions: AuthenticationSession[]): Promise; +} + +export interface IAuthenticationProvider { + readonly id: string; + readonly label: string; + readonly supportsMultipleAccounts: boolean; + dispose(): void; + manageTrustedExtensions(accountName: string): void; + removeAccountSessions(accountName: string, sessions: AuthenticationSession[]): Promise; + getSessions(scopes?: string[]): Promise; + createSession(scopes: string[]): Promise; + removeSession(sessionId: string): Promise; +} diff --git a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts index a317690769b..40f41611139 100644 --- a/src/vs/workbench/services/issue/electron-sandbox/issueService.ts +++ b/src/vs/workbench/services/issue/electron-sandbox/issueService.ts @@ -17,7 +17,7 @@ import { ExtensionType } from 'vs/platform/extensions/common/extensions'; import { platform } from 'vs/base/common/process'; import { IProductService } from 'vs/platform/product/common/productService'; import { IWorkbenchAssignmentService } from 'vs/workbench/services/assignment/common/assignmentService'; -import { IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { registerMainProcessRemoteService } from 'vs/platform/ipc/electron-sandbox/services'; import { IWorkspaceTrustManagementService } from 'vs/platform/workspace/common/workspaceTrust'; diff --git a/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts b/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts index 5ee9eef9946..29ff6f8a218 100644 --- a/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts +++ b/src/vs/workbench/services/userDataSync/browser/userDataSyncWorkbenchService.ts @@ -7,11 +7,11 @@ import { IUserDataSyncService, IAuthenticationProvider, isAuthenticationProvider import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { IUserDataSyncWorkbenchService, IUserDataSyncAccount, AccountStatus, CONTEXT_SYNC_ENABLEMENT, CONTEXT_SYNC_STATE, CONTEXT_ACCOUNT_STATE, SHOW_SYNC_LOG_COMMAND_ID, getSyncAreaLabel, IUserDataSyncPreview, IUserDataSyncResource, CONTEXT_ENABLE_SYNC_MERGES_VIEW, SYNC_MERGES_VIEW_ID, CONTEXT_ENABLE_ACTIVITY_VIEWS, SYNC_VIEW_CONTAINER_ID, SYNC_TITLE } from 'vs/workbench/services/userDataSync/common/userDataSync'; -import { AuthenticationSession, AuthenticationSessionsChangeEvent } from 'vs/editor/common/languages'; import { Disposable, DisposableStore } from 'vs/base/common/lifecycle'; import { Emitter, Event } from 'vs/base/common/event'; import { flatten, equals } from 'vs/base/common/arrays'; -import { getCurrentAuthenticationSessionInfo, IAuthenticationService } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { getCurrentAuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService'; +import { AuthenticationSession, AuthenticationSessionsChangeEvent, IAuthenticationService } from 'vs/workbench/services/authentication/common/authentication'; import { IUserDataSyncAccountService } from 'vs/platform/userDataSync/common/userDataSyncAccount'; import { IQuickInputService, IQuickPickSeparator } from 'vs/platform/quickinput/common/quickInput'; import { IStorageService, IStorageValueChangeEvent, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';