Repository navigation
Let transaction types control their SD-JWT response - #2224
Draft
TheBlackBit wants to merge 1 commit into
Draft
TheBlackBit wants to merge 1 commit into
TheBlackBit wants to merge 1 commit into
Conversation
This was referenced Nov 20, 2026
TheBlackBit
marked this pull request as draft
November 20, 2026 22:08
TheBlackBit
force-pushed
the
feat/transaction-data-hooks
branch
from
November 20, 2026 22:24
fd6339c to
169fdc6
Compare
2 tasks done
Add the generic hooks a transaction type needs to answer an OpenID4VP request that carries more than a plain key binding, without core knowing anything about the type. Every default leaves existing types unchanged. - `TransactionType.nestSdJwtResponseClaims`, default `true`. When `false`, a type's response claims are merged into the Key Binding JWT verbatim instead of being nested under `kbJwtResponseClaimName`, and arrays accumulate across items of the same type instead of the last item overwriting the others. `OpenID4VP.processTransactions()` now refuses a type that sets one of the Key Binding JWT's own claims (`iat`, `aud`, `nonce`, `sd_hash`, `transaction_data_hashes`, `transaction_data_hashes_alg`), a claim another type sets, or a value another item of its type sets differently, instead of letting one silently replace the other. - `TransactionType.sdJwtKbType()` gives the `typ` header of the Key Binding JWT, `null` (the ordinary `kb+jwt`) unless a type overrides it. A type decides it over all of its items at once, and the internal `TransactionData.sdJwtKbType()` refuses two types that ask for different values. `SdJwtKb.verify()` takes the expected type, still defaulting to `kb+jwt`. - `TransactionType.generateSdJwtResponse()` returns the Key Binding JWT claims together with disclosures that follow it, as `SdJwtTransactionResponse`. By default it returns the claims of `generateSdJwtResponseClaims()` and no disclosures. When a type returns disclosures, the OpenID4VP path presents through `SdJwt.presentWithKbDisclosures()`, which builds the same Key Binding JWT as `present()` and returns `<SD-JWT>~~<KB-JWT>~<Disclosure>~`; its `type` is required, as such a Key Binding JWT is never the ordinary `kb+jwt`. The ISO mdoc path only reads the new response type and refuses disclosures and a Key Binding JWT type other than `kb+jwt`, naming the types, since ISO/IEC 18013-5 has no place for them. A type that returns disclosures without overriding `sdJwtKbType()`, or two items that return the same disclosure, are refused with a message naming the hooks instead of failing in the presentation code. - `TransactionType.validateTogether()` lets a type refuse, before the consent prompt, a combination of its own items that one response answers together. `OpenID4VP` calls it for each credential right after parsing, inside the existing handling that reports a problem with the transaction data. `isApplicable()` may likewise throw `IllegalArgumentException` for malformed data and is reported with its reason: `DcqlQuery` translates only that call, so an unrelated `IllegalArgumentException` while matching credentials keeps its own message. Types that ask for different Key Binding JWT types are refused at the same point. - The overridable functions declare `@Throws`, so Kotlin/Native overrides do not hit a filter mismatch. The `TransactionType` KDoc gains a usage example and says which hooks apply to OpenID4VP only. Test: ./gradlew :multipaz:jvmTest (1897 tests, 0 failures), including the new SdJwtTest cases, TransactionDataSdJwtKbTypeTest, TransactionDataValidateTogetherTest and the unnested array, claim collision, Key Binding JWT disclosure, validateTogether() refusal and isApplicable() refusal cases in DigitalCredentialsPresentmentTest; ./gradlew :multipaz:compileTestKotlinIosSimulatorArm64; ./gradlew detektMetadataCommonMain. Signed-off-by: Ever Morales <ever.morales@koombea.com>
TheBlackBit
force-pushed
the
feat/transaction-data-hooks
branch
from
November 21, 2026 01:08
169fdc6 to
5800379
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2010
No-Issue: part of #2010, which #2196 closes
Why
Some transaction data types need more than the built-in handling can do. They may need a different key binding type, return extra disclosures after the Key Binding JWT, or refuse a request before the person is asked. Today a type can do none of this, so core has to be changed for each new protocol.
This PR adds the hooks and nothing else. No type uses them yet, and every default leaves existing types working as before. The first user is the AP2 type in #2178. The rule that a type's data must be shown by a renderer is in #2225; the two don't depend on each other.
What changes in
multipaznestSdJwtResponseClaims: a type can put its claims at the top level of the Key Binding JWT instead of nesting them. Arrays from several items are combined. A claim that would overwrite one of the Key Binding JWT's own claims, or another type's, is refused.sdJwtKbType(): thetypof the Key Binding JWT, decided over all of a type's items.SdJwtKb.verify()takes thetypit expects,kb+jwtby default.generateSdJwtResponse()andSdJwt.presentWithKbDisclosures(): a type can return disclosures that follow the Key Binding JWT, as<SD-JWT>~~<KB-JWT>~<Disclosure>~. This works over OpenID4VP only; the ISO/IEC 18013-5 path refuses them.validateTogether()(andisApplicable()throwing for malformed data): a type can refuse a request before the consent prompt, with its reason, instead of failing after the person approved.@Throwson the overridable functions, so Kotlin/Native overrides compile.Testing
./gradlew :multipaz:jvmTest: 1894 tests, 0 failures. New tests cover the Key Binding JWT type, disclosures after it, claim collisions andvalidateTogether().:multipaz:compileTestKotlinIosSimulatorArm64anddetektMetadataCommonMainpass.Tests pass
Appropriate changes to README are included in PR (none needed)