Credential Issuance
Install Dependency
Package: @affinidi-tdk/credential-issuance-client
npm install @affinidi-tdk/credential-issuance-client --save
You can check the latest version of this module on the NPM repository or view the source code at the GitHub repository.
Classes and Methods
Configuration API
Manage the issuance configuration for the project. Project only one issuance configuration.
createIssuanceConfig
Create an issuance configuration for the project.
Parameters
CreateIssuanceConfigInput [Object]
JSON object to provide the details of the configuration. See more here.
Example
import { ConfigurationApi, Configuration, CreateIssuanceConfigInput } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationApi(authConfiguration)
const request: CreateIssuanceConfigInput = {
"credentialSupported": [
{
"credentialTypeId": "SchemaOne",
"jsonSchemaUrl": "https://schema.affinidi.io/SchemaOneV1R1.json",
"jsonLdContextUrl": "https://schema.affinidi.io/SchemaOneV1R1.jsonld"
}
],
"issuerWalletId": "<Wallet_ID>",
"credentialOfferDuration": 3600,
"format": "ldp_vc",
}
const { data } = await api.createIssuanceConfig(request)
deleteIssuanceConfigById
Delete the issuance configuration by ID.
Parameters
configurationId [String]
ID of the issuance configuration to delete.
Example
import { ConfigurationApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationApi(authConfiguration)
const configurationId = "<Config_ID>"
const result = await api.deleteIssuanceConfigById(configurationId)
getIssuanceConfigById
Retrieves the Issuance Configuration details by ID.
Parameters
configurationId [String]
ID of the issuance configuration to retrieve.
Example
import { ConfigurationApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationApi(authConfiguration)
const configurationId = "<Config_ID>"
const result = await api.getIssuanceConfigById(configurationId)
getIssuanceConfigList
Get the list of issuance configuration for the current project.
Parameters
No Parameters Required
Example
import { ConfigurationApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationApi(authConfiguration)
const { data } = await api.getIssuanceConfigList()
updateIssuanceConfigById
Update the existing Issuance Configuration by ID.
Parameters
configurationId [String]
ID of the issuance configuration to retrieve.
UpdateIssuanceConfigInput [Object]
JSON object to provide the details to update the issuance configuration. See more here.
Example
import { ConfigurationApi, Configuration, UpdateIssuanceConfigInput } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new ConfigurationApi(authConfiguration)
const configurationId = "<Config_ID>"
const request: UpdateIssuanceConfigInput = {
"credentialSupported": [
{
"credentialTypeId": "SchemaOne",
"jsonSchemaUrl": "https://schema.affinidi.io/SchemaOneV1R1.json",
"jsonLdContextUrl": "https://schema.affinidi.io/SchemaOneV1R1.jsonld"
}
],
"issuerWalletId": "<Wallet_ID>",
"credentialOfferDuration": 3600,
"format": "ldp_vc",
}
const { data } = await api.updateIssuanceConfigById(configurationId, request)
Issuance API
Use to initiate issuance of the credential and check the status.
issuanceState
Retrieve the status of issuance.
Parameters
issuanceId [String]
ID of the initiated issuance.
projectId [String]
Project ID from where the issuance was initiated.
Example
import { IssuanceApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new IssuanceApi(authConfiguration)
const issuanceId = "<Issuance_ID>"
const projectId = "<Project_ID>"
const { data } = await api.issuanceState(issuanceId, projectId)
listIssuance
Get the list of issuance initiated in the Project.
Parameters
projectId [String]
Project ID from where to list the issuance.
Example
import { IssuanceApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new IssuanceApi(authConfiguration)
const projectId = "<Project_ID>"
const { data } = await api.listIssuance(projectId)
startIssuance
Used to initiate the issuance of the credential.
Parameters
projectId [String]
Project ID from where to initiate the issuance.
StartIssuanceInput [Object]
JSON object to provide the details of the credentials to issue. See more here.
Example
import { IssuanceApi, Configuration, StartIssuanceInput } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new IssuanceApi(authConfiguration)
const projectId = "<Project_ID>"
const request: StartIssuanceInput = {
"data": [{
"credentialTypeId": "SchemaOne",
"credentialData": {
"first_name": "FirstName",
"last_name": "LastName",
"dob": "1970-01-01",
}
}],
"holderDid": "did:key:holder-did-value",
"claimMode": "FIXED_HOLDER"
}
const { data } = await api.startIssuance(projectId, request)
Credentials API
Issue a Verifiable Credentials to the users.
generateCredentials
Generate and issue a credentil offer to the user.
Parameters
projectId [String]
Project ID from where you want to issue the credential.
CreateCredentialInput [Object]
JSON object to provide the details of the credential to generate. See more here.
Example
import { CredentialsApi, Configuration, CreateCredentialInput } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new CredentialsApi(authConfiguration)
const projectId = "<Project_ID>"
const request: CreateCredentialInput = {
"credential_identifier": "UniversityDegree-2024",
"proof": {
"proof_type": "jwt",
"jwt":
"eyJ0eXAiOiJvcGVuaWQ0dmNpLXByb29mK2p3dCIsImFsZyI6IkVTMjU2IiwiandrI
jp7Imt0eSI6IkVDIiwiY3J2IjoiUC0yNTYiLCJ4IjoiblVXQW9BdjNYWml0aDhFN2k
xOU9kYXhPTFlGT3dNLVoyRXVNMDJUaXJUNCIsInkiOiJIc2tIVThCalVpMVU5WHFpN
1N3bWo4Z3dBS18weGtjRGpFV183MVNvc0VZIn19.eyJhdWQiOiJodHRwczovL2NyZW
RlbnRpYWwtaXNzdWVyLmV4YW1wbGUuY29tIiwiaWF0IjoxNzAxOTYwNDQ0LCJub25j
ZSI6IkxhclJHU2JtVVBZdFJZTzZCUTR5bjgifQ.-a3EDsxClUB4O3LeDD5DVGEnNMT
01FCQW4P6-2-BNBqc_Zxf0Qw4CWayLEpqkAomlkLb9zioZoipdP-jvh1WlA"
}
}
const { data } = await api.generateCredentials(projectId, request)
Default API
Revoke a revocable Verifiable Credentials issued to the users.
changeCredentialStatus
Updates the status of the credential (e.g., REVOKED).
Parameters
projectId [String]
Project ID from where the credential is issued.
configurationId [String]
Configuration ID from where the credential is issued.
ChangeCredentialStatusInput [Object]
JSON object with details of the credential to revoke. See more here.
Example
import { DefaultApi, Configuration, ChangeCredentialStatusInput } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new DefaultApi(authConfiguration)
const projectId = "<Project_ID>"
const configId = "<Config_ID>"
const request: ChangeCredentialStatusInput = {
"changeReason": "INVALID_CREDENTIAL",
"issuanceRecordId": "<Record_ID>"
}
const { data } = await api.changeCredentialStatus(projectId, configId, request)
listIssuanceDataRecords
Retrieves the list of records of revocable credentials. The list contains information about the issued credential, such as status, including the record ID, which you can use to revoke a particular credential.
Parameters
projectId [String]
Project ID from where the credential is issued.
configurationId [String]
Configuration ID from where the credential is issued.
limit [Integer]
Maximum number of records to fetch in a list.
exclusiveStartKey [String]
The base64url encoded key of the first item that this operation will evaluate (it is not returned). Use the value that was returned in the previous operation.
Example
import { DefaultApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new DefaultApi(authConfiguration)
const projectId = "<Project_ID>"
const configId = "<Config_ID>"
const { data } = await api.listIssuanceDataRecords(projectId, configId)
Offer API
Used to get the credential offer initiated by the Issuance API.
getCredentialOffer
Retrieves the credential offer details.
Parameters
issuanceId [String]
ID of the issuance initiated.
Example
import { OfferApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new OfferApi(authConfiguration)
const projectId = "<Project_ID>"
const issuanceId = "<Issuance_ID>"
const result = await api.getCredentialOffer(projectId, issuanceId)
WellKnown API
Used to get the WellKnown OpenID Credential Issuer information.
getWellKnownOpenIdCredentialIssuer
Retrieves the credential issuer well-known configurations.
Parameters
No Parameters Required
Example
import { WellKnownApi, Configuration } from '@affinidi-tdk/credential-issuance-client'
// Pass the projectScopedToken generated from AuthProvider package
const authConfiguration = new Configuration({
apiKey: authProvider.fetchProjectScopedToken.bind(authProvider)
})
const api = new WellKnownApi(authConfiguration)
const projectId = "<Project_ID>"
const result = await api.getWellKnownOpenIdCredentialIssuer(projectId)
Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.