How to use the fabric-protos.msp function in fabric-protos

To help you get started, we’ve selected a few fabric-protos examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-sdk-node / test / unit / msp.js View on Github external
'use strict';

const tape = require('tape');
const _test = require('tape-promise').default;
const test = _test(tape);
const rewire = require('rewire');

const fs = require('fs-extra');
const path = require('path');
const utils = rewire('fabric-client/lib/utils.js');
const testutil = require('./util.js');
const MSP = require('fabric-client/lib/msp/msp.js');
const MSPM = require('fabric-client/lib/msp/msp-manager.js');
const {Identity} = require('fabric-common');

const mspProto = require('fabric-protos').msp;

const FABRIC = 0;
const TEST_CERT_PEM = require('./constants').TEST_CERT_PEM;

test('\n\n** MSP Tests **\n\n', async (t) => {
	testutil.resetDefaults();

	// construct MSP config objects for org0 and org1
	const configs = [];
	const mspm = new MSPM();

	let config = loadMSPConfig('peerOrg0', 'org0');
	t.pass('Successfully loaded msp config for org0');

	configs.push(config);
github hyperledger-labs / weaver-dlt-interoperability / sdks / fabric / interoperation-node-sdk / src / InteroperableHelper.ts View on Github external
const verifyDecryptedRemoteProposalResponse = async (proposalResponse) => {
    logger.debug("verifyDecryptedRemoteProposalResponse - start");
    if (!proposalResponse) {
        throw new Error("Missing proposal response");
    }
    if (proposalResponse instanceof Error) {
        return false;
    }
    if (!proposalResponse.endorsement) {
        throw new Error("Missing ProposalResponse endorsement");
    }

    const { endorsement } = proposalResponse;
    let identity;

    const sid = fabproto6.msp.SerializedIdentity.decode(endorsement.endorser);
    const { mspid } = sid;
    logger.debug("getMSPbyIdentity - found mspid %s", mspid);

    try {
        const idCryptoSuite = FabCommon.Utils.newCryptoSuite();
        idCryptoSuite.setCryptoKeyStore(FabCommon.Utils.newCryptoKeyStore());
        const idPubKey = await idCryptoSuite.importKey(sid.id_bytes.toString(), {
            // algorithm: FabCommon.CryptoAlgorithms.X509Certificate,
            ephemeral: true,
        });
        identity = new Identity(sid.id_bytes, idPubKey, sid.mspid, idCryptoSuite);
        if (!identity) {
            throw new Error("Unable to find the remote endorser identity");
        }
    } catch (error) {
        logger.error("verifyDecryptedRemoteProposalResponse - getting remote endorser identity failed with: ", error);
github hyperledger / fabric-sdk-node / fabric-client / lib / msp / Msp.js View on Github external
toProtobuf() {
		const proto_msp_config = new fabprotos.msp.MSPConfig();
		proto_msp_config.setType(0); // FABRIC
		const proto_fabric_msp_config = new fabprotos.msp.FabricMSPConfig();
		proto_fabric_msp_config.setName(this._id);
		proto_fabric_msp_config.setRootCerts(this._rootCerts);
		if (this._intermediateCerts) {
			proto_fabric_msp_config.setIntermediateCerts(this._intermediateCerts);
		}
		if (this._admins) {
			proto_fabric_msp_config.setAdmins(this._admins);
		}
		if (this._organization_units) {
			// organizational_unit_identifiers
			proto_fabric_msp_config.setOrganizationalUnitIdentifiers(this._organization_units);
		}
		if (this._tls_root_certs) {
			proto_fabric_msp_config.setTlsRootCerts(this._tls_root_certs);
		}
		if (this._tls_intermediate_certs) {
github hyperledger / fabric-sdk-node / fabric-client / lib / BlockDecoder.js View on Github external
function decodeKeyInfo(key_info_bytes) {
	const key_info = {};
	if (key_info_bytes) {
		const proto_key_info = fabprotos.msp.KeyInfo.decode(key_info_bytes);
		key_info.key_identifier = proto_key_info.getKeyIdentifier();
		key_info.key_material = 'private'; // should not show this
	}

	return key_info;
}
github hyperledger / fabric-sdk-node / fabric-client / lib / msp / Msp.js View on Github external
toProtobuf() {
		const proto_msp_config = new fabprotos.msp.MSPConfig();
		proto_msp_config.setType(0); // FABRIC
		const proto_fabric_msp_config = new fabprotos.msp.FabricMSPConfig();
		proto_fabric_msp_config.setName(this._id);
		proto_fabric_msp_config.setRootCerts(this._rootCerts);
		if (this._intermediateCerts) {
			proto_fabric_msp_config.setIntermediateCerts(this._intermediateCerts);
		}
		if (this._admins) {
			proto_fabric_msp_config.setAdmins(this._admins);
		}
		if (this._organization_units) {
			// organizational_unit_identifiers
			proto_fabric_msp_config.setOrganizationalUnitIdentifiers(this._organization_units);
		}
		if (this._tls_root_certs) {
			proto_fabric_msp_config.setTlsRootCerts(this._tls_root_certs);
github hyperledger / fabric-sdk-node / fabric-client / lib / BlockDecoder.js View on Github external
function decodeSigningIdentityInfo(signing_identity_info_bytes) {
	const signing_identity_info = {};
	if (signing_identity_info_bytes) {
		const proto_signing_identity_info = fabprotos.msp.SigningIdentityInfo.decode(signing_identity_info_bytes);
		signing_identity_info.public_signer = proto_signing_identity_info.getPublicSigner().toBuffer().toString();
		signing_identity_info.private_signer = decodeKeyInfo(proto_signing_identity_info.getPrivateSigner());
	}

	return signing_identity_info;
}
github hyperledger / fabric-sdk-node / fabric-client / lib / BlockDecoder.js View on Github external
function decodeConfigValueMSP(proto_config_value, config_value) {
	let msp_config = {};
	const proto_msp_config = fabprotos.msp.MSPConfig.decode(proto_config_value.value.value);
	if (proto_msp_config.getType() === 0) {
		msp_config = decodeFabricMSPConfig(proto_msp_config.getConfig());
	}
	config_value.value.type = proto_msp_config.type;
	config_value.value.config = msp_config;
	return config_value;
}
github hyperledger / fabric-sdk-node / fabric-common / lib / Identity.js View on Github external
serialize() {
		const serializedIdentity = new fabprotos.msp.SerializedIdentity();
		serializedIdentity.setMspid(this.getMSPId());
		serializedIdentity.setIdBytes(Buffer.from(this._certificate));
		return serializedIdentity.toBuffer();
	}
}
github hyperledger / fabric-sdk-node / fabric-client / lib / BlockDecoder.js View on Github external
function decodeFabricMSPConfig(msp_config_bytes) {
	const msp_config = {};
	const proto_msp_config = fabprotos.msp.FabricMSPConfig.decode(msp_config_bytes);

	msp_config.name = proto_msp_config.getName();
	msp_config.root_certs = toPEMcerts(proto_msp_config.getRootCerts());
	msp_config.intermediate_certs = toPEMcerts(proto_msp_config.getIntermediateCerts());
	msp_config.admins = toPEMcerts(proto_msp_config.getAdmins());
	msp_config.revocation_list = toPEMcerts(proto_msp_config.getRevocationList());
	msp_config.signing_identity = decodeSigningIdentityInfo(proto_msp_config.getSigningIdentity());
	msp_config.organizational_unit_identifiers = decodeFabricOUIdentifier(proto_msp_config.getOrganizationalUnitIdentifiers());
	msp_config.tls_root_certs = toPEMcerts(proto_msp_config.getTlsRootCerts());
	msp_config.tls_intermediate_certs = toPEMcerts(proto_msp_config.getTlsIntermediateCerts());

	return msp_config;
}