IdCard (Common API)

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

IdCard

An ID 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.

Details

  • Module common

See also

Method Summary

Name Returns Description
constructor void Create the IdCard.
fromArchive Promise Create an IdCard from a card archive.

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

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. Generally this will be present but may be omitted for system cards.
getConnectionProfile Object Connection profile for this card.

This is a mandatory field.

getCredentials Object 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 }.

getDescription String Free text description of the card.
getEnrollmentCredentials Object 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 }.

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. This should be unique within the scope of a given business network and connection profile.

This is a mandatory field.

setCredentials void Credentials to associate with this card.

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

toArchive Promise 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.

toDirectory Promise Save the content of an IdCard a directory.

Method Details

new IdCard()

Create the IdCard.

Parameters

Name Type Optional Description
metadata Object false metadata associated with the card.
connectionProfile Object false 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

void 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 Optional Description
credentials Object false 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

`` - 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 Optional Description
zipData String; ArrayBuffer; Uint8Array; Buffer; Blob; Promise false 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 Optional Description
options Object true JSZip generation options.

Sub-options

Name Type Optional Description
options.type String true 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 Optional Description
cardDirectory String false directory containing card data.
fs true 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 Optional Description
cardDirectory String false directory to save card data.
fs true Node file system API implementation to use for writing card data. Defaults to the Node implementation.