import { Event } from '../common/event'; import { StorageService } from '../browser/storage-service'; import { Disposable, DisposableCollection } from '../common/disposable'; import { MenuModelRegistry } from '../common/menu'; import { CommandRegistry } from '../common/command'; export interface AuthenticationSessionAccountInformation { readonly id: string; readonly label: string; } export interface AuthenticationSession { id: string; accessToken: string; account: AuthenticationSessionAccountInformation; scopes: ReadonlyArray; } export interface AuthenticationProviderInformation { id: string; label: string; } /** Should match the definition from the theia/vscode types */ export interface AuthenticationProviderAuthenticationSessionsChangeEvent { readonly added: readonly AuthenticationSession[] | undefined; readonly removed: readonly AuthenticationSession[] | undefined; readonly changed: readonly AuthenticationSession[] | undefined; } export interface SessionRequest { disposables: Disposable[]; requestingExtensionIds: string[]; } export interface SessionRequestInfo { [scopes: string]: SessionRequest; } /** * Our authentication provider should at least contain the following information: * - The signature of authentication providers from vscode * - Registration information about the provider (id, label) * - Provider options (supportsMultipleAccounts) * * Additionally, we provide the possibility to sign out of a specific account name. */ export interface AuthenticationProvider { id: string; label: string; supportsMultipleAccounts: boolean; hasSessions(): boolean; signOut(accountName: string): Promise; updateSessionItems(event: AuthenticationProviderAuthenticationSessionsChangeEvent): Promise; /** * @deprecated use `createSession` instead. */ login(scopes: string[]): Promise; /** * @deprecated use `removeSession` instead. */ logout(sessionId: string): Promise; /** * An [event](#Event) which fires when the array of sessions has changed, or data * within a session has changed. */ readonly onDidChangeSessions: Event; /** * Get a list of sessions. * @param scopes An optional list of scopes. If provided, the sessions returned should match * these permissions, otherwise all sessions should be returned. * @returns A promise that resolves to an array of authentication sessions. */ getSessions(scopes?: string[]): Thenable>; /** * Prompts a user to login. * @param scopes A list of scopes, permissions, that the new session should be created with. * @returns A promise that resolves to an authentication session. */ createSession(scopes: string[]): Thenable; /** * Removes the session corresponding to session id. * @param sessionId The id of the session to remove. */ removeSession(sessionId: string): Thenable; } export declare const AuthenticationService: unique symbol; export interface AuthenticationService { isAuthenticationProviderRegistered(id: string): boolean; getProviderIds(): string[]; registerAuthenticationProvider(id: string, provider: AuthenticationProvider): void; unregisterAuthenticationProvider(id: string): void; requestNewSession(id: string, scopes: string[], extensionId: string, extensionName: string): void; updateSessions(providerId: string, event: AuthenticationProviderAuthenticationSessionsChangeEvent): void; readonly onDidRegisterAuthenticationProvider: Event; readonly onDidUnregisterAuthenticationProvider: Event; readonly onDidChangeSessions: Event<{ providerId: string; label: string; event: AuthenticationProviderAuthenticationSessionsChangeEvent; }>; getSessions(providerId: string, scopes?: string[]): Promise>; getLabel(providerId: string): string; supportsMultipleAccounts(providerId: string): boolean; login(providerId: string, scopes: string[]): Promise; logout(providerId: string, sessionId: string): Promise; signOutOfAccount(providerId: string, accountName: string): Promise; } export interface SessionChangeEvent { providerId: string; label: string; event: AuthenticationProviderAuthenticationSessionsChangeEvent; } export declare class AuthenticationServiceImpl implements AuthenticationService { private noAccountsMenuItem; private noAccountsCommand; private signInRequestItems; private sessionMap; protected authenticationProviders: Map; private onDidRegisterAuthenticationProviderEmitter; readonly onDidRegisterAuthenticationProvider: Event; private onDidUnregisterAuthenticationProviderEmitter; readonly onDidUnregisterAuthenticationProvider: Event; private onDidChangeSessionsEmitter; readonly onDidChangeSessions: Event; protected readonly menus: MenuModelRegistry; protected readonly commands: CommandRegistry; protected readonly storageService: StorageService; init(): void; protected handleSessionChange(changeEvent: SessionChangeEvent): Promise; protected createAccountUi(providerId: string, providerLabel: string, session: AuthenticationSession): DisposableCollection; getProviderIds(): string[]; isAuthenticationProviderRegistered(id: string): boolean; private updateAccountsMenuItem; registerAuthenticationProvider(id: string, authenticationProvider: AuthenticationProvider): void; unregisterAuthenticationProvider(id: string): void; updateSessions(id: string, event: AuthenticationProviderAuthenticationSessionsChangeEvent): Promise; private updateNewSessionRequests; requestNewSession(providerId: string, scopes: string[], extensionId: string, extensionName: string): Promise; getLabel(id: string): string; supportsMultipleAccounts(id: string): boolean; getSessions(id: string, scopes?: string[]): Promise>; login(id: string, scopes: string[]): Promise; logout(id: string, sessionId: string): Promise; signOutOfAccount(id: string, accountName: string): Promise; } export interface AllowedExtension { id: string; name: string; } export declare function readAllowedExtensions(storageService: StorageService, providerId: string, accountName: string): Promise; //# sourceMappingURL=authentication-service.d.ts.map