Skip to content
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

Compatibility with cookie@1.0 #61

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Lucurious
Copy link

While SvelteKit still depends on cookie@0.6 (due to breaking changes discussed in sveltejs/kit#12767), this version of 'cookie' is affected by CVE-2024-47764.

As stated in the above PR, it may be advisable for some users to manually override the 'cookie' version to 0.7 or up. The recent release of cookie@1.0, however, added strict checks to ensure maxAge-values are integers (using Number.isInteger), which breaks the current method of calculating the max-age for the session-cookie.

This PR ensures that the calculated max-age values are rounded before being used in setCookie.

To ensure that this update is mostly non-breaking, the 'expiresToMaxage' utility-function was also adapted to round the max-age when calculating from days, hours and minutes. When 'calculating' from seconds, no rounding is applied to match cookie's behavior.
While it is not advisable, this means that non-integer expiry-values (such as 0.5 days) are still valid, even when using cookie@1.0.

@Lucurious Lucurious changed the title Compatibility with cookie@^1.0 Compatibility with cookie@1.0 Oct 29, 2024
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.

1 participant