Changelog - 2026-11-04
A refreshTokenPath now refreshes the token without a subclass
Behavior ChangeIn one line. authRecovery.refreshTokenPath used to only stop the refresh endpoint from starting another refresh. Now DefaultNetworkRequestService.refreshToken() also uses it: it POSTs to that path with no body, saves the token of the answer, and the request that got the 401 is retried. Every app that has a refresh endpoint wrote the same subclass for this; it can go.
ts
import type { IRestDataProviderOptions } from '@venizia/ardor';
const restDataProviderOptions: IRestDataProviderOptions = {
url: 'https://api.example.com',
authRecovery: { refreshTokenPath: '/auth/refresh' },
noAuthPaths: ['/auth/sign-in'],
};What changed
- The default refresh. With a
refreshTokenPathand the auth service,refreshToken()posts to the path with no body (the expired token is attached only when the path is not innoAuthPaths), reads{ token: { value, type } }or{ token: '<jwt>' }from the answer, and saves it through the auth service. It then returnstrue, so the original request is retried once. - The stored session is kept. A refresh keeps the same user: it saves the new token with the stored user id, and the stored
username,referenceIdandproviderare passed back with it, and the roles are never passed, so a refresh answer that carries roles in another shape cannot wipe them. - A change of session wins. If the user signed out or another user signed in while the refresh request was in flight, the token is not saved and the
401stands, and a refresh that fails after such a change does not runonAuthFailure. If the same user holds another token by then (another tab refreshed), that token is kept and used for the retry. A401that arrives after another user signed in starts no refresh. - A failure is as before. A non-2xx answer, or an answer without a token, rejects the refresh:
onAuthFailureruns once, the401stands, and the stored session is as it was. - Without a path, nothing changes. With no
refreshTokenPaththe default still returnsfalse. A subclass that overridesrefreshTokenis untouched. - Where the auth service comes from.
DefaultRestDataProvider.value(container)reads the optionalCoreBindings.DEFAULT_AUTH_SERVICEbinding and gives it to the network service as a newauthServiceoption. A network service you build yourself passes it in the options. - For another answer shape, override the new protected hook
readRefreshedToken({ data }).
Who is affected
- An app that set
refreshTokenPathonly to stop the loop, with norefreshTokenoverride. A401now sends a refresh request to that path with the old token, and on a failure runsonAuthFailure. If that path is not a refresh endpoint, remove the setting or overriderefreshToken. - An app with its own
refreshTokensubclass. No action needed. You can delete it when it only posts to the path and saves the token. - All other apps. No action needed.
See Auth recovery.