"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Identities = void 0;
const internal_1 = require("./internal");
const internal_2 = require("./utils/internal");
/**
 * Handles all Identity related functionality
 */
class Identities {
    /**
     * @hidden
     */
    constructor(context) {
        this.context = context;
        this.registerIdentity = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.registerIdentity, args] }, context);
        this.createPortfolio = (0, internal_2.createProcedureMethod)({ getProcedureAndArgs: args => [internal_1.createPortfolio, args] }, context);
    }
    /**
     * Create an Identity instance from a DID
     *
     * @throws if there is no Identity with the passed DID
     */
    getIdentity(args) {
        return __awaiter(this, void 0, void 0, function* () {
            return this.context.getIdentity(args.did);
        });
    }
    /**
     * Return whether the supplied Identity/DID exists
     */
    isIdentityValid(args) {
        return __awaiter(this, void 0, void 0, function* () {
            const { identity: did } = args;
            const identity = did instanceof internal_1.Identity ? did : new internal_1.Identity({ did }, this.context);
            return identity.exists();
        });
    }
}
exports.Identities = Identities;
//# sourceMappingURL=Identities.js.map