Skip to content

add expiresAfter to use a relative delay for expires#18

Merged
yaronf merged 3 commits intoyaronf:mainfrom
krichprollsch:expireAfter
Mar 17, 2026
Merged

add expiresAfter to use a relative delay for expires#18
yaronf merged 3 commits intoyaronf:mainfrom
krichprollsch:expireAfter

Conversation

@krichprollsch
Copy link
Copy Markdown
Contributor

Hello,

First, thank you very much for the lib!

While using the wrap handler, I found useful to have way to configure a relative expiration delay instead of configuring an absolute one.

@krichprollsch krichprollsch changed the title add expireAfter to use a relative delay for expires add expiresAfter to use a relative delay for expires Mar 8, 2026
@yaronf
Copy link
Copy Markdown
Owner

yaronf commented Mar 11, 2026

Looks good. Two comments (thanks Cursor...)

  1. Doc comment – The comment says the parameter is “as Unix time”, but it’s a delay in seconds. Suggested wording:
// SetExpiresAfter sets the "expires" parameter to createdTime + delay (seconds).
// Use this for a relative validity window instead of an absolute timestamp.
// Default: 0 (do not add the parameter).
  1. Tests – No tests were added. Suggested additions:
  • SetExpiresAfter(60) with setFakeCreated(1000) → expires = 1060
  • Error when both SetExpires and SetExpiresAfter are set
  • Optional: handler test using SetExpiresAfter instead of SetExpires(2000) for the early-expires case

Test that expiresAfter correctly computes expires as created + delay,
that setting both SetExpires and SetExpiresAfter returns an error,
and that the handler rejects expired signatures using SetExpiresAfter.
@krichprollsch
Copy link
Copy Markdown
Contributor Author

Thanks for the review and for your patience. I just updated my PR.

@yaronf
Copy link
Copy Markdown
Owner

yaronf commented Mar 17, 2026

Looks good, thanks for your contribution. I will follow up with a minor fix.

@yaronf yaronf merged commit 691910b into yaronf:main Mar 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants