Feedback on secrets API #112249

This commit is contained in:
Rachel Macfarlane 2021-01-20 09:24:13 -08:00
parent 64fa272029
commit 93ae815ba1
5 changed files with 8 additions and 8 deletions

View file

@ -34,7 +34,7 @@ export class Keychain {
constructor(private context: vscode.ExtensionContext) { } constructor(private context: vscode.ExtensionContext) { }
async setToken(token: string): Promise<void> { async setToken(token: string): Promise<void> {
try { try {
return await this.context.secrets.set(SERVICE_ID, token); return await this.context.secrets.store(SERVICE_ID, token);
} catch (e) { } catch (e) {
// Ignore // Ignore
Logger.error(`Setting token failed: ${e}`); Logger.error(`Setting token failed: ${e}`);

View file

@ -48,7 +48,7 @@ export class Keychain {
async setToken(token: string): Promise<void> { async setToken(token: string): Promise<void> {
try { try {
return await this.context.secrets.set(SERVICE_ID, token); return await this.context.secrets.store(SERVICE_ID, token);
} catch (e) { } catch (e) {
Logger.error(`Setting token failed: ${e}`); Logger.error(`Setting token failed: ${e}`);

View file

@ -2518,7 +2518,7 @@ declare module 'vscode' {
/** /**
* The key of the secret that has changed. * The key of the secret that has changed.
*/ */
key: string; readonly key: string;
} }
/** /**
@ -2539,7 +2539,7 @@ declare module 'vscode' {
* @param key The key to store the password under. * @param key The key to store the password under.
* @param value The password. * @param value The password.
*/ */
set(key: string, value: string): Thenable<void>; store(key: string, value: string): Thenable<void>;
/** /**
* Remove a secret from storage. * Remove a secret from storage.
@ -2554,7 +2554,7 @@ declare module 'vscode' {
} }
export interface ExtensionContext { export interface ExtensionContext {
secrets: SecretStorage; readonly secrets: SecretStorage;
} }
//#endregion //#endregion

View file

@ -25,7 +25,7 @@ export class ExtHostSecretState implements ExtHostSecretStateShape {
return this._proxy.$getPassword(extensionId, key); return this._proxy.$getPassword(extensionId, key);
} }
set(extensionId: string, key: string, value: string): Promise<void> { store(extensionId: string, key: string, value: string): Promise<void> {
return this._proxy.$setPassword(extensionId, key, value); return this._proxy.$setPassword(extensionId, key, value);
} }

View file

@ -33,8 +33,8 @@ export class ExtensionSecrets implements vscode.SecretStorage {
return this._secretState.get(this._id, key); return this._secretState.get(this._id, key);
} }
set(key: string, value: string): Promise<void> { store(key: string, value: string): Promise<void> {
return this._secretState.set(this._id, key, value); return this._secretState.store(this._id, key, value);
} }
delete(key: string): Promise<void> { delete(key: string): Promise<void> {