Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then((result) => {
console.log('_arr[_idx].id: '+_arr[_idx].id);
console.log('result.userID: '+result.userID);
let _mem = _arr[_idx];
_mem.secret = result.userSecret;
_mem.userID = result.userID;
memberTable.push(_mem);
// svc.saveMemberTable(memberTable);
let _meta = {};
for (each in config.composer.metaData)
{(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
_meta.businessNetwork = config.composer.network;
_meta.userName = result.userID;
_meta.enrollmentSecret = result.userSecret;
config.connectionProfile.keyValStore = _home+config.connectionProfile.keyValStore;
let tempCard = new hlc_idCard(_meta, config.connectionProfile);
return adminConnection.importCard(result.userID, tempCard)
.then ((_res) => {
if (_res) {console.log('card updated');} else {console.log('card imported');}
})
.catch((error) => {
console.error('adminConnection.importCard failed. ',error.message);
});
})
.catch((error) => {
.then((result) => {
console.log('_arr[_idx].id: '+_arr[_idx].id);
console.log('result.userID: '+result.userID);
let _mem = _arr[_idx];
_mem.secret = result.userSecret;
_mem.userID = result.userID;
memberTable.push(_mem);
// svc.saveMemberTable(memberTable);
let _meta = {};
for (each in config.composer.metaData)
{(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
_meta.businessNetwork = config.composer.network;
_meta.userName = result.userID;
_meta.enrollmentSecret = result.userSecret;
config.connectionProfile.keyValStore = _home+config.connectionProfile.keyValStore;
let tempCard = new hlc_idCard(_meta, config.connectionProfile);
return adminConnection.importCard(result.userID, tempCard)
.then ((_res) => {
if (_res) {console.log('card updated');} else {console.log('card imported');}
})
.catch((error) => {
console.error('adminConnection.importCard failed. ',error.message);
});
})
.catch((error) => {
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const AssetDeclaration = require('composer-common').AssetDeclaration;
const EventEmitter = require('events');
const Logger = require('composer-common').Logger;
const ParticipantDeclaration = require('composer-common').ParticipantDeclaration;
const TransactionDeclaration = require('composer-common').TransactionDeclaration;
const Registry = require('./registry');
const LOG = Logger.getLog('RegistryManager');
// Do not add additional types to these constants. All system types are assets.
const TYPE_MAP = {
Asset : 'AssetRegistry',
Participant : 'ParticipantRegistry',
Transaction : 'TransactionRegistry',
Network : 'Network'
};
// This is a list of non-abstract system types that we do not want registries created for.
const VIRTUAL_TYPES = [
'Network'
];
/**
* A class for managing and persisting registries.
Object.keys(result).forEach((key) => {
let cardProperties = result[key];
let idCard = new IdCard(cardProperties.metadata, cardProperties.connectionProfile);
idCard.setCredentials(cardProperties.credentials);
resultMap.set(key, idCard);
});
LOG.exit(method, resultMap);
businessNetworkCardStorePut (cardName, cardProperties, callback) {
const method = 'businessNetworkCardStorePut';
LOG.entry(method, cardName, cardProperties);
let card = new IdCard(cardProperties.metadata, cardProperties.connectionProfile);
card.setCredentials(cardProperties.credentials);
return this.businessNetworkCardStore.put(cardName, card)
.then((result) => {
callback(null, result);
LOG.exit(method, result);
})
.catch((error) => {
LOG.error(method, error);
callback(ConnectorServer.serializerr(error));
LOG.exit(method, null);
});
}
this.socket.emit('/api/businessNetworkCardStoreGet', cardName, (error, result) => {
if (error) {
return reject(ProxyUtil.inflaterr(error));
}
let cardProperties = result;
let idCard = new IdCard(cardProperties.metadata, cardProperties.connectionProfile);
idCard.setCredentials(cardProperties.credentials);
LOG.exit(method, idCard);
resolve(idCard);
});
});
it('should get one initial', () => {
component['identity'] = new IdCard({
userName: 'admin',
businessNetwork: 'conga-network'
}, {'name': 'dialup-modem', 'x-type': 'hlfv1'});
fixture.detectChanges();
let initialsElement = identityCardElement.query(By.css('.initials'));
initialsElement.nativeElement.textContent.should.equal('a');
});
exports.createCard = function(req, res, next) {
let adminConnection = new AdminConnection();
let _meta = {};
for (let each in config.composer.metaData)
{(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
_meta.businessNetwork = config.composer.network;
_meta.userName = req.body.id;
_meta.enrollmentSecret = req.body.secret;
config.connectionProfile.keyValStore = _home+config.connectionProfile.keyValStore;
let tempCard = new hlc_idCard(_meta, config.connectionProfile);
adminConnection.connect(config.composer.adminCard)
.then(() => {
return adminConnection.importCard(req.body.id, tempCard)
.then ((_res) => { let _msg = ((_res) ? 'card updated' : 'card imported');
console.log('create Card succeeded:'+_msg);
res.send({'result': 'success', 'card': _msg});
})
.catch((error) => {
console.error('adminConnection.importCard failed. ',error.message);
res.send({'result': 'failed', 'error': error.message});
});
})
.catch((error) => {
console.error('adminConnection.connect failed. ',error.message);
res.send({'result': 'failed', 'error': error.message});
});
.then((_res) => {
console.log(methodName+' svc.getThisMember('+_arr[_idx].id+') _res: ', _res);
let member = JSON.parse(_res);
let options = {};
options.registry = member.type;
let _meta = {};
for (each in config.composer.metaData)
{(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
_meta.businessNetwork = config.composer.network;
_meta.userName = member.id;
_meta.enrollmentSecret = member.secret;
console.log(methodName+' svc.getThisMember('+_arr[_idx].id+') _meta: ', _meta);
let tempCard = new hlc_idCard(_meta, admin_connection);
return adminConnection.importCard(member.id, tempCard)
.then(() => {
let currentMemberPath = path.join(basePath,member.id);
fs.mkdirSync(currentMemberPath);
for (let i=0; i<3; i++)
{(function(_idx)
{console.log(methodName+' looping on ['+_idx+'] is: '+member[CLIENT_DATA+_idx].name);
let _path = path.join(basePath,member.id,member[CLIENT_DATA+_idx].name);
fs.writeFileSync(_path, member[CLIENT_DATA+_idx].file);
})(i)
}
})
.catch((error) => {console.log(methodName+' adminConnection.importCard for '+member.id+' failed with error: ', error);})
})
.catch((_error) => {
exports.createCard = function(req, res, next) {
let methodName = 'createCard';
console.log(methodName+' entered for: ', req.body.id);
let adminConnection = new AdminConnection();
let _meta = {};
for (let each in config.composer.metaData)
{(function(_idx, _obj) {_meta[_idx] = _obj[_idx]; })(each, config.composer.metaData); }
_meta.businessNetwork = config.composer.network;
_meta.userName = req.body.id;
_meta.enrollmentSecret = req.body.secret;
let tempCard = new hlc_idCard(_meta, admin_connection);
adminConnection.connect(config.composer.adminCard)
.then(() => {
return adminConnection.importCard(req.body.id, tempCard)
.then ((_res) => { let _msg = ((_res) ? 'card updated' : 'card imported');
console.log('create Card succeeded:'+_msg);
let businessNetworkConnection = new BusinessNetworkConnection();
return businessNetworkConnection.connect(req.body.id)
.then(() => {
return businessNetworkConnection.ping()
.then((_msg) => { businessNetworkConnection.disconnect(); res.send({'result': 'success', 'card': _msg}); })
.catch((error) => { console.log(methodName+' businessNetworkConnection.ping() failed. error: ',error); businessNetworkConnection.disconnect(); res.send({'result': 'failed', 'card': error});});
})
.catch((error) =>{ console.log(methodName+' businessNetworkConnection.connect('+req.body.id+') failed. error: ',error); res.send({'result': 'failed', 'card': error});});
})
.catch((error) => {
console.error('adminConnection.importCard failed. ',error.message);