fabric-common User and fabric-client User are clashing #fabric-ca-client #fabric-sdk-node


From @bestbeforetoday in Hyperledger Chat:

Both the v2.2.0 and v1.4.11 releases of the Node SDK have been published. v2.2 is a long-term support (LTS) release accompanying the Fabric v2.2 LTS release, and has been tagged in the NPM registry as _latest_. This breaks a package dependency between v1.4 Node SDK packages prior to v1.4.11. If you are using the v1.4 Node SDK, please upgrade to v1.4.11. Release information here: https://github.com/hyperledger/fabric-sdk-node/releases

Mark Lewis

The v1.4.11 release of the Node SDK should fix this.



I have the following code:

import * as FabricCAServices from 'fabric-ca-client';
import { Gateway } from 'fabric-network';

client = gateway.getClient();
let msp = client.getMspid();
const caUser = client.getCertificateAuthority();
let caAdminUser = `${FabricNetworkConfig.caauthority.caadmin}@${caUser.getCaName()}`;
const adminUser = await client.getUserContext(caAdminUser);

if (!adminUser || adminUser === undefined) {
throw new Error(`Cannot enroll user ${registerRequest.enrollmentID} as no authorized users exist to enroll users for Org ${msp}`);

try {
let userInfo = await caUser.newIdentityService().getOne(registerRequest.enrollmentID, adminUser);

The caUser.newIdentityService().getOne(...) is complaining about the second argument adminUser. This is the error:

Argument of type 'import("/usr/local/code/fabric-network-code/node_modules/fabric-client/types/index").User' is not assignable to parameter of type 'import("/usr/local/code/fabric-network-code/node_modules/fabric-common/types/index").User'.
Type 'User' is missing the following properties from type 'User': getMspid, getEnrollmentSecret, setSigningIdentity

My package.json dependencies are listed below:

"dependencies": {
"@types/express": "^4.17.0",
"apidoc": "^0.23.0",
"body-parser": "^1.19.0",
"express": "^4.17.1",
"express-jwt": "^5.3.1",
"fabric-network": "^1.4.8",
"http-status-codes": "^1.3.2",
"json2yaml": "^1.1.0",
"jwks-rsa": "^1.6.0",
"mongoose": "^5.6.6",
"nodemon": "^1.19.1",
"portscanner": "^2.2.0",
"shelljs": "^0.8.3",
"uuid": "^3.3.3",
"yaml2json": "^1.0.2"

Fabric Network library has these dependencies:

"dependencies": {
"fabric-ca-client": "latest",
"fabric-client": "latest",

It looks like fabric-ca-client library is being pulled for v2.2.

Fabric Client being pulled in is 1.4.10:

"_from": "fabric-client@latest",
"_id": "fabric-client@1.4.10",

whereas fabric-ca-client is 2.2.0:

"_from": "fabric-ca-client@latest",
"_id": "fabric-ca-client@2.2.0",

Fabric-ca-client is in turn pulling in fabric-common 2.2.0 which also has a User type which is clashing with the fabric-client User type.

Can someone please suggest a way to resolve this?

Thank you