Finalize secrets API, closes #112249

This commit is contained in:
Rachel Macfarlane
2021-01-20 09:43:39 -08:00
parent 699b02d3ae
commit d3965a2b4d
2 changed files with 48 additions and 51 deletions
+47
View File
@@ -5821,6 +5821,11 @@ declare module 'vscode' {
setKeysForSync(keys: string[]): void;
};
/**
* A storage utility for secrets.
*/
readonly secrets: SecretStorage;
/**
* The uri of the directory containing the extension.
*/
@@ -5958,6 +5963,48 @@ declare module 'vscode' {
update(key: string, value: any): Thenable<void>;
}
/**
* The event data that is fired when a secret is added or removed.
*/
export interface SecretStorageChangeEvent {
/**
* The key of the secret that has changed.
*/
readonly key: string;
}
/**
* Represents a storage utility for secrets, information that is
* sensitive.
*/
export interface SecretStorage {
/**
* Retrieve a secret that was stored with key. Returns undefined if there
* is no password matching that key.
* @param key The key the secret was stored under.
* @returns The stored value or `undefined`.
*/
get(key: string): Thenable<string | undefined>;
/**
* Store a secret under a given key.
* @param key The key to store the secret under.
* @param value The secret.
*/
store(key: string, value: string): Thenable<void>;
/**
* Remove a secret from storage.
* @param key The key the secret was stored under.
*/
delete(key: string): Thenable<void>;
/**
* Fires when a secret is stored or deleted.
*/
onDidChange: Event<SecretStorageChangeEvent>;
}
/**
* Represents a color theme kind.
*/
+1 -51
View File
@@ -2507,57 +2507,7 @@ declare module 'vscode' {
export function openExternal(target: Uri, options?: OpenExternalOptions): Thenable<boolean>;
}
//#endregion
//#region https://github.com/microsoft/vscode/issues/112249
/**
* The event data that is fired when a secret is added or removed.
*/
export interface SecretStorageChangeEvent {
/**
* The key of the secret that has changed.
*/
readonly key: string;
}
/**
* Represents a storage utility for secrets, information that is
* sensitive.
*/
export interface SecretStorage {
/**
* Retrieve a secret that was stored with key. Returns undefined if there
* is no password matching that key.
* @param key The key the password was stored under.
* @returns The stored value or `undefined`.
*/
get(key: string): Thenable<string | undefined>;
/**
* Store a secret under a given key.
* @param key The key to store the password under.
* @param value The password.
*/
store(key: string, value: string): Thenable<void>;
/**
* Remove a secret from storage.
* @param key The key the password was stored under.
*/
delete(key: string): Thenable<void>;
/**
* Fires when a secret is set or deleted.
*/
onDidChange: Event<SecretStorageChangeEvent>;
}
export interface ExtensionContext {
readonly secrets: SecretStorage;
}
//#endregion
//#endregionn
//#region https://github.com/Microsoft/vscode/issues/15178