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

Commit

Permalink
Merge pull request #447 from Baha-sk/model_validation
Browse files Browse the repository at this point in the history
feat: wallet model validation
  • Loading branch information
baha-ai authored Oct 24, 2022
2 parents c6aa434 + aa8bd71 commit 5d86c45
Show file tree
Hide file tree
Showing 22 changed files with 157 additions and 22 deletions.
1 change: 1 addition & 0 deletions cmd/agent-js-worker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func getAriesHandlers(ctx *context.Provider, r controllercmd.MessageHandler,
EDVBatchEndpointExtensionEnabled: true,
WebKMSGNAPSigner: headerFunc,
EDVGNAPSigner: headerFunc,
ValidateDataModel: opts.ValidateDataModel,
}))
if err != nil {
return nil, err
Expand Down
3 changes: 3 additions & 0 deletions cmd/wallet-js-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Wallet JavaScript SDK for user agent wallet operations.

Refer this [documentation](docs/wallet_sdk.md) to learn more about wallet SDK.

# Pre requisite

In order to successfully run tests in this wallet package, you must first build and install [agent-js-workder](../agent-js-worker/README.md).

# Build it

Expand Down
2 changes: 1 addition & 1 deletion cmd/wallet-js-sdk/src/collection/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {

const JSONLD_CTX_COLLECTION = [
"https://w3id.org/wallet/v1",
"https://trustbloc.github.io/context/wallet/collections-v1.jsonld",
"https://trustbloc.github.io/context/wallet/manifest-mapping-v1.jsonld"
];
const DEF_COLLECTION_TYPE = "Vault";

Expand Down
4 changes: 2 additions & 2 deletions cmd/wallet-js-sdk/src/credential/credential-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import jp from "jsonpath";

const JSONLD_CTX_BLINDED_ROUTING_MANIFEST_MAPPING = [
"https://w3id.org/wallet/v1",
"https://trustbloc.github.io/context/wallet/manifest-mapping-v1.jsonld",
"https://trustbloc.github.io/context/wallet/manifest-mapping-v1.jsonld"
];

const JSONLD_CREDENTIAL_METADATA_MODEL = [
"https://w3id.org/wallet/v1",
"https://www.w3.org/2018/credentials/v1",
"https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld",
"https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld"
];

const MANIFEST_MAPPING_METADATA_TYPE = "ManifestMapping";
Expand Down
1 change: 1 addition & 0 deletions cmd/wallet-js-sdk/test/fixtures/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ mediatorWSEndPoint = ws://localhost:10092
did-anchor-origin = https://testnet.orb.local
bloc-domain = https://testnet.orb.local
context-provider-url[] = http://localhost:10096/agent-startup-contexts.json
validate-data-model = true
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,106 @@

}
}
},
{
"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
}
}
}
]
}
3 changes: 2 additions & 1 deletion cmd/wallet-js-sdk/test/fixtures/testdata/prc-vc.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://w3id.org/citizenship/v1"
"https://w3id.org/citizenship/v1",
"https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld"
],
"id": "https://issuer.oidp.uscis.gov/credentials/83627465",
"type": [
Expand Down
14 changes: 8 additions & 6 deletions cmd/wallet-js-sdk/test/fixtures/testdata/udc-bbs-vc.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"@context": ["https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", "https://w3id.org/security/bbs/v1"],
"@context": ["https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", "https://w3id.org/security/bbs/v1", "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld", {"description": "https://schema.org/description"}],
"credentialSubject": {
"degree": {"type": "BachelorDegree", "university": "MIT"},
"degree": {"type": "BachelorDegree", "name": "Bachelor of Science and Arts"},
"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/1872",
"id": "http://example.edu/credentials/11873",
"issuanceDate": "2010-01-01T19:23:24Z",
"issuer": {"id": "did:example:76e12ec712ebc6f1c221ebfeb1f", "name": "Example University"},
"name": "University Degree",
"proof": {
"created": "2021-03-29T13:27:36.483097-04:00",
"created": "2022-10-05T16:54:47.420704-04:00",
"proofPurpose": "assertionMethod",
"proofValue": "rw7FeV6K1wimnYogF9qd-N0zmq5QlaIoszg64HciTca-mK_WU4E1jIusKTT6EnN2GZz04NVPBIw4yhc0kTwIZ07etMvfWUlHt_KMoy2CfTw8FBhrf66q4h7Qcqxh_Kxp6yCHyB4A-MmURlKKb8o-4w",
"proofValue": "lQTjwHlvh3kiDMP1SQdMm296-OfRG7V17-sS9NMRDZagp2uFrDpTF3OHWEw2IRYJAoc_9IePn0cVoImZ5wG7_F8VMnLiGQA58n8YCIKSDllf3bkVrMzgnx6X3SDp1C1WaVPhwx-UBbXTIzAjINQoHw",
"type": "BbsBlsSignature2020",
"verificationMethod": "did:key:zUC72c7u4BYVmfYinDceXkNAwzPEyuEE23kUmJDjLy8495KH3pjLwFhae1Fww9qxxRdLnS2VNNwni6W3KbYZKsicDtiNNEp76fYWR6HCD8jAz6ihwmLRjcHH6kB294Xfg1SL1qQ#zUC72c7u4BYVmfYinDceXkNAwzPEyuEE23kUmJDjLy8495KH3pjLwFhae1Fww9qxxRdLnS2VNNwni6W3KbYZKsicDtiNNEp76fYWR6HCD8jAz6ihwmLRjcHH6kB294Xfg1SL1qQ"
},
"referenceNumber": 83294847,
"referenceId": 83294847,
"type": ["VerifiableCredential", "UniversityDegreeCredential"]
}
14 changes: 8 additions & 6 deletions cmd/wallet-js-sdk/test/fixtures/testdata/udc-frame.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"@context": ["https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", "https://w3id.org/security/bbs/v1"],
"@context": ["https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", "https://w3id.org/security/bbs/v1", "https://trustbloc.github.io/context/wallet/credential-metadata-v1.jsonld", {"description": "https://schema.org/description"}],
"credentialSubject": {
"degree": {"type": "BachelorDegree", "university": "MIT"},
"degree": {"type": "BachelorDegree", "name": "Bachelor of Science and Arts"},
"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/1872",
"id": "http://example.edu/credentials/11873",
"issuanceDate": "2010-01-01T19:23:24Z",
"issuer": {"id": "did:example:76e12ec712ebc6f1c221ebfeb1f", "name": "Example University"},
"name": "University Degree",
"proof": {
"created": "2021-03-29T13:27:36.483097-04:00",
"created": "2022-10-05T16:54:47.420704-04:00",
"proofPurpose": "assertionMethod",
"proofValue": "rw7FeV6K1wimnYogF9qd-N0zmq5QlaIoszg64HciTca-mK_WU4E1jIusKTT6EnN2GZz04NVPBIw4yhc0kTwIZ07etMvfWUlHt_KMoy2CfTw8FBhrf66q4h7Qcqxh_Kxp6yCHyB4A-MmURlKKb8o-4w",
"proofValue": "lQTjwHlvh3kiDMP1SQdMm296-OfRG7V17-sS9NMRDZagp2uFrDpTF3OHWEw2IRYJAoc_9IePn0cVoImZ5wG7_F8VMnLiGQA58n8YCIKSDllf3bkVrMzgnx6X3SDp1C1WaVPhwx-UBbXTIzAjINQoHw",
"type": "BbsBlsSignature2020",
"verificationMethod": "did:key:zUC72c7u4BYVmfYinDceXkNAwzPEyuEE23kUmJDjLy8495KH3pjLwFhae1Fww9qxxRdLnS2VNNwni6W3KbYZKsicDtiNNEp76fYWR6HCD8jAz6ihwmLRjcHH6kB294Xfg1SL1qQ#zUC72c7u4BYVmfYinDceXkNAwzPEyuEE23kUmJDjLy8495KH3pjLwFhae1Fww9qxxRdLnS2VNNwni6W3KbYZKsicDtiNNEp76fYWR6HCD8jAz6ihwmLRjcHH6kB294Xfg1SL1qQ"
},
"referenceNumber": 83294847,
"referenceId": 83294847,
"type": ["VerifiableCredential", "UniversityDegreeCredential"]
}
8 changes: 5 additions & 3 deletions cmd/wallet-js-sdk/test/fixtures/testdata/udc-vc.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/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": {
"type": "BachelorDegree",
"university": "MIT"
"name": "Bachelor of Science and Arts"
},
"id": "did:example:ebfeb1f712ebc6f1c276e12ec21",
"name": "Jayden Doe",
Expand All @@ -23,7 +25,7 @@
"id": "did:example:76e12ec712ebc6f1c221ebfeb1f",
"name": "Example University"
},
"referenceNumber": 83294847,
"referenceId": 83294847,
"type": [
"VerifiableCredential",
"UniversityDegreeCredential"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ before(async function () {
walletUserAgent = await loadFrameworks({
name: WALLET_USER,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});

// load sample VCs from testdata.
Expand Down
2 changes: 2 additions & 0 deletions cmd/wallet-js-sdk/test/specs/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function loadFrameworks({
keyType = "ed25519",
keyAgreementType = "p256kw",
enableDIDComm = false,
contextProviderURL = []
} = {}) {
let agentOpts = JSON.parse(JSON.stringify(agentStartupOpts));
agentOpts["indexed-db-namespace"] = `${name}db`;
Expand All @@ -61,6 +62,7 @@ export async function loadFrameworks({
agentOpts["key-type"] = keyType;
agentOpts["key-agreement-type"] = keyAgreementType;
agentOpts["enableDIDComm"] = enableDIDComm;
agentOpts["context-provider-url"] = contextProviderURL;

if (logLevel) {
agentOpts["log-level"] = logLevel;
Expand Down
2 changes: 2 additions & 0 deletions cmd/wallet-js-sdk/test/specs/didcomm/connect.v1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ before(async function () {
name: ALICE_LABEL,
mediaTypeProfiles: ["didcomm/aip2;env=rfc19"],
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});
bob = await loadFrameworks({
name: BOB_LABEL,
mediaTypeProfiles: ["didcomm/aip2;env=rfc19"],
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});
});

Expand Down
2 changes: 2 additions & 0 deletions cmd/wallet-js-sdk/test/specs/didcomm/connect.v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@ before(async function () {
keyType: "ecdsap256ieee1363",
keyAgreementType: "p256kw",
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});
bob = await loadFrameworks({
name: BOB_LABEL_V2,
mediaTypeProfiles: ["didcomm/v2"],
keyType: "ecdsap256ieee1363",
keyAgreementType: "p256kw",
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});

aliceDID = await createWalletAndPublicDID(alice, ALICE_LABEL_V2, aliceDID)
Expand Down
1 change: 1 addition & 0 deletions cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v1.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ before(async function () {
walletUserAgent = await loadFrameworks({
name: WALLET_WACI_USER,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});

// issuer agent
Expand Down
1 change: 1 addition & 0 deletions cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v2.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ before(async function () {
keyType: KEY_TYPE,
keyAgreementType: KEY_AGREEMENT_TYPE,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});

// issuer agent
Expand Down
6 changes: 5 additions & 1 deletion cmd/wallet-js-sdk/test/specs/didmanager/didmanager.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const signatureType = 'Ed25519VerificationKey2018'
let rick

before(async function () {
rick = await loadFrameworks({ name: RICK_USER, enableDIDComm: true });
rick = await loadFrameworks({
name: RICK_USER,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});
});

after(function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ before(async function () {
walletAgent = await loadFrameworks({
name: WALLET_USER,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});
await connectToMediator(walletAgent, testConfig.mediatorEndPoint);
let conns = await getMediatorConnections(walletAgent);
Expand Down
5 changes: 4 additions & 1 deletion cmd/wallet-js-sdk/test/specs/universal/vcwallet.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ let walletAgent, rp, sampleMetadata;


before(async function () {
walletAgent = await loadFrameworks({ name: WALLET_USER });
walletAgent = await loadFrameworks({
name: WALLET_USER,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});

rp = new VerifierAdapter(RELYING_PARTY);
await rp.init();
Expand Down
6 changes: 5 additions & 1 deletion cmd/wallet-js-sdk/test/specs/user/wallet-user.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ const JOHN_USER = "john-agent";
let john;

before(async function () {
john = await loadFrameworks({ name: JOHN_USER, enableDIDComm: true });
john = await loadFrameworks({
name: JOHN_USER,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});
});

after(function () {
Expand Down
1 change: 1 addition & 0 deletions cmd/wallet-js-sdk/test/specs/util/helper.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ before(async function () {
walletUserAgent = await loadFrameworks({
name: WALLET_USER,
enableDIDComm: true,
contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"]
});

issuer = new IssuerAdapter(VC_ISSUER);
Expand Down
1 change: 1 addition & 0 deletions pkg/agentsetup/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type AgentStartOpts struct {
GNAPSigningJWK string `json:"gnap-signing-jwk"`
GNAPAccessToken string `json:"gnap-access-token"`
GNAPUserSubject string `json:"gnap-user-subject"`
ValidateDataModel bool `json:"validate-data-model"`
}

type UserConfig struct {
Expand Down

0 comments on commit 5d86c45

Please sign in to comment.