-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support notBefore and expiresIn as strings #364
Conversation
c77055d
to
a873f47
Compare
@@ -27,9 +27,11 @@ Create a signer function by calling `createSigner` and providing one or more of | |||
|
|||
- `mutatePayload`: If set to `true`, the original payload will be modified in place (via `Object.assign`) by the signing function. This is useful if you need a raw reference to the payload after claims have been applied to it but before it has been encoded into a token. Default is `false`. | |||
|
|||
- `expiresIn`: Time span (in milliseconds) after which the token expires, added as the `exp` claim in the payload as defined by the [section 4.1.4 of RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4). This will override any existing value in the claim. | |||
- `expiresIn`: Time span (in milliseconds or text describing time) after which the token expires, added as the `exp` claim in the payload as defined by the [section 4.1.4 of RFC 7519](https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4). This will override any existing value in the claim. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather, or in addition to providing explicit example, mention the library we use to parse the string format of the time. it's a popular library so mentioning that one is more explanatory than providing explicit examples
test/signer.spec.js
Outdated
@@ -355,6 +355,20 @@ test('it respects payload exp claim (if supplied), overriding the default expire | |||
t.end() | |||
}) | |||
|
|||
test('it supports expiresIn as a string', t => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: use async tests so you don't have to remember to call t.end to end the test. simply making the test function async achieves that. I appreciate you are complying with the existing convention in this codebase, but I prefer we update it to the new syntax. t.end is only useful when doing assertions in callbacks, which is a niche use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Woah . That was quick 🔥 |
Closes #363
uses https://github.com/lukeed/ms underneath
Had to adjust the tests, update the docs and implement the ms lib