Skip to content

Commit ace3143

Browse files
author
Mr. Angry
committed
Updating SDK README For NPM Publish
Updating the Node.js SDK README file to include the most up to date information and to point to updated Node.js documenation on readthedocs. Also, updating the package.json file to update the package version number as this is being published to NPM. Change-Id: I15dbb9dacf9fb3abc5ab3289f925cc3cc97a1d2b Signed-off-by: Anna D Derbakova <[email protected]>
1 parent 0fa60ba commit ace3143

File tree

2 files changed

+88
-30
lines changed

2 files changed

+88
-30
lines changed

sdk/node/README.md

+75-28
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,99 @@
1-
## Hyperledger Fabric Client SDK for Node.js
1+
# Hyperledger Fabric Client SDK for Node.js
22

3-
The Hyperledger Fabric Client SDK (HFC) provides a powerful and easy to use API to interact with a Hyperledger Fabric blockchain.
3+
## Overview
44

5-
To learn about how to install and use the Node.js SDK, please visit the [fabric documentation](http://hyperledger-fabric.readthedocs.io/en/latest/Setup/NodeSDK-setup).
5+
The Hyperledger Fabric Client SDK (HFC) provides a powerful and easy to use API to interact with a [Hyperledger Fabric](https://www.hyperledger.org/) blockchain from a Node.js application. It provides a set of APIs to register and enroll new network clients, to deploy new chaincodes to the network, and to interact with existing chaincodes through chaincode function invocations and queries.
66

7-
The [Going Deeper](#going-deeper) section discusses HFC's pluggability and extensibility design. It also describes the main object hierarchy to help you get started in navigating the reference documentation. The top-level class is `Chain`.
7+
To view the complete Node.js SDK documentation, additional usage samples, and getting started materials please visit the Hyperledger Fabric [SDK documentation page](http://hyperledger-fabric.readthedocs.io/en/latest/nodeSDK/node-sdk-guide/).
88

9-
The [Future Work](#future-work) section describes some upcoming work to be done.
9+
## Installation
1010

11-
**WARNING**: To view the reference documentation correctly, you first need to build the SDK and confirm functionality by [running the unit tests](#running-unit-tests). Subsequently open the following URLs directly in your browser. Be sure to replace YOUR-FABRIC-DIR with the path to your fabric directory.
11+
If you are interfacing with a network running the Hyperledger Fabric [`v0.5-developer-preview`](https://github.com/hyperledger-archives/fabric/tree/v0.5-developer-preview) branch, you must use the hfc version 0.5.x release and install it with the following command:
1212

13-
`file:///YOUR-FABRIC-DIR/sdk/node/doc/modules/_hfc_.html`
13+
npm install [email protected]
1414

15-
`file:///YOUR-FABRIC-DIR/sdk/node/doc/classes/_hfc_.chain.html`
15+
For networks running newer versions of the Hyperledger Fabric, please install the version of hfc that corresponds to the same version of the Fabric code base. For example, for the Fabric v0.6 branch install hfc with the following command:
1616

17-
### Going Deeper
17+
npm install [email protected]
1818

19-
#### Pluggability
20-
HFC was designed to support two pluggable components:
19+
## Usage
2120

22-
1. Pluggable key value store which is used to retrieve and store keys associated with a member. The key value store is used to store sensitive private keys, so care must be taken to properly protect access.
21+
### Terminology
2322

24-
2. Pluggable member service which is used to register and enroll members. Member services enables hyperledger to be a permissioned blockchain, providing security services such as anonymity, unlinkability of transactions, and confidentiality
23+
In order to transact on a Hyperledger blockchain, you must first have an identity which is both **registered** and **enrolled**. **Registration** means issuing a user invitation to join a blockchain network. **Enrollment** means accepting a user invitation to join a blockchain network.
2524

26-
#### HFC objects and reference documentation
27-
HFC is written primarily in typescript and is object-oriented. The source can be found in the `fabric/sdk/node/src` directory.
25+
In the current Hyperleger Fabric implementation, the administative user admin is already registered on the network by the virtue of the fact that their user ID and password pair are already added to the membership services server confiruation file, [membersrvc.yaml](https://github.com/hyperledger/fabric/blob/master/membersrvc/membersrvc.yaml). Therefore, the admin user must only enroll to be able to transact on the network. After enrollment, the administrative user is then able to register and enroll new users, in the role of a registrar. New users are added to the network programmatically, through the HFC `chain.registerAndEnroll` API.
2826

29-
To go deeper, you can view the reference documentation in your browser by opening the [reference documentation](doc/modules/_hfc_.html) and clicking on **"hfc"** on the right-hand side under **"Globals"**. This will work after you have built the SDK per the instruction [here](#building-the-client-sdk).
27+
### Example
3028

31-
The following is a high-level description of the HFC objects (classes and interfaces) to help guide you through the object hierarchy.
29+
An example presented in the [SDK documentation](http://hyperledger-fabric.readthedocs.io/en/latest/nodeSDK/sample-standalone-app/) demonstrated a typical application using the hfc.
3230

33-
* The main top-level class is [Chain](doc/classes/_hfc_.chain.html). It is the client's representation of a chain. HFC allows you to interact with multiple chains and to share a single [KeyValStore](doc/interfaces/_hfc_.keyvalstore.html) and [MemberServices](doc/interfaces/_hfc_.memberservices.html) object with multiple Chain objects as needed. For each chain, you add one or more [Peer](doc/classes/_hfc_.peer.html) objects which represents the endpoint(s) to which HFC connects to transact on the chain.
31+
The application sets up a target for the membership service server and enrolls the `admin` user. Subsequently, the admin user is set as the registrar user and registers and enrolls a new member, `JohnDoe`. The new member, `JohnDoe`, is then able to transact on the blockchain by deploying a chaincode, invoking a chaincode function, and querying chaincode state.
3432

35-
* The [KeyValStore](doc/interfaces/_hfc_.keyvalstore.html) is a very simple interface which HFC uses to store and retrieve all persistent data. This data includes private keys, so it is very important to keep this storage secure. The default implementation is a simple file-based version found in the [FileKeyValStore](doc/classes/_hfc_.filekeyvalstore.html) class.
33+
### Chaincode Deployment
3634

37-
* The [MemberServices](doc/interfaces/_hfc_.memberservices.html) interface is implemented by the [MemberServicesImpl](doc/classes/_hfc_.memberservicesimpl.html) class and provides security and identity related features such as privacy, unlinkability, and confidentiality. This implementation issues *ECerts* (enrollment certificates) and *TCerts* (transaction certificates). ECerts are for enrollment identity and TCerts are for transactions.
35+
Chaincode may be deployed in **development** mode or **network** mode. **Development** mode refers to running the chaincode as a stand alone process outside the network peer. This approach is useful while doing chaincode development and testing. The approach is described [here](http://hyperledger-fabric.readthedocs.io/en/latest/Setup/Chaincode-setup/). **Network** mode refers to packaging the chaincode and its dependencies and subsequently deploying the package to an existing network as a Docker container. To have the chaincode deployment with hfc succeed in network mode, you must properly set up the chaincode project and its dependencies. The instructions for doing so can be found in the [Chaincode Deployment](http://hyperledger-fabric.readthedocs.io/en/latest/nodeSDK/node-sdk-indepth/#chaincode-deployment) section of the Node.js SDK documentation page.
3836

39-
* The [Member](doc/classes/_hfc_.member.html) class most often represents an end user who transacts on the chain, but it may also represent other types of members such as peers. From the Member class, you can *register* and *enroll* members or users. This interacts with the [MemberServices](doc/interfaces/_hfc_.memberservices.html) object. You can also deploy, query, and invoke chaincode directly, which interacts with the [Peer](doc/classes/_hfc_.peer.html). The implementation for deploy, query and invoke simply creates a temporary [TransactionContext](doc/classes/_hfc_.transactioncontext.html) object and delegates the work to it.
37+
### Enabling TLS
4038

41-
* The [TransactionContext](doc/classes/_hfc_.transactioncontext.html) class implements the bulk of the deploy, invoke, and query logic. It interacts with MemberServices to get a TCert to perform these operations. Note that there is a one-to-one relationship between TCert and TransactionContext; in other words, a single TransactionContext will always use the same TCert. If you want to issue multiple transactions with the same TCert, then you can get a [TransactionContext](doc/classes/_hfc_.transactioncontext.html) object from a [Member](doc/classes/_hfc_.member.html) object directly and issue multiple deploy, invoke, or query operations on it. Note however that if you do this, these transactions are linkable, which means someone could tell that they came from the same user, though not know which user. For this reason, you will typically just call deploy, invoke, and query on the User or Member object.
39+
If you wish to enable TLS connection between the member services, the peers, and the chaincode container, please see the [Enabling TLS](http://hyperledger-fabric.readthedocs.io/en/latest/nodeSDK/node-sdk-indepth/#enabling-tls) section within the Node.js SDK documentation.
4240

43-
## Future Work
44-
The following is a list of known remaining work to be done.
41+
## Objects, Classes, And Interfaces
4542

46-
* The reference documentation needs to be made simpler to follow as there are currently some internal classes and interfaces that are being exposed.
43+
HFC is written primarily in Typescript and is object-oriented. The source can be found in the [fabric/sdk/node](https://github.com/hyperledger/fabric/tree/master/sdk/node) directory of the Hyperledger Fabric project. To better understand the object hierarchy, please read the high-level descriptions of the HFC objects (classes and interfaces) in the [HFC Objects](http://hyperledger-fabric.readthedocs.io/en/latest/nodeSDK/node-sdk-indepth/#hfc-objects) section within the Node.js SDK documentation. You can also build the complete reference documentation locally by following the instructions [here](http://hyperledger-fabric.readthedocs.io/en/latest/nodeSDK/app-developer-env-setup/).
4744

48-
* We are investigating how to make deployment of a chaincode simpler by not requiring you to set up a specific directory structure with dependencies.
45+
## Unit Tests
4946

50-
* Implement events appropriately, both custom and non-custom. The 'complete' event for `deploy` and `invoke` is currently implemented by simply waiting a set number of seconds (5 for invoke, 20 for deploy). It needs to receive a complete event from the server with the result of the transaction and make this available to the caller. This has not yet been implemented.
47+
HFC includes a set of unit tests implemented with the [tape framework](https://github.com/substack/tape). Currently, the unit tests are designed to run inside the Hyperledger Fabric Vagrant development environment. To run the unit tests, first set up the Hyperledger Fabric Vagrant development environment per the instructions [here](http://hyperledger-fabric.readthedocs.io/en/latest/dev-setup/devenv/).
5148

52-
* Support SHA2. HFC currently supports SHA3.
49+
Launch the Vagrant VM and log into the VM by executing the following command:
50+
51+
vagrant ssh
52+
53+
Run the unit tests within the Vagrant environment with the following commands:
54+
55+
cd $GOPATH/src/github.com/hyperledger/fabric
56+
make node-sdk-unit-tests
57+
58+
The following are brief descriptions of each of the unit tests that are being run.
59+
60+
#### registrar
61+
62+
The [registrar.js](https://github.com/hyperledger/fabric/blob/master/sdk/node/test/unit/registrar.js) test case exercises registering users with the membership services server. It also tests registering a designated registrar user which can then register additional users.
63+
64+
#### chain-tests
65+
66+
The [chain-tests.js](https://github.com/hyperledger/fabric/blob/master/sdk/node/test/unit/chain-tests.js) test case exercises the [chaincode_example02.go](https://github.com/hyperledger/fabric/tree/master/examples/chaincode/go/chaincode_example02) chaincode when it has been deployed in both development mode and network mode.
67+
68+
#### asset-mgmt
69+
70+
The [asset-mgmt.js](https://github.com/hyperledger/fabric/blob/master/sdk/node/test/unit/asset-mgmt.js) test case exercises the [asset_management.go](https://github.com/hyperledger/fabric/tree/master/examples/chaincode/go/asset_management) chaincode when it has been deployed in both development mode and network mode.
71+
72+
#### asset-mgmt-with-roles
73+
74+
The [asset-mgmt-with-roles.js](https://github.com/hyperledger/fabric/blob/master/sdk/node/test/unit/asset-mgmt-with-roles.js) test case exercises the [asset_management_with_roles.go](https://github.com/hyperledger/fabric/tree/master/examples/chaincode/go/asset_management_with_roles) chaincode when it has been deployed in both development mode and network mode.
75+
76+
## Basic Troubleshooting
77+
78+
Keep in mind that you can perform the enrollment process with the membership services server only once, as the enrollmentSecret is a one-time-use password. If you have performed a user registration/enrollment with the membership services and subsequently deleted the crypto tokens stored on the client side, the next time you try to enroll, errors similar to the ones below will be seen.
79+
80+
```
81+
Error: identity or token do not match
82+
```
83+
```
84+
Error: user is already registered
85+
```
86+
87+
To address this, remove any stored crypto material from the CA server by following the instructions [here](https://github.com/hyperledger/fabric/blob/master/docs/Setup/Chaincode-setup.md#removing-temporary-files-when-security-is-enabled). You will also need to remove any of the crypto tokens stored on the client side by deleting the KeyValStore directory. That directory is configurable and is set to `/tmp/keyValStore` within the unit tests.
88+
89+
## Support
90+
91+
We use [Hyperledger Slack](https://hyperledgerproject.slack.com/) for communication regarding the SDK and any potential issues. Please join SDK related channels on Slack such as #fabric-sdk and #nodesdk. If you would like to file a bug report or submit a request for a feature please do so on Jira [here](https://jira.hyperledger.org).
92+
93+
## Contributing
94+
95+
We welcome any contributions to the Hyperledger Fabric Node.js SDK project. If you would like to contribute please read the contribution guidelines [here](http://hyperledger-fabric.readthedocs.io/en/latest/CONTRIBUTING/) for more information.
96+
97+
## License
98+
99+
Contributed to the Hyperledger Project under the [Apache Software License 2.0](https://github.com/hyperledger/fabric/blob/master/LICENSE).

sdk/node/package.json

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
{
22
"name": "hfc",
3-
"version": "0.0.2",
3+
"version": "0.6.2",
4+
"description": "The Hyperledger Fabric Client SDK (HFC) provides a powerful and easy to use API to interact with a Hyperledger Fabric blockchain.",
5+
"keywords": [
6+
"hfc",
7+
"hyperledger",
8+
"blockchain"
9+
],
410
"bin": "./bin/main.js",
511
"typings": "hfc.d.ts",
612
"main": "index.js",
13+
"repository": {
14+
"type": "github",
15+
"url": "https://github.com/hyperledger/fabric"
16+
},
717
"dependencies": {
818
"aes-js": "^1.0.0",
919
"asn1": "https://github.com/mcavage/node-asn1",
@@ -36,5 +46,6 @@
3646
"devDependencies": {
3747
"tape": "^4.5.1",
3848
"x509": "^0.2.6"
39-
}
49+
},
50+
"license": "Apache License v2.0"
4051
}

0 commit comments

Comments
 (0)