text: "use strict";
  Object.defineProperty(exports, "__esModule", { value: true });
  var tslib_1 = require("tslib");
  var typescript_map_1 = require("typescript-map");
  var RadixSimpleIdentity_1 = tslib_1.__importDefault(require("./RadixSimpleIdentity"));
  var RadixRemoteIdentity_1 = tslib_1.__importDefault(require("./RadixRemoteIdentity"));
  var atommodel_1 = require("../atommodel");
  var RadixUtil_1 = require("../common/RadixUtil");
  var RadixIdentityManager = /** @class */ (function () {
      function RadixIdentityManager() {
          this.identities = new typescript_map_1.TSMap();
      }
      /**
       * Generates a new random RadixSimpleIdentity
       *
       * @returns An instance of a RadixSimpleIdentity
       */
      RadixIdentityManager.prototype.generateSimpleIdentity = function () {
          var address = atommodel_1.RadixAddress.generateNew();
          var identity = new RadixSimpleIdentity_1.default(address);
          this.identities.set(address.getAddress(), identity);
          return identity;
      };
      /**
       * Generates a new RadixSimpleIdentity from an arbitrary byte buffer.
       *
       * @param seed Buffer seed for the address of the identity
       * @returns An instance of a RadixSimpleIdentity
       */
      RadixIdentityManager.prototype.generateSimpleIdentityFromSeed = function (seed) {
          var hash = RadixUtil_1.radixHash(seed);
          var address = atommodel_1.RadixAddress.fromPrivate(hash);
          var identity = new RadixSimpleIdentity_1.default(address);
          this.identities.set(address.getAddress(), identity);
          return identity;
      };
      /**
       * Adds a new RadixSimpleIdentity
       *
       * @param address - The key pair of the identity(must have a private key)
       * @returns An instance of a RadixSimpleIdentity
       */
      RadixIdentityManager.prototype.addSimpleIdentity = function (address) {
          var identity = new RadixSimpleIdentity_1.default(address);
          this.identities.set(address.getAddress(), identity);
          return identity;
      };
      /**
       * Generates a new RadixRemoteIdentity
       *
       * @param name - The name of the application that wants to use the remote identity
       * @param description - The description of the application that wants to use the remote identity
       * @param [host] - The host of the wallet
       * @param [port] - The port in which the wallet server is being exposed
       * @returns A promise with an instance of a RadixRemoteIdentity
       */
      RadixIdentityManager.prototype.generateRemoteIdentity = function (name, description, permissions, host, port) {
          return tslib_1.__awaiter(this, void 0, void 0, function () {
              var error_1;
              return tslib_1.__generator(this, function (_a) {
                  switch (_a.label) {
                      case 0:
                          _a.trys.push([0, 2, , 3]);
                          return [4 /*yield*/, RadixRemoteIdentity_1.default.createNew(name, description, permissions, host, port)];
                      case 1: return [2 /*return*/, _a.sent()];
                      case 2:
                          error_1 = _a.sent();
                          throw error_1;
                      case 3: return [2 /*return*/];
                  }
              });
          });
      };
      /**
       * Adds a new RadixIdentity to the set of available identities
       *
       * @returns A RadixIdentity
       */
      RadixIdentityManager.prototype.addIdentity = function (identity) {
          this.identities.set(identity.account.getAddress(), identity);
          return identity;
      };
      return RadixIdentityManager;
  }());
  exports.default = RadixIdentityManager;
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiUmFkaXhJZGVudGl0eU1hbmFnZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvbW9kdWxlcy9pZGVudGl0eS9SYWRpeElkZW50aXR5TWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxpREFBc0M7QUFHdEMsc0ZBQXVEO0FBQ3ZELHNGQUF1RDtBQUN2RCwwQ0FBNEM7QUFDNUMsaURBQWdEO0FBRWhEO0lBQUE7UUFDVyxlQUFVLEdBQWlDLElBQUksc0JBQUssRUFBRSxDQUFBO0lBOEVqRSxDQUFDO0lBNUVHOzs7O09BSUc7SUFDSSxxREFBc0IsR0FBN0I7UUFDSSxJQUFNLE9BQU8sR0FBRyx3QkFBWSxDQUFDLFdBQVcsRUFBRSxDQUFBO1FBQzFDLElBQU0sUUFBUSxHQUFHLElBQUksNkJBQW1CLENBQUMsT0FBTyxDQUFDLENBQUE7UUFFakQsSUFBSSxDQUFDLFVBQVUsQ0FBQyxHQUFHLENBQUMsT0FBTyxDQUFDLFVBQVUsRUFBRSxFQUFFLFFBQVEsQ0FBQyxDQUFBO1FBRW5ELE9BQU8sUUFBUSxDQUFBO0lBQ25CL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