How to use the fabric-common.User.createUser function in fabric-common

To help you get started, we’ve selected a few fabric-common 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 / ts-scenario / steps / lib / utility / clientUtils.ts View on Github external
function createAdminUserForOrg(ccp: CommonConnectionProfileHelper, orgName: string): User {

	const org: any = ccp.getOrganization(orgName);
	if (!org) {
		throw new Error(`Could not find organization ${orgName} in configuration`);
	}

	const keyPEM: Buffer = fs.readFileSync(org.adminPrivateKeyPEM.path);
	const certPEM: Buffer = fs.readFileSync(org.signedCertPEM.path);

	// Create user and return
	return User.createUser(Constants.ADMIN_NAME, Constants.ADMIN_PW, org.mspid, certPEM.toString(), keyPEM.toString());
}
github hyperledger / fabric-sdk-node / test / scenario / features / steps / base_steps.js View on Github external
function getUser() {
	let data = fs.readFileSync(path.join(__dirname, '../../../fixtures/crypto-material/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/keystore/key.pem'));
	const keyPEM = Buffer.from(data).toString();
	data = fs.readFileSync(path.join(__dirname, '../../../fixtures/crypto-material/crypto-config/peerOrganizations/org1.example.com/users/Admin@org1.example.com/msp/signcerts/Admin@org1.example.com-cert.pem'));
	const certPEM = Buffer.from(data).toString();

	const user = User.createUser('admin', 'adminpw', 'Org1MSP', certPEM, keyPEM);
	return user;
}