Skip to content

Commit

Permalink
wip: oid4vp integration
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <[email protected]>
  • Loading branch information
joeyschmoe authored and Ryanmtate committed Oct 9, 2024
1 parent 9505a1c commit fc56ec0
Show file tree
Hide file tree
Showing 10 changed files with 427 additions and 283 deletions.
210 changes: 103 additions & 107 deletions MobileSdk/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,140 +1,136 @@
plugins {
id("com.android.library")
id("org.jetbrains.kotlin.android")
`maven-publish`
id("signing")
id("com.gradleup.nmcp")
id("com.android.library")
id("org.jetbrains.kotlin.android")
`maven-publish`
id("signing")
id("com.gradleup.nmcp")
}

publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/spruceid/mobile-sdk-kt")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
}
publications {
create<MavenPublication>("debug") {
groupId = "com.spruceid.mobile.sdk"
artifactId = "mobilesdk"
version = System.getenv("VERSION")

afterEvaluate { from(components["release"]) }
}
// Creates a Maven publication called "release".
create<MavenPublication>("release") {
groupId = "com.spruceid.mobile.sdk"
artifactId = "mobilesdk"
version = System.getenv("VERSION")

afterEvaluate { from(components["release"]) }

pom {
packaging = "aar"
name.set("mobilesdk")
description.set("Android SpruceID Mobile SDK")
url.set("https://github.com/spruceid/mobile-sdk-kt")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/license/mit/")
}
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Spruce Systems, Inc.")
email.set("[email protected]")
}
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/spruceid/mobile-sdk-kt")
credentials {
username = System.getenv("GITHUB_ACTOR")
password = System.getenv("GITHUB_TOKEN")
}
}
scm {
url.set(pom.url.get())
connection.set("scm:git:${url.get()}.git")
developerConnection.set("scm:git:${url.get()}.git")
}
publications {
// Creates a Maven publication called "release".
create<MavenPublication>("release") {
groupId = "com.spruceid.mobile.sdk"
artifactId = "mobilesdk"
version = System.getenv("VERSION")

afterEvaluate { from(components["release"]) }

pom {
packaging = "aar"
name.set("mobilesdk")
description.set("Android SpruceID Mobile SDK")
url.set("https://github.com/spruceid/mobile-sdk-kt")
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/license/mit/")
}
license {
name.set("Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
name.set("Spruce Systems, Inc.")
email.set("[email protected]")
}
}
scm {
url.set(pom.url.get())
connection.set("scm:git:${url.get()}.git")
developerConnection.set("scm:git:${url.get()}.git")
}
}
}
}
}
}
}

signing {
useGpgCmd()
sign(publishing.publications["release"])
useGpgCmd()
sign(publishing.publications["release"])
}

