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

feat(sdk): support for VC model 2.0 #816

Closed
wants to merge 1 commit into from
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
12 changes: 7 additions & 5 deletions cmd/wallet-sdk-gomobile/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

module github.com/trustbloc/wallet-sdk/cmd/wallet-sdk-gomobile

go 1.22
go 1.22.0

toolchain go1.23.2

require (
github.com/go-jose/go-jose/v3 v3.0.1
Expand Down Expand Up @@ -70,12 +72,12 @@ require (
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/crypto v0.28.0 // indirect
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/sys v0.26.0 // indirect
golang.org/x/text v0.19.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
16 changes: 8 additions & 8 deletions cmd/wallet-sdk-gomobile/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -178,28 +178,28 @@ golang.org/x/crypto v0.0.0-20190611184440-5c40567a22f8/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw=
golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ=
golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
Expand Down
21 changes: 19 additions & 2 deletions demo/app/lib/scenarios/handle_openid_vp_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SPDX-License-Identifier: Apache-2.0
*/

import 'dart:developer';
import 'dart:convert';
import 'package:app/wallet_sdk/wallet_sdk.dart';
import 'package:app/views/custom_error.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -51,8 +52,24 @@ void handleOpenIDVpFlow(BuildContext context, String qrCodeURL) async {
for (var cred in credentials) {
log('multi cred flow $submission and ${credentials.length}');
for (var inputDescriptor in submission.inputDescriptors) {
Map<String, dynamic> payload = Jwt.parseJwt(cred);
if (inputDescriptor.matchedVCsID.contains(payload['jti'])) {
Map<String, dynamic>? payload;
try {
payload = Jwt.parseJwt(cred);
} catch (jwtError) {
try {
payload = json.decode(cred) as Map<String, dynamic>;
} catch (jsonError) {
log('error while parsing cred as json: $jsonError');
continue;
}
}
var key = payload['jti'] ?? payload['id'];
if (key == null) {
log('no key found in cred payload');
continue;
}
if (inputDescriptor.matchedVCsID.contains(key)) {
log('matched vc with id $key added to list');
var credentialDisplayData = storedCredentials
.where((element) => cred.contains(element.value.rawCredential))
.map((e) => e.value)
Expand Down
7 changes: 7 additions & 0 deletions internal/testutil/contexts/examples_v2.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"@context": [
{
"@vocab": "https://www.w3.org/ns/credentials/examples#"
}
]
}
6 changes: 6 additions & 0 deletions internal/testutil/document_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var (
credentialExamples []byte
//go:embed contexts/examples_v1.jsonld
vcExamples []byte
//go:embed contexts/examples_v2.jsonld
vcExamplesV2 []byte
//go:embed contexts/odrl.jsonld
odrl []byte
//go:embed contexts/citizenship_v1.jsonld
Expand Down Expand Up @@ -62,6 +64,10 @@ func DocumentLoader(t *testing.T, extraContexts ...ldcontext.Document) *lddocloa
URL: "https://trustbloc.github.io/context/vc/examples-v1.jsonld",
Content: vcExamples,
},
{
URL: "https://www.w3.org/ns/credentials/examples/v2",
Content: vcExamplesV2,
},
{
URL: "https://www.w3.org/ns/odrl.jsonld",
Content: odrl,
Expand Down
6 changes: 4 additions & 2 deletions test/integration/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

module github.com/trustbloc/wallet-sdk/test/integration/helper

go 1.22
go 1.22.0

toolchain go1.23.2

require github.com/trustbloc/wallet-sdk/test/integration v0.0.0-20221207181956-419a3951143f

Expand All @@ -18,7 +20,7 @@ require (
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.23.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/net v0.30.0 // indirect
golang.org/x/oauth2 v0.13.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.31.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions test/integration/cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ go.uber.org/zap v1.23.0 h1:OjGQ5KQDEUawVHxNwQgPpiypGHOxo2mNZsOqTak4fFY=
go.uber.org/zap v1.23.0/go.mod h1:D+nX8jyLsMHMYrln8A0rJjFt/T/9/bGgIhAqxv5URuY=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/oauth2 v0.13.0 h1:jDDenyj+WgFtmV3zYVoi8aE2BwtXFLWOA67ZfNWftiY=
golang.org/x/oauth2 v0.13.0/go.mod h1:/JMhi4ZRXAf4HG9LiNmxvk+45+96RUlVThiH8FzNBn0=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws=
golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand Down
104 changes: 104 additions & 0 deletions test/integration/expecteddisplaydata/university_degree_v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"issuer_display": {
"name": "University Degree Issuer 2.0",
"locale": "en-US"
},
"credential_displays": [
{
"overview": {
"name": "University Degree Credential",
"locale": "en-US",
"logo": {
"uri": "https://example.com/public/logo.png",
"alt_text": "a square logo of a degree verification"
},
"background_color": "#12107c",
"text_color": "#FFFFFF"
},
"claims": [
{
"raw_id": "familyName",
"label": "Family Name",
"value_type": "string",
"raw_value": "John Doe",
"locale": "en-US"
},
{
"raw_id": "givenName",
"label": "Given Name",
"value_type": "string",
"raw_value": "John",
"locale": "en-US"
},
{
"raw_id": "degree",
"label": "Degree",
"value_type": "string",
"raw_value": "MIT",
"locale": "en-US"
},
{
"raw_id": "degreeSchool",
"label": "Degree School",
"value_type": "string",
"raw_value": "MIT school",
"locale": "en-US"
},
{
"raw_id": "photo",
"label": "Photo",
"value_type": "image",
"raw_value": "binary data"
}
]
},
{
"overview": {
"name": "University Degree Credential",
"locale": "en-US",
"logo": {
"uri": "https://example.com/public/logo.png",
"alt_text": "a square logo of a degree verification"
},
"background_color": "#12107c",
"text_color": "#FFFFFF"
},
"claims": [
{
"raw_id": "familyName",
"label": "Family Name",
"value_type": "string",
"raw_value": "John Doe",
"locale": "en-US"
},
{
"raw_id": "givenName",
"label": "Given Name",
"value_type": "string",
"raw_value": "John",
"locale": "en-US"
},
{
"raw_id": "degree",
"label": "Degree",
"value_type": "string",
"raw_value": "MS",
"locale": "en-US"
},
{
"raw_id": "degreeSchool",
"label": "Degree School",
"value_type": "string",
"raw_value": "Stanford",
"locale": "en-US"
},
{
"raw_id": "photo",
"label": "Photo",
"value_type": "image",
"raw_value": "binary data"
}
]
}
]
}
10 changes: 10 additions & 0 deletions test/integration/fixtures/file-server/ld-contexts.json
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@
}]
}
},
{
"url": "https://www.w3.org/ns/credentials/examples/v2",
"content" : {
"@context": [
{
"@vocab": "https://www.w3.org/ns/credentials/examples#"
}
]
}
},
{
"url": "https://www.w3.org/ns/odrl.jsonld",
"content": {
Expand Down
Loading
Loading