Skip to content

Expire session when refresh is unsupported and the access token has expired - #80

Open
germ-mark wants to merge 1 commit into
mainfrom
llm/refresh-not-supported-terminal
Open

Expire session when refresh is unsupported and the access token has expired#80
germ-mark wants to merge 1 commit into
mainfrom
llm/refresh-not-supported-terminal

Conversation

@germ-mark

Copy link
Copy Markdown
Contributor

Adopts oauth4swift 0.6.0's OAuth.Errors.refreshNotSupported (germ-network/oauth4swift#58) in AtprotoOAuthAgent.startRefresh. The generic catch restored the previous state and returned the old access token for every refresh error, so a server whose grant_types_supported excludes refresh_token could never reach .expired — once its access token lapsed, the session became a permanent 401 zombie.

Now refreshNotSupported is caught distinctly: while the access token is still valid the session is preserved as before; once it has expired the agent goes terminal (save stream yields nil, state → .expired, .loggedOut emitted), matching the existing nil-token-state path. Bumps the oauth4swift floor to 0.6.0 (pulls GermConvenience 0.3.0) and re-resolves the demo app's pins to match.

Tests: two new AgentStateMachineTests cover the preserve and terminal paths; full suite passes and the demo app builds against 0.6.0.

🤖 Generated with Claude Code

oauth4swift 0.6.0's refresh gate throws refreshNotSupported when the
server's grant_types_supported excludes refresh_token. The generic catch
restored the old access token, so a gated server with expiring tokens
became a permanent 401 zombie session. Keep the session while the access
token is valid; transition to .expired once it isn't.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 235acff

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@germ-network/atprotooauth Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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