The [VcDataModel] instance representing the core data model of a verifiable credential.
The issuer of the credential.
The subject of the credential.
The type of the credential.
Signs the verifiable credential and returns it as a signed JWT.
The sign options used to sign the credential.
The JWT representing the signed verifiable credential.
const vcJwt = verifiableCredential.sign({ did: myDid });
Static
createCreate a [VerifiableCredential] based on the provided parameters.
The options to use when creating the Verifiable Credential.
A [VerifiableCredential] instance.
const vc = await VerifiableCredential.create({
type: 'StreetCredibility',
issuer: 'did:ex:issuer',
subject: 'did:ex:subject',
data: { 'arbitrary': 'data' }
})
Static
parseParses a JWT into a [VerifiableCredential] instance.
The verifiable credential JWT as a [String].
A [VerifiableCredential] instance derived from the JWT.
const vc = VerifiableCredential.parseJwt({ vcJwt: signedVcJwt })
Static
verifyVerifies the integrity and authenticity of a Verifiable Credential (VC) encoded as a JSON Web Token (JWT).
This function performs several crucial validation steps to ensure the trustworthiness of the provided VC:
alg
and kid
in the JWT header.kid
parameter.If any of these steps fail, the function will throw a [Error] with a message indicating the nature of the failure:
Once the verifications are successful, when recreating the VC data model object, this function will:
The parameters for the verification process.
The Verifiable Credential in JWT format as a [string].
try {
VerifiableCredential.verify({ vcJwt: signedVcJwt })
console.log("VC Verification successful!")
} catch (e: Error) {
console.log("VC Verification failed: ${e.message}")
}
Error if the verification fails at any step, providing a message with failure details.
Error if critical JWT header elements are absent.
VerifiableCredential
represents a digitally verifiable credential according to the W3C Verifiable Credentials Data Model.It provides functionalities to sign, verify, and create credentials, offering a concise API to work with JWT representations of verifiable credentials and ensuring that the signatures and claims within those JWTs can be validated.