diff --git a/cmd/agent-js-worker/main.go b/cmd/agent-js-worker/main.go index 71a507d2..3b8301ca 100644 --- a/cmd/agent-js-worker/main.go +++ b/cmd/agent-js-worker/main.go @@ -153,6 +153,7 @@ func getAriesHandlers(ctx *context.Provider, r controllercmd.MessageHandler, EDVBatchEndpointExtensionEnabled: true, WebKMSGNAPSigner: headerFunc, EDVGNAPSigner: headerFunc, + //ValidateDataModel: true, })) if err != nil { return nil, err diff --git a/cmd/wallet-js-sdk/README.md b/cmd/wallet-js-sdk/README.md index b65fdd7c..05e4dbba 100644 --- a/cmd/wallet-js-sdk/README.md +++ b/cmd/wallet-js-sdk/README.md @@ -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 diff --git a/cmd/wallet-js-sdk/src/collection/collections.js b/cmd/wallet-js-sdk/src/collection/collections.js index 3e7a84fd..d00993e2 100644 --- a/cmd/wallet-js-sdk/src/collection/collections.js +++ b/cmd/wallet-js-sdk/src/collection/collections.js @@ -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"; diff --git a/cmd/wallet-js-sdk/src/credential/credential-manager.js b/cmd/wallet-js-sdk/src/credential/credential-manager.js index bf2e1699..ba35596a 100644 --- a/cmd/wallet-js-sdk/src/credential/credential-manager.js +++ b/cmd/wallet-js-sdk/src/credential/credential-manager.js @@ -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"; diff --git a/cmd/wallet-js-sdk/test/fixtures/testdata/contexts/agent-startup-contexts.json b/cmd/wallet-js-sdk/test/fixtures/testdata/contexts/agent-startup-contexts.json index 842ad66e..becc5823 100644 --- a/cmd/wallet-js-sdk/test/fixtures/testdata/contexts/agent-startup-contexts.json +++ b/cmd/wallet-js-sdk/test/fixtures/testdata/contexts/agent-startup-contexts.json @@ -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 + } + } } ] } \ No newline at end of file diff --git a/cmd/wallet-js-sdk/test/fixtures/testdata/prc-vc.json b/cmd/wallet-js-sdk/test/fixtures/testdata/prc-vc.json index 59c8afa4..b7ffc041 100644 --- a/cmd/wallet-js-sdk/test/fixtures/testdata/prc-vc.json +++ b/cmd/wallet-js-sdk/test/fixtures/testdata/prc-vc.json @@ -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": [ diff --git a/cmd/wallet-js-sdk/test/fixtures/testdata/udc-bbs-vc.json b/cmd/wallet-js-sdk/test/fixtures/testdata/udc-bbs-vc.json index d504b783..786c9705 100644 --- a/cmd/wallet-js-sdk/test/fixtures/testdata/udc-bbs-vc.json +++ b/cmd/wallet-js-sdk/test/fixtures/testdata/udc-bbs-vc.json @@ -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"] } diff --git a/cmd/wallet-js-sdk/test/fixtures/testdata/udc-frame.json b/cmd/wallet-js-sdk/test/fixtures/testdata/udc-frame.json index d504b783..786c9705 100644 --- a/cmd/wallet-js-sdk/test/fixtures/testdata/udc-frame.json +++ b/cmd/wallet-js-sdk/test/fixtures/testdata/udc-frame.json @@ -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"] } diff --git a/cmd/wallet-js-sdk/test/fixtures/testdata/udc-vc.json b/cmd/wallet-js-sdk/test/fixtures/testdata/udc-vc.json index e274ed10..f115c6e4 100644 --- a/cmd/wallet-js-sdk/test/fixtures/testdata/udc-vc.json +++ b/cmd/wallet-js-sdk/test/fixtures/testdata/udc-vc.json @@ -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", @@ -23,7 +25,7 @@ "id": "did:example:76e12ec712ebc6f1c221ebfeb1f", "name": "Example University" }, - "referenceNumber": 83294847, + "referenceId": 83294847, "type": [ "VerifiableCredential", "UniversityDegreeCredential" diff --git a/cmd/wallet-js-sdk/test/specs/collection/collection-manager.spec.js b/cmd/wallet-js-sdk/test/specs/collection/collection-manager.spec.js index 3d9273d8..ae3eb828 100644 --- a/cmd/wallet-js-sdk/test/specs/collection/collection-manager.spec.js +++ b/cmd/wallet-js-sdk/test/specs/collection/collection-manager.spec.js @@ -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. diff --git a/cmd/wallet-js-sdk/test/specs/common.js b/cmd/wallet-js-sdk/test/specs/common.js index 2ee54b13..109b577b 100644 --- a/cmd/wallet-js-sdk/test/specs/common.js +++ b/cmd/wallet-js-sdk/test/specs/common.js @@ -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`; @@ -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; diff --git a/cmd/wallet-js-sdk/test/specs/didcomm/connect.v1.spec.js b/cmd/wallet-js-sdk/test/specs/didcomm/connect.v1.spec.js index ddc0e7e9..4131867e 100644 --- a/cmd/wallet-js-sdk/test/specs/didcomm/connect.v1.spec.js +++ b/cmd/wallet-js-sdk/test/specs/didcomm/connect.v1.spec.js @@ -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"] }); }); diff --git a/cmd/wallet-js-sdk/test/specs/didcomm/connect.v2.spec.js b/cmd/wallet-js-sdk/test/specs/didcomm/connect.v2.spec.js index c2d433b2..24f0c853 100644 --- a/cmd/wallet-js-sdk/test/specs/didcomm/connect.v2.spec.js +++ b/cmd/wallet-js-sdk/test/specs/didcomm/connect.v2.spec.js @@ -35,6 +35,7 @@ before(async function () { keyType: "ecdsap256ieee1363", keyAgreementType: "p256kw", enableDIDComm: true, + contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"] }); bob = await loadFrameworks({ name: BOB_LABEL_V2, @@ -42,6 +43,7 @@ before(async function () { keyType: "ecdsap256ieee1363", keyAgreementType: "p256kw", enableDIDComm: true, + contextProviderURL: ["http://localhost:10096/agent-startup-contexts.json"] }); aliceDID = await createWalletAndPublicDID(alice, ALICE_LABEL_V2, aliceDID) diff --git a/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v1.spec.js b/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v1.spec.js index a448aea9..32682f86 100644 --- a/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v1.spec.js +++ b/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v1.spec.js @@ -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 diff --git a/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v2.spec.js b/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v2.spec.js index 87af949e..4df93d72 100644 --- a/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v2.spec.js +++ b/cmd/wallet-js-sdk/test/specs/didcomm/didcomm.v2.spec.js @@ -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 diff --git a/cmd/wallet-js-sdk/test/specs/didmanager/didmanager.spec.js b/cmd/wallet-js-sdk/test/specs/didmanager/didmanager.spec.js index 6fc862c5..4eceb83b 100644 --- a/cmd/wallet-js-sdk/test/specs/didmanager/didmanager.spec.js +++ b/cmd/wallet-js-sdk/test/specs/didmanager/didmanager.spec.js @@ -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 () { diff --git a/cmd/wallet-js-sdk/test/specs/universal/didcommwallet.spec.js b/cmd/wallet-js-sdk/test/specs/universal/didcommwallet.spec.js index d3bd1295..0615e4ed 100644 --- a/cmd/wallet-js-sdk/test/specs/universal/didcommwallet.spec.js +++ b/cmd/wallet-js-sdk/test/specs/universal/didcommwallet.spec.js @@ -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); diff --git a/cmd/wallet-js-sdk/test/specs/universal/vcwallet.spec.js b/cmd/wallet-js-sdk/test/specs/universal/vcwallet.spec.js index e37cd2fc..36784fef 100644 --- a/cmd/wallet-js-sdk/test/specs/universal/vcwallet.spec.js +++ b/cmd/wallet-js-sdk/test/specs/universal/vcwallet.spec.js @@ -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(); diff --git a/cmd/wallet-js-sdk/test/specs/user/wallet-user.spec.js b/cmd/wallet-js-sdk/test/specs/user/wallet-user.spec.js index c72e2ac6..28eb0a24 100644 --- a/cmd/wallet-js-sdk/test/specs/user/wallet-user.spec.js +++ b/cmd/wallet-js-sdk/test/specs/user/wallet-user.spec.js @@ -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 () { diff --git a/cmd/wallet-js-sdk/test/specs/util/helper.spec.js b/cmd/wallet-js-sdk/test/specs/util/helper.spec.js index 5eeee3b8..84cc09c8 100644 --- a/cmd/wallet-js-sdk/test/specs/util/helper.spec.js +++ b/cmd/wallet-js-sdk/test/specs/util/helper.spec.js @@ -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);