@@ -56,8 +56,8 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
5656 return ! ! ( sessions . filter ( session => session . scopes . sort ( ) . join ( ' ' ) === orderedScopes ) . length ) ;
5757 }
5858
59- async getSession ( requestingExtension : IExtensionDescription , providerId : string , scopes : string [ ] , options : vscode . AuthenticationGetSessionOptions & { createIfNone : true } ) : Promise < vscode . AuthenticationSession2 > ;
60- async getSession ( requestingExtension : IExtensionDescription , providerId : string , scopes : string [ ] , options : vscode . AuthenticationGetSessionOptions ) : Promise < vscode . AuthenticationSession2 | undefined > {
59+ async getSession ( requestingExtension : IExtensionDescription , providerId : string , scopes : string [ ] , options : vscode . AuthenticationGetSessionOptions & { createIfNone : true } ) : Promise < vscode . AuthenticationSession > ;
60+ async getSession ( requestingExtension : IExtensionDescription , providerId : string , scopes : string [ ] , options : vscode . AuthenticationGetSessionOptions ) : Promise < vscode . AuthenticationSession | undefined > {
6161 const provider = this . _authenticationProviders . get ( providerId ) ;
6262 const extensionName = requestingExtension . displayName || requestingExtension . name ;
6363 const extensionId = ExtensionIdentifier . toKey ( requestingExtension . identifier ) ;
@@ -100,71 +100,6 @@ export class ExtHostAuthentication implements ExtHostAuthenticationShape {
100100 }
101101 }
102102
103- async getSessions ( requestingExtension : IExtensionDescription , providerId : string , scopes : string [ ] ) : Promise < readonly vscode . AuthenticationSession [ ] > {
104- const extensionId = ExtensionIdentifier . toKey ( requestingExtension . identifier ) ;
105- const orderedScopes = scopes . sort ( ) . join ( ' ' ) ;
106- const sessions = await this . resolveSessions ( providerId ) ;
107- return sessions
108- . filter ( session => session . scopes . sort ( ) . join ( ' ' ) === orderedScopes )
109- . map ( session => {
110- return {
111- id : session . id ,
112- account : session . account ,
113- scopes : session . scopes ,
114- getAccessToken : async ( ) => {
115- const isAllowed = await this . _proxy . $getSessionsPrompt (
116- providerId ,
117- session . account . displayName ,
118- '' , // TODO
119- // provider.displayName,
120- extensionId ,
121- requestingExtension . displayName || requestingExtension . name ) ;
122-
123- if ( ! isAllowed ) {
124- throw new Error ( 'User did not consent to token access.' ) ;
125- }
126-
127- return session . accessToken ;
128- }
129- } ;
130- } ) ;
131- }
132-
133- async login ( requestingExtension : IExtensionDescription , providerId : string , scopes : string [ ] ) : Promise < vscode . AuthenticationSession > {
134- const provider = this . _authenticationProviders . get ( providerId ) ;
135- if ( ! provider ) {
136- throw new Error ( `No authentication provider with id '${ providerId } ' is currently registered.` ) ;
137- }
138-
139- const extensionName = requestingExtension . displayName || requestingExtension . name ;
140- const isAllowed = await this . _proxy . $loginPrompt ( provider . displayName , extensionName ) ;
141- if ( ! isAllowed ) {
142- throw new Error ( 'User did not consent to login.' ) ;
143- }
144-
145- const session = await provider . login ( scopes ) ;
146- await this . _proxy . $setTrustedExtension ( provider . id , session . account . displayName , ExtensionIdentifier . toKey ( requestingExtension . identifier ) , extensionName ) ;
147- return {
148- id : session . id ,
149- account : session . account ,
150- scopes : session . scopes ,
151- getAccessToken : async ( ) => {
152- const isAllowed = await this . _proxy . $getSessionsPrompt (
153- provider . id ,
154- session . account . displayName ,
155- provider . displayName ,
156- ExtensionIdentifier . toKey ( requestingExtension . identifier ) ,
157- requestingExtension . displayName || requestingExtension . name ) ;
158-
159- if ( ! isAllowed ) {
160- throw new Error ( 'User did not consent to token access.' ) ;
161- }
162-
163- return session . accessToken ;
164- }
165- } ;
166- }
167-
168103 async logout ( providerId : string , sessionId : string ) : Promise < void > {
169104 const provider = this . _authenticationProviders . get ( providerId ) ;
170105 if ( ! provider ) {
0 commit comments