Difficulty: Hard
Type: Bug
Summary
Fix the SIWE auth provider so TypeScript builds reliably and unauthorised API responses consistently reset the admin session.
Current Behaviour
lib/wallet/providers.tsx uses AdminSessionStatus but only imports SiweAuthSession from the API types. The provider also defines an unauthorised error handling path inside React Query configuration, but the invalidation event flow is incomplete and may not actually clear cached session state when an API call returns 401.
Expected Behaviour
The SIWE provider should typecheck cleanly and any unauthorised API response should clear the stored token, reset admin auth state, and invalidate related React Query cache entries.
Suggested Implementation
Import AdminSessionStatus from lib/api/types.ts. Replace the current query-level unauthorised handling with a supported React Query v5 pattern, such as a QueryCache or MutationCache onError handler on the QueryClient. When an ApiError has code === 'unauthorized', clear the SIWE session, dispatch or directly call the invalidation flow, and remove session and access decision queries.
Files or Areas Likely Affected
lib/wallet/providers.tsx
lib/api/errors.ts
lib/query/
test/*.test.ts
Acceptance Criteria
Additional Notes
This should stay aligned with React Query v5 APIs. Avoid relying on unsupported query option callbacks that may not fire or may fail typechecking.
Difficulty: Hard
Type: Bug
Summary
Fix the SIWE auth provider so TypeScript builds reliably and unauthorised API responses consistently reset the admin session.
Current Behaviour
lib/wallet/providers.tsxusesAdminSessionStatusbut only importsSiweAuthSessionfrom the API types. The provider also defines an unauthorised error handling path inside React Query configuration, but the invalidation event flow is incomplete and may not actually clear cached session state when an API call returns401.Expected Behaviour
The SIWE provider should typecheck cleanly and any unauthorised API response should clear the stored token, reset admin auth state, and invalidate related React Query cache entries.
Suggested Implementation
Import
AdminSessionStatusfromlib/api/types.ts. Replace the current query-level unauthorised handling with a supported React Query v5 pattern, such as aQueryCacheorMutationCacheonErrorhandler on theQueryClient. When anApiErrorhascode === 'unauthorized', clear the SIWE session, dispatch or directly call the invalidation flow, and removesessionand access decision queries.Files or Areas Likely Affected
lib/wallet/providers.tsxlib/api/errors.tslib/query/test/*.test.tsAcceptance Criteria
npm run typecheckpasses without missing type imports.401API error clears the stored SIWE auth session.Additional Notes
This should stay aligned with React Query v5 APIs. Avoid relying on unsupported query option callbacks that may not fire or may fail typechecking.