1 | import { Event } from '../common/event';
|
2 | import { StorageService } from '../browser/storage-service';
|
3 | import { Disposable, DisposableCollection } from '../common/disposable';
|
4 | import { MenuModelRegistry } from '../common/menu';
|
5 | import { CommandRegistry } from '../common/command';
|
6 | export interface AuthenticationSessionAccountInformation {
|
7 | readonly id: string;
|
8 | readonly label: string;
|
9 | }
|
10 | export interface AuthenticationSession {
|
11 | id: string;
|
12 | accessToken: string;
|
13 | account: AuthenticationSessionAccountInformation;
|
14 | scopes: ReadonlyArray<string>;
|
15 | }
|
16 | export interface AuthenticationProviderInformation {
|
17 | id: string;
|
18 | label: string;
|
19 | }
|
20 |
|
21 | export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
|
22 | readonly added: readonly AuthenticationSession[] | undefined;
|
23 | readonly removed: readonly AuthenticationSession[] | undefined;
|
24 | readonly changed: readonly AuthenticationSession[] | undefined;
|
25 | }
|
26 | export interface SessionRequest {
|
27 | disposables: Disposable[];
|
28 | requestingExtensionIds: string[];
|
29 | }
|
30 | export interface SessionRequestInfo {
|
31 | [scopes: string]: SessionRequest;
|
32 | }
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 | export interface AuthenticationProvider {
|
42 | id: string;
|
43 | label: string;
|
44 | supportsMultipleAccounts: boolean;
|
45 | hasSessions(): boolean;
|
46 | signOut(accountName: string): Promise<void>;
|
47 | updateSessionItems(event: AuthenticationProviderAuthenticationSessionsChangeEvent): Promise<void>;
|
48 | |
49 |
|
50 |
|
51 | login(scopes: string[]): Promise<AuthenticationSession>;
|
52 | |
53 |
|
54 |
|
55 | logout(sessionId: string): Promise<void>;
|
56 | |
57 |
|
58 |
|
59 |
|
60 | readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
|
61 | |
62 |
|
63 |
|
64 |
|
65 |
|
66 |
|
67 | getSessions(scopes?: string[]): Thenable<ReadonlyArray<AuthenticationSession>>;
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 | createSession(scopes: string[]): Thenable<AuthenticationSession>;
|
74 | |
75 |
|
76 |
|
77 |
|
78 | removeSession(sessionId: string): Thenable<void>;
|
79 | }
|
80 | export declare const AuthenticationService: unique symbol;
|
81 | export interface AuthenticationService {
|
82 | isAuthenticationProviderRegistered(id: string): boolean;
|
83 | getProviderIds(): string[];
|
84 | registerAuthenticationProvider(id: string, provider: AuthenticationProvider): void;
|
85 | unregisterAuthenticationProvider(id: string): void;
|
86 | requestNewSession(id: string, scopes: string[], extensionId: string, extensionName: string): void;
|
87 | updateSessions(providerId: string, event: AuthenticationProviderAuthenticationSessionsChangeEvent): void;
|
88 | readonly onDidRegisterAuthenticationProvider: Event<AuthenticationProviderInformation>;
|
89 | readonly onDidUnregisterAuthenticationProvider: Event<AuthenticationProviderInformation>;
|
90 | readonly onDidChangeSessions: Event<{
|
91 | providerId: string;
|
92 | label: string;
|
93 | event: AuthenticationProviderAuthenticationSessionsChangeEvent;
|
94 | }>;
|
95 | getSessions(providerId: string, scopes?: string[]): Promise<ReadonlyArray<AuthenticationSession>>;
|
96 | getLabel(providerId: string): string;
|
97 | supportsMultipleAccounts(providerId: string): boolean;
|
98 | login(providerId: string, scopes: string[]): Promise<AuthenticationSession>;
|
99 | logout(providerId: string, sessionId: string): Promise<void>;
|
100 | signOutOfAccount(providerId: string, accountName: string): Promise<void>;
|
101 | }
|
102 | export interface SessionChangeEvent {
|
103 | providerId: string;
|
104 | label: string;
|
105 | event: AuthenticationProviderAuthenticationSessionsChangeEvent;
|
106 | }
|
107 | export declare class AuthenticationServiceImpl implements AuthenticationService {
|
108 | private noAccountsMenuItem;
|
109 | private noAccountsCommand;
|
110 | private signInRequestItems;
|
111 | private sessionMap;
|
112 | protected authenticationProviders: Map<string, AuthenticationProvider>;
|
113 | private onDidRegisterAuthenticationProviderEmitter;
|
114 | readonly onDidRegisterAuthenticationProvider: Event<AuthenticationProviderInformation>;
|
115 | private onDidUnregisterAuthenticationProviderEmitter;
|
116 | readonly onDidUnregisterAuthenticationProvider: Event<AuthenticationProviderInformation>;
|
117 | private onDidChangeSessionsEmitter;
|
118 | readonly onDidChangeSessions: Event<SessionChangeEvent>;
|
119 | protected readonly menus: MenuModelRegistry;
|
120 | protected readonly commands: CommandRegistry;
|
121 | protected readonly storageService: StorageService;
|
122 | init(): void;
|
123 | protected handleSessionChange(changeEvent: SessionChangeEvent): Promise<void>;
|
124 | protected createAccountUi(providerId: string, providerLabel: string, session: AuthenticationSession): DisposableCollection;
|
125 | getProviderIds(): string[];
|
126 | isAuthenticationProviderRegistered(id: string): boolean;
|
127 | private updateAccountsMenuItem;
|
128 | registerAuthenticationProvider(id: string, authenticationProvider: AuthenticationProvider): void;
|
129 | unregisterAuthenticationProvider(id: string): void;
|
130 | updateSessions(id: string, event: AuthenticationProviderAuthenticationSessionsChangeEvent): Promise<void>;
|
131 | private updateNewSessionRequests;
|
132 | requestNewSession(providerId: string, scopes: string[], extensionId: string, extensionName: string): Promise<void>;
|
133 | getLabel(id: string): string;
|
134 | supportsMultipleAccounts(id: string): boolean;
|
135 | getSessions(id: string, scopes?: string[]): Promise<ReadonlyArray<AuthenticationSession>>;
|
136 | login(id: string, scopes: string[]): Promise<AuthenticationSession>;
|
137 | logout(id: string, sessionId: string): Promise<void>;
|
138 | signOutOfAccount(id: string, accountName: string): Promise<void>;
|
139 | }
|
140 | export interface AllowedExtension {
|
141 | id: string;
|
142 | name: string;
|
143 | }
|
144 | export declare function readAllowedExtensions(storageService: StorageService, providerId: string, accountName: string): Promise<AllowedExtension[]>;
|
145 |
|
\ | No newline at end of file |