Skip to content

Commit

Permalink
Finalize getAccounts API
Browse files Browse the repository at this point in the history
Fixes #152399
  • Loading branch information
TylerLeonhardt committed Aug 5, 2024
1 parent 773fa66 commit bb116cb
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 88 deletions.
3 changes: 0 additions & 3 deletions extensions/github-authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
"Other"
],
"api": "none",
"enabledApiProposals": [
"authGetSessions"
],
"extensionKind": [
"ui",
"workspace"
Expand Down
3 changes: 1 addition & 2 deletions extensions/github-authentication/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
},
"include": [
"src/**/*",
"../../src/vscode-dts/vscode.d.ts",
"../../src/vscode-dts/vscode.proposed.authGetSessions.d.ts"
"../../src/vscode-dts/vscode.d.ts"
]
}
3 changes: 1 addition & 2 deletions extensions/microsoft-authentication/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
],
"activationEvents": [],
"enabledApiProposals": [
"idToken",
"authGetSessions"
"idToken"
],
"capabilities": {
"virtualWorkspaces": true,
Expand Down
3 changes: 1 addition & 2 deletions extensions/microsoft-authentication/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"include": [
"src/**/*",
"../../src/vscode-dts/vscode.d.ts",
"../../src/vscode-dts/vscode.proposed.idToken.d.ts",
"../../src/vscode-dts/vscode.proposed.authGetSessions.d.ts"
"../../src/vscode-dts/vscode.proposed.idToken.d.ts"
]
}
3 changes: 0 additions & 3 deletions src/vs/platform/extensions/common/extensionsApiProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const _allApiProposals = {
attributableCoverage: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.attributableCoverage.d.ts',
},
authGetSessions: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authGetSessions.d.ts',
},
authLearnMore: {
proposal: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authLearnMore.d.ts',
},
Expand Down
4 changes: 0 additions & 4 deletions src/vs/workbench/api/common/extHost.api.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,13 +290,9 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
if (typeof options?.forceNewSession === 'object' && options.forceNewSession.learnMore) {
checkProposedApiEnabled(extension, 'authLearnMore');
}
if (options?.account) {
checkProposedApiEnabled(extension, 'authGetSessions');
}
return extHostAuthentication.getSession(extension, providerId, scopes, options as any);
},
getAccounts(providerId: string) {
checkProposedApiEnabled(extension, 'authGetSessions');
return extHostAuthentication.getAccounts(providerId);
},
// TODO: remove this after GHPR and Codespaces move off of it
Expand Down
37 changes: 35 additions & 2 deletions src/vscode-dts/vscode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16882,6 +16882,11 @@ declare module 'vscode' {
* Note: you cannot use this option with any other options that prompt the user like {@link AuthenticationGetSessionOptions.createIfNone createIfNone}.
*/
silent?: boolean;

/**
* The account that you would like to get a session for. This is passed down to the Authentication Provider to be used for creating the correct session.
*/
account?: AuthenticationSessionAccountInformation;
}

/**
Expand Down Expand Up @@ -16942,6 +16947,18 @@ declare module 'vscode' {
readonly changed: readonly AuthenticationSession[] | undefined;
}

/**
* The options passed in to the {@link AuthenticationProvider.getSessions} and
* {@link AuthenticationProvider.createSession} call.
*/
export interface AuthenticationProviderSessionOptions {
/**
* The account that is being asked about. If this is passed in, the provider should
* attempt to return the sessions that are only related to this account.
*/
account?: AuthenticationSessionAccountInformation;
}

/**
* A provider for performing authentication to a service.
*/
Expand All @@ -16956,9 +16973,10 @@ declare module 'vscode' {
* Get a list of sessions.
* @param scopes An optional list of scopes. If provided, the sessions returned should match
* these permissions, otherwise all sessions should be returned.
* @param options Additional options for getting sessions.
* @returns A promise that resolves to an array of authentication sessions.
*/
getSessions(scopes?: readonly string[]): Thenable<readonly AuthenticationSession[]>;
getSessions(scopes: readonly string[] | undefined, options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession[]>;

/**
* Prompts a user to login.
Expand All @@ -16971,9 +16989,10 @@ declare module 'vscode' {
* then this should never be called if there is already an existing session matching these
* scopes.
* @param scopes A list of scopes, permissions, that the new session should be created with.
* @param options Additional options for creating a session.
* @returns A promise that resolves to an authentication session.
*/
createSession(scopes: readonly string[]): Thenable<AuthenticationSession>;
createSession(scopes: readonly string[], options: AuthenticationProviderSessionOptions): Thenable<AuthenticationSession>;

/**
* Removes the session corresponding to session id.
Expand Down Expand Up @@ -17036,6 +17055,20 @@ declare module 'vscode' {
*/
export function getSession(providerId: string, scopes: readonly string[], options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;

/**
* Get all accounts that the user is logged in to for the specified provider.
* Use this paired with {@link getSession} in order to get an authentication session for a specific account.
*
* 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'.
*
* Note: Getting accounts does not imply that your extension has access to that account or its authentication sessions. You can verify access to the account by calling {@link getSession}.
*
* @param providerId The id of the provider to use
* @returns A thenable that resolves to a readonly array of authentication accounts.
*/
export function getAccounts(providerId: string): Thenable<readonly AuthenticationSessionAccountInformation[]>;

/**
* An {@link Event} which fires when the authentication sessions of an authentication provider have
* been added, removed, or changed.
Expand Down
70 changes: 0 additions & 70 deletions src/vscode-dts/vscode.proposed.authGetSessions.d.ts

This file was deleted.

0 comments on commit bb116cb

Please sign in to comment.