diff --git a/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt b/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt index e2f4887..942f1dc 100644 --- a/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt +++ b/src/main/kotlin/id/walt/service/SSIKit2WalletService.kt @@ -183,7 +183,7 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco /** * @return redirect uri */ - override suspend fun usePresentationRequest(request: String, did: String, selectedCredentialIds: List, disclosures: Map>): Result { + override suspend fun usePresentationRequest(request: String, did: String, selectedCredentialIds: List, disclosures: Map>?): Result { val credentialWallet = getCredentialWallet(did) val authReq = AuthorizationRequest.fromHttpQueryString(Url(request).encodedQuery) @@ -192,7 +192,9 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco println("USING PRESENTATION REQUEST, SELECTED CREDENTIALS: $selectedCredentialIds") SessionAttributes.HACK_outsideMappedSelectedCredentialsPerSession[authReq.state + authReq.presentationDefinition] = selectedCredentialIds - SessionAttributes.HACK_outsideMappedSelectedDisclosuresPerSession[authReq.state + authReq.presentationDefinition] = disclosures + if (disclosures != null) { + SessionAttributes.HACK_outsideMappedSelectedDisclosuresPerSession[authReq.state + authReq.presentationDefinition] = disclosures + } val presentationSession = credentialWallet.initializeAuthorization(authReq, 60.seconds, selectedCredentialIds.toSet()) println("Initialized authorization (VPPresentationSession): $presentationSession") diff --git a/src/main/kotlin/id/walt/service/WalletKitWalletService.kt b/src/main/kotlin/id/walt/service/WalletKitWalletService.kt index 8813ecd..4aeb084 100644 --- a/src/main/kotlin/id/walt/service/WalletKitWalletService.kt +++ b/src/main/kotlin/id/walt/service/WalletKitWalletService.kt @@ -200,7 +200,7 @@ class WalletKitWalletService(accountId: UUID, walletId: UUID) : WalletService(ac val state: String? ) - override suspend fun usePresentationRequest(request: String, did: String, selectedCredentialIds: List, disclosures: Map>): Result { + override suspend fun usePresentationRequest(request: String, did: String, selectedCredentialIds: List, disclosures: Map>?): Result { val decoded = URLDecoder.decode(request, Charset.defaultCharset()) val queryParams = getQueryParams(decoded) val redirectUri = queryParams["redirect_uri"]?.first() diff --git a/src/main/kotlin/id/walt/service/WalletService.kt b/src/main/kotlin/id/walt/service/WalletService.kt index b2b8db4..7306cec 100644 --- a/src/main/kotlin/id/walt/service/WalletService.kt +++ b/src/main/kotlin/id/walt/service/WalletService.kt @@ -22,7 +22,7 @@ abstract class WalletService(val accountId: UUID, val walletId: UUID) { abstract fun matchCredentialsByPresentationDefinition(presentationDefinition: PresentationDefinition): List // SIOP - abstract suspend fun usePresentationRequest(request: String, did: String, selectedCredentialIds: List, disclosures: Map>): Result + abstract suspend fun usePresentationRequest(request: String, did: String, selectedCredentialIds: List, disclosures: Map>?): Result abstract suspend fun resolvePresentationRequest(request: String): String abstract suspend fun useOfferRequest(offer: String, did: String) diff --git a/src/main/kotlin/id/walt/service/oidc4vc/TestCredentialWallet.kt b/src/main/kotlin/id/walt/service/oidc4vc/TestCredentialWallet.kt index 1a4bb84..6a1ded5 100644 --- a/src/main/kotlin/id/walt/service/oidc4vc/TestCredentialWallet.kt +++ b/src/main/kotlin/id/walt/service/oidc4vc/TestCredentialWallet.kt @@ -111,12 +111,25 @@ class TestCredentialWallet( val selectedCredentials = HACK_outsideMappedSelectedCredentialsPerSession[session.authorizationRequest!!.state + session.authorizationRequest.presentationDefinition]!! val selectedDisclosures = - HACK_outsideMappedSelectedDisclosuresPerSession[session.authorizationRequest!!.state + session.authorizationRequest.presentationDefinition]!! + HACK_outsideMappedSelectedDisclosuresPerSession[session.authorizationRequest!!.state + session.authorizationRequest.presentationDefinition] println("Selected credentials: $selectedCredentials") val matchedCredentials = walletService.getCredentialsByIds(selectedCredentials) println("Matched credentials: $matchedCredentials") + println("Using disclosures: $selectedDisclosures") + + val credentialsPresented = matchedCredentials.map { + if (selectedDisclosures?.containsKey(it.id) == true) { + it.document + "~${selectedDisclosures[it.id]!!.joinToString("~") }" + } else { + it.document + } + } + + println("Credentials presented: $credentialsPresented") + + val vp = Json.encodeToString( mapOf( "sub" to this.did, @@ -130,7 +143,7 @@ class TestCredentialWallet( "type" to listOf("VerifiablePresentation"), "id" to "urn:uuid:${UUID.generateUUID().toString().lowercase()}", "holder" to this.did, - "verifiableCredential" to matchedCredentials.map { it.document } + "verifiableCredential" to credentialsPresented ) ).toJsonElement() ) diff --git a/src/main/kotlin/id/walt/web/controllers/ExchangeController.kt b/src/main/kotlin/id/walt/web/controllers/ExchangeController.kt index c0ec817..f4aaf6a 100644 --- a/src/main/kotlin/id/walt/web/controllers/ExchangeController.kt +++ b/src/main/kotlin/id/walt/web/controllers/ExchangeController.kt @@ -106,9 +106,10 @@ fun Application.exchange() = walletRoute { ?: throw IllegalArgumentException("No DID to use supplied") val selectedCredentialIds = req.selectedCredentials // TODO -> ?: auto matching + val disclosures = req.disclosures - val result = wallet.usePresentationRequest(request, did, selectedCredentialIds, emptyMap()) // TODO add disclosures here + val result = wallet.usePresentationRequest(request, did, selectedCredentialIds, disclosures) // TODO add disclosures here if (result.isSuccess) { wallet.addOperationHistory(