IdCard (Common API)

Overview - Common API - Client API - Admin API - Runtime API

IdCard

Business Network Card. Encapsulates credentials and other information required to connect to a specific business network as a specific user.

Instances of this class can be created using IdCard.fromArchive or IdCard.fromDirectory, as well as the constructor.

Details

  • Module common

Method Summary

Name Returns Description
constructor void Create the IdCard
fromArchive Promise Create an IdCard from a card archive
fromDirectory Promise Create an IdCard from a directory consisting of the content of an ID card
getBusinessNetworkName String Name of the business network to which the ID card applies
getConnectionProfile Object Connection profile for this card
getCredentials Object Credentials associated with this card, and which are used to connect to the associated business network
getDescription String Free text description of the card
getEnrollmentCredentials Object Enrollment credentials
getRoles String[] Special roles for which this ID can be used, which can include:
  • PeerAdmin
  • ChannelAdmin
  • Issuer
getUserName String Name of the user identity associated with the card
setCredentials void Credentials to associate with this card
toArchive Promise Generate a card archive representing this ID card
toDirectory Promise Save the content of an IdCard a directory

Method Details

new IdCard()

Create the IdCard.

Parameters

Name Type Mandatory Description
metadata Object Yes metadata associated with the card.
connectionProfile Object Yes connection profile associated with the card.

getUserName

String getUserName( )

Name of the user identity associated with the card. This should be unique within the scope of a given business network and connection profile. This is a mandatory field.

Returns

String - Name of the user identity.

Parameters

No parameters

getDescription

String getDescription( )

Free text description of the card.

Returns

String - card description.

Parameters

No parameters

getBusinessNetworkName

String getBusinessNetworkName( )

Name of the business network to which the ID card applies. Generally this will be present but may be omitted for system cards.

Returns

String - business network name.

Parameters

No parameters

getConnectionProfile

Object getConnectionProfile( )

Connection profile for this card. This is a mandatory field.

Returns

Object - connection profile.

Parameters

No parameters

getCredentials

Object getCredentials( )

Credentials associated with this card, and which are used to connect to the associated business network.

For PKI-based authentication, the credentials are expected to be of the form: { certificate: String, privateKey: String }.

Returns

Object - credentials.

Parameters

No parameters

setCredentials

setCredentials( Object credentials )

Credentials to associate with this card.

For PKI-based authentication, the credentials are expected to be of the form: { certificate: String, privateKey: String }.

Parameters

Name Type Mandatory Description
credentials Object Yes credentials.

getEnrollmentCredentials

Object getEnrollmentCredentials( )

Enrollment credentials. If there are no credentials associated with this card, these credentials are used to enroll with a business network and obtain certificates.

For an ID/secret enrollment scheme, the credentials are expected to be of the form: { secret: String }.

Returns

Object - enrollment credentials, or null if none exist.

Parameters

No parameters

getRoles

String[] getRoles( )

Special roles for which this ID can be used, which can include:

  • PeerAdmin
  • ChannelAdmin
  • Issuer

Returns

String - roles.

Parameters

No parameters

fromArchive

Promise fromArchive( String; ArrayBuffer; Uint8Array; Buffer; Blob; Promise zipdata )

Create an IdCard from a card archive.

Valid types for zipData are any of the types supported by JSZip.

Returns

Promise - Promise to the instantiated IdCard.

Parameters

Name Type Mandatory Description
zipData String; ArrayBuffer; Uint8Array; Buffer; Blob; Promise Yes card archive data.

toArchive

Promise toArchive( [Object options] )

Generate a card archive representing this ID card.

The default value for the options.type parameter is arraybuffer. See JSZip documentation for other valid values.

Returns

Promise - Promise of the generated ZIP file; by default an ArrayBuffer.

Parameters

Name Type Mandatory Description
options Object Yes JSZip generation options.

Sub-options

Name Type Mandatory Description
options.type String Yes type of the resulting ZIP file data.

fromDirectory

Promise fromDirectory( String carddirectory, [ fs] )

Create an IdCard from a directory consisting of the content of an ID card.

Returns

Promise - Promise that resolves to an IdCard.

Parameters

Name Type Mandatory Description
cardDirectory String Yes directory containing card data.
fs Yes Node file system API implementation to use for reading card data. Defaults to the Node implementation.

toDirectory

Promise toDirectory( String carddirectory, [ fs] )

Save the content of an IdCard a directory.

Returns

Promise - Promise that resolves then the save is complete.

Parameters

Name Type Mandatory Description
cardDirectory String Yes directory to save card data.
fs Yes Node file system API implementation to use for writing card data. Defaults to the Node implementation.

Inherited methods