Skip to content

Commit a3a1ab9

Browse files
fix: inconsistency in the CredentialObject definition (#238)
* fix: inconsistency in the CredentialObject definition * make CredentialObject properties required in IssuerMetadata
1 parent b323bdc commit a3a1ab9

6 files changed

Lines changed: 66 additions & 26 deletions

File tree

artifacts/src/main/resources/issuance/credential-object-schema.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
},
4646
"required": [
4747
"id",
48-
"credentialType",
49-
"offerReason",
50-
"bindingMethods",
51-
"profile",
52-
"issuancePolicy",
5348
"type"
5449
]
5550
}

artifacts/src/main/resources/issuance/example/issuer-metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"type": "CredentialObject",
1111
"credentialType": "CompanyCredential",
1212
"offerReason": "reissue",
13+
"credentialSchema": "https://example.com/company-credential-schema.json",
1314
"bindingMethods": [
1415
"did:web"
1516
],

artifacts/src/main/resources/issuance/issuer-metadata-schema.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,21 @@
1818
"credentialsSupported": {
1919
"type": "array",
2020
"items": {
21-
"$ref": "https://w3id.org/dspace-dcp/v1.0/issuance/credential-object-schema.json#/definitions/CredentialObject"
21+
"allOf": [
22+
{
23+
"$ref": "https://w3id.org/dspace-dcp/v1.0/issuance/credential-object-schema.json#/definitions/CredentialObject"
24+
},
25+
{
26+
"type": "object",
27+
"required": [
28+
"credentialType",
29+
"credentialSchema",
30+
"offerReason",
31+
"bindingMethods",
32+
"profile"
33+
]
34+
}
35+
]
2236
}
2337
},
2438
"issuer": {

artifacts/src/test/java/org/eclipse/dcp/schema/issuance/CredentialObjectSchemaTest.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,18 @@ public class CredentialObjectSchemaTest extends AbstractSchemaTest {
9898
@Test
9999
void verifySchema() {
100100
assertThat(schema.validate(CREDENTIAL_OBJECT, JSON)).isEmpty();
101+
}
102+
103+
@Test
104+
void verifySchema_missingRequiredFields() {
101105
assertThat(schema.validate(INVALID_CREDENTIAL_OBJECT, JSON))
102106
.extracting(this::errorExtractor)
103107
.containsExactly(
104-
error("id", REQUIRED),
105-
error("credentialType", REQUIRED),
106-
error("offerReason", REQUIRED),
107-
error("bindingMethods", REQUIRED),
108-
error("profile", REQUIRED),
109-
error("issuancePolicy", REQUIRED));
108+
error("id", REQUIRED));
109+
}
110110

111+
@Test
112+
void verifySchema_missingTypeAndContext() {
111113
assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT, JSON))
112114
.hasSize(1)
113115
.extracting(this::errorExtractor)

