Stabilize authentication consumer side, fixes #100993
This commit is contained in:
parent
51cdb49940
commit
12f63d9c66
|
@ -9,7 +9,7 @@ import { keychain } from './common/keychain';
|
|||
import { GitHubServer, NETWORK_ERROR } from './githubServer';
|
||||
import Logger from './common/logger';
|
||||
|
||||
export const onDidChangeSessions = new vscode.EventEmitter<vscode.AuthenticationSessionsChangeEvent>();
|
||||
export const onDidChangeSessions = new vscode.EventEmitter<vscode.AuthenticationProviderAuthenticationSessionsChangeEvent>();
|
||||
|
||||
interface SessionData {
|
||||
id: string;
|
||||
|
|
|
@ -73,7 +73,7 @@ function parseQuery(uri: vscode.Uri) {
|
|||
}, {});
|
||||
}
|
||||
|
||||
export const onDidChangeSessions = new vscode.EventEmitter<vscode.AuthenticationSessionsChangeEvent>();
|
||||
export const onDidChangeSessions = new vscode.EventEmitter<vscode.AuthenticationProviderAuthenticationSessionsChangeEvent>();
|
||||
|
||||
export const REFRESH_NETWORK_FAILURE = 'Network failure';
|
||||
|
||||
|
|
116
src/vs/vscode.d.ts
vendored
116
src/vs/vscode.d.ts
vendored
|
@ -11521,6 +11521,122 @@ declare module 'vscode' {
|
|||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
/**
|
||||
* Represents a session of a currently logged in user.
|
||||
*/
|
||||
export interface AuthenticationSession {
|
||||
/**
|
||||
* The identifier of the authentication session.
|
||||
*/
|
||||
readonly id: string;
|
||||
|
||||
/**
|
||||
* The access token.
|
||||
*/
|
||||
readonly accessToken: string;
|
||||
|
||||
/**
|
||||
* The account associated with the session.
|
||||
*/
|
||||
readonly account: AuthenticationSessionAccountInformation;
|
||||
|
||||
/**
|
||||
* The permissions granted by the session's access token. Available scopes
|
||||
* are defined by the [AuthenticationProvider](#AuthenticationProvider).
|
||||
*/
|
||||
readonly scopes: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The information of an account associated with an [AuthenticationSession](#AuthenticationSession).
|
||||
*/
|
||||
export interface AuthenticationSessionAccountInformation {
|
||||
/**
|
||||
* The unique identifier of the account.
|
||||
*/
|
||||
readonly id: string;
|
||||
|
||||
/**
|
||||
* The human-readable name of the account.
|
||||
*/
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Options to be used when getting an [AuthenticationSession](#AuthenticationSession) from an [AuthenticationProvider](#AuthenticationProvider).
|
||||
*/
|
||||
export interface AuthenticationGetSessionOptions {
|
||||
/**
|
||||
* Whether login should be performed if there is no matching session. Defaults to false.
|
||||
*/
|
||||
createIfNone?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the existing user session preference should be cleared. Set to allow the user to switch accounts.
|
||||
* Defaults to false.
|
||||
*/
|
||||
clearSessionPreference?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic information about an[authenticationProvider](#AuthenticationProvider)
|
||||
*/
|
||||
export interface AuthenticationProviderInformation {
|
||||
/**
|
||||
* The unique identifier of the authentication provider.
|
||||
*/
|
||||
readonly id: string;
|
||||
|
||||
/**
|
||||
* The human-readable name of the authentication provider.
|
||||
*/
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed.
|
||||
*/
|
||||
export interface AuthenticationSessionsChangeEvent {
|
||||
/**
|
||||
* The [authenticationProvider](#AuthenticationProvider) that has had its sessions change.
|
||||
*/
|
||||
readonly provider: AuthenticationProviderInformation;
|
||||
}
|
||||
|
||||
export namespace authentication {
|
||||
/**
|
||||
* Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
|
||||
* registered, or if the user does not consent to sharing authentication information with
|
||||
* the extension. If there are multiple sessions with the same scopes, the user will be shown a
|
||||
* quickpick to select which account they would like to use.
|
||||
* @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
|
||||
* @param options The [getSessionOptions](#GetSessionOptions) to use
|
||||
* @returns A thenable that resolves to an authentication session
|
||||
*/
|
||||
export function getSession(providerId: string, scopes: string[], options: AuthenticationGetSessionOptions & { createIfNone: true }): Thenable<AuthenticationSession>;
|
||||
|
||||
/**
|
||||
* Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
|
||||
* registered, or if the user does not consent to sharing authentication information with
|
||||
* the extension. If there are multiple sessions with the same scopes, the user will be shown a
|
||||
* quickpick to select which account they would like to use.
|
||||
* @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
|
||||
* @param options The [getSessionOptions](#GetSessionOptions) to use
|
||||
* @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
|
||||
*/
|
||||
export function getSession(providerId: string, scopes: string[], options: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when the array of sessions has changed, or data
|
||||
* within a session has changed for a provider. Fires with the ids of the providers
|
||||
* that have had session data change.
|
||||
*/
|
||||
export const onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
111
src/vs/vscode.proposed.d.ts
vendored
111
src/vs/vscode.proposed.d.ts
vendored
|
@ -18,59 +18,6 @@ declare module 'vscode' {
|
|||
|
||||
// #region auth provider: https://github.com/microsoft/vscode/issues/88309
|
||||
|
||||
export interface AuthenticationSession {
|
||||
/**
|
||||
* The identifier of the authentication session.
|
||||
*/
|
||||
readonly id: string;
|
||||
|
||||
/**
|
||||
* The access token.
|
||||
*/
|
||||
readonly accessToken: string;
|
||||
|
||||
/**
|
||||
* The account associated with the session.
|
||||
*/
|
||||
readonly account: AuthenticationSessionAccountInformation;
|
||||
|
||||
/**
|
||||
* The permissions granted by the session's access token. Available scopes
|
||||
* are defined by the authentication provider.
|
||||
*/
|
||||
readonly scopes: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The information of an account associated with an authentication session.
|
||||
*/
|
||||
export interface AuthenticationSessionAccountInformation {
|
||||
/**
|
||||
* The unique identifier of the account.
|
||||
*/
|
||||
readonly id: string;
|
||||
|
||||
/**
|
||||
* The human-readable name of the account.
|
||||
*/
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic information about an[authenticationProvider](#AuthenticationProvider)
|
||||
*/
|
||||
export interface AuthenticationProviderInformation {
|
||||
/**
|
||||
* The unique identifier of the authentication provider.
|
||||
*/
|
||||
readonly id: string;
|
||||
|
||||
/**
|
||||
* The human-readable name of the authentication provider.
|
||||
*/
|
||||
readonly label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when an [AuthenticationProvider](#AuthenticationProvider) is added or removed.
|
||||
*/
|
||||
|
@ -86,33 +33,10 @@ declare module 'vscode' {
|
|||
readonly removed: ReadonlyArray<AuthenticationProviderInformation>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to be used when getting a session from an [AuthenticationProvider](#AuthenticationProvider).
|
||||
*/
|
||||
export interface AuthenticationGetSessionOptions {
|
||||
/**
|
||||
* Whether login should be performed if there is no matching session. Defaults to false.
|
||||
*/
|
||||
createIfNone?: boolean;
|
||||
|
||||
/**
|
||||
* Whether the existing user session preference should be cleared. Set to allow the user to switch accounts.
|
||||
* Defaults to false.
|
||||
*/
|
||||
clearSessionPreference?: boolean;
|
||||
}
|
||||
|
||||
export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
|
||||
/**
|
||||
* The [authenticationProvider](#AuthenticationProvider) that has had its sessions change.
|
||||
*/
|
||||
readonly provider: AuthenticationProviderInformation;
|
||||
}
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed.
|
||||
*/
|
||||
export interface AuthenticationSessionsChangeEvent {
|
||||
export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
|
||||
/**
|
||||
* The ids of the [AuthenticationSession](#AuthenticationSession)s that have been added.
|
||||
*/
|
||||
|
@ -156,7 +80,7 @@ declare module 'vscode' {
|
|||
* An [event](#Event) which fires when the array of sessions has changed, or data
|
||||
* within a session has changed.
|
||||
*/
|
||||
readonly onDidChangeSessions: Event<AuthenticationSessionsChangeEvent>;
|
||||
readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
|
||||
|
||||
/**
|
||||
* Returns an array of current sessions.
|
||||
|
@ -210,30 +134,6 @@ declare module 'vscode' {
|
|||
*/
|
||||
export const providers: ReadonlyArray<AuthenticationProviderInformation>;
|
||||
|
||||
/**
|
||||
* Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
|
||||
* registered, or if the user does not consent to sharing authentication information with
|
||||
* the extension. If there are multiple sessions with the same scopes, the user will be shown a
|
||||
* quickpick to select which account they would like to use.
|
||||
* @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
|
||||
* @param options The [getSessionOptions](#GetSessionOptions) to use
|
||||
* @returns A thenable that resolves to an authentication session
|
||||
*/
|
||||
export function getSession(providerId: string, scopes: string[], options: AuthenticationGetSessionOptions & { createIfNone: true }): Thenable<AuthenticationSession>;
|
||||
|
||||
/**
|
||||
* Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
|
||||
* registered, or if the user does not consent to sharing authentication information with
|
||||
* the extension. If there are multiple sessions with the same scopes, the user will be shown a
|
||||
* quickpick to select which account they would like to use.
|
||||
* @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
|
||||
* @param options The [getSessionOptions](#GetSessionOptions) to use
|
||||
* @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
|
||||
*/
|
||||
export function getSession(providerId: string, scopes: string[], options: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Logout of a specific session.
|
||||
|
@ -242,13 +142,6 @@ declare module 'vscode' {
|
|||
* provider
|
||||
*/
|
||||
export function logout(providerId: string, sessionId: string): Thenable<void>;
|
||||
|
||||
/**
|
||||
* An [event](#Event) which fires when the array of sessions has changed, or data
|
||||
* within a session has changed for a provider. Fires with the ids of the providers
|
||||
* that have had session data change.
|
||||
*/
|
||||
export const onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
|
Loading…
Reference in a new issue