onUnauthorized
Called by XrpcClient on HTTP 401. Recovers every recoverable cause in one call so the single retry that XrpcClient performs always carries fresh state. Control flow:
If the server rotated
DPoP-Nonce, store and persist it eagerly. Persisting before any refresh attempt means a refresh that throws (e.g. transient network failure) won't lose the rotated nonce.If the bound access token is a JWT whose
expis past (or within a small skew window) — i.e. the next request would 401 withinvalid_tokenregardless of nonce — refresh proactively.If only the nonce was recoverable (opaque/non-expired token, new nonce already persisted in step 1), return
true.Otherwise (no nonce signal: same nonce, no nonce header) refresh.