artifacts/src/test/java/org/eclipse/dcp/schema/issuance/IssuerMetadataSchemaTest.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,22 @@ public class IssuerMetadataSchemaTest extends AbstractSchemaTest {
3131
"issuer": "did:web:issuer-url",
3232
"credentialsSupported": [%s]
3333
}""";
34-
34+
public static final String CREDENTIAL_OBJECT_INCOMPLETE = """
35+
{
36+
"id": "d5c77b0e-7f4e-4fd5-8c5f-28b5fc3f96d1",
37+
"type": "CredentialObject",
38+
"credentialType": "VerifiableCredential",
39+
"offerReason": "reissue",
40+
"bindingMethods": [
41+
"did:web"
42+
]
43+
}
44+
""";
3545
private static final String INVALID_ISSUER_METADATA = """
3646
{
3747
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
3848
"type": "IssuerMetadata"
3949
}""";
40-
4150
private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT = """
4251
{
4352
"issuer": "did:web:issuer-url",
@@ -47,10 +56,25 @@ public class IssuerMetadataSchemaTest extends AbstractSchemaTest {
4756
@Test
4857
void verifySchema() {
4958
assertThat(schema.validate(ISSUER_METADATA.formatted(CREDENTIAL_OBJECT), JSON)).isEmpty();
59+
}
60+
61+
@Test
62+
void verifySchema_missingIssuerAndCredentialsSupported() {
5063
assertThat(schema.validate(INVALID_ISSUER_METADATA, JSON))
5164
.extracting(this::errorExtractor)
5265
.containsExactly(error("issuer", REQUIRED), error("credentialsSupported", REQUIRED));
5366

67+
}
68+
69+
@Test
70+
void verifySchema_credentialSupportedIsIncomplete() {
71+
assertThat(schema.validate(ISSUER_METADATA.formatted(CREDENTIAL_OBJECT_INCOMPLETE), JSON))
72+
.extracting(this::errorExtractor)
73+
.containsExactlyInAnyOrder(error("credentialSchema", REQUIRED), error("profile", REQUIRED));
74+
}
75+
76+
@Test
77+
void verifySchema_missingTypeAndContext() {
5478
assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT.formatted(CREDENTIAL_OBJECT), JSON))
5579
.hasSize(2)
5680
.extracting(this::errorExtractor)

specifications/credential.issuance.protocol.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,18 @@ a [=Verifiable Credential=] offer.
208208

209209
### Credential Offer Message
210210

211-
| | |
212-
|--------------|---------------------------------------------------------------------------------------------------------------------|
213-
| **Schema** | [JSON Schema](./resources/issuance/credential-offer-message-schema.json) |
214-
| **Required** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1). |
215-
| | - `type`: A string specifying the `CredentialOfferMessage` type. |
216-
| | - `issuer`: The [=Credential Issuer=] DID. |
217-
| | - `credentials`: A JSON array, where every entry is a JSON object of type [[[#credentialobject]]] or a JSON string. |
218-
219-
If the `credentials` property entries are type string, the value MUST be one of the `id` values of an object in the
220-
`credentialsSupported` returned from the [[[#issuer-metadata-api]]]. When processing, the [=Credential Service=]
221-
MUST resolve this string value to the respective object.
211+
| | |
212+
|--------------|--------------------------------------------------------------------------------------------------------------|
213+
| **Schema** | [JSON Schema](./resources/issuance/credential-offer-message-schema.json) |
214+
| **Required** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1). |
215+
| | - `type`: A string specifying the `CredentialOfferMessage` type. |
216+
| | - `issuer`: The [=Credential Issuer=] DID. |
217+
| | - `credentials`: A non-empty JSON array, where every entry is a JSON object of type [[[#credentialobject]]]. |
218+
219+
If the entries in the `credentials` property are _sparse_, i.e., only contain an `id`, the values of all other properties
220+
of the [[[#credentialobject]]] must be taken from the `credentialsSupported` list returned from
221+
the [[[#issuer-metadata-api]]]. When processing, the [=Credential Service=] MUST resolve this string value to the
222+
respective object.
222223

223224
The following is a non-normative example of a credential offer request:
224225

@@ -233,9 +234,9 @@ The following is a non-normative example of a credential offer request:
233234
|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
234235
| **Schema** | [JSON Schema](./resources/issuance/credential-object-schema.json) |
235236
| **Required** | - `type`: A string specifying the `CredentialObject` type. |
236-
| | - `credentialType`: A single string specifying type of credential being offered. |
237237
| | - `id`: a string defining a unique, stable identifier for this `CredentialObject` |
238238
| **Optional** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1). As the `credentialObject` is usually embedded, its context is provided by the enveloping object. |
239+
| | - `credentialType`: A single string specifying type of credential being offered. |
239240
| | - `bindingMethods`: An array of strings defining the key material that an issued credential is bound to. |
240241
| | - `credentialSchema`: A URL pointing to the credential schema of the object in a VC's `credentialSubject` property. |
241242
| | - `profile`: An string containing the alias of the [profiles](#profiles-of-the-decentralized-claims-protocol), e.g. `"vc20-bssl/jwt"`. |
@@ -278,6 +279,9 @@ The following is a non-normative example of a `IssuerMetadata` response object:
278279
</pre>
279280
</aside>
280281

282+
Every `CredentialObject` in the `credentialsSupported` array MUST contain all optional properties defined
283+
in [[[#credentialobject]]].
284+
281285
## Credential Request Status API
282286

283287
The Credential Request Status API defines the REQUIRED [=Issuer Service=] endpoint for conveying the status of a

0 commit comments

Comments
 (0)