Remove getSessions API in favor of getAccounts (#218238)

Azure folks (the only ones using this proposed API) have not depended on getSessions yet so it's safe to delete.
This commit is contained in:
Tyler James Leonhardt 2024-06-25 22:34:31 -07:00 committed by GitHub
parent 0feeac7b76
commit 6e345d4606
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 0 additions and 47 deletions

View file

@ -260,18 +260,6 @@ export class MainThreadAuthentication extends Disposable implements MainThreadAu
return session;
}
async $getSessions(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string): Promise<AuthenticationSession[]> {
const sessions = await this.authenticationService.getSessions(providerId, [...scopes], undefined, true);
const accessibleSessions = sessions.filter(s => this.authenticationAccessService.isAccessAllowed(providerId, s.account.label, extensionId));
if (accessibleSessions.length) {
this.sendProviderUsageTelemetry(extensionId, providerId);
for (const session of accessibleSessions) {
this.authenticationUsageService.addAccountUsage(providerId, session.account.label, extensionId, extensionName);
}
}
return accessibleSessions;
}
async $getAccounts(providerId: string): Promise<ReadonlyArray<AuthenticationSessionAccount>> {
const sessions = await this.authenticationService.getSessions(providerId);
const accounts = new Array<AuthenticationSessionAccount>();

View file

@ -294,10 +294,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
}
return extHostAuthentication.getSession(extension, providerId, scopes, options as any);
},
getSessions(providerId: string, scopes: readonly string[]) {
checkProposedApiEnabled(extension, 'authGetSessions');
return extHostAuthentication.getSessions(extension, providerId, scopes);
},
getAccounts(providerId: string) {
checkProposedApiEnabled(extension, 'authGetSessions');
return extHostAuthentication.getAccounts(providerId);

View file

@ -162,7 +162,6 @@ export interface MainThreadAuthenticationShape extends IDisposable {
$ensureProvider(id: string): Promise<void>;
$sendDidChangeSessions(providerId: string, event: AuthenticationSessionsChangeEvent): void;
$getSession(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string, options: { createIfNone?: boolean; forceNewSession?: boolean | AuthenticationForceNewSessionOptions; clearSessionPreference?: boolean }): Promise<AuthenticationSession | undefined>;
$getSessions(providerId: string, scopes: readonly string[], extensionId: string, extensionName: string): Promise<AuthenticationSession[]>;
$getAccounts(providerId: string): Promise<ReadonlyArray<AuthenticationSessionAccount>>;
$removeSession(providerId: string, sessionId: string): Promise<void>;
}

View file

@ -32,7 +32,6 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
readonly onDidChangeSessions: Event<vscode.AuthenticationSessionsChangeEvent> = this._onDidChangeSessions.event;
private _getSessionTaskSingler = new TaskSingler<vscode.AuthenticationSession | undefined>();
private _getSessionsTaskSingler = new TaskSingler<ReadonlyArray<vscode.AuthenticationSession>>();
constructor(
@IExtHostRpcService extHostRpc: IExtHostRpcService
@ -54,16 +53,6 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
});
}
async getSessions(requestingExtension: IExtensionDescription, providerId: string, scopes: readonly string[]): Promise<ReadonlyArray<vscode.AuthenticationSession>> {
const extensionId = ExtensionIdentifier.toKey(requestingExtension.identifier);
const sortedScopes = [...scopes].sort().join(' ');
return await this._getSessionsTaskSingler.getOrCreate(`${extensionId} ${sortedScopes}`, async () => {
await this._proxy.$ensureProvider(providerId);
const extensionName = requestingExtension.displayName || requestingExtension.name;
return this._proxy.$getSessions(providerId, scopes, extensionId, extensionName);
});
}
async getAccounts(providerId: string) {
await this._proxy.$ensureProvider(providerId);
return await this._proxy.$getAccounts(providerId);

View file

@ -67,23 +67,4 @@ declare module 'vscode' {
*/
createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession>;
}
// THE BELOW IS THE OLD PROPOSAL WHICH WILL BE REMOVED BUT KEPT UNTIL THE NEW PROPOSAL IS ADOPTED BY ALL PARTIES
export namespace authentication {
/**
* Get all authentication sessions matching the desired scopes that this extension has access to. In order to request access,
* use {@link getSession}. To request an additional account, specify {@link AuthenticationGetSessionOptions.clearSessionPreference}
* and {@link AuthenticationGetSessionOptions.createIfNone} together.
*
* 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'.
*
* @param providerId The id of the provider to use
* @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
* @returns A thenable that resolves to a readonly array of authentication sessions.
* @deprecated Use {@link getAccounts} instead.
*/
export function getSessions(providerId: string, scopes: readonly string[]): Thenable<readonly AuthenticationSession[]>;
}
}