Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
var member = new User(username);
var cryptoSuite = client.getCryptoSuite();
if (!cryptoSuite) {
cryptoSuite = hfc.newCryptoSuite();
if (userOrg) {
cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore({ path: module.exports.storePathForOrg(nid, cpOrgs[userOrg].name) }));
client.setCryptoSuite(cryptoSuite);
}
}
member.setCryptoSuite(cryptoSuite);
// need to enroll it with CA server
var orgCA = cpOrgs[userOrg].certificateAuthorities[0];
var cop = new copService(caUrl, tlsOptions, cpCAs[orgCA].caName, cryptoSuite);
return cop.enroll({
enrollmentID: username,
enrollmentSecret: password
}).then((enrollment) => {
logger.info('[getMember] Successfully enrolled user \'' + username + '\'');
return member.setEnrollment(enrollment.key, enrollment.certificate, cpOrgs[userOrg].mspid);
}).then(() => {
var skipPersistence = false;
if (!client.getStateStore()) {
skipPersistence = true;
}
return client.setUserContext(member, skipPersistence);
}).then(() => {
return resolve(member);
return resolve(user);
}
const member = new User(username);
let cryptoSuite = client.getCryptoSuite();
if (!cryptoSuite) {
cryptoSuite = Client.newCryptoSuite();
if (userOrg) {
cryptoSuite.setCryptoKeyStore(Client.newCryptoKeyStore({path: module.exports.storePathForOrg(ORGS[userOrg].name)}));
client.setCryptoSuite(cryptoSuite);
}
}
member.setCryptoSuite(cryptoSuite);
// need to enroll it with CA server
const cop = new copService(caUrl, tlsOptions, ORGS[userOrg].ca.name, cryptoSuite);
return cop.enroll({
enrollmentID: username,
enrollmentSecret: password
}).then((enrollment) => {
t.pass('Successfully enrolled user \'' + username + '\'');
return member.setEnrollment(enrollment.key, enrollment.certificate, ORGS[userOrg].mspid);
}).then(() => {
let skipPersistence = false;
if (!client.getStateStore()) {
skipPersistence = true;
}
return client.setUserContext(member, skipPersistence);
}).then(() => {
return resolve(member);
}).catch((err) => {