Skip to content

Commit 609e636

Browse files
Also check for secret storage provider before using old API (microsoft#187105)
This allows a nice migration path for web environments: 1. Embedder implements a secret storage provider in addition to the credentials provider they already have 2. Wait a release or 2 3. Remove the credentials provider from the embedder Once all known embedders do number 1, we can delete the `_oldMainThreadSecretState` entirely.
1 parent c9073ad commit 609e636

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/vs/workbench/api/browser/mainThreadSecretState.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class OldMainThreadSecretState extends Disposable implements MainThreadSecretSta
110110
export class MainThreadSecretState extends Disposable implements MainThreadSecretStateShape {
111111
private readonly _proxy: ExtHostSecretStateShape;
112112

113+
// TODO: Remove this when all known embedders implement a secret storage provider
113114
private readonly _oldMainThreadSecretState: OldMainThreadSecretState | undefined;
114115

115116
private readonly _sequencer = new SequencerByKey<string>();
@@ -131,7 +132,11 @@ export class MainThreadSecretState extends Disposable implements MainThreadSecre
131132

132133
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostSecretState);
133134

134-
if (environmentService.options?.credentialsProvider) {
135+
// If the embedder doesn't implement a secret storage provider, then we need to use the old API
136+
// to ensure that secrets are still stored in a secure way. This is only temporary until all
137+
// embedders implement a secret storage provider.
138+
// TODO: Remove this when all known embedders implement a secret storage provider
139+
if (environmentService.options?.credentialsProvider && !environmentService.options?.secretStorageProvider) {
135140
this._oldMainThreadSecretState = this._register(new OldMainThreadSecretState(
136141
this._proxy,
137142
credentialsService,
@@ -158,7 +163,7 @@ export class MainThreadSecretState extends Disposable implements MainThreadSecre
158163
}
159164

160165
private async doGetPassword(extensionId: string, key: string): Promise<string | undefined> {
161-
// TODO: Remove this when we remove the old API
166+
// TODO: Remove this when all known embedders implement a secret storage provider
162167
if (this._oldMainThreadSecretState) {
163168
return await this._oldMainThreadSecretState.$getPassword(extensionId, key);
164169
}
@@ -184,7 +189,7 @@ export class MainThreadSecretState extends Disposable implements MainThreadSecre
184189
}
185190

186191
private async doSetPassword(extensionId: string, key: string, value: string): Promise<void> {
187-
// TODO: Remove this when we remove the old API
192+
// TODO: Remove this when all known embedders implement a secret storage provider
188193
if (this._oldMainThreadSecretState) {
189194
return await this._oldMainThreadSecretState.$setPassword(extensionId, key, value);
190195
}
@@ -200,7 +205,7 @@ export class MainThreadSecretState extends Disposable implements MainThreadSecre
200205
}
201206

202207
private async doDeletePassword(extensionId: string, key: string): Promise<void> {
203-
// TODO: Remove this when we remove the old API
208+
// TODO: Remove this when all known embedders implement a secret storage provider
204209
if (this._oldMainThreadSecretState) {
205210
return await this._oldMainThreadSecretState.$deletePassword(extensionId, key);
206211
}

0 commit comments

Comments
 (0)