# inji/inji-openid4vp architecture

> Architecture diagram of the GitHub repository inji/inji-openid4vp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/inji/inji-openid4vp
- Repository: https://github.com/inji/inji-openid4vp

## Overview

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: [`kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/OpenID4VP.kt`](https://github.com/inji/inji-openid4vp/blob/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/OpenID4VP.kt) (OpenID4VP), [`kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp`](https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp) (Sample app), [`kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest`](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest) (Auth request), [`kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse`](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse) (Auth response)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_g1["Kotlin library"]
  node_n1["OpenID4VP<br/>library facade<br/>[OpenID4VP.kt]"]
  node_n2["Auth request<br/>request parsing"]
  node_n3["Client schemes<br/>scheme routing"]
  node_n4["Presentation model<br/>pd model"]
  node_n5["Metadata models<br/>wallet/verifier metadata"]
  node_n6["Auth response<br/>response assembly"]
  node_n7["Unsigned VP<br/>token builder"]
  node_n8["VP tokens<br/>token model"]
  node_n9["Signing results<br/>signing output"]
  node_n10["Crypto and utils<br/>shared primitives"]
  node_n11["JWT/JWE<br/>crypto transport"]
  node_n12["Network client<br/>http boundary"]
  node_n13["Response mode<br/>delivery routing"]
  node_n14["Android shims<br/>platform impl"]
  node_n15["JVM shims<br/>platform impl"]
end

subgraph group_g2["Sample wallet"]
  node_n16["Sample app<br/>android wallet"]
  node_n17["Wallet UI<br/>compose screens"]
  node_n18["Wallet state<br/>view model"]
  node_n19["Key manager<br/>app signing"]
end

subgraph group_g3["Docs and delivery"]
  node_n20["Workflow docs<br/>spec notes"]
  node_n21["ADRs<br/>decision records"]
  node_n22["Publish CI<br/>github actions"]
end

node_n1 -->|"validates"| node_n2
node_n1 -->|"builds"| node_n6
node_n2 -->|"routes by scheme"| node_n3
node_n2 -->|"uses"| node_n4
node_n2 -->|"reads metadata"| node_n5
node_n6 -->|"creates"| node_n7
node_n7 -->|"specializes into"| node_n8
node_n8 -->|"produces"| node_n9
node_n8 -->|"signed by"| node_n11
node_n6 -->|"delivered via"| node_n13
node_n13 -->|"posts/fetches"| node_n12
node_n10 -->|"supports"| node_n11
node_n14 -->|"implements"| node_n10
node_n15 -->|"implements"| node_n10
node_n16 -->|"contains"| node_n17
node_n16 -->|"coordinates"| node_n18
node_n16 -->|"signs with"| node_n19
node_n16 -->|"integrates"| node_n1
node_n20 -->|"documents"| node_n1
node_n21 -->|"governs evolution"| node_n1
node_n22 -->|"publishes"| node_n1

click node_n1 "https://github.com/inji/inji-openid4vp/blob/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/OpenID4VP.kt"
click node_n2 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest"
click node_n3 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler"
click node_n4 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition"
click node_n5 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/clientMetadata"
click node_n6 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse"
click node_n7 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/unsignedVPToken"
click node_n8 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpToken"
click node_n9 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpTokenSigningResult"
click node_n10 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/common"
click node_n11 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/jwt"
click node_n12 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/networkManager"
click node_n13 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/responseModeHandler"
click node_n14 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/androidMain/kotlin/io/mosip/openID4VP/common"
click node_n15 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/jvmMain/kotlin/io/mosip/openID4VP/common"
click node_n16 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp"
click node_n17 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/screens"
click node_n18 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/data"
click node_n19 "https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/utils"
click node_n20 "https://github.com/inji/inji-openid4vp/blob/master/doc/OpenId4VPWorkflow.md"
click node_n21 "https://github.com/inji/inji-openid4vp/tree/master/doc/adr"
click node_n22 "https://github.com/inji/inji-openid4vp/blob/master/.github/workflows/android-maven-publish.yml"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_n1,node_n2,node_n3,node_n4,node_n5,node_n6,node_n7,node_n8,node_n9,node_n10,node_n11,node_n12,node_n13,node_n14,node_n15 toneBlue
class node_n16,node_n17,node_n18,node_n19 toneAmber
class node_n20,node_n21,node_n22 toneMint
```

## Components

### Kotlin library

Reusable OpenID4VP engine and its platform shims.

- [OpenID4VP](https://github.com/inji/inji-openid4vp/blob/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/OpenID4VP.kt): library facade · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest): request parsing · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/authorizationRequestHandler): scheme routing · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/presentationDefinition): pd 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationRequest/clientMetadata): wallet/verifier metadata · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse): response assembly · Builds authorization responses, presentation submissions, error responses, and token-wrapping structures. · `kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse`
- [Unsigned VP](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/unsignedVPToken): token builder · Constructs unsigned verifiable presentation tokens before signing, with builders per credential family. · `kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/unsignedVPToken`
- [VP tokens](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpToken): token model · Represents signed verifiable presentation token variants and the factory/builder dispatch layer. · `kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpToken`
- [Signing results](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/authorizationResponse/vpTokenSigningResult): signing output · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/common): shared primitives · Common serialization, validation, canonicalization, CBOR, date/UUID, and encoder/decoder utilities. · `kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/common`
- [JWT/JWE](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/jwt): crypto transport · Provides signing and encryption handlers used across request and response processing. · `kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/jwt`
- [Network client](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/networkManager): http boundary · Outbound HTTP boundary for request_uri retrieval and response_uri posting. · `kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/networkManager`
- [Response mode](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/commonMain/kotlin/io/mosip/openID4VP/responseModeHandler): delivery routing · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/androidMain/kotlin/io/mosip/openID4VP/common): platform impl · Android-specific decoder and encoder implementations for the shared library. · `kotlin/openID4VP/src/androidMain/kotlin/io/mosip/openID4VP/common`
- [JVM shims](https://github.com/inji/inji-openid4vp/tree/master/kotlin/openID4VP/src/jvmMain/kotlin/io/mosip/openID4VP/common): platform impl · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp): android wallet · 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](https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/screens): compose screens · MainActivity, app shell, and Compose screens that guide the demo wallet journey. · `kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/screens`
- [Wallet state](https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/data): view model · SharedViewModel and hardcoded demo data used to coordinate the wallet walkthrough. · `kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/data`
- [Key manager](https://github.com/inji/inji-openid4vp/tree/master/kotlin/sampleovpwallet/src/main/java/io/mosip/sampleapp/utils): app signing · 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](https://github.com/inji/inji-openid4vp/blob/master/doc/OpenId4VPWorkflow.md): spec notes · Repository notes describing the OpenID4VP workflow and protocol expectations. · `doc/OpenId4VPWorkflow.md`
- [ADRs](https://github.com/inji/inji-openid4vp/tree/master/doc/adr): decision records · Architecture decision records documenting naming, token structure, and multi-format VP support. · `doc/adr`
- [Publish CI](https://github.com/inji/inji-openid4vp/blob/master/.github/workflows/android-maven-publish.yml): github actions · Workflow automation for artifact publishing and repository-triggered maintenance. · `.github/workflows/android-maven-publish.yml`

## Connections

- 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.
