Skip to content

Commit

Permalink
implementing pre-authorization code flow for OpenId4VCI
Browse files Browse the repository at this point in the history
  • Loading branch information
vkanellopoulos committed Jun 26, 2024
1 parent 6055e69 commit e1c3580
Show file tree
Hide file tree
Showing 37 changed files with 630 additions and 329 deletions.
50 changes: 43 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ The library provides the following functionality:
- Document issuance
- [x] Support for OpenId4VCI Draft 13 document issuance
- [x] Authorization Code Flow
- [ ] Pre-authorization Code Flow
- [x] Pre-authorization Code Flow
- [x] Support for mso_mdoc format
- [ ] Support for sd-jwt-vc format
- [x] Support credential offer
- [x] Support for DPoP JWT in authorization
- [x] Support for JWT and CWT proof types
- [ ] Support for deferred issuing
- Proximity document presentation
- [x] Support for ISO-18013-5 device retrieval
- [x] QR device engagement
Expand Down Expand Up @@ -454,6 +455,7 @@ EudiWallet.resolveDocumentOffer(offerUri) { result ->
// display the offer's data to the user
val issuerName = offer.issuerName
val offeredDocuments: List<OfferedDocument> = offer.offeredDocuments
val txCodeSpec: Offer.TxCodeSpec? = offer.txCodeSpec // information about pre-authorized flow
// ...
}
is OfferResult.Failure -> {
Expand Down Expand Up @@ -546,11 +548,23 @@ val onIssueEvent = OnIssueEvent { event ->
}
}

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

There's also available for `issueDocumentByDocType`, `issueDocumentByOfferUri` and `issueDocumentByOffer` methods to
Expand All @@ -559,7 +573,10 @@ If the `executor` parameter is null, the callback will be executed on the main t

