@autobusal/providers 1.2.9 → 1.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/Queries/apiClient.ts +25 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,16 @@ All notable changes to `@autobusal/providers` are documented here. This project
|
|
|
4
4
|
adheres to [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [1.2.11] - 2026-07-19
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- bff-mode 401 no longer logs the user out when the BFF confirms the session is still valid: the apiClient now rejects the failed request (letting react-query retry) instead of tearing down auth. A single account query 401ing (transient race or a flaky upstream call) previously bounced the user to /login even though they were logged in. Bearer mode unchanged.
|
|
12
|
+
## [1.2.10] - 2026-07-19
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Resilient bff-mode auth: on a 401 the apiClient now confirms the session with the BFF (GET /bff/session) before logging out, and transparently retries the request once if still authenticated. Prevents a transient post-login 401 (an account query racing the login cookie hand-off) from bouncing the user straight back to the login page. Bearer mode is unchanged.
|
|
7
17
|
## [1.2.9] - 2026-07-19
|
|
8
18
|
|
|
9
19
|
### Added
|
package/Queries/apiClient.ts
CHANGED
|
@@ -39,11 +39,34 @@ if (!isBffMode) {
|
|
|
39
39
|
|
|
40
40
|
apiClient.interceptors.response.use(response => (
|
|
41
41
|
response
|
|
42
|
-
), error => {
|
|
42
|
+
), async (error) => {
|
|
43
43
|
if (error.response) {
|
|
44
|
-
// if we have a 401, we go to the logout page
|
|
44
|
+
// if we have a 401, the session is gone, so we go to the logout page.
|
|
45
45
|
if (error.response.status === 401 && window.location.pathname !== '/account/logout') {
|
|
46
|
+
// bff mode: auth is a server-side httpOnly cookie the BFF manages, so a
|
|
47
|
+
// single request's 401 does NOT reliably mean "logged out" the way a
|
|
48
|
+
// bearer 401 does - a query that momentarily races the login/cookie
|
|
49
|
+
// hand-off (or a flaky upstream call) can 401 while the session is still
|
|
50
|
+
// valid. A blind logout here drops the user straight back to /login. So
|
|
51
|
+
// confirm with the BFF: only tear the session down if it agrees we are no
|
|
52
|
+
// longer authenticated; otherwise just reject and let react-query retry -
|
|
53
|
+
// the user stays logged in. bearer mode has no such ambiguity (the token
|
|
54
|
+
// is attached synchronously from localStorage) and logs out immediately.
|
|
55
|
+
if (isBffMode) {
|
|
56
|
+
try {
|
|
57
|
+
const { data } = await apiClient.get('/session');
|
|
58
|
+
|
|
59
|
+
if (data?.authenticated) {
|
|
60
|
+
return Promise.reject(error);
|
|
61
|
+
}
|
|
62
|
+
} catch {
|
|
63
|
+
// /session unreachable - fall through to logout.
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
46
67
|
window.location.href = '/account/logout';
|
|
68
|
+
|
|
69
|
+
return Promise.reject(error);
|
|
47
70
|
}
|
|
48
71
|
|
|
49
72
|
// if the user is not valid
|