diff --git a/extensions/github-authentication/package.json b/extensions/github-authentication/package.json index 3306b4b904289..7fcbc7f151ce3 100644 --- a/extensions/github-authentication/package.json +++ b/extensions/github-authentication/package.json @@ -13,9 +13,6 @@ "Other" ], "api": "none", - "enabledApiProposals": [ - "authGetSessions" - ], "extensionKind": [ "ui", "workspace" diff --git a/extensions/github-authentication/tsconfig.json b/extensions/github-authentication/tsconfig.json index 70eba984a2694..5e4713e9f3bc5 100644 --- a/extensions/github-authentication/tsconfig.json +++ b/extensions/github-authentication/tsconfig.json @@ -12,7 +12,6 @@ }, "include": [ "src/**/*", - "../../src/vscode-dts/vscode.d.ts", - "../../src/vscode-dts/vscode.proposed.authGetSessions.d.ts" + "../../src/vscode-dts/vscode.d.ts" ] } diff --git a/extensions/microsoft-authentication/package.json b/extensions/microsoft-authentication/package.json index af46f732d9226..31a7d4bd7e863 100644 --- a/extensions/microsoft-authentication/package.json +++ b/extensions/microsoft-authentication/package.json @@ -14,8 +14,7 @@ ], "activationEvents": [], "enabledApiProposals": [ - "idToken", - "authGetSessions" + "idToken" ], "capabilities": { "virtualWorkspaces": true, diff --git a/extensions/microsoft-authentication/tsconfig.json b/extensions/microsoft-authentication/tsconfig.json index cad76d078bd8a..4b9d06d1847ef 100644 --- a/extensions/microsoft-authentication/tsconfig.json +++ b/extensions/microsoft-authentication/tsconfig.json @@ -22,7 +22,6 @@ "include": [ "src/**/*", "../../src/vscode-dts/vscode.d.ts", - "../../src/vscode-dts/vscode.proposed.idToken.d.ts", - "../../src/vscode-dts/vscode.proposed.authGetSessions.d.ts" + "../../src/vscode-dts/vscode.proposed.idToken.d.ts" ] } diff --git a/src/vs/platform/extensions/common/extensionsApiProposals.ts b/src/vs/platform/extensions/common/extensionsApiProposals.ts index cd529c1b1b2a6..673643f71731a 100644 --- a/src/vs/platform/extensions/common/extensionsApiProposals.ts +++ b/src/vs/platform/extensions/common/extensionsApiProposals.ts @@ -21,9 +21,6 @@ const _allApiProposals = { attributableCoverage: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts', }, - authGetSessions: { - proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authGetSessions.d.ts', - }, authLearnMore: { proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authLearnMore.d.ts', }, diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index ae8a6fd90b2c8..98ab60ed9fb03 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -290,13 +290,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I if (typeof options?.forceNewSession === 'object' && options.forceNewSession.learnMore) { checkProposedApiEnabled(extension, 'authLearnMore'); } - if (options?.account) { - checkProposedApiEnabled(extension, 'authGetSessions'); - } return extHostAuthentication.getSession(extension, providerId, scopes, options as any); }, getAccounts(providerId: string) { - checkProposedApiEnabled(extension, 'authGetSessions'); return extHostAuthentication.getAccounts(providerId); }, // TODO: remove this after GHPR and Codespaces move off of it diff --git a/src/vscode-dts/vscode.d.ts b/src/vscode-dts/vscode.d.ts index 9198f299c5f4b..cddd91b8e0d28 100644 --- a/src/vscode-dts/vscode.d.ts +++ b/src/vscode-dts/vscode.d.ts @@ -16882,6 +16882,11 @@ declare module 'vscode' { * Note: you cannot use this option with any other options that prompt the user like {@link AuthenticationGetSessionOptions.createIfNone createIfNone}. */ silent?: boolean; + + /** + * The account that you would like to get a session for. This is passed down to the Authentication Provider to be used for creating the correct session. + */ + account?: AuthenticationSessionAccountInformation; } /** @@ -16942,6 +16947,18 @@ declare module 'vscode' { readonly changed: readonly AuthenticationSession[] | undefined; } + /** + * The options passed in to the {@link AuthenticationProvider.getSessions} and + * {@link AuthenticationProvider.createSession} call. + */ + export interface AuthenticationProviderSessionOptions { + /** + * The account that is being asked about. If this is passed in, the provider should + * attempt to return the sessions that are only related to this account. + */ + account?: AuthenticationSessionAccountInformation; + } + /** * A provider for performing authentication to a service. */ @@ -16956,9 +16973,10 @@ declare module 'vscode' { * 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. + * @param options Additional options for getting sessions. * @returns A promise that resolves to an array of authentication sessions. */ - getSessions(scopes?: readonly string[]): Thenable; + getSessions(scopes: readonly string[] | undefined, options: AuthenticationProviderSessionOptions): Thenable; /** * Prompts a user to login. @@ -16971,9 +16989,10 @@ declare module 'vscode' { * then this should never be called if there is already an existing session matching these * scopes. * @param scopes A list of scopes, permissions, that the new session should be created with. + * @param options Additional options for creating a session. * @returns A promise that resolves to an authentication session. */ - createSession(scopes: readonly string[]): Thenable; + createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Thenable; /** * Removes the session corresponding to session id. @@ -17036,6 +17055,20 @@ declare module 'vscode' { */ export function getSession(providerId: string, scopes: readonly string[], options?: AuthenticationGetSessionOptions): Thenable; + /** + * Get all accounts that the user is logged in to for the specified provider. + * Use this paired with {@link getSession} in order to get an authentication session for a specific account. + * + * Currently, there are only two authentication providers that are contributed from built in extensions + * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'. + * + * Note: Getting accounts does not imply that your extension has access to that account or its authentication sessions. You can verify access to the account by calling {@link getSession}. + * + * @param providerId The id of the provider to use + * @returns A thenable that resolves to a readonly array of authentication accounts. + */ + export function getAccounts(providerId: string): Thenable; + /** * An {@link Event} which fires when the authentication sessions of an authentication provider have * been added, removed, or changed. diff --git a/src/vscode-dts/vscode.proposed.authGetSessions.d.ts b/src/vscode-dts/vscode.proposed.authGetSessions.d.ts deleted file mode 100644 index 6d425ed3232b3..0000000000000 --- a/src/vscode-dts/vscode.proposed.authGetSessions.d.ts +++ /dev/null @@ -1,70 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -declare module 'vscode' { - - // https://github.com/microsoft/vscode/issues/152399 - - // FOR THE CONSUMER - - export namespace authentication { - /** - * Get all accounts that the user is logged in to for the specified provider. - * Use this paired with {@link getSession} in order to get an authentication session for a specific account. - * - * Currently, there are only two authentication providers that are contributed from built in extensions - * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'. - * - * Note: Getting accounts does not imply that your extension has access to that account or its authentication sessions. You can verify access to the account by calling {@link getSession}. - * - * @param providerId The id of the provider to use - * @returns A thenable that resolves to a readonly array of authentication accounts. - */ - export function getAccounts(providerId: string): Thenable; - } - - export interface AuthenticationGetSessionOptions { - /** - * The account that you would like to get a session for. This is passed down to the Authentication Provider to be used for creating the correct session. - */ - account?: AuthenticationSessionAccountInformation; - } - - // FOR THE AUTH PROVIDER - - export interface AuthenticationProviderSessionOptions { - /** - * The account that is being asked about. If this is passed in, the provider should - * attempt to return the sessions that are only related to this account. - */ - account?: AuthenticationSessionAccountInformation; - } - - export interface AuthenticationProvider { - /** - * 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. - * @param options Additional options for getting sessions. - * @returns A promise that resolves to an array of authentication sessions. - */ - getSessions(scopes: readonly string[] | undefined, options: AuthenticationProviderSessionOptions): Thenable; - /** - * Prompts a user to login. - * - * If login is successful, the onDidChangeSessions event should be fired. - * - * If login fails, a rejected promise should be returned. - * - * If the provider has specified that it does not support multiple accounts, - * then this should never be called if there is already an existing session matching these - * scopes. - * @param scopes A list of scopes, permissions, that the new session should be created with. - * @param options Additional options for creating a session. - * @returns A promise that resolves to an authentication session. - */ - createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Thenable; - } -}