Skip to content

Commit

Permalink
deprecate EudiWallet openid4vci methods and provide EudiWallet.create…
Browse files Browse the repository at this point in the history
…OpenId4VciManager to get an instance of OpenId4VciManaer; update README.mdl; update docs; bump document-manager to v0.4.2
  • Loading branch information
vkanellopoulos committed Jul 25, 2024
1 parent 49e354b commit a956c9e
Show file tree
Hide file tree
Showing 68 changed files with 731 additions and 437 deletions.
72 changes: 54 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ import eu.europa.ec.eudi.wallet.EudiWallet
import eu.europa.ec.eudi.wallet.EudiWalletConfig
import eu.europa.ec.eudi.wallet.Logger
import java.security.cert.X509Certificate

val logger = Logger { record: Logger.Record ->
// log the record
}
Expand Down Expand Up @@ -450,7 +451,10 @@ the [Initialize the library](#initialize-the-library) section.

#### Resolving Credential offer

The library provides the `EudiWallet.resolveDocumentOffer` method that resolves the credential offer URI.
First, you need an instance of the `OpenId4VciManager` class. You can create an instance of the class by calling
the `EudiWallet.createOpenId4VciManager` method.

The library provides the `OpenId4VciManager.resolveDocumentOffer` method that resolves the credential offer URI.
The method returns the resolved [`Offer`](wallet-core/src/main/java/eu/europa/ec/eudi/wallet/issue/openid4vci/Offer.kt)
object that contains the offer's data. The offer's data can be displayed to the
user.
Expand All @@ -459,7 +463,9 @@ The following example shows how to resolve a credential offer:

```kotlin
val offerUri = "https://issuer.com/?credential_offer=..."
EudiWallet.resolveDocumentOffer(offerUri) { result ->
// Create an instance of OpenId4VciManager
val openId4VciManager = EudiWallet.createOpenId4VciManager()
openId4VciManager.resolveDocumentOffer(offerUri) { result ->

when (result) {
is OfferResult.Success -> {
Expand All @@ -478,26 +484,31 @@ EudiWallet.resolveDocumentOffer(offerUri) { result ->
}
```

There is also the availability for the `EudiWallet.resolveDocumentOffer` method to specify the executor in which the
There is also the availability for the `OpenId4VciManager.resolveDocumentOffer` method to specify the executor in which
the
onResolvedOffer callback is executed, by assigning the `executor` parameter.
If the `executor` parameter is null, the callback will be executed on the main thread.

```kotlin
val executor = Executors.newSingleThreadExecutor()
EudiWallet.resolveDocumentOffer(offerUri, executor) { result ->
openId4VciManager.resolveDocumentOffer(offerUri, executor) { result ->
// ...
}
```

#### Issuing a document

First, you need an instance of the `OpenId4VciManager` class. You can create an instance of the class by calling
the `EudiWallet.createOpenId4VciManager` method.

There are two ways to issue a document using OpenID4VCI:

1. Using the `EudiWallet.issueDocumentByDocType` method, when the document's docType is known.
2. Using the `EudiWallet.issueDocumentByOffer` or `EudiWallet.issueDocumentByOfferUri` methods, when an OpenId4VCI offer
1. Using the `OpenId4VciManager.issueDocumentByDocType` method, when the document's docType is known.
2. Using the `OpenId4VciManager.issueDocumentByOffer` or `OpenId4VciManager.issueDocumentByOfferUri` methods, when an
OpenId4VCI offer
is given.

_Important Notes_:
__Important note__:

- Currently, only mso_mdoc format is supported
- Currently, only the ES256 algorithm is supported for signing OpenId4CVI proof of possession of the
Expand Down Expand Up @@ -567,23 +578,25 @@ val onIssueEvent = OnIssueEvent { event ->
}
}
}
// Create an instance of OpenId4VciManager
val openId4VciManager = EudiWallet.createOpenId4VciManager()

