Re: registeruser.js - 1.4 v 2.0


Bret Harrison <beharrison@...>
 

With NodeSDK v2 beta.3 you will get the required admin `User` object instance for calling the `register` of fabric-ca-client from the fabric-network `Wallet` rather than from the underlying Client object instance of the Gateway.

const adminIdentity = await wallet.get('admin');
const provider = wallet.getProviderRegistry().getProvider(adminIdentity.type);
const adminUser = await provider.getUserContext(adminIdentity, 'admin’);
const secret = await ca.register({
affiliation: 'org1.department1',
enrollmentID: 'user1',
role: 'client'
}, adminUser);
const enrollment = await ca.enroll({
enrollmentID: 'user1',
enrollmentSecret: secret
});
const x509Identity = {
credentials: {
certificate: enrollment.certificate,
privateKey: enrollment.key.toBytes(),
},
mspId: 'Org1MSP',
type: 'X.509',
};
await wallet.put('user1', x509Identity);

Join fabric@lists.hyperledger.org to automatically receive all group messages.