@@ -28,6 +28,7 @@ import eu.europa.ec.eudi.openid4vci.SubmissionOutcome
2828import eu.europa.ec.eudi.wallet.document.UnsignedDocument
2929import eu.europa.ec.eudi.wallet.document.credential.ProofOfPossessionSigner
3030import eu.europa.ec.eudi.wallet.provider.WalletAttestationsProvider
31+ import kotlinx.coroutines.runBlocking
3132import org.multipaz.securearea.KeyUnlockData
3233
3334internal class SubmitRequest (
@@ -204,32 +205,36 @@ internal class SubmitRequest(
204205 val keyIndex = 0
205206 val proofsSpecification = ProofsSpecification .JwtProofs .WithKeyAttestation (
206207 proofSignerProvider = { nonce ->
207- try {
208- val factory = KeyAttestationSigner .Factory (
209- signers, keyIndex, walletAttestationsProvider, keyUnlockData
210- )
211- factory(nonce).getOrThrow().also { proofSigner = it }
212- } catch (e: Throwable ) {
213-
214- val isUserAuthRequired = proofSigner.keyLockedException != null
215- if (isUserAuthRequired) {
216- val keysAndSecureAreas = mapOf (
217- proofSigner.signer.let { it.keyAlias to it.secureArea }
218- )
219- throw UserAuthRequiredException (
220- signingAlgorithm = proofSigner.signer.getKeyInfo().algorithm,
221- keysAndSecureAreas = keysAndSecureAreas,
222- resume = { keyUnlockData -> unlockResume(keyUnlockData) },
223- cause = e
224- )
225- } else {
226- throw e
227- }
228- }
208+ val factory = KeyAttestationSigner .Factory (
209+ signers, keyIndex, walletAttestationsProvider, keyUnlockData
210+ )
211+ factory(nonce).getOrThrow().also { proofSigner = it }
229212 },
230213 keyIndex = keyIndex,
231214 )
232- return with (issuer) { request(payload, proofsSpecification) }.getOrThrow()
215+ try {
216+ return with (issuer) { request(payload, proofsSpecification) }.getOrThrow()
217+ } catch (e: Throwable ) {
218+
219+ val isUserAuthRequired = proofSigner.keyLockedException != null
220+ if (isUserAuthRequired) {
221+ val keysAndSecureAreas = mapOf (
222+ proofSigner.signer.let { it.keyAlias to it.secureArea }
223+ )
224+ throw UserAuthRequiredException (
225+ signingAlgorithm = proofSigner.signer.getKeyInfo().algorithm,
226+ keysAndSecureAreas = keysAndSecureAreas,
227+ resume = { keyUnlockData ->
228+ runBlocking {
229+ unlockResume(keyUnlockData)
230+ }
231+ },
232+ cause = e
233+ )
234+ } else {
235+ throw e
236+ }
237+ }
233238
234239 }
235240
@@ -256,7 +261,9 @@ internal class SubmitRequest(
256261 throw UserAuthRequiredException (
257262 signingAlgorithm = proofSigner.algorithm,
258263 keysAndSecureAreas = keysAndSecureAreas,
259- resume = { keyUnlockData -> unlockResume(keyUnlockData) },
264+ resume = { keyUnlockData -> runBlocking {
265+ unlockResume(keyUnlockData)
266+ } },
260267 cause = e
261268 )
262269 } else {
0 commit comments