openwallet-foundation-labs / sd-jwt-python

A Python implementation of the Selective Disclosure JWT (SD-JWT) spec.
Apache License 2.0
12 stars 10 forks source link

SD_JWT_TYP_HEADER is not set correctly #9

Closed risajef closed 9 months ago

risajef commented 9 months ago

Maybe I don't understand it. But in my use-case, I want to create a SDJWT. I do it with the following code:

def make_sdjwt(data, jwc_jwk_priv, signing_algorithm):
    sd_issuer = SDJWTIssuer(data, jwc_jwk_priv, sign_alg=signing_algorithm)
    return sd_issuer.sd_jwt_issuance

But this does not set the SD_JWT_HEADER field. How do I set it? Or is it a bug?

The resulting sd-jwt is therefore missing the type field in the header.

peppelinux commented 9 months ago

yes, SD_JWT_HEADER is provided as an internal class attribute https://github.com/search?q=repo%3Aopenwallet-foundation-labs/sd-jwt-python%20SDJWTCommon&type=code

for changing it it seems that you have to overload your own class and inherit a specialized SDJWTCommon class, or differently overload the specific attribute after having create a SDJWTIssuer object

peppelinux commented 9 months ago

or better, @danielfett correct me if I'm wrong, it can be passed with the extra_header_parameters, since it will be overloaded with the dict update, see these

https://github.com/openwallet-foundation-labs/sd-jwt-python/blob/23f9d1d872612180d7b5a160adebcf2838fbe504/src/sd_jwt/issuer.py#L39

https://github.com/openwallet-foundation-labs/sd-jwt-python/blob/23f9d1d872612180d7b5a160adebcf2838fbe504/src/sd_jwt/issuer.py#L175

risajef commented 9 months ago

You are right. I had an old version as it seems. I did not have the extra_header_parameters field.

peppelinux commented 9 months ago

This PR configures a new version as well https://github.com/openwallet-foundation-labs/sd-jwt-python/pull/10