From 3d2b13cb86ea7317b6ffabb0d8b1aa929ca79189 Mon Sep 17 00:00:00 2001 From: gabe Date: Fri, 31 May 2024 15:02:30 -0700 Subject: [PATCH] Fix JSON Schema files to align with spec updates. --- package.json | 2 +- .../verifiable-credential-schema.json | 106 ++++++++++++------ .../verifiable-presentation-schema.json | 40 ++++--- 3 files changed, 96 insertions(+), 52 deletions(-) diff --git a/package.json b/package.json index 69ffd9ddb..318f05957 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "ajv": "^8.11.0", "assert": "^2.0.0", "fs": "^0.0.1-security", - "mocha": "^10.1.0", + "mocha": "^10.4.0", "yml2vocab": "^1.4.0" }, "scripts": { diff --git a/schema/verifiable-credential/verifiable-credential-schema.json b/schema/verifiable-credential/verifiable-credential-schema.json index 807775bce..4939c2564 100644 --- a/schema/verifiable-credential/verifiable-credential-schema.json +++ b/schema/verifiable-credential/verifiable-credential-schema.json @@ -24,7 +24,7 @@ }, "minProperties": 1 }, - "refreshService": { + "credentialSchema": { "type": "object", "properties": { "id": { @@ -40,14 +40,46 @@ ], "additionalProperties": true }, - "termsOfUse": { + "credentialStatus": { "type": "object", "properties": { + "id": { + "type": "string" + }, "type": { "$ref": "#/$defs/type" + } + }, + "required": [ + "id", + "type" + ], + "additionalProperties": true + }, + "refreshService": { + "type": "object", + "properties": { + "id": { + "type": "string" }, + "type": { + "$ref": "#/$defs/type" + } + }, + "required": [ + "id", + "type" + ], + "additionalProperties": true + }, + "termsOfUse": { + "type": "object", + "properties": { "id": { "type": "string" + }, + "type": { + "$ref": "#/$defs/type" } }, "required": [ @@ -147,10 +179,18 @@ "type": "string" }, "type": { - "$ref": "#/$defs/type", - "contains": { - "const": "VerifiableCredential" - } + "oneOf": [ + { + "type": "array", + "contains": { + "const": "VerifiableCredential" + } + }, + { + "type": "string", + "enum": ["VerifiableCredential"] + } + ] }, "issuer": { "oneOf": [ @@ -172,7 +212,12 @@ ] }, "validFrom": { - "type": "string" + "type": "string", + "pattern": "-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|(24:00:00(\\.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))" + }, + "validUntil": { + "type": "string", + "pattern": "-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|(24:00:00(\\.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))" }, "credentialSubject": { "oneOf": [ @@ -188,40 +233,33 @@ } ] }, - "validUntil": { - "type": "string" - }, "credentialStatus": { - "type": "object", - "properties": { - "id": { - "type": "string" + "oneOf": [ + { + "$ref": "#/$defs/credentialStatus" }, - "type": { - "$ref": "#/$defs/type" + { + "type": "array", + "items": { + "$ref": "#/$defs/credentialStatus" + }, + "minItems": 1 } - }, - "required": [ - "id", - "type" - ], - "additionalProperties": true + ] }, "credentialSchema": { - "type": "object", - "properties": { - "id": { - "type": "string" + "oneOf": [ + { + "$ref": "#/$defs/credentialSchema" }, - "type": { - "$ref": "#/$defs/type" + { + "type": "array", + "items": { + "$ref": "#/$defs/credentialSchema" + }, + "minItems": 1 } - }, - "required": [ - "id", - "type" - ], - "additionalProperties": true + ] }, "refreshService": { "oneOf": [ diff --git a/schema/verifiable-presentation/verifiable-presentation-schema.json b/schema/verifiable-presentation/verifiable-presentation-schema.json index c488b4302..0427024dc 100644 --- a/schema/verifiable-presentation/verifiable-presentation-schema.json +++ b/schema/verifiable-presentation/verifiable-presentation-schema.json @@ -4,22 +4,19 @@ "description": "JSON Schema for a Verifiable Presentation according to the Verifiable Credentials Data Model v2", "type": "object", "$defs": { - "type": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "array", - "minItems": 1 - } - ] - }, "proof": { "type": "object", "properties": { "type": { - "$ref": "#/$defs/type" + "oneOf": [ + { + "type": "string" + }, + { + "type": "array", + "minItems": 1 + } + ] }, "proofPurpose": { "type": "string" @@ -56,7 +53,8 @@ ] }, "created": { - "type": "string" + "type": "string", + "pattern": "-?([1-9][0-9]{3,}|0[0-9]{3})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])T(([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9](\\.[0-9]+)?|(24:00:00(\\.0+)?))(Z|(\\+|-)((0[0-9]|1[0-3]):[0-5][0-9]|14:00))" }, "domain": { "type": "string" @@ -96,10 +94,18 @@ "type": "string" }, "type": { - "$ref": "#/$defs/type", - "contains": { - "const": "VerifiablePresentation" - } + "oneOf": [ + { + "type": "array", + "contains": { + "const": "VerifiablePresentation" + } + }, + { + "type": "string", + "enum": ["VerifiablePresentation"] + } + ] }, "verifiableCredential": { "oneOf": [