-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Timo Glastra <timo@animo.id>
- Loading branch information
1 parent
86f6217
commit 7b13eff
Showing
16 changed files
with
710 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# OpenID for Verifiable Credentials | ||
|
||
The OpenID4VC module provides support for the [OpenID for Verifiable Credentials group of protocols](https://openid.net/sg/openid4vc/) defined under the OpenID Foundation. Currently this includes the [OpenID for Verifiable Credential Issuance](https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html), [Self-Issued OpenID Provider v2](https://openid.net/specs/openid-connect-self-issued-v2-1_0.html), and [OpenID for Verifiable Presentations](https://openid.net/specs/openid-4-verifiable-presentations-1_0.html). | ||
|
||
For the current supported versions for any of the OpenID4VC protocols, please refer to the [OpenID4VC Feature](../../features/openid4vc.md) page. | ||
|
||
The OpenID4VC Module in Credo currently exposes three modules, one for each role in the triangle trust: `OpenId4VcIssuerModule`, `OpenId4VcHolderModule`, and `OpenId4VcVerifierModule`. The issuer and verifier modules are expected to run in a cloud environment, as they require several endpoints to be exposed to the public internet. The holder module can run in a cloud environment or on a mobile device. | ||
|
||
### Installing OpenID4VC Module | ||
|
||
When using Credo with OpenID4VC you need to install the `@credo-ts/openid4vc` module: | ||
|
||
```console | ||
yarn add @credo-ts/openid4vc@^0.5.3 | ||
``` | ||
|
||
### Adding OpenID4VC Modules to the Agent | ||
|
||
After installing the dependencies, we can register the the different modules on the agent. | ||
|
||
#### Issuer and Verifier | ||
|
||
If you want to issue or verify credentials using OpenID for Verifiable Credentials, you can add the `OpenId4VcIssuerModule` and the `OpenId4VcVerifierModule`. These modules can only run on the server, in Node.JS and don't work in a React Native environment. These modules can be added separately, it's not required to use both modules. The set up for the issuer and verifier module can be combined with the set up for the holder module below to support issuance, holding, and verification OpenID4VC flows within the same agent. | ||
|
||
In the example we haven't implemented the `credentialRequestToCredentialMapper` method for the issuer module yet, this is covered in the [OpenID4VC Guides](/guides/tutorials/openid4vc). | ||
|
||
```typescript showLineNumbers set-up-openid4vc-issuer-verifier.ts section-1 | ||
|
||
``` | ||
|
||
### Holder | ||
|
||
If you want to receive and present credentials using OpenID for Verifiable Credentials, you can add the `OpenId4VcHolderModule`. This module can run in both Node.JS and React Native. | ||
|
||
```typescript showLineNumbers set-up-openid4vc-holder.ts section-1 | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import DocCardList from '@theme/DocCardList'; | ||
|
||
# OpenID for Verifiable Credentials Tutorials | ||
|
||
This section covers all tutorials related to the OpenID for Verifiable Credentials module in Credo. Before you start, make sure you have configured the required OpenID4VC modules on your agent according to the [OpenID4VC Setup Guide](/guides/getting-started/set-up/openid4vc.md) | ||
|
||
<DocCardList /> |
39 changes: 39 additions & 0 deletions
39
guides/tutorials/openid4vc/issuing-credentials-using-openid4vc-issuer-module.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Issuing Credentials using the OpenID4VC Issuer Module | ||
|
||
This tutorial will guide you through the process of issuing credentials using the OpenID4VC Issuer Module. Before starting this tutorial, make sure you have completed the [OpenID4VC Issuer Module Setup](/guides/getting-started/set-up/openid4vc.md). | ||
|
||
This guides only covers the issuance of credentials using the OpenID4VC Issuer Module. Follow the [Receiving and Proving Credentials using the OpenID4VC Holder Module](/guides/tutorials/openid4vc/receiving-and-proving-credentials-using-openid4vc-holder-module.md) guide to learn how to receive and prove credentials using the OpenID4VC Holder Module. | ||
|
||
## Creating the issuer | ||
|
||
Once you have set-up your agent (under `issuer` variable), we first need to configure your issuer and the credentials you want to issue. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-2 | ||
|
||
``` | ||
|
||
If you want to update the display metadata or the credentials supported by the issuer, you can use the `issuer.modules.openId4VcIssuer.updateIssuer` method. | ||
|
||
## Creating a credential offer | ||
|
||
Once you have configured the issuer, you can create a credential offer. The credential offer method will generate a credential offer URI that you can share with a holder. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-3 | ||
|
||
``` | ||
|
||
We have also added an event listener that listens for state changed events, this allows us to know when the issuance session is done. | ||
|
||
## Implementing the credential mapper | ||
|
||
The OpenID4VC Issuer Module setup didn't cover the implementation of the `credentialRequestToCredentialMapper` yet. When you create a credential offer with the OpenID4VC Issuer Module in Credo, you don't have to provide the credential data directly. | ||
|
||
Instead, you provide a `credentialRequestToCredentialMapper` function in the agent configuration, that will be called when the holder requests the credential. | ||
|
||
This allows you to dynamically generate the credential data based on the holder's request, and means you also don't have to store any credential data in the agent. | ||
|
||
Below is an example `credentialRequestToCredentialMapper` function that generates a credential based on the holder's request. Make sure to register this function in the agent configuration `modules.openId4VcIssuer.endpoints.credential.credentialsRequestToCredentialMapper`. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-4 | ||
|
||
``` |
25 changes: 25 additions & 0 deletions
25
...ls/openid4vc/receiving-and-proving-credentials-using-openid4vc-holder-module.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Receiving and Proving Credentials using the OpenID4VC Holder Module | ||
|
||
This tutorial will guide you through the process of receiving and proving credentials using the OpenID4VC Holder Module. Before starting this tutorial, make sure you have completed the [OpenID4VC Holder Module Setup](/guides/getting-started/set-up/openid4vc.md). | ||
|
||
This guides only covers the receiving and proving of credentials using the OpenID4VC Holder Module. Follow the [Issuing Credentials using the OpenID4VC Issuer Module](/guides/tutorials/openid4vc/issuing-credentials-using-openid4vc-issuer-module.md) and [Verifying Credentials using the OpenID4VC Verifier Module](/guides/tutorials/openid4vc/verifying-credentials-using-openid4vc-verifier-module.md) guides to learn how to issue and verify credentials using the OpenID4VC Issuer and Verifier Modules. | ||
|
||
## Resolving and accepting a credential offer | ||
|
||
Once you have set-up your agent (under `holder` variable), and have a credential offer (either created using the issuer module, or an external OpenID4VC issuer), we can resolve and accept the credential offer. | ||
|
||
The `credentialBindingResolver` is a method you need to provide that configures how the credential should be bound to the wallet. The implemented binding resolver in this tutorial first checks if the issuer supports `did:key` and will use that. Otherwise it will check if jwk is supported. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-6 | ||
|
||
``` | ||
|
||
Finally the credentials are stored using the SD JWT VC and W3C modules. In a wallet application you could choose to first show the credential to the user before storing it in the wallet. | ||
|
||
## Resolving and accepting an authorization request (presentation request) | ||
|
||
Once you have a credential in your wallet, you can start presenting it based on a receive authorization request including an OpenID4VP presentation request (either created using the verifier module, or an external OpenID4VC verifier). First we resolve the authorization request, and then we accept it and present the credential in our wallet. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-9 | ||
|
||
``` |
23 changes: 23 additions & 0 deletions
23
...es/tutorials/openid4vc/verifying-credentials-using-openid4vc-verifier-module.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Verifying Credentials using the OpenID4VC Verifier Module | ||
|
||
This tutorial will guide you through the process of verifying credentials using the OpenID4VC Verifier Module. Before starting this tutorial, make sure you have completed the [OpenID4VC Verifier Module Setup](/guides/getting-started/set-up/openid4vc.md). | ||
|
||
This guides only covers the verification of credentials using the OpenID4VC Verifier Module. Follow the [Issuing Credentials using the OpenID4VC Issuer Module](/guides/tutorials/openid4vc/issuing-credentials-using-openid4vc-issuer-module.md) and [Receiving and Proving Credentials using the OpenID4VC Holder Module](/guides/tutorials/openid4vc/receiving-and-proving-credentials-using-openid4vc-holder-module.md) guide to learn how to issuer, receive and prove credentials using the OpenID4VC Issuer and Holder Modules. | ||
|
||
## Creating the verifier | ||
|
||
Once you have set-up your agent (under `verifier` variable), we first need to configure your verifier. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-7 | ||
|
||
``` | ||
|
||
## Creating an authorization request | ||
|
||
Once you have configured the verifier, you can create an authorization request including an OpenID4VP presentation request based on [DIF Presentation Exchange V2](https://identity.foundation/presentation-exchange/spec/v2.0.0/). The authorization request method will generate an authorization request URI that you can share with a holder. | ||
|
||
```typescript showLineNumbers sd-jwt-vc-openid4vc.ts section-8 | ||
|
||
``` | ||
|
||
We have also added an event listener that listens for state changed events, this allows us to know when the verification session is done. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.