Skip to content

Commit

Permalink
feat: add holderPid and issuerPid for correlation (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood authored Feb 20, 2025
1 parent f86e6b6 commit 69d3d52
Show file tree
Hide file tree
Showing 12 changed files with 99 additions and 29 deletions.
23 changes: 18 additions & 5 deletions artifacts/src/main/resources/context/dcp.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@
"@context": {
"credentials": {
"@id": "dcp:credentials",
"@container": "@set"
"@container": "@set",
"@type": "@json"
},
"issuerPid": {
"@id": "dcp:issuerPid",
"@type": "@id"
},
"requestId": {
"@id": "dcp:requestId",
"holderPid": {
"@id": "dcp:holderPid",
"@type": "@id"
}
}
Expand Down Expand Up @@ -69,6 +74,10 @@
"CredentialRequestMessage": {
"@id": "dcp:CredentialRequestMessage",
"@context": {
"holderPid": {
"@id": "dcp:holderPid",
"@type": "@id"
},
"credentials": {
"@id": "dcp:credentials",
"@type": "@json"
Expand All @@ -79,8 +88,12 @@
"CredentialStatus": {
"@id": "dcp:CredentialStatus",
"@context": {
"requestId": {
"@id": "dcp:requestId",
"holderPid": {
"@id": "dcp:holderPid",
"@type": "@id"
},
"issuerPid": {
"@id": "dcp:issuerPid",
"@type": "@id"
},
"status": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,26 @@
"$ref": "https://w3id.org/dspace-dcp/v1.0/presentation/credential-message-schema.json#/definitions/CredentialContainer"
}
},
"requestId": {
"issuerPid": {
"type": "string"
},
"holderPid": {
"type": "string"
},
"credentialType": {
"type": "string",
"const": "CredentialMessage"
},
"format":{
"format": {
"type": "string"
}
},
"required": [
"@context",
"type",
"credentials",
"requestId"
"issuerPid",
"holderPid"
]
},
"CredentialContainer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"type": {
"type": "string"
},
"holderPid": {
"type": "string"
},
"credentials": {
"type": "array",
"items": {
Expand All @@ -39,6 +42,7 @@
},
"required": [
"@context",
"holderPid",
"credentials",
"type"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"CredentialStatusClass": {
"type": "object",
"properties": {
"requestId": {
"issuerPid": {
"type": "string"
},
"holderPid": {
"type": "string"
},
"status": {
Expand All @@ -29,7 +32,8 @@
}
},
"required": [
"requestId",
"issuerPid",
"holderPid",
"status",
"type"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"format": "json-ld"
}
],
"requestId": "requestId"
"issuerPid": "issuerPid",
"holderPid": "holderPid"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"
],
"type": "CredentialRequestMessage",
"holderPid": "holderPid",
"credentials": [
{
"credentialType": "MembershipCredential",
Expand All @@ -16,6 +17,5 @@
"credentialType": "Iso9001Credential",
"format": "vcdm20_jose"
}

]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"
],
"type": "CredentialStatus",
"requestId": "requestId",
"issuerPid": "issuerPid",
"holderPid": "holderPid",
"status": "RECEIVED"
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ void verifyCredentialRequestMessage() {
verifyRoundTrip("/issuance/example/credential-request-message.json", "/issuance/credential-request-message-schema.json");
}

@Test
void verifyCredentialMessage() {
verifyRoundTrip("/issuance/example/credential-message.json", "/issuance/credential-message-schema.json");
}

@Test
void verifyCredentialOfferMessage() {
verifyRoundTrip("/issuance/example/credential-offer-message.json", "/issuance/credential-offer-message-schema.json");
Expand Down Expand Up @@ -56,7 +61,8 @@ void verifyCredentialStatus_withStatus(String status) throws IOException {
{
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
"type": "CredentialStatus",
"requestId": "requestId",
"issuerPid": "issuerPid",
"holderPid": "holderPid",
"status": "%s"
}""".formatted(status);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public class CredentialMessageSchemaTest extends AbstractSchemaTest {
"format": "json-ld"
}
],
"requestId": "requestId"
"issuerPid": "issuerPid",
"holderPid": "holderPid"
}""";

private static final String INVALID_CREDENTIAL_MESSAGE = """
Expand All @@ -60,7 +61,8 @@ public class CredentialMessageSchemaTest extends AbstractSchemaTest {
"format": "jwt"
}
],
"requestId": "requestId"
"issuerPid": "issuerPid",
"holderPid": "holderPid"
}""";


Expand All @@ -73,15 +75,16 @@ public class CredentialMessageSchemaTest extends AbstractSchemaTest {
"format": "jwt"
}
],
"requestId": "requestId"
"issuerPid": "issuerPid",
"holderPid": "holderPid"
}""";

@Test
void verifySchema() {
assertThat(schema.validate(CREDENTIAL_MESSAGE_MESSAGE, JSON)).isEmpty();
assertThat(schema.validate(INVALID_CREDENTIAL_MESSAGE, JSON))
.extracting(this::errorExtractor)
.containsExactly(error("credentials", REQUIRED), error("requestId", REQUIRED));
.containsExactly(error("credentials", REQUIRED), error("issuerPid", REQUIRED), error("holderPid", REQUIRED));

assertThat(schema.validate(INVALID_CREDENTIAL_MESSAGE_INVALID_CREDENTIAL_CONTAINER, JSON))
.extracting(this::errorExtractor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,27 @@
public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest {

private static final String CREDENTIAL_REQUEST_MESSAGE = """
{
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
"type": "CredentialRequestMessage",
"holderPid": "holderPid",
"credentials": [
{
"credentialType": "MembershipCredential",
"format": "vcdm11_jwt"
},
{
"credentialType": "OrganizationCredential",
"format": "vcdm11_ld"
},
{
"credentialType": "Iso9001Credential",
"format": "vcdm20_jose"
}
]
}""";

private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_HOLDER_REQUEST_ID = """
{
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
"type": "CredentialRequestMessage",
Expand All @@ -47,6 +68,7 @@ public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest {
{
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
"type": "CredentialRequestMessage",
"holderPid": "holderPid",
"credentials": [
{
"credentialType": "MembershipCredential"
Expand All @@ -66,6 +88,7 @@ public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest {
{
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
"type": "CredentialRequestMessage",
"holderPid": "holderPid",
"credentials": [
{
"format": "vcdm11_ld"
Expand All @@ -75,6 +98,7 @@ public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest {

private static final String INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_TYPE_AND_CONTEXT = """
{
"holderPid": "holderPid",
"credentials": [
{
"credentialType": "MembershipCredential",
Expand All @@ -87,6 +111,11 @@ public class CredentialRequestMessageSchemaTest extends AbstractSchemaTest {
@Test
void verifySchema() {
assertThat(schema.validate(CREDENTIAL_REQUEST_MESSAGE, JSON)).isEmpty();

assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_HOLDER_REQUEST_ID, JSON))
.extracting(this::errorExtractor)
.containsExactly(error("holderPid", REQUIRED));

assertThat(schema.validate(INVALID_CREDENTIAL_REQUEST_MESSAGE_NO_FORMAT, JSON))
.extracting(this::errorExtractor)
.containsExactly(error("format", REQUIRED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class CredentialStatusSchemaTest extends AbstractSchemaTest {
{
"@context": ["https://w3id.org/dspace-dcp/v1.0/dcp.jsonld"],
"type": "CredentialStatus",
"requestId": "requestId",
"issuerPid": "issuerPid",
"holderPid": "holderPid",
"status": "%s"
}""";

Expand All @@ -41,7 +42,8 @@ public class CredentialStatusSchemaTest extends AbstractSchemaTest {

private static final String INVALID_CREDENTIAL_STATUS_MESSAGE_NO_TYPE_AND_CONTEXT = """
{
"requestId": "requestId",
"issuerPid": "issuerPid",
"holderPid": "holderPid",
"status": "RECEIVED"
}""";

Expand All @@ -52,7 +54,7 @@ void verifySchema() {
.containsExactly(error(null, ENUM));
assertThat(schema.validate(INVALID_CREDENTIAL_STATUS, JSON))
.extracting(this::errorExtractor)
.containsExactly(error("requestId", REQUIRED), error("status", REQUIRED));
.containsExactly(error("issuerPid", REQUIRED), error("holderPid", REQUIRED), error("status", REQUIRED));

assertThat(schema.validate(INVALID_CREDENTIAL_STATUS_MESSAGE_NO_TYPE_AND_CONTEXT, JSON))
.hasSize(2)
Expand Down
19 changes: 11 additions & 8 deletions specifications/credential.issuance.protocol.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ Self-Issued ID Token to provide the pre-authorization code to the issuer.
| **Schema** | [JSON Schema](./resources/issuance/credential-request-message-schema.json) |
| **Required** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1). |
| | - `type`: A string specifying the `CredentialRequestMessage` type |
| | - `holderPid`: A string corresponding to the request id on the Holder side type |
| | - `credentials`: a JSON array of objects, each containing a `format`, which is A JSON string <br/>that describes the format of the credential to be issued <br/>and a `type`: A JSON array of strings that specifies the VC type being requested |

The following is a non-normative example of a `CredentialRequestMessage`:
Expand Down Expand Up @@ -145,7 +146,8 @@ exact error code is implementation-specific.
| **Schema** | [JSON Schema](./resources/issuance/credential-message-schema.json) |
| **Required** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1) |
| | - `type`: A string specifying the `Credential Message` type. |
| | - `requestId`: A string corresponding to the issuance request id. |
| | - `issuerPid`: A string corresponding to the issuance id on the Issuer side. |
| | - `holderPid`: A string corresponding to the issuance id on the Holder side. |
| | - `credentials`: An array of [Credential Container](#credential-container) Json objects as defined in the following. |

The following is a non-normative example of the [Credential Message](#credential-message) JSON body:
Expand Down Expand Up @@ -279,13 +281,14 @@ with `Bearer` of the request.

### CredentialStatus

| | |
|--------------|-----------------------------------------------------------------------------|
| **Schema** | [JSON Schema](./resources/issuance/credential-status-schema.json) |
| **Required** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1). |
| | - `type`: A string specifying the `CredentialStatus` type |
| | - `requestId`: A string corresponding to the request id |
| | - `status`: A string with a value of `RECEIVED`, `REJECTED`, or `ISSUED` |
| | |
|--------------|-------------------------------------------------------------------------------------|
| **Schema** | [JSON Schema](./resources/issuance/credential-status-schema.json) |
| **Required** | - `@context`: Specifies a valid Json-Ld context ([[json-ld11]], sect. 3.1). |
| | - `type`: A string specifying the `CredentialStatus` type |
| | - `issuerPid`: A string corresponding to the issuance id on the Issuer side |
| | - `holderPid`: A string corresponding to the issuance id on the Holder side |
| | - `status`: A string with a value of `RECEIVED`, `REJECTED`, or `ISSUED` |

The following is a non-normative example of a `CredentialStatus` response object:

Expand Down

0 comments on commit 69d3d52

Please sign in to comment.