From c37904c16d16e381e6ce37371fa7723e2a942a29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=A4der?= Date: Wed, 17 Apr 2024 13:20:45 +0200 Subject: [PATCH] Add dummy command to fix github authentication built-int flows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also includes code to consider sessions which are not created, but restored from storage at registration time Fixes #13599 Partial fix for #12821 Contributed on behalof of STMicroelectronics Signed-off-by: Thomas Mäder --- .../browser/plugin-vscode-commands-contribution.ts | 10 ++++++++++ packages/plugin-ext/src/plugin/authentication-ext.ts | 11 +++++++++++ 2 files changed, 21 insertions(+) diff --git a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts index 092f71e93d16a..ba9790c4f051a 100755 --- a/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts +++ b/packages/plugin-ext-vscode/src/browser/plugin-vscode-commands-contribution.ts @@ -82,6 +82,12 @@ import { CodeEditorWidgetUtil } from '@theia/plugin-ext/lib/main/browser/menus/v import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution'; export namespace VscodeCommands { + + export const GET_CODE_EXCHANGE_ENDPOINTS: Command = { + id: 'workbench.getCodeExchangeProxyEndpoints' // this command is used in the github auth built-in + // see: https://github.com/microsoft/vscode/blob/191be39e5ac872e03f9d79cc859d9917f40ad935/extensions/github-authentication/src/githubServer.ts#L60 + }; + export const OPEN: Command = { id: 'vscode.open' }; @@ -230,6 +236,10 @@ export class PluginVscodeCommandsContribution implements CommandContribution { } registerCommands(commands: CommandRegistry): void { + commands.registerCommand(VscodeCommands.GET_CODE_EXCHANGE_ENDPOINTS, { + execute: () => undefined // this is a dummy implementation: only used in the case of web apps, which is not supported yet. + }); + commands.registerCommand(VscodeCommands.OPEN, { isVisible: () => false, execute: async (resource: URI | string, columnOrOptions?: ViewColumn | TextDocumentShowOptions) => { diff --git a/packages/plugin-ext/src/plugin/authentication-ext.ts b/packages/plugin-ext/src/plugin/authentication-ext.ts index 25dba1325d0ab..7cf0e3e1c349a 100644 --- a/packages/plugin-ext/src/plugin/authentication-ext.ts +++ b/packages/plugin-ext/src/plugin/authentication-ext.ts @@ -63,6 +63,17 @@ export class AuthenticationExtImpl implements AuthenticationExt { } this.authenticationProviders.set(id, provider); + + provider.getSessions().then(sessions => { // sessions might have been restored from secret storage + if (sessions.length > 0) { + this.proxy.$onDidChangeSessions(id, { + added: sessions, + removed: [], + changed: [] + }); + } + }); + const listener = provider.onDidChangeSessions(e => { this.proxy.$onDidChangeSessions(id, e); });