decentralized-identity / did-jwt-vc

Create and verify W3C Verifiable Credentials and Presentations in JWT format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Not possible to set expiresIn or canonicalize when creating a VC

nikolockenvitz opened this issue ยท comments

Hello,
I was not able to create a VC with an expiry time. I see no way of setting the option expiresIn of the underlying library did-jwt because I cannot inject further options in the second argument.

// did-jwt
export async function createJWT(
  payload: Partial<JWTPayload>,
  { issuer, signer, alg, expiresIn, canonicalize }: JWTOptions,
  header: Partial<JWTHeader> = {}
): Promise<string> { // ...

did-jwt-vc/src/index.ts

Lines 75 to 85 in 170ab40

return createJWT(
parsedPayload,
{
issuer: issuer.did || parsedPayload.iss || '',
signer: issuer.signer,
},
{
...options.header,
alg: issuer.alg || options.header?.alg || JWT_ALG,
}
)

Similarly, canonicalize in the JWTOptions (did-jwt) cannot be set.

Good catch!
Are you willing to contribute a PR with a fix?

I noticed that expiration time can also be defined by setting exp directly in the payload. However, for canonicalize such workarounds are not possible and using expiresIn might also be more comfortable to use in some cases.

๐ŸŽ‰ This issue has been resolved in version 2.1.7 ๐ŸŽ‰

The release is available on:

Your semantic-release bot ๐Ÿ“ฆ๐Ÿš€