jwtk / njwt

Node.js JWT support
Apache License 2.0
432 stars 49 forks source link

JWT expiration and issuedAt properties and setters are inconsistent #93

Open ande8135 opened 1 year ago

ande8135 commented 1 year ago

The Jwt.prototype.setIssuedAt() and .setExpiration() functions are both time-related, but take in three separate arguments of inconsistent types. IssuedAt only takes in an integer representing seconds, while Expiration can take an integer representing milliseconds, or a Date object. Can you make these arguments consistent?

njwt.create(...)
  .setIssuedAt(seconds)
  .setExpiration(date or milliseconds);

IssuedAt: https://github.com/jwtk/njwt/blob/ce98cd49a9381330cd7daa2250b817a59b134e56/index.js#L182-L185 https://github.com/jwtk/njwt/blob/ce98cd49a9381330cd7daa2250b817a59b134e56/index.js#L155-L157 https://github.com/jwtk/njwt/blob/ce98cd49a9381330cd7daa2250b817a59b134e56/index.js#L38-L40

Expiration: https://github.com/jwtk/njwt/blob/ce98cd49a9381330cd7daa2250b817a59b134e56/index.js#L188

shuowu-okta commented 1 year ago

@ande8135 Thanks for reporting the issue!

Internal Ref: OKTA-573091