CredentialTransformer
Credential transformer for format conversion.
Provides format conversion between different credential representations:
JSON-LD (default W3C VC format)
JWT (compact, widely supported)
CBOR (binary, efficient - RFC 8949 compliant)
Recommended Usage (Elegant DSL API):
// Use extension functions directly on VerifiableCredential (recommended)
val jwt = credential.toJwt()
val jsonLd = credential.toJsonLd()
val cbor = credential.toCbor()
// Convert from formats
val credential = jwtString.fromJwt()
val credential = jsonLdObject.toCredential()
val credential = cborBytes.fromCbor()
// Round-trip transformations
val recovered = credential.roundTripJwt()Alternative Usage (Direct API):
val transformer = CredentialTransformer()
val jwt = transformer.toJwt(credential)
val credential = transformer.fromJwt(jwt)With TrustWeave Integration:
val jwt = trustWeave.toJwt(credential)
val jsonLd = trustWeave.toJsonLd(credential)With DSL Builder:
val jwt = credential.transform {
toJwt()
}This public class is a thin facade over org.trustweave.credential.internal.transform.CredentialTransformer, so both entry points share one implementation (and one set of security rules).
See also
For extension functions
For DSL builder
Functions
Convert CBOR bytes to credential.
Convert JSON-LD to credential.
Convert a JWS-secured JWT to a credential (signature not verified). Unsecured (alg: none) JWTs are rejected; see the overload with allowUnsecured.
Convert a JWT to a credential, accepting unsecured (alg: none) JWTs only when allowUnsecured is true — e.g. to read back the output of toJwt.
Convert credential to CBOR (RFC 8949) bytes.
Convert credential to JSON-LD format.
Convert credential to an unsecured JWT (alg: none) with the credential in the vc claim. For signed JWTs, use CredentialService.issue().