new User(cfg)
Constructor for a member.
Parameters:
Name | Type | Description |
---|---|---|
cfg |
string | Object | 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 |
Methods
-
<async, static> createUser(opts)
-
Returns a User object with signing identities based on the private key and the corresponding x509 certificate. This allows applications to use pre-existing crypto materials (private keys and certificates) to construct user objects with signing capabilities, as an alternative to dynamically enrolling users with fabric-ca
Parameters:
Name Type Description opts
UserOpts Essential information about the user Returns:
the user object.- Type
- User
-
<static> newCryptoSuite(setting)
-
This is a factory method. It returns a new instance of the CryptoSuite API implementation, based on the "setting" that is passed in, or if skipped, based on default values of the CryptoSetting properties.
Parameters:
Name Type Description setting
CryptoSetting Optional Returns:
a new instance of the CryptoSuite API implementation- Type
- module:api.CryptoSuite
-
<async> fromString(str)
-
Set the current state of this member from a string based JSON object
Parameters:
Name Type Description str
string the member state serialized Returns:
Promise of the unmarshalled Member object represented by the serialized string- Type
- Member
-
getAffiliation()
-
Get the affiliation.
Returns:
The affiliation.- Type
- string
-
getCryptoSuite()
-
Get the module:api.CryptoSuite cryptoSuite object for this User instance.
Returns:
the cryptoSuite used to store crypto and key store settings- Type
- module:api.CryptoSuite
-
getEnrollmentSecret()
-
Get the enrollment secret.
Returns:
The password.- Type
- string
-
getIdentity()
-
Get the Identity object for this User instance, used to verify signatures
Returns:
the identity object that encapsulates the user's enrollment certificate- Type
- Identity
-
getMspid()
-
Get the MSP Id.
Returns:
The mspid.- Type
- string
-
getName()
-
Get the member name.
Returns:
The member name.- Type
- string
-
getRoles()
-
Get the roles.
Returns:
The roles.- Type
- Array.<string>
-
getSigningIdentity()
-
Get the SigningIdentity object for this User instance, used to generate signatures
Returns:
the identity object that encapsulates the user's private key for signing- Type
- SigningIdentity
-
isEnrolled()
-
Determine if this name has been enrolled.
Returns:
True if enrolled; otherwise, false.- Type
- boolean
-
setAffiliation(affiliation)
-
Set the affiliation.
Parameters:
Name Type Description affiliation
string The affiliation. -
setCryptoSuite(cryptoSuite)
-
Set the cryptoSuite. When the application needs to use crypto settings or a key store other than the default, it needs to set a cryptoSuite instance that was created with the desired CryptoSuite settings and CryptoKeyStore options.
Parameters:
Name Type Description cryptoSuite
module:api.CryptoSuite The cryptoSuite. -
<async> setEnrollment(privateKey, certificate, mspId)
-
Set the enrollment object for this User instance
Parameters:
Name Type Description privateKey
module:api.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 Returns:
Promise for successful completion of creating the user's signing Identity- Type
- Promise
-
setRoles(roles)
-
Set the roles.
Parameters:
Name Type Description roles
Array.<string> The roles. -
setSigningIdentity(the)
-
Set the SigningIdentity object for this User instance, used to generate signatures
Parameters:
Name Type Description the
SigningIdentity identity object that encapsulates the user's private key for signing -
toString()
-
Save the current state of this member as a string
Returns:
The state of this member as a string- Type
- string