Skip to main content

Credential Wallet

A Credential Wallet holds the credentials issued by the Issuer. The Credential Wallet is implemented with a Credential Interface that lets you interact with the credential storage.

The methods described below let you create and manage a credential wallet:

Get List of Credentials with list() method

This method retrieves a set of Verifiable Credentials in the W3C format:

list(): Promise<W3CCredential[]>;

Click here for the API Reference.

Save Credentials with save() method

This method saves the W3C Credentials to the database using upsert.

save(credential: W3CCredential): Promise<void>;

Click here for the API Reference.

Save All Credentials with saveAll() method

This method saves a batch of W3C Credentials to the database using upsert.

saveAll(credentials: W3CCredential[]): Promise<void>;

Click here for the API Reference.

Remove Credential with remove() method

This method removes a W3C credential from data storage.

remove(id: string): Promise<void>;

Click here for the API Reference.

Find Credentials with Query with findByQuery() method

This method lets you find credentials using the Iden3 protocol's query language.

findByQuery(query: ProofQuery): Promise<W3CCredential[]>;

where ProofQuery can contain parameters including:

  • allowedIssuers: issuers that are allowed to issue a credential,
  • claimId: ID of the credential issued,
  • `credentialSubjectId : ID of the subject of the credential to whom a credential is issued,
  • type: type of credential issued,
  • schema: JSON schema used to create a credential,
  • credentialSubject: subject of the credential to whom a credential is issued.

This credential is then used to create a proof.

export interface ProofQuery {
allowedIssuers?: string[];
credentialSubject?: { [key: string]: unknown };
schema?: string; // string url
claimId?: string;
credentialSubjectId?: string;
context?: string;
type?: string;
}

Read more on Query Language here.

Click here for the API Reference.

Retrieve Auth BJJ Credential with getAuthBJJCredential() method

This method allows you to retrieve a credential of Auth BJJ type for a specific user so that it can be used for signing.

 getAuthBJJCredential(did: DID): Promise<W3CCredential>;

where did is the DID of the issuer that has issued the credential.

This method returns a Verifiable Credential of the type Auth BJJ.

Click here for the API Reference.

Get Revocation Status for a Credential with getRevocationStatusFromCredential() method

This method retrieves or builds revocation status for a given credential.

getRevocationStatusFromCredential(cred: W3CCredential): Promise<RevocationStatus>;

where cred is the Credential for which the revocation status is to be retrieved.

The method returns a revocation status of the credential (whether a credential is revoked or not). The credential status could be either the SparseMerkleTreeProof or Iden3ReverseSparseMerkleTreeProof (if Reverse Hash Service is used) type.

Click here for the API Reference.

Get Revocation Status Depending on Type of Credential Status with getRevocationStatus() method

This method retrieves the revocation status for a given credential depending on the type of its credential status.

 /**
*
*
* @param {(CredentialStatus )} credStatus - credentialStatus field of the Verifiable Credential.
* @param {CredentialStatusResolveOptions} credentialStatusResolveOptions - options to resolve credential status
* @returns `Promise<RevocationStatus>`
*/
getRevocationStatus(
credStatus: CredentialStatus,
credentialStatusResolveOptions?: CredentialStatusResolveOptions
): Promise<RevocationStatus>;

where credStatus is the credential status type: with or without Reverse Hash Service / Agent / Onchain.

credentialStatusResolveOptions are:

  • issuerDID is the DID of the Issuer.
  • userDID is the DID of the user who retrieves the status.
  • issuerData is the metadata related to an Issuer. This metadata is contained in either the Signature Proof (BJJ Signature Proof) or Iden3SparseMerkleTreeProof (Merkle Tree Proof).

The method returns the revocation status of the credential (a credential is revoked or not).

Click here for the API Reference.

Create a Credential using createCredential() method

This method creates a Verifiable Credential in the W3C format.

  createCredential(issuer: DID, request: CredentialRequest, schema: JSONSchema): W3CCredential;

where Issuer is the DID of the Issuer. request is the specification for the credential creation parameters. schema is the JSON schema used for creating a credential.

The method returns a Verifiable Credential in the W3C format.

Click here for the API Reference.