Skip to content

feat: jsonld parsing without re-serialization#849

Merged
NSeydoux merged 85 commits intomainfrom
feat/jsonld-parsing-without-serialization
Dec 18, 2023
Merged

feat: jsonld parsing without re-serialization#849
NSeydoux merged 85 commits intomainfrom
feat/jsonld-parsing-without-serialization

Conversation

@jeswr
Copy link
Contributor

@jeswr jeswr commented Oct 24, 2023

Note that the custom caching mechanism here is only temporary. There is work upstream to:

@jeswr jeswr requested a review from a team as a code owner October 24, 2023 23:15
@vercel
Copy link

vercel bot commented Oct 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
solid-client-vc-js ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 17, 2023 11:24pm

@jeswr jeswr temporarily deployed to ESS Dev-2-2 October 24, 2023 23:22 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS Dev-2-2 October 24, 2023 23:35 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS PodSpaces October 24, 2023 23:37 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS Dev-2-2 October 24, 2023 23:37 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS PodSpaces October 24, 2023 23:48 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS PodSpaces October 24, 2023 23:48 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS Dev-2-2 October 24, 2023 23:48 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS PodSpaces October 24, 2023 23:48 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS PodSpaces October 24, 2023 23:48 — with GitHub Actions Inactive
@jeswr jeswr temporarily deployed to ESS Dev-2-2 October 24, 2023 23:48 — with GitHub Actions Inactive
@NSeydoux

This comment was marked as resolved.

Comment on lines +85 to 119
export type VerifiableCredentialBase = JsonLd & {
id: Iri;
/**
* @deprecated Use RDFJS API instead
*/
type: Iri[];
/**
* @deprecated Use RDFJS API instead
*/
issuer: Iri;
/**
* ISO-8601 formatted date
* @deprecated Use RDFJS API instead
*/
issuanceDate: string;
/**
* Entity the credential makes claim about.
* @deprecated Use RDFJS API instead
*/
credentialSubject: {
/**
* @deprecated Use RDFJS API instead
*/
id: Iri;
/**
* The claim set is open, as any RDF graph is suitable for a set of claims.
* @deprecated Use RDFJS API instead
*/
[property: string]: unknown;
};
/**
* @deprecated Use RDFJS API instead
*/
proof: Proof;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be easier to have something like

export type WithId = { id: IRI };
// @deprecated Prefer using the RDFJS API
export type VcObject = {
  issuer: IRI;
   ...
};
export type VerifiableCredential = JsonLd & WithId & VcObject & DatasetCore;

to allow having one deprecations warning for all properties instead of individual warnings for each property?

Copy link
Contributor Author

@jeswr jeswr Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortuantely this isn't sufficient to show strikethrough deprecation of the properties on editors like vccode

image

vs

image

getVerifiableCredential,
getVerifiableCredentialApiConfiguration,
/**
* @hidden @deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the @deprecated annotation used just to be more explicit than the hidden one if used by a dependant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct - I expect the only consumers of this function to be us in the access-grants library, and I want us to have the liberty to remove it at any time.

);
}

const parsedVc = await verifiableCredentialToDataset(vc as { id: string }, {

This comment was marked as resolved.

Comment on lines +393 to +399
expect(presentationAsDataset.match(null, cred.holder, null).size).toBe(0);
expect(
isRdfjsVerifiablePresentation(
presentationAsDataset,
namedNode(mockedPresentation.id!),
),
).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was expecting this to return false, in consistence with the legacy API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case is similar to #849 (comment). The parser will ignore the holder because the context requires it to be an IRI.

So in RDFJS there is no holder triple; and since holder is allowed to be undefined this function returns true.

Similar to #849 (comment), if this makes sense to you, thumbs up this comment and I will add a comment.

Comment on lines +343 to +353
expect(
mockedPresentationAsDataset.match(null, cred.verifiableCredential, null)
.size,
).toBe(0);
expect(isVerifiablePresentation(mockedPresentation)).toBe(false);
expect(
isRdfjsVerifiablePresentation(
mockedPresentationAsDataset,
namedNode(mockedPresentation.id!),
),
).toBe(true);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems contradictory

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this is parsed as JSON-LD it is treated as there being no verifiable credentials; so this is a valid presentation in RDFJS; but when treated as json we have an empty object.

So in this case I would actually expect them to return different results.

If that makes sense, thumbs up this comment and I'll comment this on the test.

});
});

it.skip("throws if the dereferenced data has an unsupported content type", async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this disabled?

Copy link
Contributor Author

@jeswr jeswr Dec 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this would be a new check (the code for this is also currently deleted and/or disabled) - I suggest we enable it in the next major version.

@NSeydoux NSeydoux mentioned this pull request Mar 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants