Skip to content

Commit

Permalink
Renaming the packages to official names
Browse files Browse the repository at this point in the history
[FAB-1897]
Per discussions in the community, package names for the node.js
SDK has been changed like the following:
- hfc to fabric-client
- hfc-cop to fabric-ca-client

This is step 1 of the alpha release activities [FAB-1896]

Change-Id: Ic2cc80bfd467c22c1fe3a6b37a62159bf258aedd
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Jan 27, 2017
1 parent 4bd1a9d commit fd85330
Show file tree
Hide file tree
Showing 85 changed files with 2,238 additions and 151 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![Build Status](https://jenkins.hyperledger.org/buildStatus/icon?job=fabric-sdk-node-merge-x86_64)](https://jenkins.hyperledger.org/view/fabric-sdk-node/job/fabric-sdk-node-merge-x86_64/)
[![Documentation Status](https://readthedocs.org/projects/fabric-sdk-node/badge/?version=master)](http://fabric-sdk-node.readthedocs.io/en/master/?badge=master)

The Hyperledger Fabric Client SDK (HFC) makes it easy to use APIs to interact with a Hyperledger Fabric blockchain.
The Hyperledger Fabric Client SDK makes it easy to use APIs to interact with a Hyperledger Fabric blockchain.

As an application developer, 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).

Expand All @@ -19,13 +19,13 @@ To build and test, the following pre-requisites must be installed first:
Clone the project and launch the following commands to install the dependencies and perform various tasks.

This project publishes two separate npm packages:
* `hfc` - main client for the Hyperledger Fabric. Applications can use this package to deploy chaincodes, submit transactions and make queries against a Hyperledger Fabric-based blockchain network.
* `hfc-cop` - client for the optional component in Hyperledger Fabric, [fabric-ca](https://github.com/hyperledger/fabric-ca). The fabric-ca component allows applications to enroll Peers and application users to establish trusted identities on the blockchain network. It also provides support for pseudonymous transaction submissions with Transaction Certificates. If the target blockchain network is configured with standard Certificate Authorities for trust anchors, then the application does not need to use this package.
* `fabric-client` - main client for the Hyperledger Fabric. Applications can use this package to deploy chaincodes, submit transactions and make queries against a Hyperledger Fabric-based blockchain network.
* `fabric-ca-client` - client for the optional component in Hyperledger Fabric, [fabric-ca](https://github.com/hyperledger/fabric-ca). The fabric-ca component allows applications to enroll Peers and application users to establish trusted identities on the blockchain network. It also provides support for pseudonymous transaction submissions with Transaction Certificates. If the target blockchain network is configured with standard Certificate Authorities for trust anchors, then the application does not need to use this package.

In the project root folder:
* `npm install` to install dependencies
* `gulp cop` to copy common dependent modules from the `hfc` folder to the `hfc-cop` folder
* `gulp watch` to set up watch that updates hfc-cop's shared dependencies from hfc/lib and updates installed hfc and hfc-cop modules in node_modules. This command does not return, so you should keep it running in a separate command window as you work on the code and test in another command window
* `gulp ca` to copy common dependent modules from the `fabric-client` folder to the `fabric-ca-client` folder
* `gulp watch` to set up watch that updates fabric-ca-client's shared dependencies from fabric-client/lib and updates installed fabric-client and fabric-ca-client modules in node_modules. This command does not return, so you should keep it running in a separate command window as you work on the code and test in another command window
* optionally, `gulp doc` to generate API docs if you want to review the doc content
* `npm test` to run the headless tests that do not require any additional set up

Expand Down Expand Up @@ -144,4 +144,4 @@ HFC defines the following abstract classes for application developers to supply

2. The cryptography suite used by the default implementation uses ECDSA for asymmetric keys cryptography, AES for encryption and SHA2/3 for secure hashes. A different suite can be plugged in with "CRYPTO_SUITE" environment variable specifying full require() path to the alternative implementation of the api.CrytoSuite abstract class.

3. If the user application uses an alternative membership service than the one provided by the component `fabric-ca`, the client code will likely need to use an alternative client to `hfc-cop` to interact with that membership service.
3. If the user application uses an alternative membership service than the one provided by the component `fabric-ca`, the client code will likely need to use an alternative client to `fabric-ca-client` to interact with that membership service.
24 changes: 24 additions & 0 deletions build/tasks/ca.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

var gulp = require('gulp');
var debug = require('gulp-debug');

const DEPS = [
'fabric-client/lib/api.js',
'fabric-client/lib/hash.js',
'fabric-client/lib/utils.js',
'fabric-client/lib/Config.js',
'fabric-client/lib/Remote.js',
'fabric-client/lib/impl/CouchDBKeyValueStore.js',
'fabric-client/lib/impl/CryptoSuite_ECDSA_AES.js',
'fabric-client/lib/impl/ecdsa/*',
'fabric-client/lib/impl/FileKeyValueStore.js'
];

gulp.task('ca', function() {
return gulp.src(DEPS, { base: 'fabric-client/' })
.pipe(debug())
.pipe(gulp.dest('fabric-ca-client/'));
});

module.exports.DEPS = DEPS;
24 changes: 0 additions & 24 deletions build/tasks/cop.js

This file was deleted.

26 changes: 13 additions & 13 deletions build/tasks/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ var jsdoc = require('gulp-jsdoc3');
gulp.task('doc', function () {
gulp.src([
'README.md',
'hfc/index.js',
'hfc/lib/api.js',
'hfc/lib/impl/FileKeyValueStore.js',
'hfc/lib/impl/CouchDBKeyValueStore.js',
'hfc/lib/impl/CryptoSuite_ECDSA_AES.js',
'hfc/lib/impl/ecdsa/key.js',
'hfc/lib/Chain.js',
'hfc/lib/Peer.js',
'hfc/lib/User.js',
'hfc/lib/Client.js',
'hfc/lib/X509Certificate.js',
'hfc-cop/index.js',
'hfc-cop/lib/FabricCOPImpl.js'
'fabric-client/index.js',
'fabric-client/lib/api.js',
'fabric-client/lib/impl/FileKeyValueStore.js',
'fabric-client/lib/impl/CouchDBKeyValueStore.js',
'fabric-client/lib/impl/CryptoSuite_ECDSA_AES.js',
'fabric-client/lib/impl/ecdsa/key.js',
'fabric-client/lib/Chain.js',
'fabric-client/lib/Peer.js',
'fabric-client/lib/User.js',
'fabric-client/lib/Client.js',
'fabric-client/lib/X509Certificate.js',
'fabric-ca-client/index.js',
'fabric-ca-client/lib/FabricCAClientImpl.js'
], {read: false})
.pipe(jsdoc())
.pipe(gulp.dest('./docs/gen'));
Expand Down
2 changes: 1 addition & 1 deletion build/tasks/eslint.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var gulp = require('gulp');
var eslint = require('gulp-eslint');

gulp.task('lint', function () {
return gulp.src(['**/*.js', 'hfc/**/*.js', '!node_modules/**', '!docs/**', '!coverage/**', '!tmp/**', 'hfc-cop/lib/*.js'])
return gulp.src(['**/*.js', 'fabric-client/**/*.js', '!node_modules/**', '!docs/**', '!coverage/**', '!tmp/**', 'fabric-ca-client/lib/*.js'])
.pipe(eslint(
{
env: ['es6', 'node'],
Expand Down
4 changes: 2 additions & 2 deletions build/tasks/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ var istanbul = require('gulp-istanbul');

gulp.task('pre-test', function() {
return gulp.src([
'node_modules/hfc/lib/**/*.js',
'node_modules/hfc-cop/lib/FabricCOPImpl.js'])
'node_modules/fabric-client/lib/**/*.js',
'node_modules/fabric-ca-client/lib/FabricCAClientImpl.js'])
.pipe(istanbul())
.pipe(istanbul.hookRequire());
});
Expand Down
18 changes: 9 additions & 9 deletions build/tasks/watch.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
var gulp = require('gulp'),
watch = require('gulp-watch'),
debug = require('gulp-debug'),
cop = require('./cop.js');
ca = require('./ca.js');

gulp.task('watch', function () {
watch(cop.DEPS, { ignoreInitial: false, base: 'hfc/' })
watch(ca.DEPS, { ignoreInitial: false, base: 'fabric-client/' })
.pipe(debug())
.pipe(gulp.dest('hfc-cop/'));
.pipe(gulp.dest('fabric-ca-client/'));

watch([
'hfc/index.js',
'hfc/config/**/*',
'hfc/lib/**/*',
'hfc-cop/index.js',
'hfc-cop/config/**/*',
'hfc-cop/lib/**/*'
'fabric-client/index.js',
'fabric-client/config/**/*',
'fabric-client/lib/**/*',
'fabric-ca-client/index.js',
'fabric-ca-client/config/**/*',
'fabric-ca-client/lib/**/*'
], { ignoreInitial: false, base: './' })
.pipe(debug())
.pipe(gulp.dest('node_modules'));
Expand Down
5 changes: 5 additions & 0 deletions fabric-ca-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Hyperledger Fabric Member Service Client for Node.js

This package encapsulates the APIs to interact with the Fabric member service to manage user certificates lifecycle such as register, enroll, renew and revoke. There is a separate package that interacts with Peers and Orderers of the Fabric network to deploy chaincodes, send transaction invocations and perform chaincode queries, and that is called `fabric-client`.

For application developer documentations, please visit [http://fabric-sdk-node.readthedocs.io/en/master/](http://fabric-sdk-node.readthedocs.io/en/master/)
File renamed without changes.
11 changes: 6 additions & 5 deletions hfc-cop/index.js → fabric-ca-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
*/

/**
* This is the pluggable module for the "hfc-cop" (Hyperledger Fabric Client Membership Services
* aka "COP") package. COP is not an acronym. The name was selected because:
* - it provides police-like security functionality for Hyperledger Fabric, and
* - it is shorter and easier to say and write “COP” rather than “Membership Services"
* This is the main module for the "fabric-ca-client" package. It communicates with the
* "fabric-ca" server to manage user certificates lifecycle including register, enroll,
* renew and revoke, so that the application can use the properly signed certificates to
* authenticate with the fabric
*
* @module hfc-cop
* @module fabric-ca-client
*/
module.exports = require('./lib/FabricCAClientImpl.js');
2 changes: 1 addition & 1 deletion hfc/lib/Config.js → fabric-ca-client/lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/**
* This is the configuration class for the "hfc" (Hyperledger Fabric Client) package.
* This is the configuration class for the "fabric-client" package.
* It provides all configuration settings using "config" node.js package to retrieve the
* settings from JSON based files, environment settings, and command line startup settings
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var https = require('https');
var urlParser = require('url');


var logger = utils.getLogger('FabricCOPImpl.js');
var logger = utils.getLogger('FabricCAClientImpl.js');

/**
* This is an implementation of the member service client which communicates with the Fabric COP server.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions hfc-cop/package.json → fabric-ca-client/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hfc-cop",
"version": "0.0.1",
"main": "./lib/FabricCOPImpl.js",
"name": "fabric-ca-client",
"version": "0.1.0",
"main": "index.js",
"repository": {
"type": "gerrit",
"url": "http://gerrit.hyperledger.org/r/fabric-sdk-node"
Expand Down
5 changes: 5 additions & 0 deletions fabric-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Hyperledger Fabric Client for Node.js

This package encapsulates the APIs to interact with Peers and Orderers of the Fabric network to deploy chaincodes, send transaction invocations and perform chaincode queries. There is a separate package that interacts with the Fabric member service to manage user certificates lifecycle such as register, enroll, renew and revoke, and that is called `fabric-ca-client`.

For application developer documentations, please visit [http://fabric-sdk-node.readthedocs.io/en/master/](http://fabric-sdk-node.readthedocs.io/en/master/)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"crypto-keysize": 256,
"crypto-suite": "./impl/CryptoSuite_ECDSA_AES.js",
"key-value-store": "./impl/FileKeyValueStore.js",
"member-service": "./impl/FabricCOPImpl.js",
"nonce-size" : 24,
"dockerfile-contents" : "from hyperledger/fabric-ccenv\nCOPY . $GOPATH/src/build-chaincode/\nWORKDIR $GOPATH\n\nRUN go install build-chaincode && mv $GOPATH/bin/build-chaincode $GOPATH/bin/%s"
}
4 changes: 2 additions & 2 deletions hfc/index.js → fabric-client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

/**
* This is the main module for the "hfc" (Hyperledger Fabric Client) package. It provides the convenience
* This is the main module for the "fabric-client" package. It provides the convenience
* APIs to the classes of the package including [Chain]{@link module:api.Chain}
*
* @module hfc
* @module fabric-client
*/

module.exports = require('./lib/Client.js');
File renamed without changes.
File renamed without changes.
152 changes: 152 additions & 0 deletions fabric-client/lib/Config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
/**
* Copyright 2016 IBM All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* This is the configuration class for the "fabric-client" package.
* It provides all configuration settings using "config" node.js package to retrieve the
* settings from JSON based files, environment settings, and command line startup settings
*
* configuration settings will be overridden in this order
* first files are loaded in this order
* $NODE_CONFIG_DIR/default.json
* $NODE_CONFIG_DIR/$NODE_ENV.json
*
* NODE_CONFIG_DIR defaults to './config' the configuration directory is relative to where the application is started
* NODE_ENV defaults to 'development'
*
* then then following environment setting will override file settings
* $NODE_CONFIG
* $ export NODE_CONFIG='{"request-timeout": 3000 }'
*
* then the command line setting will override all
* node myapp.js --NODE_CONFIG='{"request-timeout": 7000 }'
*
*
* see the following for complete information on the configuration settings
* https://www.npmjs.com/package/config
*/

'use strict';

var nconf = require('nconf');
var path = require('path');

//
// The class representing the hierarchy of configuration settings.
//
//

var Config = class {

// Setup nconf to use (search order):
// 1. in memory - all settings added with utils.setConfigSetting(name,value)
// 2. Command-line arguments
// 3. Environment variables (names will be change from AAA-BBB to aaa-bbb)
// 4. user Files - all files added with the addConfigFile(path)
// will be ordered by when added, were last one added will override previously added files
// 5. The file located at 'config/default.json' with default settings
//
constructor() {
nconf.use('memory');
nconf.argv();
nconf.env();
nconf.use('mapenv', {type:'memory'});
this.mapSettings(nconf.stores['mapenv'], process.env);
this._fileStores = [];
// reference to configuration settings
this._config = nconf;
// setup the location of the default config shipped with code
var default_config = path.resolve( __dirname, '../config/default.json');
this.reorderFileStores(default_config);
}

//
// utility method to map (convert) the environment(upper case and underscores) style
// names to configuration (lower case and dashes) style names
//
mapSettings(store, settings) {
for(var key in settings) {
var value = settings[key];
key = key.toLowerCase();
key = key.replace(/_/g, '-');
// if(store.get(key)) {
// throw new Error('Unable to map environment variable to configuration setting.
// There is another config setting with the same converted name:'+key);
// }
store.set(key,value);
}
}

//
// utility method to reload the file based stores so
// the last one added is on the top of the files hierarchy
//
reorderFileStores(path) {
// first remove all the file stores
for(var x in this._fileStores) {
this._config.remove(this._fileStores[x]);
}
// now add this new file store to the front of the list
this._fileStores.unshift(path);
// now load all the file stores
for(var x in this._fileStores) {
var name = this._fileStores[x];
this._config.file(name, name);
}
}

//
// Add an additional file
//
file(path) {
if(typeof path !== 'string') {
throw new Error('The "path" parameter must be a string');
}
// just reuse the path name as the store name...will be unique
this.reorderFileStores(path);
}

//
// Get the config setting with name.
// If the setting is not found returns the default value provided.
//
get(name, default_value) {
var return_value = null;

try {
return_value = this._config.get(name);
}
catch(err) {
return_value = default_value;
}

if(return_value === null || return_value === undefined) {
return_value = default_value;
}

return return_value;
}

//
// Set a value into the 'memory' store of config settings. This will override all other settings
//
set(name, value) {
this._config.set(name,value);
}

};

module.exports = Config;
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit fd85330

Please sign in to comment.