new User(cfg)
Constructor for a member.
Parameters:
Name | 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 |
Methods
-
fromString(str, no_save)
-
Set the current state of this member from a string based JSON object
Parameters:
Name Type Description str
string the member state serialized no_save
boolean to indicate that the cryptoSuite should not save 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 -
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
-
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, skipPersistence)
-
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 skipPersistence
boolean Whether to persist this user 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. -
toString()
-
Save the current state of this member as a string
Returns:
The state of this member as a string- Type
- string