From 67ded11020014caf9f9627f3756d398adaeae848 Mon Sep 17 00:00:00 2001 From: Rachel Macfarlane Date: Mon, 22 Feb 2021 15:14:14 -0800 Subject: [PATCH] Add authentication provider registration to stable API, closes #88309 --- src/vs/vscode.d.ts | 81 ++++++++++++++++++++++++++++++++ src/vs/vscode.proposed.d.ts | 92 +++---------------------------------- 2 files changed, 88 insertions(+), 85 deletions(-) diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index b8f07070bdeaf..0145dcc867cce 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -12331,6 +12331,73 @@ declare module 'vscode' { readonly provider: AuthenticationProviderInformation; } + /** + * Options for creating an [AuthenticationProvider](#AuthenticationProvider). + */ + export interface AuthenticationProviderOptions { + /** + * Whether it is possible to be signed into multiple accounts at once with this provider. + * If not specified, will default to false. + */ + readonly supportsMultipleAccounts?: boolean; + } + + /** + * An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed. + */ + export interface AuthenticationProviderAuthenticationSessionsChangeEvent { + /** + * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been added. + */ + readonly added: ReadonlyArray; + + /** + * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been removed. + */ + readonly removed: ReadonlyArray; + + /** + * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been changed. + */ + readonly changed: ReadonlyArray; + } + + /** + * A provider for performing authentication to a service. + */ + export interface AuthenticationProvider { + /** + * 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. + */ + // eslint-disable-next-line vscode-dts-provider-naming + 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. + */ + // eslint-disable-next-line vscode-dts-provider-naming + createSession(scopes: string[]): Thenable; + + /** + * Removes the session corresponding to session id. + * @param sessionId The id of the session to remove. + */ + // eslint-disable-next-line vscode-dts-provider-naming + removeSession(sessionId: string): Thenable; + } + + /** * Namespace for authentication. */ @@ -12370,6 +12437,20 @@ declare module 'vscode' { * been added, removed, or changed. */ export const onDidChangeSessions: Event; + + /** + * Register an authentication provider. + * + * There can only be one provider per id and an error is being thrown when an id + * has already been used by another provider. Ids are case-sensitive. + * + * @param id The unique identifier of the provider. + * @param label The human-readable name of the provider. + * @param provider The authentication provider provider. + * @params options Additional options for the provider. + * @return A [disposable](#Disposable) that unregisters this provider when being disposed. + */ + export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable; } } diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index be131a4db87db..64e9072b04d0d 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -33,87 +33,7 @@ declare module 'vscode' { readonly removed: ReadonlyArray; } - /** - * An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed. - */ - export interface AuthenticationProviderAuthenticationSessionsChangeEvent { - /** - * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been added. - */ - readonly added: ReadonlyArray; - - /** - * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been removed. - */ - readonly removed: ReadonlyArray; - - /** - * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been changed. - */ - readonly changed: ReadonlyArray; - } - - /** - * A provider for performing authentication to a service. - */ - export interface AuthenticationProvider { - /** - * 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. - */ - // eslint-disable-next-line vscode-dts-provider-naming - 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. - */ - // eslint-disable-next-line vscode-dts-provider-naming - createSession(scopes: string[]): Thenable; - - /** - * Removes the session corresponding to session id. - * @param sessionId The id of the session to remove. - */ - // eslint-disable-next-line vscode-dts-provider-naming - removeSession(sessionId: string): Thenable; - } - - /** - * Options for creating an [AuthenticationProvider](#AuthentcationProvider). - */ - export interface AuthenticationProviderOptions { - /** - * Whether it is possible to be signed into multiple accounts at once with this provider. - * If not specified, will default to false. - */ - readonly supportsMultipleAccounts?: boolean; - } - export namespace authentication { - /** - * Register an authentication provider. - * - * There can only be one provider per id and an error is being thrown when an id - * has already been used by another provider. Ids are case-sensitive. - * - * @param id The unique identifier of the provider. - * @param label The human-readable name of the provider. - * @param provider The authentication provider provider. - * @params options Additional options for the provider. - * @return A [disposable](#Disposable) that unregisters this provider when being disposed. - */ - export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable; - /** * @deprecated - getSession should now trigger extension activation. * Fires with the provider id that was registered or unregistered. @@ -121,16 +41,18 @@ declare module 'vscode' { export const onDidChangeAuthenticationProviders: Event; /** + * @deprecated * An array of the information of authentication providers that are currently registered. */ export const providers: ReadonlyArray; /** - * Logout of a specific session. - * @param providerId The id of the provider to use - * @param sessionId The session id to remove - * provider - */ + * @deprecated + * Logout of a specific session. + * @param providerId The id of the provider to use + * @param sessionId The session id to remove + * provider + */ export function logout(providerId: string, sessionId: string): Thenable; }