New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ibm-blockchain-js

Package Overview
Dependencies
Maintainers
2
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ibm-blockchain-js - npm Package Compare versions

Comparing version 1.2.4 to 1.2.5

62

index.js

@@ -110,3 +110,3 @@ 'use strict';

async.each(arr, function(i, a_cb) {
if(options.network.users[i]){ //make sure we still have a enrollID for this network
if(options.network.users[i]){ //make sure we still have a enrollId for this network
var maxRetry = 2;

@@ -603,6 +603,6 @@ if(options.network.options && options.network.options.maxRetry) maxRetry = options.network.options.maxRetry;

cb = enrollId;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}
if(enrollId == null) { //if enrollId not provided, use known valid one
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}

@@ -645,8 +645,8 @@

//============================================================================================================================
ibc.prototype.register = function(index, enrollID, enrollSecret, maxRetry, cb) {
register(index, enrollID, enrollSecret, maxRetry, 1, cb);
ibc.prototype.register = function(index, enrollId, enrollSecret, maxRetry, cb) {
register(index, enrollId, enrollSecret, maxRetry, 1, cb);
};
function register(index, enrollID, enrollSecret, maxRetry, attempt, cb){
logger.log('[ibc-js] Registering ', ibc.chaincode.details.peers[index].name, ' w/enrollID - ' + enrollID);
function register(index, enrollId, enrollSecret, maxRetry, attempt, cb){
logger.log('[ibc-js] Registering ', ibc.chaincode.details.peers[index].name, ' w/enrollId - ' + enrollId);
var options = {

@@ -660,3 +660,3 @@ path: '/registrar',

var body = {
enrollId: enrollID,
enrollId: enrollId,
enrollSecret: enrollSecret

@@ -666,11 +666,11 @@ };

options.success = function(statusCode, data){
logger.log('[ibc-js] Registration success x' + attempt + ' :', enrollID);
ibc.chaincode.details.peers[index].enrollID = enrollID; //remember a valid enrollID for this peer
logger.log('[ibc-js] Registration success x' + attempt + ' :', enrollId);
ibc.chaincode.details.peers[index].enrollId = enrollId; //remember a valid enrollId for this peer
if(cb) cb(null, data);
};
options.failure = function(statusCode, e){
logger.error('[ibc-js] Register - failure x' + attempt + ' :', enrollID, statusCode);
logger.error('[ibc-js] Register - failure x' + attempt + ' :', enrollId, statusCode);
if(attempt <= maxRetry){ //lets try again after a short delay, maybe the peer is still starting
logger.log('[ibc-js] \tgoing to try to register again in 30 secs');
setTimeout(function(){register(index, enrollID, enrollSecret, maxRetry, ++attempt, cb);}, 30000);
setTimeout(function(){register(index, enrollId, enrollSecret, maxRetry, ++attempt, cb);}, 30000);
}

@@ -685,8 +685,8 @@ else{

//============================================================================================================================
// EXTERNAL - unregister() - unregister a enrollId from a peer (only for a blockchain network with membership), enrollID can no longer make transactions
// EXTERNAL - unregister() - unregister a enrollId from a peer (only for a blockchain network with membership), enrollId can no longer make transactions
//============================================================================================================================
ibc.prototype.unregister = function(index, enrollID, cb) {
logger.log('[ibc-js] Unregistering ', ibc.chaincode.details.peers[index].name, ' w/enrollID - ' + enrollID);
ibc.prototype.unregister = function(index, enrollId, cb) {
logger.log('[ibc-js] Unregistering ', ibc.chaincode.details.peers[index].name, ' w/enrollId - ' + enrollId);
var options = {
path: '/registrar/' + enrollID,
path: '/registrar/' + enrollId,
host: ibc.chaincode.details.peers[index].api_host,

@@ -698,8 +698,8 @@ port: pick_port(index),

options.success = function(statusCode, data){
logger.log('[ibc-js] Unregistering success:', enrollID);
ibc.chaincode.details.peers[index].enrollID = null; //unremember a valid enrollID for this peer
logger.log('[ibc-js] Unregistering success:', enrollId);
ibc.chaincode.details.peers[index].enrollId = null; //unremember a valid enrollId for this peer
if(cb) cb(null, data);
};
options.failure = function(statusCode, e){
logger.log('[ibc-js] Unregistering - failure:', enrollID, statusCode);
logger.log('[ibc-js] Unregistering - failure:', enrollId, statusCode);
if(cb) cb(helper.eFmt('unregister() error', statusCode, e), null);

@@ -711,8 +711,8 @@ };

//============================================================================================================================
// EXTERNAL - check_register() - check if a enrollID is registered or not with a peer
// EXTERNAL - check_register() - check if a enrollId is registered or not with a peer
//============================================================================================================================
ibc.prototype.check_register = function(index, enrollID, cb) {
logger.log('[ibc-js] Checking ', ibc.chaincode.details.peers[index].name, ' w/enrollID - ' + enrollID);
ibc.prototype.check_register = function(index, enrollId, cb) {
logger.log('[ibc-js] Checking ', ibc.chaincode.details.peers[index].name, ' w/enrollId - ' + enrollId);
var options = {
path: '/registrar/' + enrollID,
path: '/registrar/' + enrollId,
host: ibc.chaincode.details.peers[index].api_host,

@@ -724,7 +724,7 @@ port: pick_port(index),

options.success = function(statusCode, data){
logger.log('[ibc-js] Check Register success:', enrollID);
logger.log('[ibc-js] Check Register success:', enrollId);
if(cb) cb(null, data);
};
options.failure = function(statusCode, e){
logger.error('[ibc-js] Check Register - failure:', enrollID, statusCode);
logger.error('[ibc-js] Check Register - failure:', enrollId, statusCode);
if(cb) cb(helper.eFmt('check_register() error', statusCode, e), null);

@@ -741,6 +741,6 @@ };

cb = enrollId;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}
if(enrollId == null) { //if enrollId not provided, use known valid one
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}

@@ -912,6 +912,6 @@

cb = enrollId;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}
if(enrollId == null) { //if enrollId not provided, use known valid one
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}

@@ -983,6 +983,6 @@

cb = enrollId;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}
if(enrollId == null) { //if enrollId not provided, use known valid one
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollID;
enrollId = ibc.chaincode.details.peers[ibc.selectedPeer].enrollId;
}

@@ -989,0 +989,0 @@

{
"name": "ibm-blockchain-js",
"version": "1.2.4",
"version": "1.2.5",
"description": "A library for easily interacting with IBM Blockchain.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -63,3 +63,3 @@ *Are you looking for the Marbles app demo? That’s not here, head to the [marbles example](https://github.com/IBM-Blockchain/marbles)*

users: [{
"enrollID": "user1",
"enrollId": "user1",
"enrollSecret": "xxxxxxxx"

@@ -184,5 +184,5 @@ }],

1. ibc.network(options.network.peers, options.network.options) *check out other options in ibc.network()*
1. ibc.network(options.network.peers, options.network.options) *check out other options in [ibc.network()](#ibcnetworkarraypeers-optionsk)*
1. ibc.register(...)
- It will register the first peer with the first enrollID, the 2nd peer against the 2nd enrollID and so on.
- It will register the first peer with the first enrollId, the 2nd peer against the 2nd enrollId and so on.
- This function only runs if valid users are found in options.network.users. A valid user is one that contains 'type_1'.

@@ -193,2 +193,6 @@ - Any errors in register will stop execution and run callback(err).

Options
- **maxRetry** = integer - number of times to retry this call before giving up.
- [more] - same options as the function ibc.network(), [see network()](#ibcnetworkarraypeers-optionsk) for details
Ex:

@@ -206,3 +210,3 @@

users: [{
"enrollID": "user1",
"enrollId": "user1",
"enrollSecret": "xxxxxxxx"

@@ -213,3 +217,4 @@ }],

timeout: 60000,
tls: false
tls: true,
maxRetry: 3
}

@@ -219,4 +224,4 @@ },

zip_url: 'https://github.com/ibm-blockchain/marbles-chaincode/archive/master.zip', //http/https of a link to download zip
unzip_dir: 'marbles-chaincode-master/part2_v1.0.0', //name/path to folder that contains the chaincode you want to deploy (path relative to unzipped root)
git_url: 'https://github.com/ibm-blockchain/marbles-chaincode/part2_v1.0.0', //git https URL. should point to the desired chaincode repo AND directory
unzip_dir: 'marbles-chaincode-master/part2_v1.0.0', //name/path to folder that contains the chaincode you want to deploy (path relative to unzipped root)
git_url: 'https://github.com/ibm-blockchain/marbles-chaincode/part2_v1.0.0', //git https URL. should point to the desired chaincode repo AND directory

@@ -256,5 +261,5 @@ deployed_name: null //[optional] this is the hashed name of a deployed chaincode. if you want to run with chaincode that is already deployed set it now, else it will be set when you deploy with the sdk

The optional options parameter should be an object with the field `quiet` and/or `timeout`.
- quiet = boolean - when true will print out only minimal HTTP debug information. Defaults `true`.
- timeout = integer - time in ms to wait for a http response. Defaults `60000`.
- tls = boolean - when `false` will use HTTP instead of HTTPS. Defaults `true`.
- **quiet** = boolean - when true will print out only minimal HTTP debug information. Defaults `true`.
- **timeout** = integer - time in ms to wait for a http response. Defaults `60000`.
- **tls** = boolean - when `false` will use HTTP instead of HTTPS. Defaults `true`.

@@ -266,11 +271,17 @@ Ex:

{
"api_host": "xxx.xxx.xxx.xxx",
"api_port": "xxxxx",
"api_port_tls": "xxx",
"id": "xxxxxx-xxxx-xxx-xxx-xxxxxxxxxxxx_vpx"
"api_host": "xxx.xxx.xxx.xxx", //ip or hostname of api for this peer
"api_port": "xxxxx", //port for api, non tls
"api_port_tls": "xxx", //port for api with tls.
"id": "xxxxxx-xxxx-xxx-xxx-xxxxxxxxxxxx_vpx" //unique id of peer (string)
}
]
ibc.network(peers, {quiet: false, timeout: 120000});
ibc.network(peers, {quiet: false, timeout: 120000}); //can pass config options
```
Note **only** the field names you see above (`api_host`, `api_port`, `api_port_tls`, `id`) are required.
If you are using a Bluemix network you will see lots of other fields in the credentials JSON blob, but they are not needed.
Its also fine to include the extra fields.
You can ommit the field `api_port_tls` if your network does not support tls.
Make sure the `options.tls` is `true`.
### ibc.save(path [callback])

@@ -362,10 +373,10 @@ Save the [Chaincode Summary File](#ccsf) to a path.

### ibc.register(peerIndex, enrollID, enrollsecret, maxRetry, [callback])
### ibc.register(peerIndex, enrollId, enrollsecret, maxRetry, [callback])
Only applicable on a network with security enabled.
`register()` will register against peer[peerIndex] with the provided credentials.
If successful, the peer will now use this `enrollID` to perform any http requests.
- peerIndex = integer - position of peer in peers array (the one you fed ibc.networks()) you want to register against.
- enrollID = string - name of secure context user.
- enrollSecret = string - password/secret/api key of secure context user.
- maxRetry = integer - number of times to retry this call before giving up.
If successful, the peer will now use this `enrollId` to perform any http requests.
- **peerIndex** = integer - position of peer in peers array (the one you fed ibc.networks()) you want to register against.
- **enrollId** = string - name of secure context user.
- **enrollSecret** = string - password/secret/api key of secure context user.
- **maxRetry** = integer - number of times to retry this call before giving up.

@@ -410,12 +421,12 @@ Ex:

### chaincode.deploy(func, args, [options], [enrollID], [callback])
### chaincode.deploy(func, args, [options], [enrollId], [callback])
Deploy the chaincode.
Call GoLang function named 'func' and feed it 'args'.
Usually "args" is an array of strings.
The `enrollID` parameter should be the desired secure context enrollID that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollID for the selected peer. (this is only relevant in a permissioned network)
The `enrollId` parameter should be the desired secure context enrollId that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollId for the selected peer. (this is only relevant in a permissioned network)
Options:
- save_path = save the [Chaincode Summary File](#ccsf) to 'save_path'.
- delay_ms = time in milliseconds to postpone the callback after deploy. Default is `40000`
- **save_path** = save the [Chaincode Summary File](#ccsf) to 'save_path'.
- **delay_ms** = time in milliseconds to postpone the callback after deploy. Default is `40000`

@@ -428,7 +439,7 @@ Ex:

### chaincode.query.CUSTOM_FUNCTION_NAME(args, [enrollID], [callback])
### chaincode.query.CUSTOM_FUNCTION_NAME(args, [enrollId], [callback])
Will invoke your Go function CUSTOM_FUNCTION_NAME and pass it `args`.
Usually `args` is an array of strings.
The `enrollID` parameter should be the desired secure context enrollID that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollID for the selected peer. (this is only relevant in a permissioned network)
The `enrollId` parameter should be the desired secure context enrollId that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollId for the selected peer. (this is only relevant in a permissioned network)

@@ -443,7 +454,7 @@ Ex:

### chaincode.invoke.CUSTOM_FUNCTION_NAME(args, [enrollID], [callback])
### chaincode.invoke.CUSTOM_FUNCTION_NAME(args, [enrollId], [callback])
Will query your Go function CUSTOM_FUNCTION_NAME and pass it `args`.
Usually `args` is an array of strings.
The `enrollID` parameter should be the desired secure context enrollID that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollID for the selected peer. (this is only relevant in a permissioned network)
The `enrollId` parameter should be the desired secure context enrollId that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollId for the selected peer. (this is only relevant in a permissioned network)

@@ -458,3 +469,3 @@ Ex:

### chaincode.query.read(name, [enrollID], [callback]) *depreciated 4/1/2016*
### chaincode.query.read(name, [enrollId], [callback]) *depreciated 4/1/2016*
*This function is only here to help people transition from ibc v0.0.x to v1.x.x.*

@@ -467,4 +478,4 @@ *You should create your own read() function in your chaincode which will overwrite this prebuilt one.*

This will call the `Query()` function in the Go chaincode.
The `enrollID` parameter should be the desired secure context enrollID that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollID for the selected peer. (this is only relevant in a permissioned network)
The `enrollId` parameter should be the desired secure context enrollId that has already been registered against the selected peer.
If left `null` the SDK will use a known enrollId for the selected peer. (this is only relevant in a permissioned network)

@@ -542,3 +553,3 @@ ***

"tls": false,
"enrollID": "user1"
"enrollId": "user1"
}],

@@ -561,4 +572,4 @@ "timestamp": 1459779181971,

- Correct behavior of `ibc.load()` is to remove any enrollIDs that do not contain 'type_1' in their name.
This is to conform to the OBC Peer spec of what enrollIDs a dev's app should use.
- Correct behavior of `ibc.load()` is to remove any enrollIds that do not contain 'type_1' in their name.
This is to conform to the OBC Peer spec of what enrollIds a dev's app should use.
If this is not applicable for your network (ie you have a custom IBM Blockchain network) you can easily create your own version of `ibc.load()` for your needs.

@@ -565,0 +576,0 @@ I would copy the code found in `ibc.load()` then modify it to fit your own needs.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc