Skip to content

Commit

Permalink
extend oid4vc service
Browse files Browse the repository at this point in the history
  • Loading branch information
eike-hass committed May 2, 2024
1 parent fa2d414 commit 5f379a0
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 73 deletions.
6 changes: 3 additions & 3 deletions .env → .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ ISSUERS_BANK_FRAGMENT=VP3zow4GGBNc9iyIIjz4K-5lF431-F5BScq9mu_ix9A
ISSUERS_INSURANCE_DID=did:iota:rms:0xf80c51348cf3238df1133156c78965d1d5f9aba2bf070c23fbbb96edb336e154
ISSUERS_INSURANCE_KEYID=wzpXeDX5THLnKaelgd410bkfu7ZMPyH3
ISSUERS_INSURANCE_FRAGMENT=mZXm9mJwj7d6Xrmz21KuoD07exo3IS9YVYqpNY5F8XI
INSURANCE_PUBLIC_URL=https://insurance.selv.local
BANK_PUBLIC_URL=https://bank.selv.local
GOVERNMENT_PUBLIC_URL=https://government.selv.local
INSURANCE_PUBLIC_URL=https://insurance.selv.local:${HTTP_PORT}
BANK_PUBLIC_URL=https://bank.selv.local:${HTTP_PORT}
GOVERNMENT_PUBLIC_URL=https://government.selv.local:${HTTP_PORT}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
data/**
!data/.gitkeep
!data/.gitkeep

.env
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
### Setup
Add following domains to your host files:
- `selv.local`
- `backend.selv.local`
- `bank.selv.local`
- `government.selv.local`
- `insurance.selv.local`

Copy .env.template to .env

### Tooling
1. create stronghold
1. copy to data
Expand Down
6 changes: 3 additions & 3 deletions oid4vc/TangleLabs/src/grpcService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const createService = async (
const requestId = crypto.randomUUID();
const request = await rp.createRequest({
requestBy: "reference",
requestUri: `${process.env.PUBLIC_URL}/offer/${requestId}`,
requestUri: encodeURIComponent(`${process.env.PUBLIC_URL}/offer/${requestId}`),
responseType: "id_token",
state: call.request.state,
nonce: call.request.nonce,
Expand Down Expand Up @@ -62,7 +62,7 @@ export const createService = async (
const request = await rp.createRequest({
presentationDefinition: call.request.presentationDefinition,
requestBy: "reference",
requestUri: `${process.env.PUBLIC_URL}/offer/${requestId}`,
requestUri: encodeURIComponent(`${process.env.PUBLIC_URL}/offer/${requestId}`),
responseType: "vp_token",
state: call.request.state,
nonce: call.request.nonce,
Expand Down Expand Up @@ -92,7 +92,7 @@ export const createService = async (
{
credentials: call.request.credentials,
requestBy: "reference",
credentialOfferUri: `${process.env.PUBLIC_URL}/credential-offer/${requestId}`,
credentialOfferUri: encodeURIComponent(`${process.env.PUBLIC_URL}/credential-offer/${requestId}`),
},
{ state: call.request.state }
);
Expand Down
2 changes: 2 additions & 0 deletions proto/oid4vc/oid4vci.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ service OID4VCI {

message OfferConfig {
repeated string credentials = 1;
optional string nonce = 2;
optional string state = 3;
}

message Offer {
Expand Down
66 changes: 12 additions & 54 deletions tooling/API/OID4VC/Impierce/HTTP.http
Original file line number Diff line number Diff line change
@@ -1,57 +1,15 @@
@host=http://bank.selv.local:81
@host=http://insurance.selv.iota.org
###
GET /api/health
POST /v1/credentials
###
{{
const crypto = require('crypto');

const holder_did = "did:key:z6MkquY2TrE7KeuBNRAJ4eZbPqtYeCyGXe8seQNfK1ZXAumj";
const state = "775dd08e-c0cd-417b-9a0e-f65f8bd33fea";
const nonce = "QtIxNkPd_NX_hBqIeTR7-";

const header = {
"kid": "did:key:z6MkquY2TrE7KeuBNRAJ4eZbPqtYeCyGXe8seQNfK1ZXAumj#z6MkquY2TrE7KeuBNRAJ4eZbPqtYeCyGXe8seQNfK1ZXAumj",
"alg": "EdDSA",
"typ": "JWT"
}
const encodedHeaders = Buffer.from(JSON.stringify(header), "utf8").toString("base64url");

const claims = {
"iat": 1714457784,
"request_uri": `${host}/api/offers/siop/N5NGrHKYYxMMIC3uZ9BLn`, //TODO: what is that?
"response_type": "id_token",
state,
"client_metadata": {
"subject_syntax_types_supported": [
"did:key"
],
"id_token_signing_alg_values_supported": [
"EdDSA"
],
"client_name": "TEST",
"logo_uri": "TBD"
},
"redirect_uri": `${host}/api/auth`,
"resolver": {
"registry": {}
},
"scope": "openid",
"response_mode": "post",
"client_id": holder_did,
nonce,
"iss": holder_did
GET /v1/credentials/{credential_id}
###
POST /v1/offers
###
POST /v1/authorization_requests
Content-Type: application/json
{
"nonce": "0d520cbe176ab9e1f7888c70888020d84a69672a4baabd3ce1c6aaad8f6420c0"
}
const encodedPayload = Buffer.from(JSON.stringify(claims), "utf8").toString("base64url");

const encodedSignature = crypto.createHmac('sha256', "mysecret").update(`${encodedHeaders}.${encodedPayload}`).digest("base64url")

console.log(encodedSignature);
const jwt = `${encodedHeaders}.${encodedPayload}.${encodedSignature}`;
console.log(jwt);
exports.jwt = jwt
}}

POST /api/auth
Content-Type: application/x-www-form-urlencoded

id_token={{jwt}}
###
GET /v1/authorization_requests/06adfc99a128b078726c9cca383df3883db1e8dbd0270518bd4af7eb5a8e9191
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
@host=http://bank.selv.local:81
@host=http://insurance.selv.iota.org
###
GET /api/health
###
GET /.well-known/oauth-authorization-server
###
GET /.well-known/openid-credential-issuer
###
GET /auth/token
###
GET /openid4vci/credential
###
GET /request/032f4ed9fbe94e6ea1b58e0a97f011dc4a6ca21e260da715c23bbf717574a434
###
POST /redirect
Content-Type: application/x-www-form-urlencoded

id_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSIsImtpZCI6ImRpZDppb3RhOnJtczoweGY4MGM1MTM0OGNmMzIzOGRmMTEzMzE1NmM3ODk2NWQxZDVmOWFiYTJiZjA3MGMyM2ZiYmI5NmVkYjMzNmUxNTQjbVpYbTltSndqN2Q2WHJtejIxS3VvRDA3ZXhvM0lTOVlWWXFwTlk1RjhYSSJ9
###
{{
const crypto = require('crypto');

Expand Down
26 changes: 17 additions & 9 deletions web/src/components/QRCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,21 @@ import React from 'react';
import QRCode from 'qrcode.react';

export default ({ text, size }: { text: string; size?: number; }) => (
<div className='qr-code'>
{ text && (
<QRCode
value={text}
size={size || 290}
level='H'
/>
)}
</div>
<>
<div className='qr-code'>
{text && (
<QRCode
value={text}
size={size || 290}
level='H'
/>
)}
</div>
<div>
<a href={text}>Klick</a>
</div>
<div>
<span style={{lineBreak: "anywhere"}}>{text}</span>
</div>
</>
);
2 changes: 1 addition & 1 deletion web/src/styles/pages/scanQRcode.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
background: #FFFFFF;
border-radius: 22px;
width: 370px;
height: 370px;
//height: 370px;
z-index: 4;
margin: 50px 0;
}
Expand Down

0 comments on commit 5f379a0

Please sign in to comment.