"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyPairIdentity = void 0;
const utils_1 = require("@streamr/utils");
const Identity_1 = require("./Identity");
/**
 * KeyPairIdentity is an Identity that is defined by a public key and a private key.
 * It uses the public key as the UserID.
 */
class KeyPairIdentity extends Identity_1.Identity {
    publicKeyString;
    publicKey;
    privateKey;
    constructor(publicKey, privateKey) {
        super();
        this.publicKey = publicKey;
        this.privateKey = privateKey;
        this.publicKeyString = (0, utils_1.toUserId)(this.publicKey);
        this.assertValidKeyPair();
    }
    async getUserIdRaw() {
        return this.publicKey;
    }
    async getUserId() {
        return this.publicKeyString;
    }
    async getPrivateKey() {
        return this.privateKey;
    }
    // eslint-disable-next-line class-methods-use-this
    async getTransactionSigner(_rpcProviderSource) {
        throw new Error('This key pair can not sign transactions!');
    }
    /** @internal */
    static getKeyPairFromConfig(config) {
        const result = config.auth;
        if (!result.privateKey) {
            throw new Error('A privateKey was expected in the config, but none is defined!');
        }
        return result;
    }
}
exports.KeyPairIdentity = KeyPairIdentity;
//# sourceMappingURL=KeyPairIdentity.js.map