From c738bbd8a7abc17a82bcf4056c5adaff171011fa Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Thu, 31 Aug 2017 20:27:07 -0700 Subject: [PATCH] Revert "Remove proposed credentials API (#31131)" This reverts commit abea60daf8257659acbdd890f132bbd215369099. --- src/vs/vscode.proposed.d.ts | 34 +++++++++++++++++++ src/vs/workbench/api/node/extHost.api.impl.ts | 7 ++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index ea4fd5b1e492a..ab3d567b7e826 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -70,6 +70,40 @@ declare module 'vscode' { export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable; } + /** + * Namespace for handling credentials. + */ + export namespace credentials { + + /** + * Read a previously stored secret from the credential store. + * + * @param service The service of the credential. + * @param account The account of the credential. + * @return A promise for the secret of the credential. + */ + export function readSecret(service: string, account: string): Thenable; + + /** + * Write a secret to the credential store. + * + * @param service The service of the credential. + * @param account The account of the credential. + * @param secret The secret of the credential to write to the credential store. + * @return A promise indicating completion of the operation. + */ + export function writeSecret(service: string, account: string, secret: string): Thenable; + + /** + * Delete a previously stored secret from the credential store. + * + * @param service The service of the credential. + * @param account The account of the credential. + * @return A promise resolving to true if there was a secret for that service and account. + */ + export function deleteSecret(service: string, account: string): Thenable; + } + /** * Represents a color in RGBA space. */ diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 0ad36fa49eb5d..cb2ee9b893bc1 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -520,7 +520,7 @@ export function createApiFactory( }; // namespace: credentials - const credentials = { + const credentials: typeof vscode.credentials = { readSecret(service: string, account: string): Thenable { return extHostCredentials.readSecret(service, account); }, @@ -544,6 +544,7 @@ export function createApiFactory( workspace, scm, debug, + credentials, // types CancellationTokenSource: CancellationTokenSource, CodeLens: extHostTypes.CodeLens, @@ -598,8 +599,8 @@ export function createApiFactory( Task: extHostTypes.Task, ConfigurationTarget: extHostTypes.ConfigurationTarget }; - if (extension.enableProposedApi && extension.isBuiltin) { - api['credentials'] = credentials; + if (!extension.enableProposedApi) { + delete api.credentials; // Instead of error to avoid #31854 } return api; };