nmcp {
afterEvaluate {
publish("release") {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
publicationType = "AUTOMATIC"
afterEvaluate {
publish("release") {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
publicationType = "AUTOMATIC"
}
}
}
}

android {
namespace = "com.spruceid.mobile.sdk"
compileSdk = 35

defaultConfig {
minSdk = 26
defaultConfig {
minSdk = 26

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

kotlinOptions { jvmTarget = "1.8" }
kotlinOptions { jvmTarget = "1.8" }

buildFeatures {
compose = true
viewBinding = true
}
buildFeatures {
compose = true
viewBinding = true
}

composeOptions { kotlinCompilerExtensionVersion = "1.5.11" }
composeOptions { kotlinCompilerExtensionVersion = "1.5.11" }

publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
publishing {
singleVariant("release") {
withSourcesJar()
withJavadocJar()
}
}
}
}

dependencies {
api("com.spruceid.mobile.sdk.rs:mobilesdkrs:0.0.36")
//noinspection GradleCompatible
implementation("com.android.support:appcompat-v7:28.0.0")
/* Begin UI dependencies */
implementation("androidx.compose.material3:material3:1.2.1")
implementation("androidx.camera:camera-camera2:1.3.2")
implementation("androidx.camera:camera-lifecycle:1.3.2")
implementation("androidx.camera:camera-view:1.3.2")
implementation("com.google.zxing:core:3.5.1")
implementation("com.google.accompanist:accompanist-permissions:0.34.0")
implementation("androidx.camera:camera-mlkit-vision:1.3.0-alpha06")
implementation("com.google.android.gms:play-services-mlkit-text-recognition:19.0.0")
/* End UI dependencies */
implementation("androidx.datastore:datastore-preferences:1.1.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("com.android.support.test:runner:1.0.2")
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
api("com.spruceid.mobile.sdk.rs:mobilesdkrs:0.0.99b")
//noinspection GradleCompatible
implementation("com.android.support:appcompat-v7:28.0.0")
/* Begin UI dependencies */
implementation("androidx.compose.material3:material3:1.2.1")
implementation("androidx.camera:camera-camera2:1.3.2")
implementation("androidx.camera:camera-lifecycle:1.3.2")
implementation("androidx.camera:camera-view:1.3.2")
implementation("com.google.zxing:core:3.5.1")
implementation("com.google.accompanist:accompanist-permissions:0.34.0")
implementation("androidx.camera:camera-mlkit-vision:1.3.0-alpha06")
implementation("com.google.android.gms:play-services-mlkit-text-recognition:19.0.0")
/* End UI dependencies */
implementation("androidx.datastore:datastore-preferences:1.1.1")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("com.android.support.test:runner:1.0.2")
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2")
}
13 changes: 13 additions & 0 deletions example/.idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.Surface
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.ui.Modifier
import androidx.lifecycle.coroutineScope
import androidx.navigation.NavHostController
import androidx.navigation.compose.rememberNavController
import com.spruceid.mobilesdkexample.db.AppDatabase
Expand All @@ -19,6 +21,10 @@ import com.spruceid.mobilesdkexample.ui.theme.Bg
import com.spruceid.mobilesdkexample.ui.theme.MobileSdkTheme
import com.spruceid.mobilesdkexample.viewmodels.IRawCredentialsViewModel
import com.spruceid.mobilesdkexample.viewmodels.RawCredentialsViewModelFactory
import kotlinx.coroutines.launch
import com.spruceid.mobile.sdk.KeyManager

const val DEFAULT_KEY_ID = "key-1"

class MainActivity : ComponentActivity() {
private lateinit var navController: NavHostController
Expand All @@ -28,7 +34,11 @@ class MainActivity : ComponentActivity() {

val deepLinkUri: Uri? = intent.data
if (deepLinkUri != null) {
// @TODO: integrate with the OID4VP flow
// Remove? TBD
if (deepLinkUri.scheme == "oid4vp://") {
// NOTE: See DispatchQRView.kt for handling OID4VP QR code scanning,
// and credential selection.
}
}

enableEdgeToEdge()
Expand All @@ -44,6 +54,32 @@ class MainActivity : ComponentActivity() {
val credentialsViewModel: IRawCredentialsViewModel by viewModels {
RawCredentialsViewModelFactory((application as MainApplication).rawCredentialsRepository)
}

// Insert a raw credential into the rawCredentialsRepository,
// using a suspend / async method.
LaunchedEffect(credentialsViewModel) {
lifecycle.coroutineScope.launch {
// Setup a default keyId for the RequestSigner.
// Check the key manager if the key exists, if not, create it.
val km = KeyManager()

if (!km.keyExists(DEFAULT_KEY_ID)) {
// Key does not exist, create it.
km.generateSigningKey(DEFAULT_KEY_ID)
}


// Clear the raw credentials table.
// credentialsViewModel.deleteAllRawCredentials()
// // Load the exampleSdJwt into the raw credentials table.
// credentialsViewModel.saveRawCredential(
// com.spruceid.mobilesdkexample.db.RawCredentials(
// rawCredential = exampleSdJwt
// )
// )
}
}

SetupNavGraph(navController, credentialsViewModel)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ const val VERIFY_VC_PATH = "verify_vc"
const val VERIFIER_SETTINGS_HOME_PATH = "verifier_settings_home"
const val WALLET_SETTINGS_HOME_PATH = "wallet_settings_home"
const val ADD_TO_WALLET_PATH = "add_to_wallet/{rawCredential}"
const val OID4VP_PATH = "oid4vp/{params}"
const val SCAN_QR_PATH = "scan_qr"
const val OID4VCI_PATH = "oid4vci"


const val HANDLE_OID4VP_PATH = "oid4vp/{url}"

sealed class Screen(val route: String) {
object HomeScreen : Screen(HOME_SCREEN_PATH)
Expand All @@ -20,6 +19,7 @@ sealed class Screen(val route: String) {
object VerifierSettingsHomeScreen : Screen(VERIFIER_SETTINGS_HOME_PATH)
object WalletSettingsHomeScreen : Screen(WALLET_SETTINGS_HOME_PATH)
object AddToWalletScreen : Screen(ADD_TO_WALLET_PATH)
object ScanQRScreen : Screen(OID4VP_PATH)
object ScanQRScreen : Screen(SCAN_QR_PATH)
object OID4VCIScreen : Screen(OID4VCI_PATH)
}
object HandleOID4VP : Screen(HANDLE_OID4VP_PATH)
}
Loading

0 comments on commit fc56ec0

Please sign in to comment.