openwallet-foundation-labs / sd-jwt-js

A JavaScript implementation of the Selective Disclosure JWT (SD-JWT) spec.
https://sdjwt.js.org/
Apache License 2.0
36 stars 11 forks source link

Support JWS JSON Serialization #242

Open lukasjhan opened 2 months ago

lukasjhan commented 2 months ago

In sd-jwt draft 09 section 9, JSON Serialization method is added. Let's support this feature in our library

lukasjhan commented 1 week ago

There are two kinds of serialization, flatten and general.

I was thinking about adding the converting function between:

What do you think about it? @cre8

cre8 commented 1 week ago

That does not make so much sense: A generalised Json serialisation can have multiple issuer signatures (required for jades signature). So we can not transfer from this to compact when there are more than one. With flattened it should be possible.

I started the implementation that you pass the issuance function a value what kind of type do you want and the return value is based on this.

Then we need to update the decode function and verify so the three options can be consumed. The default one should be compact to not break any existing implementations

lukasjhan commented 1 week ago

Yeah, you're right. A generalised Json serialisation can have multiple signatures. So there is a possibility that it cannot be converted to a compact one.

I think it's better to approach it the way you said. :)

cre8 commented 1 week ago

I have implemented it for the issuance, but decoding and tests are missing. Maybe I am able to create a pr until Friday