"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/**
 * External dependencies
 */
const Configstore = require('configstore');
/**
 * Internal dependencies
 */


class Insecure {
  constructor(file) {
    this.file = file;
    this.configstore = new Configstore(this.file);
  }

  getPassword(service) {
    return new Promise((resolve, reject) => {
      let password = null;

      try {
        password = this.configstore.get(service);
      } catch (e) {
        return reject(e);
      }

      return resolve(password);
    });
  }

  setPassword(service, password) {
    return new Promise((resolve, reject) => {
      try {
        this.configstore.set(service, password);
      } catch (e) {
        return reject(e);
      }

      resolve(true);
    });
  }

  deletePassword(service) {
    return new Promise((resolve, reject) => {
      try {
        this.configstore.delete(service);
      } catch (e) {
        return reject(e);
      }

      resolve(true);
    });
  }

}

exports.default = Insecure;