diff --git a/src/3.0/__tests__/e2e.test.ts b/src/3.0/__tests__/e2e.test.ts index a8662d7b..c20f01fc 100644 --- a/src/3.0/__tests__/e2e.test.ts +++ b/src/3.0/__tests__/e2e.test.ts @@ -19,7 +19,7 @@ import sampleDid from "../schema/sample-credential-did.json"; const openAttestationDataWithDid = sampleDid as OpenAttestationDocument; -const openAttestationData: OpenAttestationDocument = { +const openAttestationData = { "@context": [ "https://www.w3.org/2018/credentials/v1", "https://www.w3.org/2018/credentials/examples/v1", @@ -30,7 +30,7 @@ const openAttestationData: OpenAttestationDocument = { validFrom: "2010-01-01T19:23:24Z", issuanceDate: "2010-01-01T19:23:24Z", name: "document owner name", - type: ["VerifiableCredential", "UniversityDegreeCredential"], + type: ["VerifiableCredential", "UniversityDegreeCredential", "OpenAttestationCredential"], credentialSubject: { id: "did:example:ebfeb1f712ebc6f1c276e12ec21", degree: { @@ -56,6 +56,7 @@ const openAttestationData: OpenAttestationDocument = { }, issuer: { id: "http://some.example.com", + type: "OpenAttestationIssuer", name: "DEMO STORE", }, }; diff --git a/src/3.0/schema/sample-credential-did.json b/src/3.0/schema/sample-credential-did.json index 9e98f16d..2a2bd948 100644 --- a/src/3.0/schema/sample-credential-did.json +++ b/src/3.0/schema/sample-credential-did.json @@ -11,9 +11,10 @@ "validFrom": "2010-01-01T19:23:24Z", "issuer": { "id": "https://example.com", + "type": "OpenAttestationIssuer", "name": "DEMO STORE" }, - "type": ["VerifiableCredential", "DrivingLicenceCredential"], + "type": ["VerifiableCredential", "DrivingLicenceCredential", "OpenAttestationCredential"], "credentialSubject": { "id": "did:example:SERIAL_NUMBER_123", "class": [ diff --git a/src/3.0/schema/sample-credential-document-store.json b/src/3.0/schema/sample-credential-document-store.json index 565e07be..674d5e4f 100644 --- a/src/3.0/schema/sample-credential-document-store.json +++ b/src/3.0/schema/sample-credential-document-store.json @@ -5,15 +5,16 @@ "https://schemata.openattestation.com/com/openattestation/1.0/OpenAttestation.v3.json", "https://schemata.openattestation.com/com/openattestation/1.0/CustomContext.json" ], + "type": ["VerifiableCredential", "DrivingLicenceCredential", "OpenAttestationCredential"], "reference": "SERIAL_NUMBER_123", "name": "Republic of Singapore Driving Licence", "issuanceDate": "2010-01-01T19:23:24Z", "validFrom": "2010-01-01T19:23:24Z", "issuer": { "id": "https://example.com", + "type": "OpenAttestationIssuer", "name": "DEMO STORE" }, - "type": ["VerifiableCredential", "DrivingLicenceCredential"], "credentialSubject": { "id": "did:example:SERIAL_NUMBER_123", "class": [ diff --git a/src/3.0/schema/schema.json b/src/3.0/schema/schema.json index 6658f9f6..1121c0fb 100644 --- a/src/3.0/schema/schema.json +++ b/src/3.0/schema/schema.json @@ -31,7 +31,7 @@ } }, "required": ["id", "name"], - "additionalProperties": false + "additionalProperties": true } }, "properties": { diff --git a/src/3.0/schema/schema.test.ts b/src/3.0/schema/schema.test.ts index eeedb77c..ad539e27 100644 --- a/src/3.0/schema/schema.test.ts +++ b/src/3.0/schema/schema.test.ts @@ -506,39 +506,6 @@ describe("schema/3.0", () => { const wrappedDocument = await wrapDocument(document, { externalSchemaId: $id, version: SchemaId.v3 }); expect(wrappedDocument.version).toStrictEqual(SchemaId.v3); }); - it("should be invalid when adding additional data", async () => { - expect.assertions(2); - - const document = { ...cloneDeep(sampleDoc), issuer: { ...sample.issuer, key: "any" } }; - try { - await wrapDocument(document, { externalSchemaId: $id, version: SchemaId.v3 }); - } catch (e) { - expect(e).toHaveProperty("message", "Invalid document"); - expect(e).toHaveProperty("validationErrors", [ - { - keyword: "additionalProperties", - instancePath: "/issuer", - schemaPath: "#/definitions/issuer/additionalProperties", - params: { additionalProperty: "key" }, - message: "must NOT have additional properties", - }, - { - keyword: "type", - instancePath: "/issuer", - schemaPath: "#/properties/issuer/oneOf/1/type", - params: { type: "string" }, - message: "must be string", - }, - { - keyword: "oneOf", - instancePath: "/issuer", - schemaPath: "#/properties/issuer/oneOf", - params: { passingSchemas: null }, - message: "must match exactly one schema in oneOf", - }, - ]); - } - }); it("should be invalid when id is not a URI", async () => { expect.assertions(2); diff --git a/src/3.0/validate/validate.ts b/src/3.0/validate/validate.ts index d6a8e068..3e97dcb5 100644 --- a/src/3.0/validate/validate.ts +++ b/src/3.0/validate/validate.ts @@ -111,7 +111,11 @@ export async function validateW3C(credential: await expand(credential, { expansionMap: (info) => { if (info.unmappedProperty) { - throw new Error("The property '" + info.unmappedProperty + "' in the input was not defined in the context"); + throw new Error( + `"The property ${info.activeProperty ? `${info.activeProperty}.` : ""}${ + info.unmappedProperty + } in the input was not defined in the context"` + ); } }, documentLoader, diff --git a/src/shared/utils/__tests__/diagnose.test.ts b/src/shared/utils/__tests__/diagnose.test.ts index 8a57d0c3..d01af6ed 100644 --- a/src/shared/utils/__tests__/diagnose.test.ts +++ b/src/shared/utils/__tests__/diagnose.test.ts @@ -36,10 +36,11 @@ describe("diagnose", () => { ], issuer: { name: "name", + type: "OpenAttestationIssuer", id: "https://example.com", }, issuanceDate: "2010-01-01T19:23:24Z", - type: ["VerifiableCredential", "UniversityDegreeCredential"], + type: ["VerifiableCredential", "UniversityDegreeCredential", "OpenAttestationCredential"], credentialSubject: { id: "did:example:ebfeb1f712ebc6f1c276e12ec21", degree: { @@ -53,6 +54,11 @@ describe("diagnose", () => { type: v3.ProofType.OpenAttestationProofMethod, method: v3.Method.DocumentStore, }, + template: { + url: "https://", + name: "", + type: v3.TemplateType.EmbeddedRenderer, + }, identityProof: { identifier: "whatever", type: v2.IdentityProofType.DNSTxt, @@ -60,11 +66,6 @@ describe("diagnose", () => { }, name: "", reference: "", - template: { - url: "https://", - name: "", - type: v3.TemplateType.EmbeddedRenderer, - }, validFrom: "2010-01-01T19:23:24Z", }, { version: SchemaId.v3 } diff --git a/src/shared/utils/__tests__/guard.test.ts b/src/shared/utils/__tests__/guard.test.ts index 0ce9384a..eb1dc12d 100644 --- a/src/shared/utils/__tests__/guard.test.ts +++ b/src/shared/utils/__tests__/guard.test.ts @@ -45,7 +45,7 @@ describe("guard", () => { id: "https://example.com", }, issuanceDate: "2010-01-01T19:23:24Z", - type: ["VerifiableCredential", "UniversityDegreeCredential"], + type: ["VerifiableCredential", "UniversityDegreeCredential", "OpenAttestationCredential"], credentialSubject: { id: "did:example:ebfeb1f712ebc6f1c276e12ec21", degree: { @@ -63,14 +63,14 @@ describe("guard", () => { identifier: "whatever", type: v2.IdentityProofType.DNSTxt, }, + template: { + url: "https://", + name: "", + type: v3.TemplateType.EmbeddedRenderer, + }, }, name: "", reference: "", - template: { - url: "https://", - name: "", - type: v3.TemplateType.EmbeddedRenderer, - }, validFrom: "2010-01-01T19:23:24Z", }, { version: SchemaId.v3 } diff --git a/src/shared/utils/__tests__/utils.test.ts b/src/shared/utils/__tests__/utils.test.ts index b3113c35..08f624fb 100644 --- a/src/shared/utils/__tests__/utils.test.ts +++ b/src/shared/utils/__tests__/utils.test.ts @@ -41,10 +41,11 @@ describe("Util Functions", () => { ], issuer: { name: "name", + type: "OpenAttestationIssuer", id: "https://example.com", }, issuanceDate: "2010-01-01T19:23:24Z", - type: ["VerifiableCredential", "UniversityDegreeCredential"], + type: ["VerifiableCredential", "UniversityDegreeCredential", "OpenAttestationCredential"], credentialSubject: { id: "did:example:ebfeb1f712ebc6f1c276e12ec21", degree: { @@ -62,14 +63,14 @@ describe("Util Functions", () => { identifier: "whatever", type: v2.IdentityProofType.DNSTxt, }, + template: { + url: "https://", + name: "", + type: v3.TemplateType.EmbeddedRenderer, + }, }, name: "", reference: "", - template: { - url: "https://", - name: "", - type: v3.TemplateType.EmbeddedRenderer, - }, validFrom: "2010-01-01T19:23:24Z", }, { version: SchemaId.v3 } @@ -83,10 +84,11 @@ describe("Util Functions", () => { ], issuer: { name: "name", + type: "OpenAttestationIssuer", id: "https://example.com", }, issuanceDate: "2010-01-01T19:23:24Z", - type: ["VerifiableCredential", "UniversityDegreeCredential"], + type: ["VerifiableCredential", "UniversityDegreeCredential", "OpenAttestationCredential"], credentialSubject: { id: "did:example:ebfeb1f712ebc6f1c276e12ec21", degree: { @@ -104,14 +106,14 @@ describe("Util Functions", () => { identifier: "whatever", type: v2.IdentityProofType.DNSTxt, }, + template: { + url: "https://", + name: "", + type: v3.TemplateType.EmbeddedRenderer, + }, }, name: "", reference: "", - template: { - url: "https://", - name: "", - type: v3.TemplateType.EmbeddedRenderer, - }, validFrom: "2010-01-01T19:23:24Z", }, { version: SchemaId.v3 }