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 12 forks source link

Add correct payload to SDJwtVcInstance #189

Open cre8 opened 5 months ago

cre8 commented 5 months ago

When decoding an sd-jwt-vc credential with

const sdjwtvc = await sdjwt.decode(credential.credential as string);
console.log(sdjwtvc.jwt!.payload!.jti);

it will throw an error that jti comes from an index signature. It would be correct that we pass SdJwtVcPayload to the decode function so it knows that the default values from a JWT can be set.

Current solution is to cast it manually like console.log((sdjwtvc.jwt!.payload as SdJwtVcPayload).jti);

According to the SD-JWT-VC spec, jti is not a known value, but according to the JWT spec it is. Should we also add all values that are in a JWT also to the payload of a Sdjwtvc? Of course marking them all as optional.

lukasjhan commented 5 months ago

@cre8 I think it would be better to include the JWT spec. It would be inconvenient to use it by casting.