openwallet-foundation/credo-ts

Indy-vdr: Cannot read properties of undefined (reading 'poolCreate') during new schema & credential registration tutorial

Closed this issue · 8 comments

I've been following the Aries JS tutorials, but I'm unable to initialise the agent after updating the config to match what's provided here. I've opted to use the IndyVdrModule.

I'm using Node 20, but have also tried using Node 18 and I get the same error.

When running my application, I get the following error:

/.../project/node_modules/@hyperledger/indy-vdr-shared/build/builder/PoolCreate.js:12
        const handle = indyVdr_1.indyVdr.poolCreate(options);
                                         ^

TypeError: Cannot read properties of undefined (reading 'poolCreate')
    at new PoolCreate (/.../project/node_modules/@hyperledger/indy-vdr-shared/build/builder/PoolCreate.js:12:42)
    at IndyVdrPool.connect (/.../project/node_modules/@aries-framework/indy-vdr/build/pool/IndyVdrPool.js:22:22)
    at IndyVdrModule.initialize (/.../project/node_modules/@aries-framework/indy-vdr/build/IndyVdrModule.js:35:28)
    at Agent.initialize (/.../project/node_modules/@aries-framework/core/build/agent/Agent.js:127:30)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async initialiseOrgAgent (file:///.../project/aries/initialiseOrgAgent.js:79:3)
    at async startServer (file:///.../project/index.js:14:17)

Here is the index file:

import "dotenv/config";
import { initialiseOrgAgent } from "./aries/initialiseOrgAgent.js";
import { createNewInvitation } from "./aries/createNewInvitation.js";
import { setupConnectionListener } from "./aries/setupConnectionListener.js";
import { registerTestCredential } from "./aries/registerTestCredential.js";

const onConnection = () =>
  console.log(
    "We now have an active connection to use in the following tutorials"
  );

const startServer = async () => {
  console.log("Init Aries agent");
  const agent = await initialiseOrgAgent();

  console.log("Registering credential definition");
  await registerTestCredential(agent);

  console.log("Creating invite for new credential");
  const { outOfBandRecord, invitationUrl } = await createNewInvitation(agent);

  console.log(invitationUrl);

  console.log("Listening for connection changes...");
  setupConnectionListener(agent, outOfBandRecord, onConnection);
};

export default startServer;

startServer();

And here is the function use to initialise the agent:

import { AskarModule } from "@aries-framework/askar";
import { ariesAskar } from "@hyperledger/aries-askar-nodejs";
import { Agent } from "@aries-framework/core";
import { agentDependencies } from "@aries-framework/node";
import {
  HttpOutboundTransport,
  WsOutboundTransport,
  ConnectionsModule,
  DidsModule,
} from "@aries-framework/core";
import { HttpInboundTransport } from "@aries-framework/node";
import {
  IndyVdrAnonCredsRegistry,
  IndyVdrIndyDidRegistrar,
  IndyVdrIndyDidResolver,
  IndyVdrModule,
} from "@aries-framework/indy-vdr";
import { indyVdr } from "@hyperledger/indy-vdr-nodejs";
import { AnonCredsModule } from "@aries-framework/anoncreds";
import { AnonCredsRsModule } from "@aries-framework/anoncreds-rs";
import { anoncreds } from "@hyperledger/anoncreds-nodejs";

export const initialiseOrgAgent = async () => {
  // Simple agent configuration. This sets some basic fields like the wallet
  // configuration and the label.
  const config = {
    label: "demo-agent-org",
    walletConfig: {
      id: "<someId>",
      key: "demoagentorg0000000000000000000",
    },
    endpoints: ["http://localhost:3001"],
    logger: console,
  };

  // A new instance of an agent is created here
  const agent = new Agent({
    config,
    dependencies: agentDependencies,
    modules: {
      askar: new AskarModule({ ariesAskar }),
      connections: new ConnectionsModule({ autoAcceptConnections: true }),
      anoncredsRs: new AnonCredsRsModule({
        anoncreds,
      }),
      indyVdr: new IndyVdrModule({
        indyVdr,
        networks: [
          {
            isProduction: false,
            indyNamespace: "bcovrin:test",
            genesisTransactions: "<transactions>",
            connectOnStartup: true,
          },
        ],
      }),
      anoncreds: new AnonCredsModule({
        registries: [new IndyVdrAnonCredsRegistry()],
      }),
      dids: new DidsModule({
        registrars: [new IndyVdrIndyDidRegistrar()],
        resolvers: [new IndyVdrIndyDidResolver()],
      }),
    },
  });

  agent.registerOutboundTransport(new WsOutboundTransport());
  agent.registerOutboundTransport(new HttpOutboundTransport());
  agent.registerInboundTransport(new HttpInboundTransport({ port: 3001 }));

  // Initialize the agent
  await agent.initialize();

  return agent;
};

From what I can tell, when the IndyVdrModule is initialised, it's trying to use an unregistered instance of indyVdr - is there something I'm missing here? Should this be an issue in @hyperledger/indy-vdr instead?

  • Which OS / Architecture are you running this on?
  • Which versions are you using of the indy-vdr and AFJ dependencies?

Setup seems correct to me, so I assume something went wrong during the installation. There is a particular issue on Windows which messes up the installation. See the fix here: #1522 (comment)

I'm on MacOS 14.0, on an Apple M1 Pro Macbook.

Here are the dependencies from my package.json:

  "dependencies": {
    "@aries-framework/anoncreds-rs": "0.4.2",
    "@aries-framework/askar": "0.4.2",
    "@aries-framework/core": "0.4.2",
    "@aries-framework/indy-vdr": "0.4.2",
    "@aries-framework/node": "0.4.2",
    "@hyperledger/anoncreds-nodejs": "0.2.0-dev.1",
    "@hyperledger/aries-askar-nodejs": "0.1.1",
    "@hyperledger/indy-vdr-nodejs": "0.2.0-dev.2",
    "dotenv": "^16.3.1"
  },

Also, I've been using npm v9.8.1 as my package manager

Could you try using ^0.1.0 of all the hyperledger dependencies?

Could you try using ^0.1.0 of all the hyperledger dependencies?

This worked - I no longer see the error, and the agent successfully registers the credential definition. I'm not familiar with the internals of these dependencies - any idea what the differences are?

For more reference, here's the full package.json now:

{
  "license": "CC-BY-SA-4.0",
  "name": "aries-learning-server",
  "main": "index.js",
  "type": "module",
  "version": "1.0.0",
  "scripts": {
    "start": "node index"
  },
  "dependencies": {
    "@aries-framework/anoncreds-rs": "0.4.2",
    "@aries-framework/askar": "0.4.2",
    "@aries-framework/core": "0.4.2",
    "@aries-framework/indy-vdr": "0.4.2",
    "@aries-framework/node": "0.4.2",
    "@hyperledger/anoncreds-nodejs": "^0.1.0",
    "@hyperledger/aries-askar-nodejs": "^0.1.0",
    "@hyperledger/indy-vdr-nodejs": "^0.1.0",
    "dotenv": "^16.3.1"
  },
  "devDependencies": {
    "eslint": "^8.52.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-config-prettier": "^9.0.0",
    "eslint-plugin-import": "^2.29.0"
  },
  "overrides": {
    "ref-napi": "npm:@2060.io/ref-napi"
  }
}

The latest shared components, i.e. the @hyperledger/xxx dependencies are not yet compatible with the latest modules from AFJ. We are currently working on it though.

We should rather quickly look into releasing -dev.xx versions as alpha versions on npm as that would've prevented this error.

Already opened an issue for this: hyperledger/anoncreds-rs#248

The latest shared components, i.e. the @hyperledger/xxx dependencies are not yet compatible with the latest modules from AFJ. We are currently working on it though.

We should rather quickly look into releasing -dev.xx versions as alpha versions on npm as that would've prevented this error.

Got it, thanks for your time and help!