Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Also check for secret storage provider before using old API #187105

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/vs/workbench/api/browser/mainThreadSecretState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class OldMainThreadSecretState extends Disposable implements MainThreadSecretSta
export class MainThreadSecretState extends Disposable implements MainThreadSecretStateShape {
private readonly _proxy: ExtHostSecretStateShape;

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

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

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

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

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

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

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