Skip to content

Commit 1e0b12d

Browse files
Remove vscode-encrypt from node.js side (microsoft#189252)
* Remove vscode-encrypt from node.js side Now that we've had a version of the product that has done the migration logic, we no longer need vscode-encrypt on the node side. This removes all references of vscode-encrypt from the node side. I will also remove it from the package.jsons in distro. * remove machineId
1 parent 9096930 commit 1e0b12d

File tree

5 files changed

+4
-116
lines changed

5 files changed

+4
-116
lines changed

build/.moduleignore

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,6 @@ vsda/SECURITY.md
114114
vsda/targets
115115
!vsda/build/Release/vsda.node
116116

117-
vscode-encrypt/build/**
118-
vscode-encrypt/src/**
119-
vscode-encrypt/vendor/**
120-
vscode-encrypt/.gitignore
121-
vscode-encrypt/binding.gyp
122-
vscode-encrypt/README.md
123-
!vscode-encrypt/build/Release/vscode-encrypt-native.node
124-
125117
@vscode/policy-watcher/build/**
126118
@vscode/policy-watcher/.husky/**
127119
@vscode/policy-watcher/src/**

src/vs/code/electron-main/app.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ export class CodeApplication extends Disposable {
934934
services.set(IIssueMainService, new SyncDescriptor(IssueMainService, [this.userEnv]));
935935

936936
// Encryption
937-
services.set(IEncryptionMainService, new SyncDescriptor(EncryptionMainService, [machineId]));
937+
services.set(IEncryptionMainService, new SyncDescriptor(EncryptionMainService));
938938

939939
// Keyboard Layout
940940
services.set(IKeyboardLayoutMainService, new SyncDescriptor(KeyboardLayoutMainService));

src/vs/platform/encryption/electron-main/encryptionMainService.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export class EncryptionMainService implements IEncryptionMainService {
2121
_serviceBrand: undefined;
2222

2323
constructor(
24-
private readonly machineId: string,
2524
@ILogService private readonly logService: ILogService
2625
) {
2726
// if this commandLine switch is set, the user has opted in to using basic text encryption
@@ -47,17 +46,11 @@ export class EncryptionMainService implements IEncryptionMainService {
4746
try {
4847
parsedValue = JSON.parse(value);
4948
if (!parsedValue.data) {
50-
this.logService.trace('[EncryptionMainService] Unable to parse encrypted value. Attempting old decryption.');
51-
return this.oldDecrypt(value);
49+
throw new Error(`[EncryptionMainService] Invalid encrypted valu: ${value}`);
5250
}
53-
} catch (e) {
54-
this.logService.trace('[EncryptionMainService] Unable to parse encrypted value. Attempting old decryption.', e);
55-
return this.oldDecrypt(value);
56-
}
57-
const bufferToDecrypt = Buffer.from(parsedValue.data);
51+
const bufferToDecrypt = Buffer.from(parsedValue.data);
5852

59-
this.logService.trace('[EncryptionMainService] Decrypting value.');
60-
try {
53+
this.logService.trace('[EncryptionMainService] Decrypting value.');
6154
const result = safeStorage.decryptString(bufferToDecrypt);
6255
this.logService.trace('[EncryptionMainService] Decrypted value.');
6356
return result;
@@ -104,21 +97,4 @@ export class EncryptionMainService implements IEncryptionMainService {
10497

10598
safeStorage.setUsePlainTextEncryption(true);
10699
}
107-
108-
// TODO: Remove this after a few releases
109-
private async oldDecrypt(value: string): Promise<string> {
110-
let encryption: { decrypt(salt: string, value: string): Promise<string> };
111-
try {
112-
encryption = await new Promise((resolve, reject) => require(['vscode-encrypt'], resolve, reject));
113-
} catch (e) {
114-
return value;
115-
}
116-
117-
try {
118-
return encryption.decrypt(this.machineId, value);
119-
} catch (e) {
120-
this.logService.error(e);
121-
return value;
122-
}
123-
}
124100
}

src/vs/platform/encryption/node/encryptionMainService.ts

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/vs/platform/environment/test/node/nativeModules.integrationTest.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import * as assert from 'assert';
77
import { isLinux, isWindows } from 'vs/base/common/platform';
88
import { flakySuite } from 'vs/base/test/common/testUtils';
9-
import { Encryption } from 'vs/platform/encryption/node/encryptionMainService';
109

1110
function testErrorMessage(module: string): string {
1211
return `Unable to load "${module}" dependency. It was probably not compiled for the right operating system architecture or had missing build tools.`;
@@ -61,21 +60,6 @@ flakySuite('Native Modules (all platforms)', () => {
6160
assert.ok(typeof sqlite3.Database === 'function', testErrorMessage('@vscode/sqlite3'));
6261
});
6362

64-
test('vscode-encrypt', async () => {
65-
try {
66-
const vscodeEncrypt: Encryption = globalThis._VSCODE_NODE_MODULES['vscode-encrypt'];
67-
const encrypted = await vscodeEncrypt.encrypt('salt', 'value');
68-
const decrypted = await vscodeEncrypt.decrypt('salt', encrypted);
69-
70-
assert.ok(typeof encrypted === 'string', testErrorMessage('vscode-encrypt'));
71-
assert.ok(typeof decrypted === 'string', testErrorMessage('vscode-encrypt'));
72-
} catch (error) {
73-
if (error.code !== 'MODULE_NOT_FOUND') {
74-
throw error;
75-
}
76-
}
77-
});
78-
7963
test('vsda', async () => {
8064
try {
8165
const vsda: any = globalThis._VSCODE_NODE_MODULES['vsda'];

0 commit comments

Comments
 (0)