"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KeyPairIdentity = void 0;
const utils_1 = require("@streamr/utils");
const Identity_1 = require("./Identity");
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);
        if (this.publicKey.length !== this.getExpectedPublicKeyLength()) {
            throw new Error(`Unexpected publicKey length! Expected ${this.getExpectedPublicKeyLength()} bytes, got ${this.publicKey.length} bytes.`);
        }
        if (this.privateKey.length !== this.getExpectedPrivateKeyLength()) {
            throw new Error(`Unexpected privateKey length! Expected ${this.getExpectedPrivateKeyLength()} bytes, got ${this.privateKey.length} bytes.`);
        }
        this.assertKeyPairIsValid();
    }
    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!');
    }
    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