EudiWallet.issueDocumentByDocType(
openId4VciManager.issueDocumentByDocType(
docType = "eu.europa.ec.eudi.pid.1",
txCode = "<Transaction Code for Pre-authorized flow>", // if transaction code is provided
onEvent = onIssueEvent
onIssueEvent = onIssueEvent
)
// or
EudiWallet.issueDocumentByOfferUri(
openId4VciManager.issueDocumentByOfferUri(
offerUri = "https://issuer.com/?credential_offer=...",
txCode = "<Transaction Code for Pre-authorized flow>", // if transaction code is provided
onEvent = onIssueEvent
onIssueEvent = onIssueEvent
)
// or given a resolved offer object
EudiWallet.issueDocumentByOffer(
openId4VciManager.issueDocumentByOffer(
offer = offer,
txCode = "<Transaction Code for Pre-authorized flow>", // if transaction code is provided
onEvent = onIssueEvent
onIssueEvent = onIssueEvent
)
```

Expand All @@ -592,8 +605,12 @@ specify the executor in which the onIssueEvent callback is executed, by assignin
If the `executor` parameter is null, the callback will be executed on the main thread.

```kotlin

// Create an instance of OpenId4VciManager
val openId4VciManager = EudiWallet.createOpenId4VciManager()

val executor = Executors.newSingleThreadExecutor()
EudiWallet.issueDocumentByDocType(
openId4VciManager.issueDocumentByDocType(
docType = "eu.europa.ec.eudi.pid.1",
executor = executor
) { event ->
Expand All @@ -605,9 +622,16 @@ EudiWallet.issueDocumentByDocType(

For the authorization code flow to work, the application must handle the redirect URI. The redirect URI is the URI that
the Issuer will redirect the user to after the user has authenticated and authorized. The redirect URI must be handled
by the application and resume the issuance process by calling the `EudiWallet.resumeOpenId4VciWithAuthorization`.
by the application and resume the issuance process by calling the `OpenId4VciManager.resumeWithAuthorization`.
Also, the redirect uri declared in the OpenId4VCI configuration must be declared in the application's manifest file.

__Important note__: The `resumeWithAuthorization` method must be called from the same OpenId4VciManager instance
that was used to start the issuance process. You will need to keep the reference of the `OpenId4VciManager` instance
that
was used for calling the `issueDocumentByDocType`, `issueDocumentByOfferUri` or `issueDocumentByOffer` method and use
this
same instance to call the `resumeWithAuthorization` method.

```xml

<!-- AndroidManifest.xml -->
Expand Down Expand Up @@ -644,15 +668,23 @@ EudiWalletConfig.Builder(applicationContext)
```

```kotlin
import javax.management.openmbean.OpenMBeanInfo

class SomeActivity : AppCompatActivity() {

val openId4VciManager: OpenId4VciManager
get() {
// get the OpenId4VciManager instance that was created during the issuance process
// ...
}

// ...
override fun onResume() {
super.onResume()
// check if intent is from the redirect uri to resume the issuance process
// ...
// then call
EudiWallet.resumeOpenId4VciWithAuthorization(intent)
intent.data?.let { uri -> openId4VciManager.resumeWithAuthorization(uri) }
}
// ...
}
Expand Down Expand Up @@ -680,12 +712,13 @@ passing the transaction code as in the `txCode` parameter.
#### Deferred Issuance

When the document issuance is deferred, the `IssueEvent.DocumentDeferred` event is triggered. The deferred document can
be issued later by calling the `EudiWallet.issueDeferredDocument` method.
be issued later by calling the `OpenId4VciManager.issueDeferredDocument` method.

```kotlin
val documentId = "documentId"
val openId4VciManager: OpenId4VciManager = EudiWallet.createOpenId4VciManager()

EudiWallet.issueDeferredDocument(documentId) { result ->
openId4VciManager.issueDeferredDocument(documentId) { result ->
when (result) {
is DeferredIssueResult.DocumentIssued -> {
// document issued
Expand All @@ -697,6 +730,9 @@ EudiWallet.issueDeferredDocument(documentId) { result ->
is DeferredIssueResult.DocumentNotReady -> {
// The document is not issued yet
}
is DeferredIssueResult.DocumentExpired -> {
// The document is expired and cannot be issued
}
}
}
```
Expand Down
16 changes: 16 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# Changelog

## [0.11.0-SNAPSHOT]

__ 25 Jul 2024__

- Deprecate OpenId4Vci methods through EudiWallet object
- Add Eudi.createOpenId4VciManager method to create OpenId4VciManager object
- Bumb eudi-lib-andorid-wallet-document-manager to v0.4.2

## [0.10.3-SNAPSHOT]

__ 23 Jul 2024__

- Support custom logger for OpenId4VCI and OpenId4VP via OpenId4VCIConfig
- Fix OpenId4VCI resume authorization
- Return DocumentExpired data class from issueDeferredDocument method when the document is expired

## [0.10.2]

__ 17 Jul 2024__
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentExpired](index.md)/[DocumentExpired](-document-expired.md)

# DocumentExpired

[androidJvm]\
constructor(documentId: DocumentId,
name: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html),
docType: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentExpired](index.md)/[docType](doc-type.md)

# docType

[androidJvm]\
open override
val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentExpired](index.md)/[documentId](document-id.md)

# documentId

[androidJvm]\
open override val [documentId](document-id.md): DocumentId
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentExpired](index.md)

# DocumentExpired

[androidJvm]\
data class [DocumentExpired](index.md)(val documentId: DocumentId, val
name: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), val
docType: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)) : [DeferredIssueResult](../index.md)

Document issuance expired.

## Constructors

| | |
|-----------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DocumentExpired](-document-expired.md) | [androidJvm]<br>constructor(documentId: DocumentId, name: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), docType: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)) |

## Properties

| Name | Summary |
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [docType](doc-type.md) | [androidJvm]<br>open override val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the document type |
| [documentId](document-id.md) | [androidJvm]<br>open override val [documentId](document-id.md): DocumentId<br>the id of the expired document |
| [name](name.md) | [androidJvm]<br>open override val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the name of the document |
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentExpired](index.md)/[name](name.md)

# name

[androidJvm]\
open override val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@

[androidJvm]\
constructor(documentId: DocumentId,
name: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html),
docType: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html),
cause: [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentFailed](index.md)/[docType](doc-type.md)

# docType

[androidJvm]\
open override
val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# documentId

[androidJvm]\
val [documentId](document-id.md): DocumentId
open override val [documentId](document-id.md): DocumentId
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,23 @@

[androidJvm]\
data class [DocumentFailed](index.md)(val documentId: DocumentId, val
name: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), val
docType: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), val
cause: [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)) : [DeferredIssueResult](../index.md), [OpenId4VciResult.Erroneous](../../-open-id4-vci-result/-erroneous/index.md)

Document issuance failed.

## Constructors

| | |
|---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|
| [DocumentFailed](-document-failed.md) | [androidJvm]<br>constructor(documentId: DocumentId, cause: [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)) |
| | |
|---------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DocumentFailed](-document-failed.md) | [androidJvm]<br>constructor(documentId: DocumentId, name: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), docType: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), cause: [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)) |

## Properties

| Name | Summary |
|------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [cause](cause.md) | [androidJvm]<br>open override val [cause](cause.md): [Throwable](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-throwable/index.html)<br>the error that caused the failure |
| [documentId](document-id.md) | [androidJvm]<br>val [documentId](document-id.md): DocumentId |
| [docType](doc-type.md) | [androidJvm]<br>open override val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the document type |
| [documentId](document-id.md) | [androidJvm]<br>open override val [documentId](document-id.md): DocumentId<br>the id of the failed document |
| [name](name.md) | [androidJvm]<br>open override val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the name of the document |
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[wallet-core](../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../index.md)/[DeferredIssueResult](../index.md)/[DocumentFailed](index.md)/[name](name.md)

# name

[androidJvm]\
open override val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# docType

[androidJvm]\
open override
val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# documentId

[androidJvm]\
val [documentId](document-id.md): DocumentId
open override val [documentId](document-id.md): DocumentId
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ Document issued successfully.

## Properties

| Name | Summary |
|------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [docType](doc-type.md) | [androidJvm]<br>val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the document type |
| [documentId](document-id.md) | [androidJvm]<br>val [documentId](document-id.md): DocumentId<br>the id of the issued document |
| [name](name.md) | [androidJvm]<br>val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the name of the document |
| Name | Summary |
|------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [docType](doc-type.md) | [androidJvm]<br>open override val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the document type |
| [documentId](document-id.md) | [androidJvm]<br>open override val [documentId](document-id.md): DocumentId<br>the id of the issued document |
| [name](name.md) | [androidJvm]<br>open override val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the name of the document |
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# name

[androidJvm]\
val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
open override val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# docType

[androidJvm]\
open override
val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# documentId

[androidJvm]\
val [documentId](document-id.md): DocumentId
open override val [documentId](document-id.md): DocumentId
Loading

0 comments on commit a956c9e

Please sign in to comment.