#136424 add to proposed api

This commit is contained in:
Sandeep Somavarapu 2021-11-15 09:52:06 +01:00
parent f76b133e69
commit 5243c4021a
No known key found for this signature in database
GPG key ID: 1FED25EC4646638B
4 changed files with 15 additions and 7 deletions

View file

@ -19,7 +19,7 @@ export interface ResolvedAuthority {
export interface ResolvedOptions {
readonly extensionHostEnv?: { [key: string]: string | null };
readonly isTrusted?: boolean;
readonly initializeUsingAccount?: { providerId: string, sessionId: string };
readonly authenticationSession?: { id: string, providerId: string };
}
export interface TunnelDescription {

View file

@ -698,7 +698,8 @@ export abstract class AbstractExtHostExtensionService extends Disposable impleme
};
const options: ResolvedOptions = {
extensionHostEnv: result.extensionHostEnv,
isTrusted: result.isTrusted
isTrusted: result.isTrusted,
authenticationSession: result.authenticationSession ? { id: result.authenticationSession.id, providerId: result.authenticationSession.providerId } : undefined
};
return {

View file

@ -67,20 +67,20 @@ export class RemoteExtensionsInitializerContribution implements IWorkbenchContri
}
// Skip: No account is provided to initialize
const resolvedAuthority = await this.remoteAuthorityResolverService.resolveAuthority(connection.remoteAuthority);
if (!resolvedAuthority.options?.initializeUsingAccount) {
if (!resolvedAuthority.options?.authenticationSession) {
return;
}
const sessions = await this.authenticationService.getSessions(resolvedAuthority.options?.initializeUsingAccount.providerId);
const session = sessions.find(s => s.id === resolvedAuthority.options?.initializeUsingAccount?.sessionId);
const sessions = await this.authenticationService.getSessions(resolvedAuthority.options?.authenticationSession.providerId);
const session = sessions.find(s => s.id === resolvedAuthority.options?.authenticationSession?.id);
// Skip: Session is not found
if (!session) {
this.logService.info('Skipping initializing remote extensions because the account with given session id is not found', resolvedAuthority.options.initializeUsingAccount.sessionId);
this.logService.info('Skipping initializing remote extensions because the account with given session id is not found', resolvedAuthority.options.authenticationSession.id);
return;
}
const userDataSyncStoreClient = this.instantiationService.createInstance(UserDataSyncStoreClient, this.userDataSyncStoreManagementService.userDataSyncStore.url);
userDataSyncStoreClient.setAuthToken(session.accessToken, resolvedAuthority.options.initializeUsingAccount.providerId);
userDataSyncStoreClient.setAuthToken(session.accessToken, resolvedAuthority.options.authenticationSession.providerId);
const userData = await userDataSyncStoreClient.read(SyncResource.Extensions, null);
const serviceCollection = new ServiceCollection();

View file

@ -30,6 +30,13 @@ declare module 'vscode' {
extensionHostEnv?: { [key: string]: string | null; };
isTrusted?: boolean;
/**
* When provided, remote server will be initialized with the data synced using given user account.
* **Note:** Initialization happens only when VSCode is opened in Desktop and only extensions are initialized as of now.
*/
// authenticationSession(ForInitialization|ForInitializingExtensions)?
authenticationSession?: AuthenticationSession & { providerId: string };
}
export interface TunnelPrivacy {