~james/core

core/web/src/lib/auth/session.ts -rw-r--r-- 485 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
import { OAuthResponseError, TokenRefreshError } from "@atcute/oauth-browser-client";

// a refresh that the pds rejected outright, the session is gone and only a new
// authorization brings it back. anything else (network, 5xx) is transient.
export const isDeadSessionError = (cause: unknown): boolean =>
	cause instanceof TokenRefreshError ||
	(cause instanceof OAuthResponseError &&
		cause.status === 400 &&
		(cause.error === "invalid_grant" || cause.error === "invalid_token"));