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

Commit a3bb7b1

Browse files
refactor: suggestion to inject selectedCredentials in initializeAuthorization of wallet provider
1 parent a597db9 commit a3bb7b1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/main/kotlin/id/walt/service/SSIKit2WalletService.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,7 @@ class SSIKit2WalletService(accountId: UUID, walletId: UUID) : WalletService(acco
189189

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

192-
val presentationSession = credentialWallet.initializeAuthorization(authReq, 60.seconds)
193-
.copy(selectedCredentialIds = selectedCredentialIds.toSet())
192+
val presentationSession = credentialWallet.initializeAuthorization(authReq, 60.seconds, selectedCredentialIds.toSet())
194193

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

src/main/kotlin/id/walt/service/oidc4vc/TestCredentialWallet.kt

+11
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import kotlinx.uuid.UUID
3232
import kotlinx.uuid.generateUUID
3333
import kotlin.io.encoding.Base64
3434
import kotlin.io.encoding.ExperimentalEncodingApi
35+
import kotlin.time.Duration
3536
import kotlin.time.Duration.Companion.minutes
3637

3738
const val WALLET_PORT = 8001
@@ -245,4 +246,14 @@ class TestCredentialWallet(
245246
fun parsePresentationRequest(request: String): AuthorizationRequest {
246247
return resolveVPAuthorizationParameters(AuthorizationRequest.fromHttpQueryString(Url(request).encodedQuery))
247248
}
249+
250+
fun initializeAuthorization(
251+
authorizationRequest: AuthorizationRequest,
252+
expiresIn: Duration,
253+
selectedCredentials: Set<String>
254+
): VPresentationSession {
255+
return super.initializeAuthorization(authorizationRequest, expiresIn).copy(selectedCredentialIds = selectedCredentials).also {
256+
putSession(it.id, it)
257+
}
258+
}
248259
}

0 commit comments

Comments
 (0)