Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WD-136] Exposing par request #88

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import android.net.Uri
import eu.europa.ec.eudi.openid4vci.DefaultHttpClientFactory
import eu.europa.ec.eudi.openid4vci.DeferredIssuer
import eu.europa.ec.eudi.wallet.document.*
import eu.europa.ec.eudi.wallet.issue.openidvci.PARResponse
import eu.europa.ec.eudi.wallet.issue.openidvci.PKCEVerifier
import eu.europa.ec.eudi.wallet.internal.mainExecutor
import eu.europa.ec.eudi.wallet.issue.openid4vci.IssueEvent.Companion.failure
import eu.europa.ec.eudi.wallet.logging.Logger
Expand Down Expand Up @@ -187,6 +189,17 @@ internal class DefaultOpenId4VciManager(
resumeWithAuthorization(Uri.parse(uri))
}

override suspend fun performPushAuthorizationRequest(docType: String): PARResponse {
val offer = offerCreator.createOffer(docType)
val issuer = issuerCreator.createIssuer(offer)
val parResponse = issuerAuthorization.performPushAuthorizationRequest(issuer)
return PARResponse(
authorizationCodeURL = parResponse.authorizationCodeURL.value,
pkceVerifier = PKCEVerifier(codeVerifier = parResponse.pkceVerifier.codeVerifier, codeVerifierMethod = parResponse.pkceVerifier.codeVerifierMethod),
state = parResponse.state
)
}

/**
* Issues the given [Offer].
*/
Expand All @@ -195,7 +208,6 @@ internal class DefaultOpenId4VciManager(
txCode: String?,
listener: OpenId4VciManager.OnResult<IssueEvent>,
) {
offer as DefaultOffer
val issuer = issuerCreator.createIssuer(offer)
var authorizedRequest = issuerAuthorization.authorize(issuer, txCode)
listener(IssueEvent.Started(offer.offeredDocuments.size))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ internal class IssuerAuthorization(

var continuation: CancellableContinuation<Result<Response>>? = null

suspend fun performPushAuthorizationRequest(issuer: Issuer): AuthorizationRequestPrepared {
return issuer.prepareAuthorizationRequest().getOrThrow()
}

/**
* Authorizes the given [Issuer] and returns the authorized request.
* If txCode is provided, it will be used to authorize the issuer,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ package eu.europa.ec.eudi.wallet.issue.openid4vci
import android.content.Context
import android.net.Uri
import androidx.annotation.IntDef
import eu.europa.ec.eudi.openid4vci.AuthorizationRequestPrepared
import eu.europa.ec.eudi.wallet.document.DeferredDocument
import eu.europa.ec.eudi.wallet.document.DocumentManager
import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config.ParUsage.Companion.IF_SUPPORTED
import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config.ParUsage.Companion.NEVER
import eu.europa.ec.eudi.wallet.issue.openid4vci.OpenId4VciManager.Config.ParUsage.Companion.REQUIRED
import eu.europa.ec.eudi.wallet.issue.openidvci.PARResponse
import eu.europa.ec.eudi.wallet.logging.Logger
import io.ktor.client.*
import java.util.concurrent.Executor
Expand Down Expand Up @@ -377,4 +379,6 @@ interface OpenId4VciManager {
fun make(block: Builder.() -> Unit) = Builder().apply(block).build()
}
}

suspend fun performPushAuthorizationRequest(docType: String): PARResponse
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package eu.europa.ec.eudi.wallet.issue.openidvci

import java.net.URL

data class PARResponse (
val authorizationCodeURL: URL,
val pkceVerifier: PKCEVerifier,
val state: String,
)

data class PKCEVerifier(
val codeVerifier: String,
val codeVerifierMethod: String,
)
Loading