Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ proguard-project.txt
# Android Studio/IDEA
*.iml
.idea
.kotlin
2 changes: 1 addition & 1 deletion CredentialProvider/MyVault/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ espressoCore = "3.6.1"
lifecycleRuntime = "2.8.7"
activityCompose = "1.10.0"
composeBom = "2025.02.00"
credentials = "1.6.0"
credentials = "1.7.0-alpha02"
room = "2.7.2"
biometrics = "1.2.0-alpha05"
accompanist = "0.28.0"
Expand Down
58 changes: 58 additions & 0 deletions DigitalCredentialsApp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Digital Credentials Sample App

This is a sample repository for the **Digital Credentials API** integration in Android, showcasing how to request and parse verifiable credentials using the Credential Manager.

The Digital Credentials Sample App is a functional Android app built with Kotlin and Jetpack Compose. It is designed to help developers understand the workflow for retrieving and presenting digital credentials, such as Mobile Driver's Licenses (mDL) and Verified Emails, using the OpenID4VP and DCQL standards.

## Features

This sample app implements the following use cases:

* **Get Digital Credential (mdoc)**: Request a Mobile Driver's License (mDL) or other ISO 18013-5 compliant credentials.
* **Get Verified Email**: Request a verified email address using the SD-JWT (Selective Disclosure JWT) format.
* **OpenID4VP & DCQL Support**: Demonstrates how to construct modern, simplified Digital Credential Query Language (DCQL) requests.
* **CBOR & SD-JWT Parsing**: Includes a reference implementation for decoding CBOR-based mDoc data and parsing selectively disclosed claims from SD-JWTs.

## Requirements

* Latest release of [Android Studio](https://developer.android.com/studio)
* Java 17 or higher
* A physical device or emulator running Android 9 (API level 28) or higher.
* A digital wallet app (like [CMWallet](https://github.com/digitalcredentialsdev/CMWallet)) installed and registered on the device to test the generic retrieval flow. This is not needed to test email verification functionality.

## Typical Workflow

* **Launch the app**: The main screen presents two primary actions for credential retrieval.
* **Request a Credential**: Tap on "Get Digital Credential (mdoc)" or "Get Verified Email".
* **Credential Selection**: The Credential Manager bottom sheet will appear, listing available credentials from registered wallets.
* **User Consent**: Once a credential is selected, the wallet app will handle user consent and authentication.
* **Result Display**: The app receives the response, validates it locally (simulated), parses the individual claims (e.g., Given Name, Email), and displays them in the UI.

## Architecture & Design

### Credential Manager Integration

Credential Manager calls are centralized in `CredentialManagerUtil.kt`. The app uses `GetDigitalCredentialOption` to pass JSON requests formatted according to the OpenID4VP specification.

### Data Requests

The `Requests.kt` file contains the logic for generating dynamic JSON requests. It supports:
- **DCQL Query Structure**: Simplified claim requests using paths.
- **Client Metadata**: Specifies supported algorithms for secure credential exchange.

### Parsing Logic

Since digital credentials come in various formats, the app includes robust parsing utilities:
- **CBOR Decoding**: A dedicated `Cbor.kt` utility handles the binary mDoc format, including manual unwrapping of Tag 24 items.
- **SD-JWT Parsing**: Logic to extract claims from Selective Disclosure JWTs by decoding individual disclosures.

### UI Layer

Built with **Jetpack Compose**, the UI follows a simple MVI-like pattern:
- `MainScreen.kt`: Handles the UI layout and interaction events.
- `MainViewModel.kt`: Manages the state of the credential request (Initial, Loading, Success, or Error).
- `MainUiState.kt`: Defines the data model for the UI states and extracted claims.

## License

This sample is distributed under the terms of the Apache License (Version 2.0). See the [LICENSE](LICENSE) file for more information.
62 changes: 62 additions & 0 deletions DigitalCredentialsApp/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'org.jetbrains.kotlin.plugin.compose'
}

android {
namespace 'com.example.digitalcredentialsapp'
compileSdk 35

defaultConfig {
applicationId "com.example.digitalcredentialsapp"
minSdk 26
targetSdk 35
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
compose true
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0'
implementation 'androidx.lifecycle:lifecycle-runtime-compose:2.7.0'

// Compose
implementation platform('androidx.compose:compose-bom:2024.02.00')
implementation 'androidx.compose.ui:ui'
implementation 'androidx.compose.ui:ui-graphics'
implementation 'androidx.compose.ui:ui-tooling-preview'
implementation 'androidx.compose.material3:material3'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0'

// Credential Manager
implementation("androidx.credentials:credentials:1.6.0-beta01")
implementation("androidx.credentials:credentials-play-services-auth:1.6.0-beta01")

// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'

debugImplementation 'androidx.compose.ui:ui-tooling'
debugImplementation 'androidx.compose.ui:ui-test-manifest'
}
19 changes: 19 additions & 0 deletions DigitalCredentialsApp/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:allowBackup="true"
android:label="Digital Credentials Demo"
android:supportsRtl="true"
android:theme="@android:style/Theme.DeviceDefault.NoActionBar">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading
Loading