```kotlin
val executor = Executors.newSingleThreadExecutor()
EudiWallet.issueDocumentByDocType("eu.europa.ec.eudiw.pid.1", executor) { event ->
EudiWallet.issueDocumentByDocType(
docType = "eu.europa.ec.eudiw.pid.1",
executor = executor
) { event ->
// ...
}
```
Expand All @@ -578,8 +595,8 @@ Also, the redirect uri declared in the OpenId4VCI configuration must be declared
<application>
<!-- rest of manifest -->
<activity
android:name=".MainActivity"
android:exported="true">
android:name=".MainActivity"
android:exported="true">
<!-- rest of activity -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
Expand Down Expand Up @@ -621,6 +638,25 @@ class SomeActivity : AppCompatActivity() {
}
```

##### Pre-Authorization code flow

When Issuer supports the pre-authorization code flow, the resolved offer will also contain the corresponding
information. Specifically, the `txCodeSpec` field in the `Offer` object will contain:

- The input mode, whether it is NUMERIC or TEXT
- The expected length of the input
- The description of the input

From the user's perspective, the application must provide a way to input the transaction code.

When the transaction code is provided, the issuance process can be resumed by calling any of the following methods:

- `EudiWallet.issueDocumentByDocType`
- `EudiWallet.issueDocumentByOfferUri`
- `EudiWallet.issueDocumentByOffer`

passing the transaction code as in the `txCode` parameter.

### Transfer documents

The library supports the following 3 ways to transfer documents:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# asPair

[androidJvm]\
fun [asPair](as-pair.md)(): [Pair](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-pair/index.html)
open fun [asPair](as-pair.md)(): [Pair](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-pair/index.html)
&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
&gt;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# docType

[androidJvm]\
val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)
abstract 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,20 +3,19 @@
# OfferedDocument

[androidJvm]\
data class [OfferedDocument](index.md)
interface [OfferedDocument](index.md)

An item to be issued.

## Functions

| Name | Summary |
|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [asPair](as-pair.md) | [androidJvm]<br>fun [asPair](as-pair.md)(): [Pair](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-pair/index.html)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;<br>Converts this item to a pair of name and document type. |
| [toString](to-string.md) | [androidJvm]<br>open override fun [toString](to-string.md)(): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| Name | Summary |
|----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [asPair](as-pair.md) | [androidJvm]<br>open fun [asPair](as-pair.md)(): [Pair](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-pair/index.html)&lt;[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)&gt;<br>Converts this item to a pair of name and document type. |

## 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 of the item |
| [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 item |
| Name | Summary |
|------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [docType](doc-type.md) | [androidJvm]<br>abstract val [docType](doc-type.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the document type of the item |
| [name](name.md) | [androidJvm]<br>abstract val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)<br>the name of the item |
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)
abstract val [name](name.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//[wallet-core](../../../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../../../index.md)/[Offer](../../../index.md)/[TxCodeSpec](../../index.md)/[InputMode](../index.md)/[NUMERIC](index.md)

# NUMERIC

[androidJvm]\
[NUMERIC](index.md)

## Properties

| Name | Summary |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [name](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-372974862%2FProperties%2F1615067946) | [androidJvm]<br>val [name](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-372974862%2FProperties%2F1615067946): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [ordinal](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-739389684%2FProperties%2F1615067946) | [androidJvm]<br>val [ordinal](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-739389684%2FProperties%2F1615067946): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//[wallet-core](../../../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../../../index.md)/[Offer](../../../index.md)/[TxCodeSpec](../../index.md)/[InputMode](../index.md)/[TEXT](index.md)

# TEXT

[androidJvm]\
[TEXT](index.md)

## Properties

| Name | Summary |
|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [name](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-372974862%2FProperties%2F1615067946) | [androidJvm]<br>val [name](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-372974862%2FProperties%2F1615067946): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [ordinal](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-739389684%2FProperties%2F1615067946) | [androidJvm]<br>val [ordinal](../../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-739389684%2FProperties%2F1615067946): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//[wallet-core](../../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../../index.md)/[Offer](../../index.md)/[TxCodeSpec](../index.md)/[InputMode](index.md)

# InputMode

[androidJvm]\
enum [InputMode](index.md) : [Enum](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-enum/index.html)
&lt;[Offer.TxCodeSpec.InputMode](index.md)&gt;

The input mode for the transaction code.

## Entries

| | |
|------------------------------------|----------------------------------------------------|
| [NUMERIC](-n-u-m-e-r-i-c/index.md) | [androidJvm]<br>[NUMERIC](-n-u-m-e-r-i-c/index.md) |
| [TEXT](-t-e-x-t/index.md) | [androidJvm]<br>[TEXT](-t-e-x-t/index.md) |

## Functions

| Name | Summary |
|------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [valueOf](value-of.md) | [androidJvm]<br>fun [valueOf](value-of.md)(value: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)): [Offer.TxCodeSpec.InputMode](index.md)<br>Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.) |
| [values](values.md) | [androidJvm]<br>fun [values](values.md)(): [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)&lt;[Offer.TxCodeSpec.InputMode](index.md)&gt;<br>Returns an array containing the constants of this enum type, in the order they're declared. |

## Properties

| Name | Summary |
|--------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [name](../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-372974862%2FProperties%2F1615067946) | [androidJvm]<br>val [name](../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-372974862%2FProperties%2F1615067946): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) |
| [ordinal](../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-739389684%2FProperties%2F1615067946) | [androidJvm]<br>val [ordinal](../../../-open-id4-vci-manager/-config/-proof-type/-c-w-t/index.md#-739389684%2FProperties%2F1615067946): [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) |
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//[wallet-core](../../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../../index.md)/[Offer](../../index.md)/[TxCodeSpec](../index.md)/[InputMode](index.md)/[valueOf](value-of.md)

# valueOf

[androidJvm]\
fun [valueOf](value-of.md)(
value: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)): [Offer.TxCodeSpec.InputMode](index.md)

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to
declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

#### Throws

| | |
|------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [IllegalArgumentException](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-illegal-argument-exception/index.html) | if this enum type has no constant with the specified name |
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//[wallet-core](../../../../../index.md)/[eu.europa.ec.eudi.wallet.issue.openid4vci](../../../index.md)/[Offer](../../index.md)/[TxCodeSpec](../index.md)/[InputMode](index.md)/[values](values.md)

# values

[androidJvm]\
fun [values](values.md)(): [Array](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-array/index.html)
&lt;[Offer.TxCodeSpec.InputMode](index.md)&gt;

Returns an array containing the constants of this enum type, in the order they're declared.

This method may be used to iterate over the constants.
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)/[Offer](../index.md)/[TxCodeSpec](index.md)/[TxCodeSpec](-tx-code-spec.md)

# TxCodeSpec

[androidJvm]\
constructor(inputMode: [Offer.TxCodeSpec.InputMode](-input-mode/index.md) = InputMode.NUMERIC,
length: [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)?,
description: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? = null)
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)/[Offer](../index.md)/[TxCodeSpec](index.md)/[description](description.md)

# description

[androidJvm]\
val [description](description.md): [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)? =
null
Loading

0 comments on commit e1c3580

Please sign in to comment.