Skip to content

Commit

Permalink
Adding sample for a simple age-verification reader app demonstrating
Browse files Browse the repository at this point in the history
use of the MdocReaderPrompt class, which allows any app to easily act
as a reader app for the common age-verification use case. This class
abstracts much of the VerificationHelper details for a simpler API which
only requires an MdocReaderSettings object as input before it can be
shown. The MdocReaderPrompt object, once created, has a `show` method
which will show relevant UI on-screen for in-person verification. Data
from the transaction is not passed back to the app

Signed-off-by: Suzanna Jiwani <[email protected]>
  • Loading branch information
suzannajiwani committed Jan 25, 2024
1 parent ca5956a commit 0c1b7f0
Show file tree
Hide file tree
Showing 33 changed files with 1,570 additions and 6 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
.gradle
/local.properties
.DS_Store
/build
*/build/
/captures
.externalNativeBuild
.idea/
fastlane/report.xml
/mdl-ref-server/mdl-server-db.sqlite3
/version*
wwwverifier/build/*
wwwverifier/build/*
samples/*/build
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ samples are included
- `age-verifier-mdl` - a simple mDL reader for age attestations.
- This application is just requesting the `age_over_21` and `portrait`. It's intended
to be used with the `preconsent-mdl` sample for performance evaluation.
- `simple-verifier` - a simple mDL reader for age attestations.
- This application requests either {`age_over_21` and `portrait`} or
{`age_over_18` and `portrait`}. It's intended to demonstrate use of the
`MdocReaderPrompt` class, which allows any app to easily act as a reader app for
the common age-verification use case.

## ISO 18013-7 Reader Website

Expand Down
3 changes: 1 addition & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
espresso-core = "3.5.1"
junit-jupiter = "5.10.0"
truth = "1.1.5"
navigation-compose = "2.7.5"

[libraries]
androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "core-ktx" }
Expand Down Expand Up @@ -86,7 +85,7 @@
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit-jupiter" }
kotlinx-coroutine-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutines-version" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }
androidx-navigation-compose = { group = "androidx.navigation", name = "navigation-compose", version.ref = "navigation-compose" }
androidx-navigation-compose = { module = "androidx.navigation:navigation-compose", version.ref = "navigation" }

[bundles]
androidx-core = ["androidx-core-ktx", "androidx-appcompat", "androidx-material", "androidx-contraint-layout", "androidx-fragment-ktx", "androidx-legacy-v4", "androidx-preference-ktx", "androidx-work"]
Expand Down
69 changes: 69 additions & 0 deletions samples/simple-verifier/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
plugins {
alias(libs.plugins.android.application)
alias libs.plugins.kotlin.android
}

android {
namespace 'com.example.simple_verifier'
compileSdk 34

defaultConfig {
applicationId "com.example.simple_verifier"
minSdk 29
targetSdk 34
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary true
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = '11'
}
buildFeatures {
compose true
}
composeOptions {
kotlinCompilerExtensionVersion '1.4.5'
}
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}

dependencies {
implementation platform(libs.compose.bom)
implementation libs.bundles.androidx.core
implementation libs.bundles.androidx.lifecycle
implementation libs.bundles.androidx.navigation
implementation libs.bundles.androidx.crypto
implementation libs.bundles.androidx.activity.compose
implementation libs.androidx.navigation.compose
implementation libs.bundles.bouncy.castle
implementation libs.bundles.compose
implementation libs.code.scanner

implementation("com.android.identity:identity-credential-android:20231002")
implementation("com.android.identity:identity-credential:20231002")

androidTestImplementation libs.androidx.test.ext.junit
androidTestImplementation libs.androidx.test.espresso
androidTestImplementation platform(libs.compose.bom)
testImplementation libs.bundles.unit.testing
testRuntimeOnly libs.junit.jupiter.engine
}
21 changes: 21 additions & 0 deletions samples/simple-verifier/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.example.simple_verifier

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.example.simple_verifier", appContext.packageName)
}
}
57 changes: 57 additions & 0 deletions samples/simple-verifier/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<uses-feature
android:name="android.hardware.nfc"
android:required="true" />

<uses-permission android:name="android.permission.INTERNET" />
<!-- As of API 31 BLE doesn't need location permission, but WiFi aware still requires it. -->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />

<!-- Legacy bluetooth permissions -->
<uses-permission android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />

<!-- Bluetooth permissions for Android 12+ -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<uses-permission android:name="android.permission.VIBRATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.IdentityCredential">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.IdentityCredential">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
Loading

0 comments on commit 0c1b7f0

Please sign in to comment.