Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

feat: wallet model validation #447

Merged
merged 1 commit into from
Oct 24, 2022
Merged

Conversation

baha-ai
Copy link
Contributor

@baha-ai baha-ai commented Oct 7, 2022

This change introduces Model validation by updating some of the existing wallet credentials.

Closes #397

Signed-off-by: Baha Shaaban [email protected]

@cla-bot cla-bot bot added the cla-signed label Oct 7, 2022
@codecov
Copy link

codecov bot commented Oct 7, 2022

Codecov Report

Base: 85.30% // Head: 85.30% // No change to project coverage 👍

Coverage data is based on head (aa8bd71) compared to base (a66e47e).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #447   +/-   ##
=======================================
  Coverage   85.30%   85.30%           
=======================================
  Files          14       14           
  Lines        1320     1320           
=======================================
  Hits         1126     1126           
  Misses        120      120           
  Partials       74       74           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@baha-ai
Copy link
Contributor Author

baha-ai commented Oct 7, 2022

?? weird, validation was failing before I create this pr with the flag set to true, now it seems to pass !

I have not changed the remaining models that were failing (like the manifest creds files, the context is still empty)

@baha-ai baha-ai changed the title feat: wallet model validation (Partial) feat: wallet model validation Oct 7, 2022
@baha-ai
Copy link
Contributor Author

baha-ai commented Oct 7, 2022

?? weird, validation was failing before I create this pr with the flag set to true, now it seems to pass !

I have not changed the remaining models that were failing (like the manifest creds files, the context is still empty)

I had bbs issue signing cmd/wallet-js-sdk/test/fixtures/testdata/udc-bbs-vc.json but realized its content is the same as cmd/wallet-js-sdk/test/fixtures/testdata/udc-vc.json. When copying the exact same content, everything seems to have worked. It seems to pass model validation as well.

Comment on lines +313 to 413
{
"url": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld",
"documentURL": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld",
"content": {
"@context": {
"@version": 1.1,

"context": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#context",
"@context": {
"@version": 1.1
}
},
"collection": "https://schema.org/collection",
"credentialType": "https://schema.org/credentialType",
"issuer": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#issuer",
"@context": {
"@version": 1.1
}
},
"issuerStyle": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#issuerStyle",
"@context": {
"@version": 1.1,
"styles": "https://schema.org/styles"
}
},
"resolved": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#resolved",
"@container": "@set",
"@context": {
"@version": 1.1,
"descriptor_id": "https://schema.org/descriptor_id",
"properties": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#properties",
"@container": "@set",
"@context": {
"@version": 1.1,
"label": "https://schema.org/label",
"schema": "https://schema.org/schema"
}
},
"customStyle": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#customStyle",
"@context": {
"@version": 1.1,
"color": "https://schema.org/color",
"alt": "https://schema.org/alt",
"uri": "https://schema.org/uri"
}
},
"styles": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#styles",
"@context": {
"@version": 1.1,
"background": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#background",
"@type": "customStyle"
},
"hero": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#hero",
"@type": "customStyle"
},
"text": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#text",
"@type": "customStyle"
},
"thumbnail": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#thumbnail",
"@type": "customStyle"
}
}
}
}
},
"xsd": "http://www.w3.org/2001/XMLSchema#",

