How inji/inji-openid4vp works
1. Repository shape
- This is a Kotlin Multiplatform repository centered on the openID4VP library, plus a separate Android sample wallet app in sampleovpwallet.
- The root also contains specification notes (doc/), architecture decisions (doc/adr/), and GitHub Actions for publishing the library artifact.
2. Core architectural split
- The reusable logic lives in kotlin/openID4VP/src/commonMain, which is the platform-agnostic OpenID4VP engine.
- Platform-specific shims exist in androidMain and jvmMain for encoding/decoding and runtime differences, keeping protocol logic shared across Android and JVM.
- Tests mirror this split with commonTest, androidUnitTest, and jvmTest.
3. Public library surface
- OpenID4VP.kt is the library façade used by wallets.
- From the README, the key flow is: validate an authorization request, build unsigned VP tokens, accept signed presentation data, and submit the final authorization response to the verifier.
4. Authorization request subsystem
- The authorizationRequest package handles parsing, validation, and normalization of verifier requests.
- It supports both by-value and by-reference requests (request_uri), and it distinguishes behavior by client_id_scheme.
- Dedicated handlers exist for pre-registered, redirect_uri, and did schemes, which is a major architectural boundary because request trust rules differ by scheme.
5. Presentation definition and metadata model
- authorizationRequest/presentationDefinition contains the OpenID4VP presentation-definition model: input descriptors, constraints, fields, filters, and limit disclosure.
- clientMetadata and WalletMetadata model verifier and wallet capabilities, including JWK/JWKS material used later for signing and encryption decisions.
6. Authorization response subsystem
- authorizationResponse assembles the response sent back to the verifier.
- It includes presentationSubmission mapping, response wrappers, error responses, and the token-building pipeline.
- The response path is format-aware: ldp_vc, mso_mdoc, dc+sd-jwt, and vc+sd-jwt each have dedicated token and signing-result models.
7. VP token construction and format specialization
- vpToken/ and unsignedVPToken/ are the main construction layers for verifiable presentation tokens.
- Each supported credential family has its own builder and model, which is important for architecture because the library does not treat all credentials uniformly.
- VPTokenFactory and VPTokenBuilder act as dispatch points over the supported VPTokenType variants.
8. Cryptography and serialization boundary
- jwt/jws and jwt/jwe provide signing and encryption primitives for the authorization request/response flow.
- common/ includes CBOR utilities, canonicalization, Jackson object mapping, field validation, UUID/date helpers, and encoder/decoder abstractions.
- The presence of URDNA2015 canonicalization and CBOR support shows the library is handling both linked-data and mdoc-style payload requirements, not just plain JWTs.
9. Network and response-mode routing
- networkManager is the boundary for outbound HTTP interactions, especially fetching request_uri content and posting to response_uri.
- responseModeHandler selects the correct delivery strategy for direct_post, direct_post.jwt, iar-post, and iar-post.jwt.
- This is where transport policy is separated from token creation: the response-mode layer decides how to send, while the authorization-response layer decides what to send.
10. End-to-end wallet flow
- The sample wallet app demonstrates the integration boundary between UI and the library.
- MainActivity, the Compose screens, and SharedViewModel drive the user journey; HardcodedOVPData and HardcodedVC provide demo credentials and requests.
- OpenID4VPManager, KeyManager, and DetachedJwtKeyManager handle app-side orchestration and signing responsibilities that sit outside the shared library.
11. Supported protocol constraints
- The README makes the main supported matrix explicit: OpenID4VP drafts 21 and 23, client_id_scheme values pre-registered, redirect_uri, and did, and response modes centered on direct_post / direct_post.jwt plus iar-post variants.
- mdoc support is special-cased: if an authorization request includes mso_mdoc, the response must use encrypted direct_post.jwt, which affects the control flow in the response-mode layer.
12. Delivery and maintenance
- The repo is set up to publish the Android/Maven artifact through GitHub Actions.
- The ADRs document evolution of naming and token structure, indicating the library has a stable core API with deliberate versioned changes rather than ad hoc protocol handling.
Main entry points: OpenID4VP.kt OpenID4VP · sampleapp Sample app · authorizationRequest Auth request · authorizationResponse Auth response
Components 22
Kotlin library
Reusable OpenID4VP engine and its platform shims.
- OpenID4VP · Public entry point used by wallet apps to validate requests, build VP tokens, and produce authorization responses.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/OpenID4VP.kt - Auth request · Parses, validates, and normalizes inbound authorization requests, including by-value and request_uri flows.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest - Client schemes · Dispatches request handling by client_id_scheme with specialized trust and validation rules.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler - Presentation model · Models presentation definition structures such as input descriptors, constraints, fields, filters, and limit disclosure.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition - Metadata models · Captures client and wallet metadata, including JWK/JWKS material used by signing and encryption decisions.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/clientMetadata - Auth response · Builds authorization responses, presentation submissions, error responses, and token-wrapping structures.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse - Unsigned VP · Constructs unsigned verifiable presentation tokens before signing, with builders per credential family.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/unsignedVPToken - VP tokens · Represents signed verifiable presentation token variants and the factory/builder dispatch layer.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpToken - Signing results · Carries format-specific signing outcomes and response metadata for LDP, mdoc, and SD-JWT flows.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpTokenSigningResult - Crypto and utils · Common serialization, validation, canonicalization, CBOR, date/UUID, and encoder/decoder utilities.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/common - JWT/JWE · Provides signing and encryption handlers used across request and response processing.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/jwt - Network client · Outbound HTTP boundary for request_uri retrieval and response_uri posting.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/networkManager - Response mode · Chooses the outbound response delivery strategy such as direct_post and direct_post.jwt.
kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/responseModeHandler - Android shims · Android-specific decoder and encoder implementations for the shared library.
kotlin/openID4VP/src/androidMain/kotlin/io/mosip/openID4VP/common - JVM shims · JVM-specific decoder and encoder implementations for the shared library.
kotlin/openID4VP/src/jvmMain/kotlin/io/mosip/openID4VP/common
Sample wallet
Android Compose app that exercises the library end to end.
- Sample app · Android sample wallet that integrates the library, drives UI flow, and demonstrates signing and matching.
kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp - Wallet UI · MainActivity, app shell, and Compose screens that guide the demo wallet journey.
kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/screens - Wallet state · SharedViewModel and hardcoded demo data used to coordinate the wallet walkthrough.
kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/data - Key manager · App-side key management and detached JWT signing helpers for the sample wallet.
kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/utils
Docs and delivery
Specification notes, ADRs, and publishing automation.
- Workflow docs · Repository notes describing the OpenID4VP workflow and protocol expectations.
doc/OpenId4VPWorkflow.md - ADRs · Architecture decision records documenting naming, token structure, and multi-format VP support.
doc/adr - Publish CI · Workflow automation for artifact publishing and repository-triggered maintenance.
.github/workflows/android-maven-publish.yml
Connections 21
- OpenID4VP → Auth request: validates · Facade delegates request handling to authorization request parsing and normalization.
- OpenID4VP → Auth response: builds · Facade exposes response construction for wallets.
- Auth request → Client schemes: routes by scheme · Request handling branches by client_id_scheme trust model.
- Auth request → Presentation model: uses · Authorization requests embed presentation-definition content.
- Auth request → Metadata models: reads metadata · Verifier and wallet metadata are part of request validation.
- Auth response → Unsigned VP: creates · Response assembly starts from unsigned VP token construction.
- Unsigned VP → VP tokens: specializes into · Unsigned tokens flow into signed VP token variants.
- VP tokens → Signing results: produces · Signed VP tokens yield format-specific signing results and metadata.
- VP tokens → JWT/JWE: signed by · Token creation relies on JWS/JWE primitives where required.
- Auth response → Response mode: delivered via · Response content is handed to response-mode routing for transport selection.
- Response mode → Network client: posts/fetches · Delivery routing uses the network client for request_uri and response_uri interactions.
- Crypto and utils → JWT/JWE: supports · Shared serialization and canonicalization utilities underpin cryptographic payload handling.
- Android shims → Crypto and utils: implements · Android supplies platform-specific encoder/decoder implementations.
- JVM shims → Crypto and utils: implements · JVM supplies platform-specific encoder/decoder implementations.
- Sample app → Wallet UI: contains · The sample wallet organizes its app shell and screens around the demo flow.
- Sample app → Wallet state: coordinates · SharedViewModel and demo data drive state through the wallet journey.
- Sample app → Key manager: signs with · Wallet utilities manage key material and detached JWT signing.
- Sample app → OpenID4VP: integrates · The sample wallet consumes the reusable OpenID4VP library.
- Workflow docs → OpenID4VP: documents · Workflow notes describe the public protocol flow implemented by the library.
- ADRs → OpenID4VP: governs evolution · ADRs capture deliberate changes to the library API and token structure.
- Publish CI → OpenID4VP: publishes · GitHub Actions package the library artifact for release.