|
5 | 5 |
|
6 | 6 | import { SequencerByKey } from 'vs/base/common/async';
|
7 | 7 | import { IEncryptionService } from 'vs/platform/encryption/common/encryptionService';
|
8 |
| -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; |
| 8 | +import { IInstantiationService, createDecorator } from 'vs/platform/instantiation/common/instantiation'; |
9 | 9 | import { IStorageService, InMemoryStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
|
10 | 10 | import { Event, PauseableEmitter } from 'vs/base/common/event';
|
11 | 11 | import { ILogService } from 'vs/platform/log/common/log';
|
| 12 | +import { isNative } from 'vs/base/common/platform'; |
| 13 | +import { INotificationService, Severity } from 'vs/platform/notification/common/notification'; |
| 14 | +import { localize } from 'vs/nls'; |
| 15 | +import { IOpenerService } from 'vs/platform/opener/common/opener'; |
| 16 | +import { once } from 'vs/base/common/functional'; |
12 | 17 |
|
13 | 18 | export const ISecretStorageService = createDecorator<ISecretStorageService>('secretStorageService');
|
14 | 19 |
|
@@ -40,7 +45,9 @@ export class SecretStorageService implements ISecretStorageService {
|
40 | 45 | constructor(
|
41 | 46 | @IStorageService private _storageService: IStorageService,
|
42 | 47 | @IEncryptionService private _encryptionService: IEncryptionService,
|
43 |
| - @ILogService private readonly _logService: ILogService, |
| 48 | + @IInstantiationService private readonly _instantiationService: IInstantiationService, |
| 49 | + @INotificationService private readonly _notificationService: INotificationService, |
| 50 | + @ILogService private readonly _logService: ILogService |
44 | 51 | ) {
|
45 | 52 | this._storageService.onDidChangeValue(e => this.onDidChangeValue(e.key));
|
46 | 53 | }
|
@@ -89,6 +96,10 @@ export class SecretStorageService implements ISecretStorageService {
|
89 | 96 | return this._sequencer.queue(key, async () => {
|
90 | 97 | await this.initialized;
|
91 | 98 |
|
| 99 | + if (isNative && this.type !== 'persisted') { |
| 100 | + this.notifyNativeUserOnce(); |
| 101 | + } |
| 102 | + |
92 | 103 | const encrypted = await this._encryptionService.encrypt(value);
|
93 | 104 | const fullKey = this.getKey(key);
|
94 | 105 | try {
|
@@ -129,4 +140,20 @@ export class SecretStorageService implements ISecretStorageService {
|
129 | 140 | private getKey(key: string): string {
|
130 | 141 | return `${this._storagePrefix}${key}`;
|
131 | 142 | }
|
| 143 | + |
| 144 | + private notifyNativeUserOnce = once(() => this.notifyNativeUser()); |
| 145 | + private notifyNativeUser(): void { |
| 146 | + this._notificationService.prompt( |
| 147 | + Severity.Warning, |
| 148 | + localize('notEncrypted', 'Secrets are not being stored on disk because encryption is not available in this environment.'), |
| 149 | + [{ |
| 150 | + label: localize('openTroubleshooting', "Open Troubleshooting"), |
| 151 | + run: () => this._instantiationService.invokeFunction(accessor => { |
| 152 | + const openerService = accessor.get(IOpenerService); |
| 153 | + // Open troubleshooting docs page |
| 154 | + return openerService.open('https://go.microsoft.com/fwlink/?linkid=2239490'); |
| 155 | + }) |
| 156 | + }] |
| 157 | + ); |
| 158 | + } |
132 | 159 | }
|
0 commit comments