Skip to content

Commit 6e345d4

Browse files
Remove getSessions API in favor of getAccounts (microsoft#218238)
Azure folks (the only ones using this proposed API) have not depended on getSessions yet so it's safe to delete.
1 parent 0feeac7 commit 6e345d4

File tree

5 files changed

+0
-47
lines changed

5 files changed

+0
-47
lines changed

src/vs/workbench/api/browser/mainThreadAuthentication.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,18 +260,6 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
260260
return session;
261261
}
262262

263-
async $getSessions(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string): Promise<AuthenticationSession[]> {
264-
const sessions = await this.authenticationService.getSessions(providerId, [...scopes], undefined, true);
265-
const accessibleSessions = sessions.filter(s => this.authenticationAccessService.isAccessAllowed(providerId, s.account.label, extensionId));
266-
if (accessibleSessions.length) {
267-
this.sendProviderUsageTelemetry(extensionId, providerId);
268-
for (const session of accessibleSessions) {
269-
this.authenticationUsageService.addAccountUsage(providerId, session.account.label, extensionId, extensionName);
270-
}
271-
}
272-
return accessibleSessions;
273-
}
274-
275263
async $getAccounts(providerId: string): Promise<ReadonlyArray<AuthenticationSessionAccount>> {
276264
const sessions = await this.authenticationService.getSessions(providerId);
277265
const accounts = new Array<AuthenticationSessionAccount>();

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
294294
}
295295
return extHostAuthentication.getSession(extension, providerId, scopes, options as any);
296296
},
297-
getSessions(providerId: string, scopes: readonly string[]) {
298-
checkProposedApiEnabled(extension, 'authGetSessions');
299-
return extHostAuthentication.getSessions(extension, providerId, scopes);
300-
},
301297
getAccounts(providerId: string) {
302298
checkProposedApiEnabled(extension, 'authGetSessions');
303299
return extHostAuthentication.getAccounts(providerId);

src/vs/workbench/api/common/extHost.protocol.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ export interface MainThreadAuthenticationShape extends IDisposable {
162162
$ensureProvider(id: string): Promise<void>;
163163
$sendDidChangeSessions(providerId: string, event: AuthenticationSessionsChangeEvent): void;
164164
$getSession(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string, options: { createIfNone?: boolean; forceNewSession?: boolean | AuthenticationForceNewSessionOptions; clearSessionPreference?: boolean }): Promise<AuthenticationSession | undefined>;
165-
$getSessions(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string): Promise<AuthenticationSession[]>;
166165
$getAccounts(providerId: string): Promise<ReadonlyArray<AuthenticationSessionAccount>>;
167166
$removeSession(providerId: string, sessionId: string): Promise<void>;
168167
}

src/vs/workbench/api/common/extHostAuthentication.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
3232
readonly onDidChangeSessions: Event<vscode.AuthenticationSessionsChangeEvent> = this._onDidChangeSessions.event;
3333

3434
private _getSessionTaskSingler = new TaskSingler<vscode.AuthenticationSession | undefined>();
35-
private _getSessionsTaskSingler = new TaskSingler<ReadonlyArray<vscode.AuthenticationSession>>();
3635

3736
constructor(
3837
@IExtHostRpcService extHostRpc: IExtHostRpcService
@@ -54,16 +53,6 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
5453
});
5554
}
5655

57-
async getSessions(requestingExtension: IExtensionDescription, providerId: string, scopes: readonly string[]): Promise<ReadonlyArray<vscode.AuthenticationSession>> {
58-
const extensionId = ExtensionIdentifier.toKey(requestingExtension.identifier);
59-
const sortedScopes = [...scopes].sort().join(' ');
60-
return await this._getSessionsTaskSingler.getOrCreate(`${extensionId} ${sortedScopes}`, async () => {
61-
await this._proxy.$ensureProvider(providerId);
62-
const extensionName = requestingExtension.displayName || requestingExtension.name;
63-
return this._proxy.$getSessions(providerId, scopes, extensionId, extensionName);
64-
});
65-
}
66-
6756
async getAccounts(providerId: string) {
6857
await this._proxy.$ensureProvider(providerId);
6958
return await this._proxy.$getAccounts(providerId);

src/vscode-dts/vscode.proposed.authGetSessions.d.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,4 @@ declare module 'vscode' {
6767
*/
6868
createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession>;
6969
}
70-
71-
// THE BELOW IS THE OLD PROPOSAL WHICH WILL BE REMOVED BUT KEPT UNTIL THE NEW PROPOSAL IS ADOPTED BY ALL PARTIES
72-
73-
export namespace authentication {
74-
/**
75-
* Get all authentication sessions matching the desired scopes that this extension has access to. In order to request access,
76-
* use {@link getSession}. To request an additional account, specify {@link AuthenticationGetSessionOptions.clearSessionPreference}
77-
* and {@link AuthenticationGetSessionOptions.createIfNone} together.
78-
*
79-
* Currently, there are only two authentication providers that are contributed from built in extensions
80-
* to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
81-
*
82-
* @param providerId The id of the provider to use
83-
* @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
84-
* @returns A thenable that resolves to a readonly array of authentication sessions.
85-
* @deprecated Use {@link getAccounts} instead.
86-
*/
87-
export function getSessions(providerId: string, scopes: readonly string[]): Thenable<readonly AuthenticationSession[]>;
88-
}
8970
}

0 commit comments

Comments
 (0)