Skip to content

Commit

Permalink
fix vc+sd-jwt type header
Browse files Browse the repository at this point in the history
  • Loading branch information
severinstampler committed Aug 5, 2024
1 parent 8ba2240 commit bf80a95
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class SDJwtVC(sdJwt: SDJwt): SDJwt(sdJwt.jwt, sdJwt.header, sdJwt.sdPayload, sdJ
}

companion object {
const val SD_JWT_VC_TYPE_HEADER = "vc+sd-jwt"

fun parse(sdJwt: String) = SDJwtVC(SDJwt.parse(sdJwt))

Expand Down Expand Up @@ -102,7 +103,7 @@ class SDJwtVC(sdJwt: SDJwt): SDJwt(sdJwt.jwt, sdJwt.header, sdJwt.sdPayload, sdJ
).let { JsonObject(it) }

val finalSdPayload = SDPayload(undisclosedPayload, sdPayload.digestedDisclosures)
return SDJwtVC(sign(finalSdPayload, jwtCryptoProvider, issuerKeyId, typ = "vc+sd-jwt", additionalJwtHeader))
return SDJwtVC(sign(finalSdPayload, jwtCryptoProvider, issuerKeyId, typ = SD_JWT_VC_TYPE_HEADER, additionalJwtHeader))
}

fun defaultPayloadProperties(issuerId: String, cnf: JsonObject, vct: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object Issuer {
subjectDid: String,

mappings: JsonObject,

type: String = "JWT",
additionalJwtHeaders: Map<String, JsonElement>,
additionalJwtOptions: Map<String, JsonElement>,

Expand All @@ -118,7 +118,7 @@ object Issuer {
subjectDid = subjectDid,
disclosureMap = disclosureMap,
additionalJwtHeaders = additionalJwtHeaders.toMutableMap().apply {
put("typ", "JWT".toJsonElement())
put("typ", type.toJsonElement())
},
additionalJwtOptions = additionalJwtOptions.toMutableMap().apply {
putAll(jwtOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ class LspPotentialIssuance(val client: HttpClient) {
assertNotNull(credResp.credential)
val sdJwtVc = SDJwtVC.parse(credResp.credential!!.jsonPrimitive.content)
assertNotNull(sdJwtVc.cnfObject)
assertEquals("vc+sd-jwt", sdJwtVc.type)
// family_name is defined as non-selective disclosable in issuance request
assertContains(sdJwtVc.undisclosedPayload.keys, "family_name")
// birthdate is defined as selective disclosable in issuance request
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ open class CIProvider : OpenIDCredentialIssuer(
issuerKey, issuerDid.ifEmpty { issuerKey.getKeyId() },
holderDid ?: holderKey?.getKeyId() ?: throw IllegalArgumentException("Either holderKey or holderDid must be given"),
request.mapping ?: JsonObject(emptyMap()),
type = SDJwtVC.SD_JWT_VC_TYPE_HEADER,
additionalJwtHeaders = request.x5Chain?.let {
mapOf("x5c" to JsonArray(it.map { cert -> cert.toJsonElement() }))
} ?: mapOf(),
Expand Down

0 comments on commit bf80a95

Please sign in to comment.