fix: stop coupling grant lifetime to session approval window#62
Open
fix: stop coupling grant lifetime to session approval window#62
Conversation
The grant flow was passing the session relay's expiresAt (an approval-window timeout) as the grant's expiresAt, causing grants to expire after ~2 hours. Grants should live until explicitly revoked (expiresAt=0), matching the protocol spec and OAuth conventions where the authorization code lifetime is distinct from the refresh token lifetime.
maciejwitowski
approved these changes
Feb 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
expiresAtas the grant'sexpiresAtexpiresAt=0(no automatic time-based expiry), living until explicitly revokedProblem
The grant flow was deriving
expiresAtfromflowState.session.expiresAt— which is the session approval window set by the session relay (typically ~2 hours). This value was being passed tocreateGrant(), causing grants to expire after ~2 hours even though the user intended a standing authorization.These are conceptually different lifetimes:
expiresAt: how long the user has to click "Allow" (interactive approval window)expiresAt: how long the builder can access data (authorization lifetime)This matches OAuth's separation: the interactive approval session (short-lived, consumed once) is distinct from the resulting authorization/consent (long-lived, revocable). The session's expiry should only gate whether the consent flow is still valid — which the flow already enforces before grant creation.
Per the protocol spec,
expiresAt=0means no automatic time-based expiry; grants remain valid until explicitly revoked (or until any future policy-based expiry is introduced).Changes
use-grant-flow.ts: RemoveexpiresAtderivation from session; don't pass it tocreateGrant()use-grant-flow.test.tsx: Update assertions to match (noexpiresAtincreateGrantcalls)Test plan
main(localStorage mock issue, unrelated)