npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fabric-sdk-config

v1.0.0

Published

Package for creating and modifying Fabric SDK node

Downloads

2

Readme

Hyperledger Fabric SDK config

Package for creating and modifying Fabric SDK node

Install

Install with npm:

$ npm install --save fabric-sdk-config

Usage

var fabConf = require('fabric-sk-config');

Create NetworkConfig instance

Parameters:

  1. name: string
  2. version: string
  3. description: string
  4. xtype: string
let networkConfig = new fabConf.NetworkConfig("supply", "1.0", "supply", "hlfv1");

Create and add Peer

Parameters:

  1. name: string
  2. url: string
  3. grpcOptions: object
  4. tlsCACerts: object | string

Variation 1 - create a Peer instance and pass it to the 'addPeer' method of the NetworkConfig class instance

let peer0 = new fabConf.NetworkConfig.Peer(
     "peer0.org1.example.com",
     "grpcs://localhost:7051",
     {"ssl-target-name-override": "peer0.org1.example.com"},
     {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"}
	 //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
 );
 
 networkConfig.addPeer(peer0);

Or variation 2 - pass the parameters directly to the 'addPeer' method

 networkConfig.addPeer(
     "peer0.org1.example.com",
     "grpcs://localhost:7051",
     {"ssl-target-name-override": "peer0.org1.example.com"},
     {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"} //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/peers/peer1.org1.example.com/tls/ca.crt"
 );

Create and add Orderer

Parameters:

  1. name: string
  2. url: string
  3. grpcOptions: object
  4. tlsCACerts: object | string

Variation 1 - create a Orderer instance and pass it to the 'addOrderer' method of the NetworkConfig class instance

let orderer = new fabConf.NetworkConfig.Orderer(
     "orderer.example.com",
     "grpcs://localhost:7050",
     {"ssl-target-name-override": "orderer.example.com"},
     {path: "artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"}  //or string "artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
 );
 
 networkConfig.addOrderer(orderer);

Or variation 2 - pass the parameters directly to the 'addOrderer' method

 networkConfig.addOrderer(
    "orderer.example.com",
     "grpcs://localhost:7050",
     {"ssl-target-name-override": "orderer.example.com"},
     {path: "artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"}  //or string "artifacts/channel/crypto-config/ordererOrganizations/example.com/orderers/orderer.example.com/tls/ca.crt"
 );

Create and add Organization

Parameters:

  1. name: string
  2. mspid: string
  3. peers names: string | string[] | Peer | Peer[]
  4. certificateAuthorities
  5. adminPrivateKey: object | string
  6. signedCert: object | string

Variation 1 - create a Organization instance and pass it to the 'addOrganization' method of the NetworkConfig class instance

let organization = new fabConf.NetworkConfig.Organization(
     "Org1",
     "Org1MSP",
     peer0, // instance of Peer. or [peer0, peer1, peer2...] or "peer0.org1.example.com" or ["peer0.org1.example.com", "peer1.org1.example.com"]
	 ca, // instance of CertificateAuthority. or [ca1, ca2] or "ca-org1" or ["ca-org1", "ca2-org1"]
     {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/5890f0061619c06fb29dea8cb304edecc020fe63f41a6db109f1e227cc1cb2a8_sk"},  //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/5890f0061619c06fb29dea8cb304edecc020fe63f41a6db109f1e227cc1cb2a8_sk"
	 {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"}  //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
 );
 
 networkConfig.addOrganization(organization);

Or variation 2 - pass the parameters directly to the 'addOrganization' method

 networkConfig.addOrganization(
      "Org1",
     "Org1MSP",
     peer0, // instance of Peer. or [peer0, peer1, peer2...] or "peer0.org1.example.com" or ["peer0.org1.example.com", "peer1.org1.example.com"]
	 ca, // instance of CertificateAuthority. or [ca1, ca2] or "ca-org1" or ["ca-org1", "ca2-org1"]
     {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/5890f0061619c06fb29dea8cb304edecc020fe63f41a6db109f1e227cc1cb2a8_sk"},  //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/keystore/5890f0061619c06fb29dea8cb304edecc020fe63f41a6db109f1e227cc1cb2a8_sk"
	 {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"}  //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/users/[email protected]/msp/signcerts/[email protected]"
 );

Create and add CertificateAuthority

Parameters:

  1. name: string
  2. url: string
  3. httpOptions: object
  4. tlsCACerts: object | string
  5. registrar: object | object[]
  6. caName: string

Variation 1 - create a CertificateAuthority instance and pass it to the 'addCertificateAuthority' method of the NetworkConfig class instance

let ca = new fabConf.NetworkConfig.Organization(
     "ca-org1",
    "https://localhost:7054",
    {verify: false},
    {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"},  //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"
    {
        enrollId: "admin",
        enrollSecret: "adminpw"
    },
    "ca-org1"
 );

 networkConfig.addCertificateAuthority(ca);

Or variation 2 - pass the parameters directly to the 'addCertificateAuthority' method

 networkConfig.addCertificateAuthority(
      "ca-org1",
    "https://localhost:7054",
    {verify: false},
    {path: "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"},  //or string "artifacts/channel/crypto-config/peerOrganizations/org1.example.com/ca/ca.org1.example.com-cert.pem"
    {
        enrollId: "admin",
        enrollSecret: "adminpw"
    },
    "ca-org1"
 );

Create and add Channel

Parameters:

  1. name: string
  2. orderers names: string | string[] | Orderer | Orderer[]
  3. channel_peers: object[]
  4. chaincodes

channel_peers format:

{
	"peer0.main.arcelormittal-fabric.test": {
		  endorsingPeer?: *boolean*
		  chaincodeQuery?: *boolean*
		  ledgerQuery?: *boolean*
		  eventSource?: *boolean*
		  discover?: *boolean*
	}
}

Variation 1 - create a Channel instance and pass it to the 'addChannel' method of the NetworkConfig class instance

let channel = new fabConf.NetworkConfig.Channel(
     "mychannel",
    orderer,  // instance of Orderer. or [orderer1, orderer2] or "orderer.example.com" or ["orderer1.example.com", "orderer2.example.com"]
    {"peer0.org1.example.com": {
            "endorsingPeer": true,
            "chaincodeQuery": true,
            "ledgerQuery": true,
            "eventSource": true
    }}
 );

 networkConfig.addChannel(channel);

Or variation 2 - pass the parameters directly to the 'addChannel' method

 networkConfig.addChannel(
      "mychannel",
    orderer,  // instance of Orderer. or [orderer1, orderer2] or "orderer.example.com" or ["orderer1.example.com", "orderer2.example.com"]
    {"peer0.org1.example.com": {
            "endorsingPeer": true,
            "chaincodeQuery": true,
            "ledgerQuery": true,
            "eventSource": true
    }}
 );

Create ClientOrgConfig instance

Parameters:

  1. name: string
  2. version: string
  3. description: string
  4. xtype: string
let ClientConfig = new fabConf.ClientOrgConfig("supply", "1.0", "supply", "hlfv1");

Create and add Client

Parameters:

  1. org_name: string
  2. credentialStore: object

Pass the parameters directly to the 'addClient' method

 ClientConfig.addClient(
     "Org1",
    {
      "path": "./fabric-client-kv-org1",
      "cryptoStore": {
        "path": "/tmp/fabric-client-kv-org1"
      },
      "wallet": "wallet-name"
    }
 );