Skip to content

Latest commit

 

History

History
2287 lines (1681 loc) · 101 KB

api1.md

File metadata and controls

2287 lines (1681 loc) · 101 KB

Module

api

This module defines the API for the pluggable components of the node.js SDK. The APIs are defined according to the Hyperledger Fabric's common SDK specification

Classes

Chain

The class representing a chain with which the client SDK interacts.

The “Chain” object captures settings for a channel, which is created by the orderers to isolate transactions delivery to peers participating on channel. A chain must be initialized after it has been configured with the list of peers and orderers. The initialization sends a get configuration block request to the primary orderer to retrieve the configuration settings for this channel.

Client

Main interaction handler with end user. A client instance provides a handler to interact with a network of peers, orderers and optionally member services. An application using the SDK may need to interact with multiple networks, each through a separate instance of the Client.

Each client when initially created should be initialized with configuration data from the consensus service, which includes a list of trusted roots, orderer certificates and IP addresses, and a list of peer certificates and IP addresses that it can access. This must be done out of band as part of bootstrapping the application environment. It is also the responsibility of the application to maintain the configuration of a client as the SDK does not persist this object.

Each Client instance can maintain several Chain instances representing channels and the associated private ledgers.

ChainCodeCBE

The ChainCodeCBE is used internal to the EventHub to hold chaincode event registration callbacks.

EventHub

The EventHub class is used to distribute events from an event source(peer)

CouchDBKeyValueStore

This is a sample database implementation of the KeyValueStore API. It uses a local or remote CouchDB database instance to store the keys.

CryptoSuite_ECDSA_AES

The CryptoSuite implementation for ECDSA, and AES algorithms using software key generation. This class implements a software-based key generation (as opposed to Hardware Security Module based key management)

KeyValueStore

This is a default implementation of the KeyValueStore API. It uses files to store the key values.

Identity

This interface is shared within the peer and client API of the membership service provider. Identity interface defines operations associated to a "certificate". That is, the public part of the identity could be thought to be a certificate, and offers solely signature verification capabilities. This is to be used at the client side when validating certificates that endorsements are signed with, and verifying signatures that correspond to these certificates.

Signer

Signer is an interface for an opaque private key that can be used for signing operations

SigningIdentity

SigningIdentity is an extension of Identity to cover signing capabilities. E.g., signing identity should be requested in the case of a client who wishes to sign proposal responses and transactions

MSPManager

MSPManager is an interface defining a manager of one or more MSPs. This essentially acts as a mediator to MSP calls and routes MSP related calls to the appropriate MSP. This object is immutable, it is initialized once and never changed.

MSP

MSP is the minimal Membership Service Provider Interface to be implemented to manage identities (in terms of signing and signature verification) represented by private keys and certificates generated from different algorithms (ECDSA, RSA, etc) and PKIs (software-managed or HSM based)

Orderer

The Orderer class represents a peer in the target blockchain network to which HFC sends a block of transactions of endorsed proposals requiring ordering.

Peer

The Peer class represents a peer in the target blockchain network to which HFC sends endorsement proposals, transaction ordering or query requests.

The Peer class represents the remote Peer node and its network membership materials, aka the ECert used to verify signatures. Peer membership represents organizations, unlike User membership which represents individuals.

When constructed, a Peer instance can be designated as an event source, in which case a “eventSourceUrl” attribute should be configured. This allows the SDK to automatically attach transaction event listeners to the event stream.

It should be noted that Peer event streams function at the Peer level and not at the chain and chaincode levels.

Remote

The Remote class represents a the base class for all remote nodes, Peer, Orderer , and MemberServicespeer.

User

The User class represents users that have been enrolled and represented by an enrollment certificate (ECert) and a signing key. The ECert must have been signed by one of the CAs the blockchain network has been configured to trust. An enrolled user (having a signing key and ECert) can conduct chaincode instantiate, transactions and queries with the Chain.

User ECerts can be obtained from a CA beforehand as part of installing and instantiating the application, or it can be obtained from the optional Fabric CA service via its enrollment process.

Sometimes User identities are confused with Peer identities. User identities represent signing capability because it has access to the private key, while Peer identities in the context of the application/SDK only has the certificate for verifying signatures. An application cannot use the Peer identity to sign things because the application doesn’t have access to the Peer identity’s private key.

Members

sjcl

Implement hash primitives. Currently SHA3 is implemented, but needs to also add SHA2.

NOTE: This is in pure java script to be compatible with the sjcl.hmac function.

Functions

bitsToBytes(a)bytes

