Skip to content

Commit

Permalink
Enforce @context array to issued VCs
Browse files Browse the repository at this point in the history
  • Loading branch information
filip26 committed Feb 15, 2024
1 parent 36f025c commit de9d835
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/apicatalog/vc/processor/Issuer.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ JsonObject postCompact(final JsonObject source) {
JsonObject compacted = source;

// TODO use options
// make sure @context is the first key
// make sure @context is the first key and an array
if (!compacted.keySet().iterator().next().equals(Keywords.CONTEXT)) {
final JsonObjectBuilder builder = Json.createObjectBuilder()
.add(Keywords.CONTEXT, compacted.get(Keywords.CONTEXT));
.add(Keywords.CONTEXT, JsonUtils.toJsonArray(compacted.get(Keywords.CONTEXT)));

compacted.entrySet().stream()
.filter(entry -> !Keywords.CONTEXT.equals(entry.getKey()))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"@context": "https://www.w3.org/ns/credentials/v2",
"@context": ["https://www.w3.org/ns/credentials/v2"],
"id": "https://apicatalog/com/vc/test-credentials#0001",
"type": "VerifiableCredential",
"issuer": "https://github.com/filip26/iron-verifiable-credentials/issuer/1",
Expand Down

0 comments on commit de9d835

Please sign in to comment.