diff --git a/src/vs/platform/encryption/common/encryptionService.ts b/src/vs/platform/encryption/common/encryptionService.ts index 59d6b38501475..c00a32a663e77 100644 --- a/src/vs/platform/encryption/common/encryptionService.ts +++ b/src/vs/platform/encryption/common/encryptionService.ts @@ -25,6 +25,19 @@ export interface ICommonEncryptionService { isEncryptionAvailable(): Promise; } +// The values provided to the `password-store` command line switch. +// Notice that they are not the same as the values returned by +// `getSelectedStorageBackend` in the `safeStorage` API. +export const enum PasswordStoreCLIOption { + kwallet = 'kwallet', + kwallet5 = 'kwallet5', + gnome = 'gnome', + gnomeKeyring = 'gnome-keyring', + gnomeLibsecret = 'gnome-libsecret', + basic = 'basic' +} + +// The values returned by `getSelectedStorageBackend` in the `safeStorage` API. export const enum KnownStorageProvider { unknown = 'unknown', basicText = 'basic_text', @@ -37,6 +50,9 @@ export const enum KnownStorageProvider { kwallet5 = 'kwallet5', kwallet6 = 'kwallet6', + // The rest of these are not returned by `getSelectedStorageBackend` + // but these were added for platform completeness. + // Windows dplib = 'dpapi', diff --git a/src/vs/platform/encryption/electron-main/encryptionMainService.ts b/src/vs/platform/encryption/electron-main/encryptionMainService.ts index 0589dc473b943..215ef85d41f83 100644 --- a/src/vs/platform/encryption/electron-main/encryptionMainService.ts +++ b/src/vs/platform/encryption/electron-main/encryptionMainService.ts @@ -5,7 +5,7 @@ import { safeStorage as safeStorageElectron, app } from 'electron'; import { isMacintosh, isWindows } from 'vs/base/common/platform'; -import { KnownStorageProvider, IEncryptionMainService } from 'vs/platform/encryption/common/encryptionService'; +import { KnownStorageProvider, IEncryptionMainService, PasswordStoreCLIOption } from 'vs/platform/encryption/common/encryptionService'; import { ILogService } from 'vs/platform/log/common/log'; // These APIs are currently only supported in our custom build of electron so @@ -25,7 +25,7 @@ export class EncryptionMainService implements IEncryptionMainService { @ILogService private readonly logService: ILogService ) { // if this commandLine switch is set, the user has opted in to using basic text encryption - if (app.commandLine.getSwitchValue('password-store') === 'basic_text') { + if (app.commandLine.getSwitchValue('password-store') === PasswordStoreCLIOption.basic) { safeStorage.setUsePlainTextEncryption?.(true); } } diff --git a/src/vs/platform/environment/common/argv.ts b/src/vs/platform/environment/common/argv.ts index 2bbfd487d7546..17476d941872f 100644 --- a/src/vs/platform/environment/common/argv.ts +++ b/src/vs/platform/environment/common/argv.ts @@ -88,6 +88,7 @@ export interface NativeParsedArgs { 'install-source'?: string; 'disable-updates'?: boolean; 'disable-keytar'?: boolean; + 'password-store'?: string; 'disable-workspace-trust'?: boolean; 'disable-crash-reporter'?: boolean; 'crash-reporter-directory'?: string; diff --git a/src/vs/workbench/services/secrets/electron-sandbox/secretStorageService.ts b/src/vs/workbench/services/secrets/electron-sandbox/secretStorageService.ts index 44d57e2549302..d89abd9110dd2 100644 --- a/src/vs/workbench/services/secrets/electron-sandbox/secretStorageService.ts +++ b/src/vs/workbench/services/secrets/electron-sandbox/secretStorageService.ts @@ -8,7 +8,7 @@ import { isLinux } from 'vs/base/common/platform'; import Severity from 'vs/base/common/severity'; import { localize } from 'vs/nls'; import { IDialogService } from 'vs/platform/dialogs/common/dialogs'; -import { IEncryptionService, KnownStorageProvider, isGnome, isKwallet } from 'vs/platform/encryption/common/encryptionService'; +import { IEncryptionService, KnownStorageProvider, PasswordStoreCLIOption, isGnome, isKwallet } from 'vs/platform/encryption/common/encryptionService'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/common/extensions'; import { ILogService } from 'vs/platform/log/common/log'; @@ -72,7 +72,7 @@ export class NativeSecretStorageService extends BaseSecretStorageService { label: localize('usePlainText', "Use weaker encryption"), run: async () => { await this._encryptionService.setUsePlainTextEncryption(); - await this._jsonEditingService.write(this._environmentService.argvResource, [{ path: ['password-store'], value: 'basic_text' }], true); + await this._jsonEditingService.write(this._environmentService.argvResource, [{ path: ['password-store'], value: PasswordStoreCLIOption.basic }], true); this.reinitialize(); } };