Convert from a bitArray to bytes (using SJCL's codec)

bytesToBits(a)bitArray

Convert from bytes to a bitArray (using SJCL's codec)

package(chaincodePath, chaincodeType, devmode)Promise

Utility function to package a chaincode. The contents will be returned as a byte array.

api

This module defines the API for the pluggable components of the node.js SDK. The APIs are defined according to the Hyperledger Fabric's common SDK specification

api.KeyValueStore

Abstract class for a Key-Value store. The Chain class uses this store to save sensitive information such as authenticated user's private keys, certificates, etc.

The SDK provides a default implementation based on files. An alternative implementation can be specified using the "KEY_VALUE_STORE" environment variable pointing to a full path to the require() package for the module.

Kind: static class of api

keyValueStore.getValue(name) ⇒

Get the value associated with name.

Kind: instance method of KeyValueStore
Returns: Promise for the value corresponding to the key. If the value does not exist in the store, returns null without rejecting the promise

Param Type Description
name string of the key

keyValueStore.setValue(name, value) ⇒ Promise

Set the value associated with name.

Kind: instance method of KeyValueStore
Returns: Promise - Promise for the 'value' object upon successful write operation

Param Type Description
name string of the key to save
value string to save

api.CryptoSuite

Abstract class for a suite of crypto algorithms used by the SDK to perform encryption, decryption and secure hashing. A complete suite includes libraries for asymmetric keys (such as ECDSA or RSA), symmetric keys (such as AES) and secure hash (such as SHA2/3).

The SDK provides a default implementation based on ECDSA + AES + SHA2/3. An alternative implementation can be specified using the "CRYPTO_SUITE" environment variable, pointing to a full path to the require() package for the module.

Kind: static class of api

cryptoSuite.generateKey(opts) ⇒ Key

Generate a key using the opts

Kind: instance method of CryptoSuite
Returns: Key - Promise of an instance of the Key class

Param Type Description
opts Object algorithm: an identifier for the algorithm to be used, such as "ECDSA" ephemeral: true if the key to generate has to be ephemeral

cryptoSuite.deriveKey(key, opts) ⇒ Key

Derives a key from k using opts.

Kind: instance method of CryptoSuite
Returns: Key - derived key

Param Type Description
key Key the source key
opts Object algorithm: an identifier for the algorithm to be used ephemeral: true if the key to generate has to be ephemeral

cryptoSuite.importKey(raw, opts) ⇒ Key

Imports a key from its raw representation using opts. If the opts.ephemeral parameter is false, the method, in addition to returning the imported Key instance, also saves the imported key in the key store as PEM files that can be retrieved using the 'getKey()' method

Kind: instance method of CryptoSuite
Returns: Key - Promise of an instance of the Key class wrapping the raw key bytes

Param Type Description
raw Array.<byte> Raw bytes of the key to import
opts Object
type: type of information that 'raw' represents: x509 certificate,
algorithm: an identifier for the algorithm to be used
ephemeral: true if the key to generate has to be ephemeral

cryptoSuite.getKey(ski) ⇒ Key

Returns the key this CSP associates to the Subject Key Identifier ski.

Kind: instance method of CryptoSuite
Returns: Key - Promise of an instance of the Key class corresponding to the ski

Param Type Description
ski Array.<byte> Subject Key Identifier specific to a Crypto Suite implementation

cryptoSuite.hash(msg, opts) ⇒ string

Hashes messages msg using options opts.

Kind: instance method of CryptoSuite
Returns: string - The hashed digest in hexidecimal string encoding

Param Type Description
msg Array.<byte> Source message to be hashed
opts Object algorithm: an identifier for the algorithm to be used, such as "SHA3"

cryptoSuite.sign(key, digest, opts) ⇒ Array.<byte>

Signs digest using key k. The opts argument should be appropriate for the algorithm used.

Kind: instance method of CryptoSuite
Returns: Array.<byte> - the resulting signature

Param Type Description
key Key Signing key (private key)
digest Array.<byte> The message digest to be signed. Note that when a signature of a hash of a larger message is needed, the caller is responsible for hashing the larger message and passing the hash (as digest) and the hash function (as opts) to sign.
opts Object hashingFunction: the function to use to hash

cryptoSuite.verify(key, signature, digest) ⇒ boolean

Verifies signature against key k and digest The opts argument should be appropriate for the algorithm used.

Kind: instance method of CryptoSuite
Returns: boolean - true if the signature verifies successfully

Param Type Description
key Key Signing verification key (public key)
signature Array.<byte> The signature to verify
digest Array.<byte> The digest that the signature was created for

cryptoSuite.encrypt(key, plainText, opts) ⇒ Array.<byte>

Encrypts plaintext using key k. The opts argument should be appropriate for the algorithm used.

Kind: instance method of CryptoSuite
Returns: Array.<byte> - Cipher text after encryption

Param Type Description
key Key Encryption key (public key)
plainText Array.<byte> Plain text to encrypt
opts Object Encryption options

cryptoSuite.decrypt(key, cipherText, opts) ⇒ Array.<byte>

Decrypts ciphertext using key k. The opts argument should be appropriate for the algorithm used.

Kind: instance method of CryptoSuite
Returns: Array.<byte> - Plain text after decryption

Param Type Description
key Key Decryption key (private key)
cipherText Array.<byte> Cipher text to decrypt
opts Object Decrypt options

api.Key

Key represents a cryptographic key. It can be symmetric or asymmetric. In the case of an asymmetric key, the key can be public or private. In the case of a private asymmetric key, the getPublicKey() method allows to retrieve the corresponding public-key. A key can be referenced via the Subject Key Identifier in DER or PEM encoding

Kind: static class of api

key.getSKI() ⇒ Array.<byte>

Returns the subject key identifier of this key in DER encoding for private keys or PEM encoding for public keys.

Kind: instance method of Key
Returns: Array.<byte> - the subject key identifier of this key

key.isSymmetric() ⇒ boolean

Returns true if this key is a symmetric key, false is this key is asymmetric

Kind: instance method of Key
Returns: boolean - if this key is a symmetric key

key.isPrivate() ⇒ boolean

Returns true if this key is an asymmetric private key, false otherwise.

Kind: instance method of Key
Returns: boolean - if this key is an asymmetric private key

key.getPublicKey() ⇒ Key

Returns the corresponding public key if this key is an asymmetric private key. If this key is already public, PublicKey returns this key itself.

Kind: instance method of Key
Returns: Key - the corresponding public key if this key is an asymmetric private key. If this key is already public, PublicKey returns this key itself.

key.toBytes() ⇒ Array.<byte>

Converts this key to its byte representation, if this operation is allowed.

Kind: instance method of Key
Returns: Array.<byte> - the byte representation of the key

Chain

The class representing a chain with which the client SDK interacts.

The “Chain” object captures settings for a channel, which is created by the orderers to isolate transactions delivery to peers participating on channel. A chain must be initialized after it has been configured with the list of peers and orderers. The initialization sends a get configuration block request to the primary orderer to retrieve the configuration settings for this channel.

Kind: global class

new Chain(name, clientContext)

Param Type Description
name string to identify different chain instances. The naming of chain instances is enforced by the ordering service and must be unique within the blockchain network
clientContext Client An instance of Client that provides operational context such as submitting User etc.

chain.initialize()

Retrieve the configuration from the primary orderer and initialize this chain (channel) with those values. Currently only the MSP config value of the channel is loaded into this chain.

Kind: instance method of Chain

chain.getName() ⇒ string

Get the chain name.

Kind: instance method of Chain
Returns: string - The name of the chain.

chain.isSecurityEnabled()

Determine if security is enabled.

Kind: instance method of Chain

chain.isPreFetchMode()

Determine if pre-fetch mode is enabled to prefetch tcerts.

Kind: instance method of Chain

chain.setPreFetchMode()

Set prefetch mode to true or false.

Kind: instance method of Chain

chain.isDevMode()

Determine if dev mode is enabled.

Kind: instance method of Chain

chain.setDevMode()

Set dev mode to true or false.

Kind: instance method of Chain

chain.getTCertBatchSize()

Get the tcert batch size.

Kind: instance method of Chain

chain.setTCertBatchSize()

Set the tcert batch size.

Kind: instance method of Chain

chain.getOrganizationUnits() ⇒ Array.<string>

Get organizational unit identifiers from the MSP's for this channel

Kind: instance method of Chain

chain.setMSPManager(the)

Set the MSP Manager for this channel This utility method will not normally be use as the initialize() method will read this channel's current configuration and reset MSPManager with the MSP's found.

Kind: instance method of Chain

Param Type Description
the MSPManager msp manager for this channel

chain.getMSPManager() ⇒ MSPManager

Get the MSP Manager for this channel

Kind: instance method of Chain

chain.addPeer(peer)

Add peer endpoint to chain.

Kind: instance method of Chain
Throws:

  • Error if the peer with that url already exists.
Param Type Description
peer Peer An instance of the Peer class that has been initialized with URL, TLC certificate, and enrollment certificate.

chain.removePeer(peer)

Remove peer endpoint from chain.

Kind: instance method of Chain

Param Type Description
peer Peer An instance of the Peer class.

chain.getPeers() ⇒ Array.<Peer>

Get peers of a chain from local information.

Kind: instance method of Chain
Returns: Array.<Peer> - The peer list on the chain.

chain.setPrimaryPeer(peer)

Set the primary peer The peer to use for doing queries. Peer must be a peer on this chain's peer list. Default: When no primary peer has been set the first peer on the list will be used.

Kind: instance method of Chain
Throws:

  • Error when peer is not on the existing peer list
Param Type Description
peer Peer An instance of the Peer class.

chain.getPrimaryPeer() ⇒ Peer

Get the primary peer The peer to use for doing queries. Default: When no primary peer has been set the first peer on the list will be used.

Kind: instance method of Chain
Returns: Peer - peer An instance of the Peer class.

chain.addOrderer(orderer)

Add orderer endpoint to a chain object, this is a local-only operation. A chain instance may choose to use a single orderer node, which will broadcast requests to the rest of the orderer network. Or if the application does not trust the orderer nodes, it can choose to use more than one by adding them to the chain instance. All APIs concerning the orderer will broadcast to all orderers simultaneously.

Kind: instance method of Chain
Throws:

  • Error if the orderer with that url already exists.
Param Type Description
orderer Orderer An instance of the Orderer class.

chain.removeOrderer(orderer)

Remove orderer endpoint from a chain object, this is a local-only operation.

Kind: instance method of Chain

Param Type Description
orderer Orderer An instance of the Orderer class.

chain.getOrderers()

Get orderers of a chain.

Kind: instance method of Chain

chain.createChannel(request) ⇒ boolean

Calls the orderer(s) to start building the new chain. Only one of the application instances needs to call this method. Once the chain is successfully created, this and other application instances only need to call joinChannel() to participate on the channel.

Kind: instance method of Chain
Returns: boolean - Whether the chain initialization process was successful.

Param Type Description
request Object An object containing the following field:
envelope : required - byte[] of the envelope object containing all required settings to initialize this channel

chain.joinChannel(request) ⇒ Promise

Sends a join channel proposal to one or more endorsing peers Will get the genesis block from the defined orderer to be used in the proposal.

Kind: instance method of Chain
Returns: Promise - A Promise for a ProposalResponse
See: /protos/peer/proposal_response.proto

Param Type Description
request Object An object containing the following fields:
targets : required - An array of Peer objects that will join this channel
txId : required - String of the transaction id
nonce : required - Integer of the once time number

chain.getChannelConfig() ⇒ ConfigEnvelope

Queries for the current config block for this chain(channel). This transaction will be made to the orderer.

Kind: instance method of Chain
Returns: ConfigEnvelope - Object containing the configuration items.
See

  • /protos/orderer/ab.proto
  • /protos/common/configtx.proto

chain.updateChain() ⇒ boolean

Calls the orderer(s) to update an existing chain. This allows the addition and deletion of Peer nodes to an existing chain, as well as the update of Peer certificate information upon certificate renewals.

Kind: instance method of Chain
Returns: boolean - Whether the chain update process was successful.

chain.isReadonly() ⇒ boolean

Get chain status to see if the underlying channel has been terminated, making it a read-only chain, where information (transactions and states) can be queried but no new transactions can be submitted.

Kind: instance method of Chain
Returns: boolean - Is read-only, true or not.

chain.queryInfo() ⇒ object

Queries for various useful information on the state of the Chain (height, known peers). This query will be made to the primary peer.

Kind: instance method of Chain
Returns: object - With height, currently the only useful info.

chain.queryBlockByHash(block) ⇒ object

Queries the ledger for Block by block hash. This query will be made to the primary peer.

Kind: instance method of Chain
Returns: object - Object containing the block.

Param Type Description
block Array.<byte> hash of the Block.

chain.queryBlock(blockNumber) ⇒ object

Queries the ledger for Block by block number. This query will be made to the primary peer.

Kind: instance method of Chain
Returns: object - Object containing the block.

Param Type Description
blockNumber number The number which is the ID of the Block.

chain.queryTransaction(transactionID) ⇒ object

Queries the ledger for Transaction by number. This query will be made to the primary peer.

Kind: instance method of Chain
Returns: object - Transaction information containing the transaction.

Param Type
transactionID number

chain.queryInstalledChaincodes(peer) ⇒ object

Queries the installed chaincodes on a peer returning the details of all chaincodes installed on a peer.

Kind: instance method of Chain
Returns: object - ChaincodeQueryResponse proto

Param Type
peer Peer

chain.queryInstantiatedChaincodes() ⇒ object

Queries the instantiated chaincodes on this channel.

Kind: instance method of Chain
Returns: object - ChaincodeQueryResponse proto

chain.queryChannels(peer) ⇒ object

Queries the names of all the channels that a peer has joined.

Kind: instance method of Chain
Returns: object - ChannelQueryResponse proto

Param Type
peer Peer

chain.sendInstallProposal(request) ⇒ Promise

Sends an install proposal to one or more endorsing peers.

Kind: instance method of Chain
Returns: Promise - A Promise for a ProposalResponse
See: /protos/peer/proposal_response.proto

Param Type Description
request Object An object containing the following fields:
chaincodePath : required - String of the path to location of the source code of the chaincode
chaincodeId : required - String of the name of the chaincode
chaincodeVersion : required - String of the version of the chaincode
chaincodePackage : optional - Byte array of the archive content for the chaincode source. The archive must have a 'src' folder containing subfolders corresponding to the 'chaincodePath' field. For instance, if the chaincodePath is 'mycompany/myproject', then the archive must contain a folder at the path 'src/mycompany/myproject', where the GO source code resides.
chaincodeType : optional - Type of chaincode ['golang', 'car', 'java'] (default 'golang')
txId : required - String of the transaction id
nonce : required - Integer of the once time number

chain.sendInstantiateProposal(request) ⇒ Promise

Sends an instantiate proposal to one or more endorsing peers.

Kind: instance method of Chain
Returns: Promise - A Promise for a ProposalResponse
See: /protos/peer/proposal_response.proto

Param Type Description
request Object An object containing the following fields:
chaincodeType : optional -- Type of chaincode ['golang', 'car', 'java'] (default 'golang')
chaincodePath : required - String of the path to location of the source code of the chaincode
chaincodeId : required - String of the name of the chaincode
chaincodeVersion : required - String of the version of the chaincode
chainId : required - String of the name of the chain
txId : required - String of the transaction id
nonce : required - Integer of the once time number
fcn : optional - String of the function to be called on the chaincode once instantiated (default 'init')
args : optional - String Array arguments specific to the chaincode being instantiated

chain.sendTransactionProposal(request) ⇒ Promise

Sends a transaction proposal to one or more endorsing peers.

Kind: instance method of Chain
Returns: Promise - A Promise for a ProposalResponse

Param Type Description
request Object
chaincodeId : The id of the chaincode to perform the transaction proposal
chainId : required - String of the name of the chain
txId : required - String of the transaction id
nonce : required - Integer of the once time number
args : an array of arguments specific to the chaincode 'invoke'

chain.sendTransaction(proposalResponses, chaincodeProposal) ⇒ Promise

Sends the orderer an endorsed proposal. The caller must use the proposal response returned from the endorser along with the original proposal request sent to the endorser.

Kind: instance method of Chain
Returns: Promise - A Promise for a BroadcastResponse. This will be an acknowledgement from the orderer of successfully submitted transaction.
See

  • /protos/peer/proposal_response.proto
  • /protos/peer/proposal.proto
  • /protos/orderer/ab.proto
Param Type Description
proposalResponses Array An array or single {ProposalResponse} objects containing the response from the endorsement
chaincodeProposal Proposal A Proposal object containing the original request for endorsement(s)

chain.queryByChaincode(request) ⇒ Promise

Sends a proposal to one or more endorsing peers that will be handled by the chaincode. This request will be presented to the chaincode 'invoke' and must understand from the arguments that this is a query request. The chaincode must also return results in the byte array format and the caller will have to be able to decode these results

Kind: instance method of Chain
Returns: Promise - A Promise for an array of byte array results from the chaincode on all Endorsing Peers

Param Type Description
request Object A JSON object with the following
targets : An array or single Endorsing Peer objects as the targets of the request
chaincodeId : The id of the chaincode to perform the query
args : an array of arguments specific to the chaincode 'innvoke' that represent a query invocation on that chaincode

chain.buildTransactionID(nonce, userContext) ⇒ string

Utility method to build an unique transaction id based on a nonce and this chain's user.

Kind: instance method of Chain
Returns: string - An unique string

Param Type Description
nonce int a one time use number
userContext User the user context

chain.buildTransactionID_getUserContext(nonce) ⇒ Promise

Utility method to build an unique transaction id based on a nonce and this chain's user. Gets the user context.

Kind: instance method of Chain
Returns: Promise - A promise for the transaction id

Param Type Description
nonce int a one time use number

chain.toString()

return a printable representation of this object

Kind: instance method of Chain

Client

Main interaction handler with end user. A client instance provides a handler to interact with a network of peers, orderers and optionally member services. An application using the SDK may need to interact with multiple networks, each through a separate instance of the Client.

Each client when initially created should be initialized with configuration data from the consensus service, which includes a list of trusted roots, orderer certificates and IP addresses, and a list of peer certificates and IP addresses that it can access. This must be done out of band as part of bootstrapping the application environment. It is also the responsibility of the application to maintain the configuration of a client as the SDK does not persist this object.

Each Client instance can maintain several Chain instances representing channels and the associated private ledgers.

Kind: global class

client.newChain(name) ⇒ Chain

Returns a chain instance with the given name. This represents a channel and its associated ledger (as explained above), and this call returns an empty object. To initialize the chain in the blockchain network, a list of participating endorsers and orderer peers must be configured first on the returned object.

Kind: instance method of Client
Returns: Chain - The uninitialized chain instance.
Throws:

  • Error if the chain by that name already exists in the application's state store
Param Type Description
name string The name of the chain. Recommend using namespaces to avoid collision.

client.getChain(name) ⇒ Chain

Get a Chain instance from the state storage. This allows existing chain instances to be saved for retrieval later and to be shared among instances of the application. Note that it’s the application/SDK’s responsibility to record the chain information. If an application is not able to look up the chain information from storage, it may call another API that queries one or more Peers for that information.

Kind: instance method of Client
Returns: Chain - The chain instance
Throws:

  • Error if the state store has not been set or a chain does not exist under that name.
Param Type Description
name string The name of the chain.

client.queryChainInfo(name, peers) ⇒ Chain

This is a network call to the designated Peer(s) to discover the chain information. The target Peer(s) must be part of the chain to be able to return the requested information.

Kind: instance method of Client
Returns: Chain - The chain instance for the name or error if the target Peer(s) does not know anything about the chain.

Param Type Description
name string The name of the chain.
peers Array.<Peer> Array of target Peers to query.

client.setStateStore(keyValueStore)

The enrollment materials for Users that have appeared in the instances of the application.

The SDK should have a built-in key value store file-based implementation to allow easy setup during development. Production systems would use a store backed by database for more robust storage and clustering, so that multiple app instances can share app state via the database. This API makes this pluggable so that different store implementations can be selected by the application.

Kind: instance method of Client

Param Type Description
keyValueStore KeyValueStore Instance of an alternative KeyValueStore implementation provided by the consuming app.

client.saveUserToStateStore() ⇒ Promise

Save the state of this member to the key value store.

Kind: instance method of Client
Returns: Promise - A Promise for the user context object upon successful save

client.setUserContext(user, skipPersistence) ⇒ Promise

Sets an instance of the User class as the security context of self client instance. This user’s credentials (ECert), or special transaction certificates that are derived from the user's ECert, will be used to conduct transactions and queries with the blockchain network. Upon setting the user context, the SDK saves the object in a persistence cache if the “state store” has been set on the Client instance. If no state store has been set, this cache will not be established and the application is responsible for setting the user context again if the application crashes and is recovered.

Kind: instance method of Client
Returns: Promise - Promise of the 'user' object upon successful persistence of the user to the state store

Param Type Description
user User An instance of the User class encapsulating the authenticated user’s signing materials (private key and enrollment certificate)
skipPersistence boolean Whether to skip saving the user object into persistence. Default is false and the method will attempt to save the user object to the state store.

client.getUserContext(name) ⇒ Promise

As explained above, the client instance can have an optional state store. The SDK saves enrolled users in the storage which can be accessed by authorized users of the application (authentication is done by the application outside of the SDK). This function attempts to load the user by name from the local storage (via the KeyValueStore interface). The loaded user object must represent an enrolled user with a valid enrollment certificate signed by a trusted CA (such as the CA server).

Kind: instance method of Client
Returns: Promise - The user object corresponding to the name, or null if the user does not exist or if the state store has not been set.

Param Type Description
name String Optional. If not specified, will only return the in-memory user context object, or null if not found in memory. If "name" is specified, will also attempt to load it from the state store if search in memory failed.

client.loadUserFromStateStore() ⇒ Promise

Restore the state of this member from the key value store (if found). If not found, do nothing.

Kind: instance method of Client
Returns: Promise - A Promise for a {User} object upon successful restore, or if the user by the name does not exist in the state store, returns null without rejecting the promise

client.getStateStore() ⇒ KeyValueStore

A convenience method for obtaining the state store object in use for this client.

Kind: instance method of Client
Returns: KeyValueStore - The KeyValueStore implementation object set within this Client, or null if it does not exist.

Client.newDefaultKeyValueStore(options) ⇒

Obtains an instance of the KeyValueStore class. By default it returns the built-in implementation, which is based on files (FileKeyValueStore). This can be overriden with an environment variable KEY_VALUE_STORE, the value of which is the full path of a CommonJS module for the alternative implementation.

Kind: static method of Client
Returns: KeyValueStore an instance of the KeyValueStore implementation

Param Type Description
options Object is whatever the implementation requires for initializing the instance. For the built-in file-based implementation, this requires a single property "path" to the top-level folder for the store

Client.setLogger(logger)

Configures a logger for the entire HFC SDK to use and override the default logger. Unless this method is called, HFC uses a default logger (based on winston). When using the built-in "winston" based logger, use the environment variable HFC_LOGGING to pass in configurations in the following format:

{ 'error': 'error.log', // 'error' logs are printed to file 'error.log' relative of the current working dir for node.js 'debug': '/tmp/myapp/debug.log', // 'debug' and anything more critical ('info', 'warn', 'error') can also be an absolute path 'info': 'console' // 'console' is a keyword for logging to console }

Kind: static method of Client

Param Type Description
logger Object a logger instance that defines the following methods: debug(), info(), warn(), error() with string interpolation methods like util.format.

Client.addConfigFile(path)

Adds a file to the top of the list of configuration setting files that are part of the hierarchical configuration. These files will override the default settings and be overriden by environment, command line arguments, and settings programmatically set into configuration settings.

hierarchy search order:

  1. memory - all settings added with sdkUtils.setConfigSetting(name,value)
  2. Command-line arguments
  3. Environment variables (names will be change from AAA-BBB to aaa-bbb)
  4. Custom 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

Kind: static method of Client

Param Type Description
path String The path to the file to be added to the top of list of configuration files

Client.setConfigSetting(name, value)

Adds a setting to override all settings that are part of the hierarchical configuration.

hierarchy search order:

  1. memory - settings added with this call
  2. Command-line arguments
  3. Environment variables (names will be change from AAA-BBB to aaa-bbb)
  4. Custom 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

Kind: static method of Client

Param Type Description
name String The name of a setting
value Object The value of a setting

Client.getConfigSetting(name, default_value)

Retrieves a setting from the hierarchical configuration and if not found will return the provided default value.

hierarchy search order:

  1. memory - settings added with sdkUtils.setConfigSetting(name,value)
  2. Command-line arguments
  3. Environment variables (names will be change from AAA-BBB to aaa-bbb)
  4. Custom 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

Kind: static method of Client

Param Type Description
name String The name of a setting
default_value Object The value of a setting if not found in the hierarchical configuration

ChainCodeCBE

The ChainCodeCBE is used internal to the EventHub to hold chaincode event registration callbacks.

Kind: global class

new ChainCodeCBE(ccid, eventNameFilter, cb)

Constructs a chaincode callback entry

Param Type Description
ccid string chaincode id
eventNameFilter string The regex used to filter events
cb function Callback for filter matches

EventHub

The EventHub class is used to distribute events from an event source(peer)

Kind: global class

new EventHub()

Constructs an unconnected EventHub

eventHub.setPeerAddr(peeraddr, opts)

Set peer url for event source

Note: Only use this if creating your own EventHub. The chain class creates a default eventHub that most Node clients can use (see eventHubConnect, eventHubDisconnect and getEventHub).

Kind: instance method of EventHub

Param Type Description
peeraddr string peer url
opts object An Object that may contain options to pass to grpcs calls
- pem {string} The certificate file, in PEM format, to use with the gRPC protocol (that is, with TransportCredentials). Required when using the grpcs protocol.
- ssl-target-name-override {string} Used in test environment only, when the server certificate's hostname (in the 'CN' field) does not match the actual host endpoint that the server process runs at, the application can work around the client TLS verify failure by setting this property to the value of the server certificate's hostname
- any other standard grpc call options will be passed to the grpc service calls directly

eventHub.isconnected() ⇒

Get connected state of eventhub

Kind: instance method of EventHub
Returns: true if connected to event source, false otherwise

eventHub.connect()

Establishes connection with peer event source

Note: Only use this if creating your own EventHub. The chain class creates a default eventHub that most Node clients can use (see eventHubConnect, eventHubDisconnect and getEventHub).

Kind: instance method of EventHub

eventHub.disconnect()

Disconnects peer event source

Note: Only use this if creating your own EventHub. The chain class creates a default eventHub that most Node clients can use (see eventHubConnect, eventHubDisconnect and getEventHub).

Kind: instance method of EventHub

eventHub.registerChaincodeEvent(ccid, eventname, callback) ⇒ object

Register a callback function to receive chaincode events.

Kind: instance method of EventHub
Returns: object - ChainCodeCBE object that should be treated as an opaque handle used to unregister (see unregisterChaincodeEvent)

Param Type Description
ccid string string chaincode id
eventname string string The regex string used to filter events
callback function Function Callback function for filter matches that takes a single parameter which is a json object representation of type "message ChaincodeEvent" from lib/proto/chaincodeevent.proto

eventHub.unregisterChaincodeEvent(ChainCodeCBE)

Unregister chaincode event registration

Kind: instance method of EventHub

Param Type Description
ChainCodeCBE object handle returned from call to registerChaincodeEvent.

eventHub.registerBlockEvent(callback)

Register a callback function to receive block events.

Kind: instance method of EventHub

Param Type Description
callback function Function that takes a single parameter which is a json object representation of type "message Block" from lib/proto/fabric.proto

eventHub.unregisterBlockEvent(callback)

Unregister block event registration

Kind: instance method of EventHub

Param Type Description
callback function Function to unregister

eventHub.registerTxEvent(txid, callback)

Register a callback function to receive transactional events.

Note: transactional event registration is primarily used by the sdk to track instantiate and invoke completion events. Nodejs clients generally should not need to call directly.

Kind: instance method of EventHub

Param Type Description
txid string string transaction id
callback function Function that takes a parameter which is a json object representation of type "message Transaction" from lib/proto/fabric.proto and a parameter which is a boolean that indicates if the transaction is invalid (true=invalid)

eventHub.unregisterTxEvent(txid)

Unregister transactional event registration.

Kind: instance method of EventHub

Param Description
txid string transaction id

eventHub.txCallback(block)

private internal callback for processing tx events

Kind: instance method of EventHub

Param Type Description
block object json object representing block of tx from the fabric

CouchDBKeyValueStore

This is a sample database implementation of the KeyValueStore API. It uses a local or remote CouchDB database instance to store the keys.

Kind: global class

new CouchDBKeyValueStore(options)

constructor

Param Type Description
options Object Contains the properties:
  • url - The CouchDB instance url.
  • name - Optional. Identifies the name of the database if different from the default of 'member_db'.
  • CryptoSuite_ECDSA_AES

    The CryptoSuite implementation for ECDSA, and AES algorithms using software key generation. This class implements a software-based key generation (as opposed to Hardware Security Module based key management)

    Kind: global class

    new CryptoSuite_ECDSA_AES(keySize, opts, KVSImplClass, hash)

    constructor

    Param Type Description
    keySize number Key size for the ECDSA algorithm, can only be 256 or 384
    opts object Implementation-specific options object for the KeyValueStore class to instantiate an instance
    KVSImplClass string Optional. The built-in key store saves private keys. The key store may be backed by different KeyValueStore implementations. If specified, the value of the argument must point to a module implementing the KeyValueStore interface.
    hash string Optional. Hash algorithm, supported values are "SHA2" and "SHA3"

    cryptoSuite_ECDSA_AES.generateKey() ⇒ Key

    This is an implementation of generateKey Returns an instance of module.api.Key representing the private key, which also encapsulates the public key. It'll also save the private key in the KeyValueStore

    Kind: instance method of CryptoSuite_ECDSA_AES
    Returns: Key - Promise of an instance of module:ECDSA_KEY containing the private key and the public key

    cryptoSuite_ECDSA_AES.deriveKey()

    This is an implementation of deriveKey To be implemented

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.importKey()

    This is an implementation of importKey

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.getKey()

    This is an implementation of getKey Returns the key this CSP associates to the Subject Key Identifier ski.

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.hash()

    This is an implementation of hash Hashes messages msg using options opts.

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.sign()

    This is an implementation of sign Signs digest using key k.

    The opts argument is not needed.

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.verify()

    This is an implementation of verify Verifies signature against key k and digest The opts argument should be appropriate for the algorithm used.

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.encrypt()

    This is an implementation of encrypt Encrypts plaintext using key k. The opts argument should be appropriate for the algorithm used.

    Kind: instance method of CryptoSuite_ECDSA_AES

    cryptoSuite_ECDSA_AES.decrypt()

    This is an implementation of decrypt Decrypts ciphertext using key k. The opts argument should be appropriate for the algorithm used.

    Kind: instance method of CryptoSuite_ECDSA_AES

    KeyValueStore

    This is a default implementation of the KeyValueStore API. It uses files to store the key values.

    Kind: global class

    new KeyValueStore(options)

    constructor

    Param Type Description
    options Object contains a single property 'path' which points to the top-level directory for the store

    Identity

    This interface is shared within the peer and client API of the membership service provider. Identity interface defines operations associated to a "certificate". That is, the public part of the identity could be thought to be a certificate, and offers solely signature verification capabilities. This is to be used at the client side when validating certificates that endorsements are signed with, and verifying signatures that correspond to these certificates.

    Kind: global class

    new Identity(id, certificate, publicKey, msp)

    Param Type Description
    id string Identifier of this identity object
    certificate string HEX string for the PEM encoded certificate
    publicKey Key The public key represented by the certificate
    msp MSP The associated MSP that manages this identity

    identity.getId() ⇒ string

    Returns the identifier of this identity

    Kind: instance method of Identity

    identity.getMSPId() ⇒ string

    Returns the identifier of the Membser Service Provider that manages this identity in terms of being able to understand the key algorithms and have access to the trusted roots needed to validate it

    Kind: instance method of Identity

    identity.isValid() ⇒ boolean

    This uses the rules that govern this identity to validate it. E.g., if it is a fabric TCert implemented as identity, validate will check the TCert signature against the assumed root certificate authority.

    Kind: instance method of Identity

    identity.getOrganizationUnits() ⇒ string

    Returns the organization units this identity is related to as long as this is public information. In certain implementations this could be implemented by certain attributes that are publicly associated to that identity, or the identifier of the root certificate authority that has provided signatures on this certificate. Examples:

    • OrganizationUnit of a fabric-tcert that was signed by TCA under name "Organization 1", would be "Organization 1".
    • OrganizationUnit of an alternative implementation of tcert signed by a public CA used by organization "Organization 1", could be provided in the clear as part of that tcert structure that this call would be able to return.

    Kind: instance method of Identity

    identity.verify(msg, signature, opts)

    Verify a signature over some message using this identity as reference

    Kind: instance method of Identity

    Param Type Description
    msg Array.<byte> The message to be verified
    signature Array.<byte> The signature generated against the message "msg"
    opts Object Options include 'policy' and 'label'

    identity.verifyAttributes()

    Verify attributes against the given attribute spec TODO: when this method's design is finalized

    Kind: instance method of Identity

    identity.serialize() ⇒ Buffer

    Converts this identity to bytes

    Kind: instance method of Identity
    Returns: Buffer - protobuf-based serialization with two fields: "mspid" and "certificate PEM bytes"

    Signer

    Signer is an interface for an opaque private key that can be used for signing operations

    Kind: global class

    new Signer(cryptoSuite, key)

    Param Type Description
    cryptoSuite CryptoSuite The underlying CryptoSuite implementation for the digital signature algorithm
    key Key The private key

    signer.getPublicKey() ⇒ Key

    Returns the public key corresponding to the opaque, private key

    Kind: instance method of Signer
    Returns: Key - The public key corresponding to the private key

    signer.sign(digest, opts)

    Signs digest with the private key.

    Hash implements the SignerOpts interface and, in most cases, one can simply pass in the hash function used as opts. Sign may also attempt to type assert opts to other types in order to obtain algorithm specific values.

    Note that when a signature of a hash of a larger message is needed, the caller is responsible for hashing the larger message and passing the hash (as digest) and the hash function (as opts) to Sign.

    Kind: instance method of Signer

    Param Type Description
    digest Array.<byte> The message to sign
    opts Object hashingFunction: the function to use to hash

    SigningIdentity

    SigningIdentity is an extension of Identity to cover signing capabilities. E.g., signing identity should be requested in the case of a client who wishes to sign proposal responses and transactions

    Kind: global class

    new SigningIdentity(id, certificate, publicKey, signer, msp)

    Param Type Description
    id string Identifier of this identity object
    certificate string HEX string for the PEM encoded certificate
    publicKey Key The public key represented by the certificate
    signer Signer The signer object encapsulating the opaque private key and the corresponding digital signature algorithm to be used for signing operations
    msp MSP The associated MSP that manages this identity

    signingIdentity.sign(msg, opts)

    Signs digest with the private key contained inside the signer.

    Kind: instance method of SigningIdentity

    Param Type Description
    msg Array.<byte> The message to sign
    opts object Options object for the signing, contains one field 'hashFunction' that allows different hashing algorithms to be used. If not present, will default to the hash function configured for the identity's own crypto suite object

    MSPManager

    MSPManager is an interface defining a manager of one or more MSPs. This essentially acts as a mediator to MSP calls and routes MSP related calls to the appropriate MSP. This object is immutable, it is initialized once and never changed.

    Kind: global class

    mspManager.loadMSPs(mspConfigs)

    Instantiates MSPs for validating identities (like the endorsor in the ProposalResponse). The MSPs loaded via this method require the CA certificate representing the Certificate Authority that signed the identities to be validated. They also optionally contain the certificates for the administrators of the organization that the CA certs represent.

    Kind: instance method of MSPManager

    Param Type Description
    mspConfigs protos/msp/mspconfig.proto An array of MSPConfig objects as defined by the protobuf protos/msp/mspconfig.proto

    mspManager.getMSPs()

    Returns the validating MSPs. Note that this does NOT return the local MSP

    Kind: instance method of MSPManager

    mspManager.deserializeIdentity(serializedIdentity) ⇒ Promise

    DeserializeIdentity deserializes an identity

    Kind: instance method of MSPManager
    Returns: Promise - Promise for an Identity instance

    Param Type Description
    serializedIdentity Array.<byte> A protobuf-based serialization of an object with two fields: mspid and idBytes for certificate PEM bytes

    MSP

    MSP is the minimal Membership Service Provider Interface to be implemented to manage identities (in terms of signing and signature verification) represented by private keys and certificates generated from different algorithms (ECDSA, RSA, etc) and PKIs (software-managed or HSM based)

    Kind: global class

    new MSP(config)

    Setup the MSP instance according to configuration information

    Param Type Description
    config Object A configuration object specific to the implementation. For this implementation it uses the following fields:
    rootCerts: array of Identity representing trust anchors for validating signing certificates. Required for MSPs used in verifying signatures
    intermediateCerts: array of Identity representing trust anchors for validating signing certificates. optional for MSPs used in verifying signatures
    admins: array of Identity representing admin privileges
    signer: SigningIdentity signing identity. Required for MSPs used in signing
    id: {string} value for the identifier of this instance
    orgs: {string} array of organizational unit identifiers
    `cryptoSuite': the underlying CryptoSuite for crypto primitive operations

    msP.getId() ⇒ string

    Get provider identifier

    Kind: instance method of MSP

    msP.getOrganizationUnits() ⇒ Array.<string>

    Get organizational unit identifiers

    Kind: instance method of MSP

    msP.getPolicy() ⇒ Object

    Obtain the policy to govern changes

    Kind: instance method of MSP

    msP.getSigningIdentity(identifier) ⇒ SigningIdentity

    Returns a signing identity corresponding to the provided identifier

    Kind: instance method of MSP

    Param Type Description
    identifier string The identifier of the requested identity object

    msP.getDefaultSigningIdentity() ⇒ SigningIdentity

    Returns the default signing identity

    Kind: instance method of MSP

    msP.deserializeIdentity(serializedIdentity) ⇒ Promise

    DeserializeIdentity deserializes an identity

    Kind: instance method of MSP
    Returns: Promise - Promise for an Identity instance

    Param Type Description
    serializedIdentity Array.<byte> A protobuf-based serialization of an object with two fields: mspid and idBytes for certificate PEM bytes

    msP.validate(id) ⇒ boolean

    Checks whether the supplied identity is valid

    Kind: instance method of MSP

    Param Type
    id Identity

    Orderer

    The Orderer class represents a peer in the target blockchain network to which HFC sends a block of transactions of endorsed proposals requiring ordering.

    Kind: global class

    new Orderer(url, opts)

    Constructs an Orderer given its endpoint configuration settings.

    Param Type Description
    url string The orderer URL with format of 'grpcs://host:port'.
    opts Object The options for the connection to the orderer.

    orderer.sendBroadcast(envelope) ⇒ Promise

    Send a Broadcast message to the orderer service.

    Kind: instance method of Orderer
    Returns: Promise - A Promise for a BroadcastResponse
    See

    • the ./proto/orderer/ab.proto
    • the ./proto/orderer/ab.proto
    Param Type Description
    envelope byte Byte data to be included in the Broadcast

    orderer.sendDeliver(envelope) ⇒ Promise

    Send a Deliver message to the orderer service.

    Kind: instance method of Orderer
    Returns: Promise - A Promise for a Block
    See

    • the ./proto/orderer/ab.proto
    • the ./proto/orderer/common.proto
    Param Type Description
    envelope byte Byte data to be included in the Deliver

    orderer.toString()

    return a printable representation of this object

    Kind: instance method of Orderer

    Peer

    The Peer class represents a peer in the target blockchain network to which HFC sends endorsement proposals, transaction ordering or query requests.

    The Peer class represents the remote Peer node and its network membership materials, aka the ECert used to verify signatures. Peer membership represents organizations, unlike User membership which represents individuals.

    When constructed, a Peer instance can be designated as an event source, in which case a “eventSourceUrl” attribute should be configured. This allows the SDK to automatically attach transaction event listeners to the event stream.

    It should be noted that Peer event streams function at the Peer level and not at the chain and chaincode levels.

    Kind: global class

    new Peer(url, opts)

    Constructs a Peer given its endpoint configuration settings.

    Param Type Description
    url string The URL with format of "grpcs://host:port".
    opts Object The options for the connection to the peer.

    peer.connectEventSource() ⇒ Promise

    Since practically all Peers are event producers, when constructing a Peer instance, an application can designate it as the event source for the application. Typically only one of the Peers on a Chain needs to be the event source, because all Peers on the Chain produce the same events. This method tells the SDK which Peer(s) to use as the event source for the client application. It is the responsibility of the SDK to manage the connection lifecycle to the Peer’s EventHub. It is the responsibility of the Client Application to understand and inform the selected Peer as to which event types it wants to receive and the call back functions to use.

    Kind: instance method of Peer
    Returns: Promise - This gives the app a handle to attach “success” and “error” listeners

    peer.isEventListened(eventName, chain)

    A network call that discovers if at least one listener has been connected to the target Peer for a given event. This helps application instance to decide whether it needs to connect to the event source in a crash recovery or multiple instance instantiation.

    Kind: instance method of Peer
    Result: boolean Whether the said event has been listened on by some application instance on that chain.

    Param Type Description
    eventName string required
    chain Chain optional

    peer.addListener(eventType, eventTypeData, eventCallback) ⇒ string

    For a Peer that is connected to eventSource, the addListener registers an EventCallBack for a set of event types. addListener can be invoked multiple times to support differing EventCallBack functions receiving different types of events.

    Note that the parameters below are optional in certain languages, like Java, that constructs an instance of a listener interface, and pass in that instance as the parameter.

    Kind: instance method of Peer
    Returns: string - An ID reference to the event listener.

    Param Type Description
    eventType string : ie. Block, Chaincode, Transaction
    eventTypeData object : Object Specific for event type as necessary, currently needed for “Chaincode” event type, specifying a matching pattern to the event name set in the chaincode(s) being executed on the target Peer, and for “Transaction” event type, specifying the transaction ID
    eventCallback class Client Application class registering for the callback.

    peer.removeListener(eventListenerRef) ⇒ boolean

    Unregisters a listener.

    Kind: instance method of Peer
    Returns: boolean - Success / Failure status

    Param Type Description
    eventListenerRef string Reference returned by SDK for event listener.

    peer.getName() ⇒ string

    Get the Peer name. Required property for the instance objects.

    Kind: instance method of Peer
    Returns: string - The name of the Peer

    peer.setName(name)

    Set the Peer name / id.

    Kind: instance method of Peer

    Param Type
    name string

    peer.getRoles() ⇒ Array.<string>

    Get the user’s roles the Peer participates in. It’s an array of possible values in “client”, and “auditor”. The member service defines two more roles reserved for peer membership: “peer” and “validator”, which are not exposed to the applications.

    Kind: instance method of Peer
    Returns: Array.<string> - The roles for this user.

    peer.setRoles(roles)

    Set the user’s roles the Peer participates in. See getRoles() for legitimate values.

    Kind: instance method of Peer

    Param Type Description
    roles Array.<string> The list of roles for the user.

    peer.getEnrollmentCertificate() ⇒ object

    Returns the Peer's enrollment certificate.

    Kind: instance method of Peer
    Returns: object - Certificate in PEM format signed by the trusted CA

    peer.setEnrollmentCertificate(enrollment)

    Set the Peer’s enrollment certificate.

    Kind: instance method of Peer

    Param Type Description
    enrollment object Certificate in PEM format signed by the trusted CA

    peer.sendProposal(proposal) ⇒

    Send an endorsement proposal to an endorser.

    Kind: instance method of Peer
    Returns: Promise for a ProposalResponse
    See: /protos/peer/fabric_proposal.proto

    Param Type Description
    proposal Proposal A proposal of type Proposal

    peer.toString()

    return a printable representation of this object

    Kind: instance method of Peer

    Remote

    The Remote class represents a the base class for all remote nodes, Peer, Orderer , and MemberServicespeer.

    Kind: global class

    new Remote(url, opts)

    Constructs an object with the endpoint configuration settings.

    Param Type Description
    url string The orderer URL with format of 'grpc(s)://host:port'.
    opts object An Object that may contain options to pass to grpcs calls
    - pem {string} The certificate file, in PEM format, to use with the gRPC protocol (that is, with TransportCredentials). Required when using the grpcs protocol.
    - ssl-target-name-override {string} Used in test environment only, when the server certificate's hostname (in the 'CN' field) does not match the actual host endpoint that the server process runs at, the application can work around the client TLS verify failure by setting this property to the value of the server certificate's hostname
    - any other standard grpc call options will be passed to the grpc service calls directly

    remote.getUrl() ⇒ string

    Get the URL of the orderer.

    Kind: instance method of Remote
    Returns: string - Get the URL associated with the Orderer.

    remote.toString()

    return a printable representation of this object

    Kind: instance method of Remote

    User

    The User class represents users that have been enrolled and represented by an enrollment certificate (ECert) and a signing key. The ECert must have been signed by one of the CAs the blockchain network has been configured to trust. An enrolled user (having a signing key and ECert) can conduct chaincode instantiate, transactions and queries with the Chain.

    User ECerts can be obtained from a CA beforehand as part of installing and instantiating the application, or it can be obtained from the optional Fabric CA service via its enrollment process.

    Sometimes User identities are confused with Peer identities. User identities represent signing capability because it has access to the private key, while Peer identities in the context of the application/SDK only has the certificate for verifying signatures. An application cannot use the Peer identity to sign things because the application doesn’t have access to the Peer identity’s private key.

    Kind: global class

    new User(cfg)

    Constructor for a member.

    Param Type Description
    cfg string The member name or an object with the following attributes: - enrollmentID {string}: user name - name {string}: user name, if "enrollmentID" is also specified, the "name" is ignored - roles {string[]}: optional. array of roles - affiliation {string}: optional. affiliation with a group or organization

    user.getName() ⇒ string

    Get the member name.

    Kind: instance method of User
    Returns: string - The member name.

    user.getRoles() ⇒ Array.<string>

    Get the roles.

    Kind: instance method of User
    Returns: Array.<string> - The roles.

    user.setRoles(roles)

    Set the roles.

    Kind: instance method of User

    Param Type Description
    roles Array.<string> The roles.

    user.getAffiliation() ⇒ string

    Get the affiliation.

    Kind: instance method of User
    Returns: string - The affiliation.

    user.setAffiliation(affiliation)

    Set the affiliation.

    Kind: instance method of User

    Param Type Description
    affiliation string The affiliation.

    user.getIdentity() ⇒ Identity

    Get the Identity object for this User instance, used to verify signatures

    Kind: instance method of User
    Returns: Identity - the identity object that encapsulates the user's enrollment certificate

    user.getSigningIdentity() ⇒ SigningIdentity

    Get the SigningIdentity object for this User instance, used to generate signatures

    Kind: instance method of User
    Returns: SigningIdentity - the identity object that encapsulates the user's private key for signing

    user.setEnrollment(privateKey, certificate, mspId, opts) ⇒ Promise

    Set the enrollment object for this User instance

    Kind: instance method of User
    Returns: Promise - Promise for successful completion of creating the user's signing Identity

    Param Type Description
    privateKey Key the private key object
    certificate string the PEM-encoded string of certificate
    mspId string The Member Service Provider id for the local signing identity
    opts object optional. an object with the following attributes, all optional: - cryptoSettings: {object} an object with the following attributes: - software {boolean}: Whether to load a software-based implementation (true) or HSM implementation (false) default is true (for software based implementation), specific implementation module is specified in the setting 'crypto-suite-software' - keysize {number}: The key size to use for the crypto suite instance. default is value of the setting 'crypto-keysize' - algorithm {string}: Digital signature algorithm, currently supporting ECDSA only with value "EC" - hash {string}: 'SHA2' or 'SHA3' - KVSImplClass: {function} the User class persists crypto keys in a CryptoKeyStore, there is a file-based implementation that is provided as the default. Application can use this parameter to override the default, such as saving the keys in a key store backed by database. If present, the value must be the class for the alternative implementation. - kvsOpts: {object}: an options object specific to the implementation in KVSImplClass

    user.getTCertBatchSize() ⇒ int

    Get the transaction certificate (tcert) batch size, which is the number of tcerts retrieved from member services each time (i.e. in a single batch).

    Kind: instance method of User
    Returns: int - The tcert batch size.

    user.setTCertBatchSize(batchSize)

    Set the transaction certificate (tcert) batch size.

    Kind: instance method of User

    Param Type
    batchSize int

    user.isEnrolled() ⇒ boolean

    Determine if this name has been enrolled.

    Kind: instance method of User
    Returns: boolean - True if enrolled; otherwise, false.

    user.fromString() ⇒ Member

    Set the current state of this member from a string based JSON object

    Kind: instance method of User
    Returns: Member - Promise of the unmarshalled Member object represented by the serialized string

    user.toString() ⇒ string

    Save the current state of this member as a string

    Kind: instance method of User
    Returns: string - The state of this member as a string

    sjcl

    Implement hash primitives. Currently SHA3 is implemented, but needs to also add SHA2.

    NOTE: This is in pure java script to be compatible with the sjcl.hmac function.

    Kind: global variable

    bitsToBytes(a) ⇒ bytes

    Convert from a bitArray to bytes (using SJCL's codec)

    Kind: global function
    Returns: bytes - the bytes converted from the bitArray

    Param Type Description
    a bits bitArray to convert from

    bytesToBits(a) ⇒ bitArray

    Convert from bytes to a bitArray (using SJCL's codec)

    Kind: global function
    Returns: bitArray - the bitArray converted from bytes

    Param Type Description
    a bytes bytes to convert from

    package(chaincodePath, chaincodeType, devmode) ⇒ Promise

    Utility function to package a chaincode. The contents will be returned as a byte array.

    Kind: global function
    Returns: Promise - A promise for the data as a byte array

    Param Type Description
    chaincodePath Object required - String of the path to location of the source code of the chaincode
    chaincodeType Object optional - String of the type of chaincode ['golang', 'car', 'java'] (default 'golang')
    devmode boolean optional - True if using dev mode