next-auth icon indicating copy to clipboard operation
next-auth copied to clipboard

JWTEncodeParams maxAge type definition

Open roberte777 opened this issue 2 years ago • 4 comments

Question 💬

In the type definition for JWTEncodeParams, maxAge is defined as optional. image

export interface JWTEncodeParams {
    /** The JWT payload. */
    token?: JWT;
    /** The secret used to encode the NextAuth.js issued JWT. */
    secret: string | Buffer;
    /**
     * The maximum age of the NextAuth.js issued JWT in seconds.
     * @default 30 * 24 * 30 * 60 // 30 days
     */
    maxAge?: number; // line being referred to in this issue!
}

Since a default value is always provided by nextauth (30 days), the maxAge field is always defined, making the question mark incorrect. Ran into this while overriding the encode function. Will fix if it is decided that I am correct. Thanks!

How to reproduce ☕️

Look at type definition for JWTEncodeParams

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

roberte777 avatar Jul 13 '22 17:07 roberte777

Since maxAge is defined internally if missing, it means the user could omit the value, hence it is optional.

balazsorban44 avatar Jul 13 '22 23:07 balazsorban44

Judged quickly, I think you are right, this is the params you receive when overriding the encode function.

You are correct. A small code snippet might have made it more clear. :+1: ~Feel free to open a PR!~ I found #4901, it just wasn't linked. :sweat_smile:

balazsorban44 avatar Jul 13 '22 23:07 balazsorban44

Judged quickly, I think you are right, this is the params you receive when overriding the encode function.

You are correct. A small code snippet might have made it more clear. 👍 ~Feel free to open a PR!~ I found #4901, it just wasn't linked. 😅

Sorry, new to all this, appreciate the feedback.

roberte777 avatar Jul 14 '22 00:07 roberte777

It looks like this issue did not receive any activity for 60 days. It will be closed in 7 days if no further activity occurs. If you think your issue is still relevant, commenting will keep it open. Thanks!

stale[bot] avatar Sep 16 '22 00:09 stale[bot]

To keep things tidy, we are closing this issue for now. If you think your issue is still relevant, leave a comment and we might reopen it. Thanks!

stale[bot] avatar Sep 24 '22 03:09 stale[bot]