Skip to content

Commit

Permalink
Add dummy command to fix github authentication built-int flows
Browse files Browse the repository at this point in the history
Also includes code to consider sessions which are not created, but
restored from storage at registration time

Fixes eclipse-theia#13599
Partial fix for eclipse-theia#12821

Contributed on behalof of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder committed Apr 17, 2024
1 parent fea794f commit c37904c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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'
};
Expand Down Expand Up @@ -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) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/plugin-ext/src/plugin/authentication-ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit c37904c

Please sign in to comment.