@theia/core
Version:
Theia is a cloud & desktop IDE framework implemented in TypeScript.
83 lines • 3.72 kB
JavaScript
// *****************************************************************************
// Copyright (C) 2021 Red Hat, Inc. and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
import { __decorate, __param } from "tslib";
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// code copied and modified from https://github.com/microsoft/vscode/blob/1.55.2/src/vs/workbench/services/credentials/common/credentials.ts#L12
import { inject, injectable } from 'inversify';
import { Emitter } from '../common/event.js';
import { KeyStoreService } from '../common/key-store.js';
export const CredentialsService = Symbol('CredentialsService');
let CredentialsServiceImpl = class CredentialsServiceImpl {
constructor(keytarService) {
this.keytarService = keytarService;
this.onDidChangePasswordEmitter = new Emitter();
this.onDidChangePassword = this.onDidChangePasswordEmitter.event;
this.credentialsProvider = new KeytarCredentialsProvider(this.keytarService);
}
getPassword(service, account) {
return this.credentialsProvider.getPassword(service, account);
}
async setPassword(service, account, password) {
await this.credentialsProvider.setPassword(service, account, password);
this.onDidChangePasswordEmitter.fire({ service, account });
}
deletePassword(service, account) {
const didDelete = this.credentialsProvider.deletePassword(service, account);
this.onDidChangePasswordEmitter.fire({ service, account });
return didDelete;
}
findPassword(service) {
return this.credentialsProvider.findPassword(service);
}
findCredentials(service) {
return this.credentialsProvider.findCredentials(service);
}
async keys(service) {
return this.credentialsProvider.keys(service);
}
};
CredentialsServiceImpl = __decorate([
injectable(),
__param(0, inject(KeyStoreService))
], CredentialsServiceImpl);
export { CredentialsServiceImpl };
class KeytarCredentialsProvider {
constructor(keytarService) {
this.keytarService = keytarService;
}
deletePassword(service, account) {
return this.keytarService.deletePassword(service, account);
}
findCredentials(service) {
return this.keytarService.findCredentials(service);
}
findPassword(service) {
return this.keytarService.findPassword(service);
}
getPassword(service, account) {
return this.keytarService.getPassword(service, account);
}
setPassword(service, account, password) {
return this.keytarService.setPassword(service, account, password);
}
keys(service) {
return this.keytarService.keys(service);
}
}
//# sourceMappingURL=credentials-service.js.map