Skip to content
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

Ensure tests exist that fail for inputs that have undefined terms and / or relative URLs #56

Open
dlongley opened this issue Jul 12, 2024 · 1 comment
Assignees

Comments

@dlongley
Copy link

The most common relative URL mistake looks like:

"type": [..., "SomeUndefinedType"]

So we should make sure to cover that.

@aljones15 aljones15 self-assigned this Jul 12, 2024
@aljones15
Copy link
Contributor

Suite now contains:

When deserializing to RDF, implementations MUST ensure that the base URL is set to null.

function invalidBaseUrl({credential, ...args}) {
const _credential = structuredClone(credential);
const invalidBaseContext = {
'@base': 'https://invalid.example.com/',
};
if(Array.isArray(_credential['@context'])) {
_credential['@context'].push(invalidBaseContext);
} else {
_credential['@context'] = [_credential['@context'], invalidBaseContext];
}
const relativeType = 'UndefinedCredential';
if(Array.isArray(_credential.type)) {
_credential.type.push(relativeType);
} else {
_credential.type = [_credential.type, relativeType];
}
return {...args, credential: _credential};
}

the context is deleted in a clean up step.

and

Implementations that use JSON-LD processing, such as RDF Dataset Canonicalization [RDF-CANON], MUST throw an error, which SHOULD be DATA_LOSS_DETECTION_ERROR, when data is dropped by a JSON-LD processor, such as when an undefined term is detected in an input document.

function undefinedTerm({credential, selectiveSuite, ...args}) {
const _credential = structuredClone(credential);
_credential.credentialSubject.undefinedTerm = 'undefinedTerm';
if(selectiveSuite) {
selectiveSuite?._cryptosuite?.options?.selectivePointers.push(
'/credentialSubject/undefinedTerm');
}
return {...args, credential: _credential, selectiveSuite};
}

LMK if that is enough to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants