Skip to content

Commit 3e95e23

Browse files
committed
Fix logic on retaining protected term definitions if redefined equivalently.
1 parent fcd3aed commit 3e95e23

File tree

4 files changed

+193
-2
lines changed

4 files changed

+193
-2
lines changed

example-files/vc1373-2.jsonld

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"@context": [
3+
{
4+
"@protected": true,
5+
"@vocab": "https://www.w3.org/ns/credentials/issuer-dependent#",
6+
"id": "@id",
7+
"type": "@type",
8+
"VerifiablePresentation": {
9+
"@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
10+
"@context": {
11+
"@protected": true,
12+
"id": "@id",
13+
"type": "@type",
14+
"holder": {
15+
"@id": "https://www.w3.org/2018/credentials#holder",
16+
"@type": "@id"
17+
},
18+
"proof": {
19+
"@id": "https://w3id.org/security#proof",
20+
"@type": "@id",
21+
"@container": "@graph"
22+
},
23+
"verifiableCredential": {
24+
"@id": "https://www.w3.org/2018/credentials#verifiableCredential",
25+
"@type": "@id",
26+
"@container": "@graph",
27+
"@context": null
28+
},
29+
"termsOfUse": {
30+
"@id": "https://www.w3.org/2018/credentials#termsOfUse",
31+
"@type": "@id"
32+
}
33+
}
34+
},
35+
"issuer": {
36+
"@id": "https://www.w3.org/2018/credentials#issuer",
37+
"@type": "@id",
38+
"@context": {
39+
"@protected": true,
40+
41+
"id": "@id",
42+
"type": "@type",
43+
44+
"description": {
45+
"@id": "https://schema.org/description",
46+
"@context": {
47+
"value": "@value", "lang": "@language", "dir": "@direction"
48+
}
49+
},
50+
"name": {
51+
"@id": "https://schema.org/name",
52+
"@context": {
53+
"value": "@value", "lang": "@language", "dir": "@direction"
54+
}
55+
}
56+
}
57+
}
58+
}
59+
],
60+
"type": "VerifiablePresentation",
61+
"verifiableCredential": ["http://university.example/credentials/1872"]
62+
}

example-files/vc1373.jsonld

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"@context": [
3+
{
4+
"@protected": true,
5+
"@vocab": "https://www.w3.org/ns/credentials/issuer-dependent#",
6+
"id": "@id",
7+
"type": "@type",
8+
"VerifiablePresentation": {
9+
"@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
10+
"@context": {
11+
"@protected": true,
12+
"id": "@id",
13+
"type": "@type",
14+
"holder": {
15+
"@id": "https://www.w3.org/2018/credentials#holder",
16+
"@type": "@id"
17+
},
18+
"proof": {
19+
"@id": "https://w3id.org/security#proof",
20+
"@type": "@id",
21+
"@container": "@graph"
22+
},
23+
"verifiableCredential": {
24+
"@id": "https://www.w3.org/2018/credentials#verifiableCredential",
25+
"@type": "@id",
26+
"@container": "@graph",
27+
"@context": null
28+
},
29+
"termsOfUse": {
30+
"@id": "https://www.w3.org/2018/credentials#termsOfUse",
31+
"@type": "@id"
32+
}
33+
}
34+
},
35+
"issuer": {
36+
"@id": "https://www.w3.org/2018/credentials#issuer",
37+
"@type": "@id",
38+
"@context": {
39+
"@protected": true,
40+
41+
"id": "@id",
42+
"type": "@type",
43+
44+
"description": {
45+
"@id": "https://schema.org/description",
46+
"@context": {
47+
"value": "@value", "lang": "@language", "dir": "@direction"
48+
}
49+
},
50+
"name": {
51+
"@id": "https://schema.org/name",
52+
"@context": {
53+
"value": "@value", "lang": "@language", "dir": "@direction"
54+
}
55+
}
56+
}
57+
}
58+
}
59+
],
60+
"type": "VerifiablePresentation",
61+
"verifiableCredential": [
62+
{
63+
"@context": [
64+
{
65+
"@protected": true,
66+
"@vocab": "https://www.w3.org/ns/credentials/issuer-dependent#",
67+
"id": "@id",
68+
"type": "@type",
69+
"VerifiablePresentation": {
70+
"@id": "https://www.w3.org/2018/credentials#VerifiablePresentation",
71+
"@context": {
72+
"@protected": true,
73+
"id": "@id",
74+
"type": "@type",
75+
"holder": {
76+
"@id": "https://www.w3.org/2018/credentials#holder",
77+
"@type": "@id"
78+
},
79+
"proof": {
80+
"@id": "https://w3id.org/security#proof",
81+
"@type": "@id",
82+
"@container": "@graph"
83+
},
84+
"verifiableCredential": {
85+
"@id": "https://www.w3.org/2018/credentials#verifiableCredential",
86+
"@type": "@id",
87+
"@container": "@graph",
88+
"@context": null
89+
},
90+
"termsOfUse": {
91+
"@id": "https://www.w3.org/2018/credentials#termsOfUse",
92+
"@type": "@id"
93+
}
94+
}
95+
},
96+
"issuer": {
97+
"@id": "https://www.w3.org/2018/credentials#issuer",
98+
"@type": "@id",
99+
"@context": {
100+
"@protected": true,
101+
102+
"id": "@id",
103+
"type": "@type",
104+
105+
"description": {
106+
"@id": "https://schema.org/description",
107+
"@context": {
108+
"value": "@value", "lang": "@language", "dir": "@direction"
109+
}
110+
},
111+
"name": {
112+
"@id": "https://schema.org/name",
113+
"@context": {
114+
"value": "@value", "lang": "@language", "dir": "@direction"
115+
}
116+
}
117+
}
118+
}
119+
}
120+
],
121+
"id": "http://university.example/credentials/1872",
122+
"type": "VerifiableCredential",
123+
"issuer": "https://university.example/issuers/565049"
124+
}
125+
]
126+
}

json-ld.gemspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Gem::Specification.new do |gem|
3737
gem.add_runtime_dependency 'multi_json', '~> 1.15'
3838
gem.add_runtime_dependency "rack", '>= 2.2', '< 4'
3939
gem.add_runtime_dependency 'rdf', '~> 3.3'
40+
gem.add_runtime_dependency 'rexml', '~> 3.2'
4041
gem.add_development_dependency 'getoptlong', '~> 0.2'
4142
gem.add_development_dependency 'jsonlint', '~> 0.4' unless is_java
4243
gem.add_development_dependency 'oj', '~> 3.15' unless is_java

lib/json/ld/context.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,11 @@ def create_term_definition(local_context, term, defined,
843843
end
844844
end
845845

846-
if previous_definition&.protected? && definition != previous_definition && !override_protected
846+
if !override_protected && previous_definition&.protected?
847+
if definition != previous_definition
848+
raise JSON::LD::JsonLdError::ProtectedTermRedefinition, "Attempt to redefine protected term #{term}"
849+
end
847850
definition = previous_definition
848-
raise JSON::LD::JsonLdError::ProtectedTermRedefinition, "Attempt to redefine protected term #{term}"
849851
end
850852

851853
term_definitions[term] = definition

0 commit comments

Comments
 (0)