"expirationDate": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#expirationDate",
"@type": "xsd:date"
},
"issuanceDate": {
"@id": "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld#issuanceDate",
"@type": "xsd:date"
},
"title": "https://schema.org/title",
"subtitle": "https://schema.org/subtitle"
}
}
},
{
"url": "https://trustbloc.github.io/context/wallet/manifest-mapping-v1.jsonld",
"documentURL": "https://trustbloc.github.io/context/wallet/manifest-mapping-v1.jsonld",
"content": {
"@context": {
"@version": 1.1
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can these custom contexts be hosted in trustbloc/context package?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

they are already in https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld,

Apparently our external remote document loader is not enabled by default in afgo, this is why the same content is copied into this context provider server we have running as part of the test. cc @aholovko

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Baha-sk you can use network based context loader here, I don't understand why we need to host it locally again if it is published.

Copy link
Contributor Author

@baha-ai baha-ai Oct 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Baha-sk you can use network based context loader here, I don't understand why we need to host it locally again if it is published.

@sudeshrshetty network based == external remote for document loading

correct me if I'm wrong @aholovko

@@ -35,13 +35,15 @@ before(async function () {
keyType: "ecdsap256ieee1363",
keyAgreementType: "p256kw",
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
Copy link
Member

@sudeshrshetty sudeshrshetty Oct 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure we need it since we are downloading all contexts from network for wallet tests

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment as above, we have a context provider hosted on port 10096

Copy link
Contributor Author

@baha-ai baha-ai Oct 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems document compaction relies on doc loader which requires the context to be pre-loaded. cc @aholovko what do you think?

I tried removing this URL variable, errors in the tests I get is:

  ✗ "before all" hook in "{root}"
        Error: agent wasm: code: 6011, message: parse vc : compact JSON-LD document: failed to compact map[string]interface {}{"@context":[]interface {}{"https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld", map[string]interface {}{"description":"https://schema.org/description"}}, "credentialSchema":[]interface {}{}, "credentialSubject":map[string]interface {}{"degree":map[string]interface {}{"name":"Bachelor of Science and Arts", "type":"BachelorDegree"}, "id":"did:example:ebfeb1f712ebc6f1c276e12ec21", "name":"Jayden Doe", "spouse":"did:example:c276e12ec21ebfeb1f712ebc6f1"}, "description":"University Degree of Mr.John Smith", "expirationDate":"2020-01-01T19:23:24Z", "id":"http://example.edu/credentials/11873", "issuanceDate":"2010-01-01T19:23:24Z", "issuer":map[string]interface {}{"id":"did:example:76e12ec712ebc6f1c221ebfeb1f", "name":"Example University"}, "name":"University Degree", "referenceId":8.3294847e+07, "type":[]interface {}{"VerifiableCredential", "UniversityDegreeCredential"}} 
                with context map[string]interface {}{"@context":[]interface {}{"https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld", map[string]interface {}{"description":"https://schema.org/description"}}} 
                and ldOptions: &ld.JsonLdOptions{Base:"", CompactArrays:true, ExpandContext:interface {}(nil), ProcessingMode:"json-ld-1.1", DocumentLoader:(*ld.DocumentLoader)(0x1717240), Embed:"@last", Explicit:false, RequireAll:true, FrameDefault:false, OmitDefault:false, OmitGraph:false, UseRdfType:false, UseNativeTypes:false, ProduceGeneralizedRdf:true, InputFormat:"", Format:"application/n-quads", Algorithm:"URGNA2012", UseNamespaces:false, OutputForm:""},
                 error: invalid term definition: a term definition must not contain resolved 
                for doc:  {"@context":["https://www.w3.org/2018/credentials/v1","https://www.w3.org/2018/credentials/examples/v1","https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld",{"description":"https://schema.org/description"}],"credentialSchema":[],"credentialSubject":{"degree":{"name":"Bachelor of Science and Arts","type":"BachelorDegree"},"id":"did:example:ebfeb1f712ebc6f1c276e12ec21","name":"Jayden Doe","spouse":"did:example:c276e12ec21ebfeb1f712ebc6f1"},"description":"University Degree of Mr.John Smith","expirationDate":"2020-01-01T19:23:24Z","id":"http://example.edu/credentials/11873","issuanceDate":"2010-01-01T19:23:24Z","issuer":{"id":"did:example:76e12ec712ebc6f1c221ebfeb1f","name":"Example University"},"name":"University Degree","referenceId":83294847,"type":["VerifiableCredential","UniversityDegreeCredential"]}, externalContext: []string(nil), docLoader: &ld.DocumentLoader{store:(*ld.ContextStoreImpl)(0x17ff300), remoteDocumentLoader:(*ld.DefaultDocumentLoader)(0x140c098)} jsonldDocumentLoader
            at dist/commons.js:4:1416
            at a.onmessage (dist/commons.js:4:20888)
...

resolved is properly defined in the context as expected, but the document loader engine can't find it without the specific contextProviderURL.

This change introduces Model validation by updating some of the existing wallet credentials.

closes trustbloc#397

Signed-off-by: Baha Shaaban <[email protected]>
@baha-ai baha-ai merged commit 5d86c45 into trustbloc:main Oct 24, 2022
@baha-ai baha-ai deleted the model_validation branch October 24, 2022 13:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable Wallet data model validation
4 participants