CredentialService
Service for managing and retrieving verifiable credentials from different sources. By default, it includes procedures for IPFS and Crossmint, but additional procedures can be added by the user.
- CredentialService().getById(credentialId: string) : Fetches the credential from crossmint using the credentialId.
- CredentialService().getCredential(collection: CredentialsCollection, tokenId: string) : Fetches the credential from the source that matches the storage location of the credential.
Remarks
To use the Crossmint procedure, a Crossmint API key with the credentials.read
scope must be set.
Extends
CredentialService
Constructors
new CredentialService()
new CredentialService(
retrievalProcedures
):CredentialService
Parameters
Parameter | Type |
---|---|
retrievalProcedures | CredentialRetrievalProcedure [] |
Returns
Overrides
CredentialServiceRaw.constructor
Defined in
presentation/getCredential.ts:100
Properties
Property | Type | Inherited from | Defined in |
---|---|---|---|
retrievalProcedures | CredentialRetrievalProcedure [] | CredentialServiceRaw.retrievalProcedures | verifiableCredentialsSDK/presentation/getCredential.ts:45 |
Methods
getById()
getById(
credentialId
):Promise
<null
|VerifiableCredentialType
>
Retrieves a verifiable credential from Crossmint using its credential ID.
Parameters
Parameter | Type | Description |
---|---|---|
credentialId | string | The ID of the credential to retrieve. |
Returns
Promise
<null
| VerifiableCredentialType
>
A promise that resolves to a VerifiableCredentialType
or null
if the credential is not found.
Throws
Will throw an error if the credential retrieval fails.
Defined in
presentation/getCredential.ts:112
getCredential()
getCredential(
collection
,tokenId
):Promise
<VerifiableCredentialType
>
Retrieves a Verifiable Credential from a given collection and token ID.
This function finds the appropriate retrieval procedure based on the collection’s metadata and uses it to fetch the credential.
Parameters
Parameter | Type | Description |
---|---|---|
collection | CredentialsCollection | The CredentialsCollection containing the credential’s metadata. |
tokenId | string | The token ID of the credential to retrieve. |
Returns
Promise
<VerifiableCredentialType
>
A promise that resolves to a VerifiableCredentialType
.
Throws
Will throw an error if the collection is not a verifiable credential collection or if the retrieval endpoint is unsupported.
Inherited from
CredentialServiceRaw.getCredential