Skip to content

Commit

Permalink
Update credential selection when presenting (#72)
Browse files Browse the repository at this point in the history
This skips the credential selection page when only one credential matches the OID4VP request.
  • Loading branch information
Juliano1612 authored Dec 20, 2024
1 parent 1c00769 commit 15815eb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
4 changes: 2 additions & 2 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "com.spruceid.mobilesdkexample"
minSdk = 26
targetSdk = 34
versionCode = 20
versionName = "1.3.0"
versionCode = 22
versionName = "1.3.2"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,16 @@ import kotlinx.coroutines.withContext
import org.json.JSONObject

class Signer(keyId: String?) : PresentationSigner {
private val keyId = if (keyId == null) "reference-app/default-signing" else keyId
private val keyId = keyId ?: "reference-app/default-signing"
private val keyManager = KeyManager()
private val jwk = keyManager.getJwk(this.keyId) ?: throw IllegalArgumentException("Invalid kid")
private var jwk: String
private val didJwk = DidMethodUtils(DidMethod.JWK)

init {
keyManager.generateSigningKey(id = this.keyId)
this.jwk = keyManager.getJwk(this.keyId) ?: throw IllegalArgumentException("Invalid kid")
}

override suspend fun sign(payload: ByteArray): ByteArray {
val signature =
keyManager.signPayload(keyId, payload)
Expand Down Expand Up @@ -151,7 +156,18 @@ fun HandleOID4VPView(
getVCPlaygroundOID4VCIContext(ctx)
)
val newurl = url.replace("authorize", "")
permissionRequest = holder!!.authorizationRequest(newurl)
val tempPermissionRequest = holder!!.authorizationRequest(newurl)
val permissionRequestCredentials = tempPermissionRequest.credentials()

if (permissionRequestCredentials.count() == 1) {
selectedCredential = permissionRequestCredentials.first()
permissionResponse =
tempPermissionRequest.createPermissionResponse(
permissionRequestCredentials
)
}

permissionRequest = tempPermissionRequest
}
} catch (e: Exception) {
err = e.localizedMessage
Expand Down

0 comments on commit 15815eb

Please sign in to comment.