Hyperledger fabric client credential store using couchdb(CouchDBKeyValueStore)

560 Views Asked by At

I'm using Hyperledger Fabric SDK for node.js to enroll a user. I'm using this code to deploy in fabric. It uses FileKeyValueStore (uses files to store the key values) to store client's user credential. I want to use CouchDBKeyValueStore to store user key in CouchDB database instance. So I found sample source code at stackoverflow. But I don't know what value should be inside the <USERNAME>, <PASSWORD>, <URL>. For example, I don't know if it's the username of the OS or the name of the user I want to register.

Hyperledger fabric client credential store using CouchDB

const Client = require('fabric-client');
const CDBKVS = require('fabric-client/lib/impl/CouchDBKeyValueStore.js');

var client = Client.loadFromConfig('test/fixtures/network.yaml');

// Set the state store
let stateStore = await new CDBKVS({url: 'https://<USERNAME>:<PASSWORD>@<URL>', name: '<DB_NAME>'})
client.setStateStore(stateStore);

// Set the crypto store
const crypto = Client.newCryptoSuite();
let cryptoKS = Client.newCryptoKeyStore(
    CDBKVS,
    {
      url: 'https://<USERNAME>:<PASSWORD>@<URL>.cloudant.com',
      name: '<DB_NAME>'
    }
);
crypto.SetCryptoKeyStore(cryptoKS);
client.setCryptoSuite(crypto);
1

There are 1 best solutions below

0
Shubham Chadokar On

It is the DB USERNAME.

If you're using couchdb docker image.

docker run --name my-couch-db -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password123 -p 3000:5984 -d couchdb

Then that connection string will be:

url: 'https://<USERNAME>:<PASSWORD>@<URL>'
url: 'https://admin:password123@localhost:3000'

Reference: https://hub.docker.com/_/couchdb