-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Library compatibility when non well-formed DIDs are present #203
Comments
Hi @vitorpamplona , thank you for opening the issue. Could you provide an example, a test case? |
Here's an example. (I can't share the original code because of health data) Check the space on the id field. {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://cowin.gov.in/credentials/vaccination/v1"
],
"type": ["VerifiableCredential", "ProofOfVaccinationCredential"],
"credentialSubject": {
"type": "Person",
"id": "did:Driving License:AA44 2022001122",
"name": "Test"
}
} JavaScript JSON-LD yields
Titanium JSON-LD does:
The fix I implemented changes 2 classes: On JsonLdToRdf, from line 108 // 1.3.1.
if (BlankNode.isWellFormed(subject)) {
rdfSubject = Rdf.createBlankNode(subject);
} else if (UriUtils.isAbsoluteUri(subject)) {
rdfSubject = Rdf.createIRI(subject);
} else if (UriUtils.isAbsoluteUri(subject.replaceAll(" ", ""))) { // <<---------- ADDED LINE
rdfSubject = Rdf.createIRI(subject); // <<---------- ADDED LINE
} else {
LOGGER.log(Level.WARNING, "Non well-formed subject [{0}] has been skipped.", subject);
continue;
} On ObjectToRdf, from line 101 if (BlankNode.isWellFormed(idString)) {
return Optional.of(Rdf.createBlankNode(idString));
} else if (UriUtils.isAbsoluteUri(idString)) {
return Optional.of(Rdf.createIRI(idString));
} else if (UriUtils.isAbsoluteUri(idString.replaceAll(" ", ""))) { // <<---------- ADDED LINE
return Optional.of(Rdf.createIRI(idString)); // <<---------- ADDED LINE
} One these 4 lines are added, the rest of the code correctly verifies the credential. |
There are two issues:
|
I understand they are not complying with the DID spec. But it might be too late for us. There are too many credentials out there already. :( |
The proposed performance re-implementation of |
Happy new year! :) |
@vitorpamplona checkout |
I confirm it's working :) |
Is there any chance this UriUtils.isAbsoluteUri(subject) restriction can be made optional for those of us trying to cryptographically verify credentials generated by javascript libraries that do not enforce that rule?
Skipping the field breaks the cryptographic verification process on around 1B existing, and otherwise valid, credentials from the DIVOC system (COVID-19 immunization records) in India. They shipped those W3C VCs with DIDs that include a space.
Otherwise, we are left having to fork this project just to remove that line. :(
The text was updated successfully, but these errors were encountered: