"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExtHostSecret = exports.ExtensionSecrets = void 0;
const ide_core_common_1 = require("@opensumi/ide-core-common");
const vscode_1 = require("../../../common/vscode");
class ExtensionSecrets {
    constructor(extensionDescription, secret) {
        this._onDidChange = new ide_core_common_1.Emitter();
        this.onDidChange = this._onDidChange.event;
        this._id = vscode_1.ExtensionIdentifier.toKey(extensionDescription.id);
        this._secret = secret;
        this._secret.onDidChangePassword((e) => {
            if (e.extensionId === this._id) {
                this._onDidChange.fire({ key: e.key });
            }
        });
    }
    get(key) {
        return this._secret.get(this._id, key);
    }
    store(key, value) {
        return this._secret.store(this._id, key, value);
    }
    delete(key) {
        return this._secret.delete(this._id, key);
    }
}
exports.ExtensionSecrets = ExtensionSecrets;
class ExtHostSecret {
    constructor(rpc) {
        this._onDidChangePassword = new ide_core_common_1.Emitter();
        this.onDidChangePassword = this._onDidChangePassword.event;
        this._proxy = rpc.getProxy(vscode_1.MainThreadAPIIdentifier.MainThreadSecret);
    }
    async $onDidChangePassword(e) {
        this._onDidChangePassword.fire(e);
    }
    get(extensionId, key) {
        return this._proxy.$getPassword(extensionId, key);
    }
    store(extensionId, key, value) {
        return this._proxy.$setPassword(extensionId, key, value);
    }
    delete(extensionId, key) {
        return this._proxy.$deletePassword(extensionId, key);
    }
}
exports.ExtHostSecret = ExtHostSecret;
//# sourceMappingURL=ext.host.secrets.js.map