text: "use strict";
  /*
   * Copyright (c) 2018, salesforce.com, inc.
   * All rights reserved.
   * SPDX-License-Identifier: BSD-3-Clause
   * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
   */
  Object.defineProperty(exports, "__esModule", { value: true });
  const path_1 = require("path");
  const fs_1 = require("../util/fs");
  const configFile_1 = require("./configFile");
  /**
   * Represent a key chain config backed by a json file.
   */
  // istanbul ignore next - getPassword/setPassword is always mocked out
  class KeychainConfig extends configFile_1.ConfigFile {
      static getFileName() {
          return 'key.json';
      }
      /**
       * Gets default options for the KeychainConfig
       */
      static getDefaultOptions() {
          return configFile_1.ConfigFile.getDefaultOptions(true, KeychainConfig.getFileName());
      }
      /**
       * Write the config file with new contents. If no new contents are passed in
       * it will write this.contents that was set from read(). Returns the written contents.
       *
       * @param newContents the new contents of the file
       */
      async write(newContents) {
          if (newContents != null) {
              this.setContents(newContents);
          }
          await fs_1.fs.mkdirp(path_1.dirname(this.getPath()));
          await fs_1.fs.writeFile(this.getPath(), JSON.stringify(this.getContents(), null, 4), { mode: '600' });
          return this.getContents();
      }
  }
  exports.KeychainConfig = KeychainConfig;
  //# sourceMappingURL=keychainConfig.js.map