Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Commit

Permalink
refactor: suggestion to inject selectedCredentials in initializeAutho…
Browse files Browse the repository at this point in the history
…rization of wallet provider
  • Loading branch information
severinstampler committed Nov 22, 2023
1 parent a597db9 commit a3bb7b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/kotlin/id/walt/service/SSIKit2WalletService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco

println("USING PRESENTATION REQUEST, SELECTED CREDENTIALS: $selectedCredentialIds")

val presentationSession = credentialWallet.initializeAuthorization(authReq, 60.seconds)
.copy(selectedCredentialIds = selectedCredentialIds.toSet())
val presentationSession = credentialWallet.initializeAuthorization(authReq, 60.seconds, selectedCredentialIds.toSet())

println("Resolved presentation definition: ${presentationSession.authorizationRequest!!.presentationDefinition!!.toJSONString()}")

Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/id/walt/service/oidc4vc/TestCredentialWallet.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import kotlinx.uuid.UUID
import kotlinx.uuid.generateUUID
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.time.Duration
import kotlin.time.Duration.Companion.minutes

const val WALLET_PORT = 8001
Expand Down Expand Up @@ -245,4 +246,14 @@ class TestCredentialWallet(
fun parsePresentationRequest(request: String): AuthorizationRequest {
return resolveVPAuthorizationParameters(AuthorizationRequest.fromHttpQueryString(Url(request).encodedQuery))
}

fun initializeAuthorization(
authorizationRequest: AuthorizationRequest,
expiresIn: Duration,
selectedCredentials: Set<String>
): VPresentationSession {
return super.initializeAuthorization(authorizationRequest, expiresIn).copy(selectedCredentialIds = selectedCredentials).also {
putSession(it.id, it)
}
}
}

0 comments on commit a3bb7b1

Please sign in to comment.