Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 23 additions & 20 deletions src/vs/workbench/api/common/extHostAuthentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,37 +129,40 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
}

$createSession(providerId: string, scopes: string[], options: vscode.AuthenticationProviderSessionOptions): Promise<vscode.AuthenticationSession> {
return this._providerOperations.queue(providerId, async () => {
const providerData = this._authenticationProviders.get(providerId);
if (providerData) {
options.authorizationServer = URI.revive(options.authorizationServer);
return await providerData.provider.createSession(scopes, options);
}

// Capture provider reference before queuing to allow ongoing operations to complete even if provider is disposed
const providerData = this._authenticationProviders.get(providerId);
if (!providerData) {
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}

return this._providerOperations.queue(providerId, async () => {
options.authorizationServer = URI.revive(options.authorizationServer);
return await providerData.provider.createSession(scopes, options);
});
}

$removeSession(providerId: string, sessionId: string): Promise<void> {
return this._providerOperations.queue(providerId, async () => {
const providerData = this._authenticationProviders.get(providerId);
if (providerData) {
return await providerData.provider.removeSession(sessionId);
}

// Capture provider reference before queuing to allow ongoing operations to complete even if provider is disposed
const providerData = this._authenticationProviders.get(providerId);
if (!providerData) {
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}

return this._providerOperations.queue(providerId, async () => {
return await providerData.provider.removeSession(sessionId);
});
}

$getSessions(providerId: string, scopes: ReadonlyArray<string> | undefined, options: vscode.AuthenticationProviderSessionOptions): Promise<ReadonlyArray<vscode.AuthenticationSession>> {
return this._providerOperations.queue(providerId, async () => {
const providerData = this._authenticationProviders.get(providerId);
if (providerData) {
options.authorizationServer = URI.revive(options.authorizationServer);
return await providerData.provider.getSessions(scopes, options);
}

// Capture provider reference before queuing to allow ongoing operations to complete even if provider is disposed
const providerData = this._authenticationProviders.get(providerId);
if (!providerData) {
throw new Error(`Unable to find authentication provider with handle: ${providerId}`);
}

return this._providerOperations.queue(providerId, async () => {
options.authorizationServer = URI.revive(options.authorizationServer);
return await providerData.provider.getSessions(scopes, options);
});
}

Expand Down
Loading