Skip to content

Commit ca4ceeb

Browse files
committed
1 parent 733f9f8 commit ca4ceeb

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

src/vs/platform/userDataSync/common/userDataSyncStoreService.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,37 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
1313
import { IAuthenticationTokenService } from 'vs/platform/authentication/common/authentication';
1414
import { IProductService } from 'vs/platform/product/common/productService';
1515
import { URI } from 'vs/base/common/uri';
16+
import { getServiceMachineId } from 'vs/platform/serviceMachineId/common/serviceMachineId';
17+
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
18+
import { IFileService } from 'vs/platform/files/common/files';
19+
import { IStorageService } from 'vs/platform/storage/common/storage';
20+
import { assign } from 'vs/base/common/objects';
21+
1622

1723
export class UserDataSyncStoreService extends Disposable implements IUserDataSyncStoreService {
1824

1925
_serviceBrand: any;
2026

2127
readonly userDataSyncStore: IUserDataSyncStore | undefined;
28+
private readonly commonHeadersPromise: Promise<{ [key: string]: string; }>;
2229

2330
constructor(
2431
@IProductService productService: IProductService,
2532
@IConfigurationService configurationService: IConfigurationService,
2633
@IRequestService private readonly requestService: IRequestService,
2734
@IAuthenticationTokenService private readonly authTokenService: IAuthenticationTokenService,
2835
@IUserDataSyncLogService private readonly logService: IUserDataSyncLogService,
36+
@IEnvironmentService environmentService: IEnvironmentService,
37+
@IFileService fileService: IFileService,
38+
@IStorageService storageService: IStorageService,
2939
) {
3040
super();
3141
this.userDataSyncStore = getUserDataSyncStore(productService, configurationService);
42+
this.commonHeadersPromise = getServiceMachineId(environmentService, fileService, storageService)
43+
.then(uuid => ({
44+
'X-Sync-Client-Id': productService.version,
45+
'X-Sync-Machine-Id': uuid
46+
}));
3247
}
3348

3449
async getAllRefs(resource: SyncResource): Promise<IResourceRefHandle[]> {
@@ -174,8 +189,11 @@ export class UserDataSyncStoreService extends Disposable implements IUserDataSyn
174189
if (!authToken) {
175190
throw new UserDataSyncStoreError('No Auth Token Available', UserDataSyncErrorCode.Unauthorized, source);
176191
}
177-
options.headers = options.headers || {};
178-
options.headers['authorization'] = `Bearer ${authToken}`;
192+
193+
const commonHeaders = await this.commonHeadersPromise;
194+
options.headers = assign(options.headers || {}, commonHeaders, {
195+
'authorization': `Bearer ${authToken}`,
196+
});
179197

180198
this.logService.trace('Sending request to server', { url: options.url, type: options.type, headers: { ...options.headers, ...{ authorization: undefined } } });
181199

0 commit comments

Comments
 (0)