Skip to content

Move the session and TTL helpers out of public.ts - #784

Open
dowski wants to merge 1 commit into
dowski/compute-refresh-token-expiryfrom
dowski/session-helpers
Open

dowski wants to merge 1 commit into
dowski/compute-refresh-token-expiryfrom
dowski/session-helpers

Conversation

@dowski

@dowski dowski commented Oct 22, 2026 •

Copy link
Copy Markdown
Collaborator

This is just a reorganization ahead of making use of the helpers and constants in an upcoming batch worker based cleanup loop.

@vercel

vercel Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
auth-v2 Ready Ready Preview Oct 28, 2026 8:43pm UTC
1 Skipped Deployment
Project Deployment Actions Updated
convex-auth-docs Ignored Ignored Oct 28, 2026 8:43pm UTC

Request Review

dowski commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator Author

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
npm i https://pkg.pr.new/@convex-dev/auth@784

commit: 57d586a

@dowski
dowski force-pushed the dowski/compute-refresh-token-expiry branch from 3f654c4 to 5658f9e Compare October 26, 2026 23:27
@dowski
dowski force-pushed the dowski/session-helpers branch from d9700da to 2df0640 Compare October 26, 2026 23:27
@dowski
dowski force-pushed the dowski/session-helpers branch from 2df0640 to b31e38f Compare October 26, 2026 23:44
@dowski
dowski force-pushed the dowski/compute-refresh-token-expiry branch from c0c444a to af785e7 Compare October 26, 2026 23:53
@dowski
dowski force-pushed the dowski/session-helpers branch from b31e38f to ffe383c Compare October 26, 2026 23:54
@dowski
dowski force-pushed the dowski/session-helpers branch from ffe383c to ccb9abb Compare October 27, 2026 14:51
@dowski
dowski force-pushed the dowski/compute-refresh-token-expiry branch from af785e7 to 82f3d10 Compare October 27, 2026 14:51
@dowski
dowski force-pushed the dowski/compute-refresh-token-expiry branch from 82f3d10 to 7ddc492 Compare October 27, 2026 15:03
@dowski
dowski force-pushed the dowski/session-helpers branch from ccb9abb to 5a2e1cd Compare October 27, 2026 15:04
@dowski
dowski force-pushed the dowski/compute-refresh-token-expiry branch from 7ddc492 to d0730ba Compare October 28, 2026 18:49
@dowski
dowski force-pushed the dowski/session-helpers branch from 5a2e1cd to 30421d4 Compare October 28, 2026 18:49
@dowski
dowski marked this pull request as ready for review October 28, 2026 20:32

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/core/src/component/expiry.ts">

<violation number="1" location="packages/core/src/component/expiry.ts:32">
P2: `NaN` and `Infinity` pass this check, and a non-finite refresh TTL makes the refresh expiry comparison always false. Reject non-finite TTLs here with `Number.isFinite` so misconfiguration cannot create non-expiring sessions.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

args.accessTokenTtlSeconds ?? DEFAULT_ACCESS_TOKEN_TTL_SECONDS;
const refreshTokenTtlSeconds =
args.refreshTokenTtlSeconds ?? DEFAULT_REFRESH_TOKEN_TTL_SECONDS;
if (accessTokenTtlSeconds <= 0 || refreshTokenTtlSeconds <= 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: NaN and Infinity pass this check, and a non-finite refresh TTL makes the refresh expiry comparison always false. Reject non-finite TTLs here with Number.isFinite so misconfiguration cannot create non-expiring sessions.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/core/src/component/expiry.ts, line 32:

<comment>`NaN` and `Infinity` pass this check, and a non-finite refresh TTL makes the refresh expiry comparison always false. Reject non-finite TTLs here with `Number.isFinite` so misconfiguration cannot create non-expiring sessions.</comment>

<file context>
@@ -0,0 +1,61 @@
+    args.accessTokenTtlSeconds ?? DEFAULT_ACCESS_TOKEN_TTL_SECONDS;
+  const refreshTokenTtlSeconds =
+    args.refreshTokenTtlSeconds ?? DEFAULT_REFRESH_TOKEN_TTL_SECONDS;
+  if (accessTokenTtlSeconds <= 0 || refreshTokenTtlSeconds <= 0) {
+    throw new Error("Token TTLs must be positive.");
+  }
</file context>
Suggested change
if (accessTokenTtlSeconds <= 0 || refreshTokenTtlSeconds <= 0) {
if (
!Number.isFinite(accessTokenTtlSeconds) ||
!Number.isFinite(refreshTokenTtlSeconds) ||
accessTokenTtlSeconds <= 0 ||
refreshTokenTtlSeconds <= 0
) {

The refresh-token lifecycle helpers (lookup, issuing, redeeming, pruning,
and deleting a session) move to component/sessions.ts, along with the
constants they use, and the TTL config and expiry helpers move to
component/expiry.ts. A newestIssuedToken helper is pulled out of
listSessions.

No behavior change. This prepares the helpers for a session cleanup loop
that needs them outside the public functions. refreshTokenExpiresAt now
takes the refresh-token TTL in seconds rather than the whole config, since
the loop will only have that value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

1 active deployment
Preview – auth-v2 — 57d586ab Deployed Oct 28, 2026 by vercel[bot]
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