@mano8/astro-auth-m8 2.2.0 → 2.4.0
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 +104 -0
- package/dist/src/runtime/api/auth.d.ts.map +1 -1
- package/dist/src/runtime/api/auth.js +12 -0
- package/dist/src/runtime/api/auth.js.map +1 -1
- package/dist/src/runtime/api/oauth.d.ts.map +1 -1
- package/dist/src/runtime/api/oauth.js +11 -2
- package/dist/src/runtime/api/oauth.js.map +1 -1
- package/dist/src/runtime/authorization.d.ts +11 -0
- package/dist/src/runtime/authorization.d.ts.map +1 -1
- package/dist/src/runtime/authorization.js +11 -0
- package/dist/src/runtime/authorization.js.map +1 -1
- package/dist/src/runtime/client.d.ts.map +1 -1
- package/dist/src/runtime/client.js +8 -0
- package/dist/src/runtime/client.js.map +1 -1
- package/dist/src/runtime/react/AuthProvider.d.ts.map +1 -1
- package/dist/src/runtime/react/AuthProvider.js +63 -15
- package/dist/src/runtime/react/AuthProvider.js.map +1 -1
- package/dist/src/runtime/sessionHint.d.ts +35 -0
- package/dist/src/runtime/sessionHint.d.ts.map +1 -0
- package/dist/src/runtime/sessionHint.js +64 -0
- package/dist/src/runtime/sessionHint.js.map +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,110 @@ This project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
The major version tracks the supported `fa-auth-m8` **API contract**, not just
|
|
7
7
|
this package's own surface: a backend contract repoint is always a major.
|
|
8
8
|
|
|
9
|
+
## [Unreleased]
|
|
10
|
+
|
|
11
|
+
## 2.4.0
|
|
12
|
+
|
|
13
|
+
No code behaviour changes; the supported backend contract stays
|
|
14
|
+
`fa-auth-m8@2.0`, range `>=2.0.0 <3.0.0`. This release exists to give the
|
|
15
|
+
fleet a published version to pin against, because what moves here is a
|
|
16
|
+
**commitment**, not an implementation: `./authorization` stops being an
|
|
17
|
+
internal module that siblings happen to be able to reach and becomes a
|
|
18
|
+
supported cross-plugin import surface, with a gate holding it to the purity
|
|
19
|
+
that promise depends on. A consumer that only reinstalls gets byte-identical
|
|
20
|
+
runtime behaviour — the point of the bump is that `^2.4.0` is now the range
|
|
21
|
+
that *means* "this package guarantees the shared hierarchy".
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **`./authorization` is now the fleet's shared role hierarchy** (remediation
|
|
26
|
+
`W7.7`, decision 4). Nothing in the published surface changes: the module,
|
|
27
|
+
its four exports and their behaviour are exactly as `2.3.0` shipped them.
|
|
28
|
+
What changes is its standing. The fleet's `no-cross-plugin-import` gate
|
|
29
|
+
(`C12`, `scripts/verify-fleet-gates.mjs`, carried byte-identically by all
|
|
30
|
+
four plugins) now exempts this one exact specifier, so a sibling plugin can
|
|
31
|
+
import the hierarchy instead of re-implementing it and pinning the copy with
|
|
32
|
+
an agreement test — which is how `RBAC-06`, one hierarchy, becomes literally
|
|
33
|
+
true again. Every other subpath of this package stays refused.
|
|
34
|
+
A new `authorization-purity` gate makes the exemption conditional rather than
|
|
35
|
+
a blanket trust: it resolves what this package publishes for
|
|
36
|
+
`./authorization`, walks its import closure, and fails on React, on any bare
|
|
37
|
+
dependency other than `zod`, or on any read of a runtime global. It runs here
|
|
38
|
+
against this repository's own build, so keeping the module framework-neutral
|
|
39
|
+
and effect-free is now a gated obligation of this repository — recorded in
|
|
40
|
+
`REPOSITORY_CONTEXT.md` and in the module's own header, so it survives the
|
|
41
|
+
next person who edits it.
|
|
42
|
+
|
|
43
|
+
## 2.3.0
|
|
44
|
+
|
|
45
|
+
Additive only; the supported backend contract stays `fa-auth-m8@2.0`, range
|
|
46
|
+
`>=2.0.0 <3.0.0`. A consumer already on `^2.2.0` resolves this release without
|
|
47
|
+
a manifest change; the fleet raised its floor to `^2.3.0` anyway, because the
|
|
48
|
+
refresh coordination below is behaviour its consumers depend on rather than an
|
|
49
|
+
optimisation they can afford to miss.
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- **The two refresh paths are coordinated** (remediation `W3.1`).
|
|
54
|
+
`AuthProvider`'s bootstrap called `refreshToken()` directly, bypassing the
|
|
55
|
+
`runRefresh` single-flight guard in `tokenStore.ts` that `client.ts`'s own
|
|
56
|
+
`401`-triggered refresh uses. Two independent guards over one *rotating*
|
|
57
|
+
token let a page mounting both paths against one expired token issue two
|
|
58
|
+
rotations — which `fa-auth-m8` correctly reads as token reuse and answers by
|
|
59
|
+
revoking every session for that account. `bootstrapSession()` now goes
|
|
60
|
+
through `runRefresh`, so whichever path reaches it first performs the
|
|
61
|
+
request and the other piggybacks on its resolved token. The existing
|
|
62
|
+
`bootstrapFailureUntil` cooldown is untouched; it is a separate concern
|
|
63
|
+
layered on top.
|
|
64
|
+
- **A transient failure no longer poisons the session hint.** The bootstrap
|
|
65
|
+
catch recorded "no session" on *any* error, and the hint has no expiry, so a
|
|
66
|
+
single `500` or one offline load made every later page load skip its refresh
|
|
67
|
+
and left a validly signed-in user looking signed out until they signed in by
|
|
68
|
+
hand. Only a `401` records the negative now; every other failure keeps the
|
|
69
|
+
retryable cooldown, which lapses and recovers on its own.
|
|
70
|
+
- **A session established outside `AuthProvider.login` clears the hint.** The
|
|
71
|
+
plugin's own `CallbackView` — and, more to the point, `fa-ui-m8`'s
|
|
72
|
+
`useGoogleLogin`, which calls `exchangeGoogleCode` + `setToken` directly and
|
|
73
|
+
then hard-navigates — never reached the provider's `login`, so a Google
|
|
74
|
+
sign-in after any earlier `401` landed on a page that skipped its bootstrap
|
|
75
|
+
and rendered as signed out. Rather than patch each UI, the hint now lives
|
|
76
|
+
beside `setToken`/`clearToken` at the points that actually establish or
|
|
77
|
+
destroy a session: login, logout, an honoured `refreshToken` (the only auth
|
|
78
|
+
call the sibling plugins make, through `installFaAuthBrowserAdapter`), a
|
|
79
|
+
completed OAuth exchange, and `client.ts`'s `401`-triggered rotation. Every
|
|
80
|
+
consumer is covered with no host change.
|
|
81
|
+
- **Every Web Storage access is guarded.** These are core sign-in paths, so an
|
|
82
|
+
environment with no `localStorage` — or one refusing access to it — must lose
|
|
83
|
+
the optimisation and never the sign-in.
|
|
84
|
+
|
|
85
|
+
### Added
|
|
86
|
+
|
|
87
|
+
- **A negative-only session hint** (`src/runtime/sessionHint.ts`, remediation
|
|
88
|
+
`W3.2`). The provider's bootstrap called `refreshToken()` unconditionally on
|
|
89
|
+
every page load, including for a browser with no session at all.
|
|
90
|
+
`fa-auth-m8`'s `refresh_token` cookie is `HttpOnly`, so this runtime cannot
|
|
91
|
+
read it to find out, and `fa-auth-m8` behaviour changes were out of scope —
|
|
92
|
+
hence a client-owned substitute that only ever records the *negative*. It is
|
|
93
|
+
cleared by default and on a successful login or bootstrap, and set only once
|
|
94
|
+
a bootstrap refresh has actually been refused, or on logout.
|
|
95
|
+
`bootstrapSession()` then skips the refresh call outright, with no network
|
|
96
|
+
request. An unset hint still always attempts the refresh exactly as before,
|
|
97
|
+
so a browser carrying a still-valid cookie from before this release is never
|
|
98
|
+
signed out on a guess. **This adds one `localStorage` key**, which is why
|
|
99
|
+
this release is a minor rather than a patch.
|
|
100
|
+
|
|
101
|
+
### Changed
|
|
102
|
+
|
|
103
|
+
- **`AuthProvider` is split into an outer component and `AuthProviderInner`**,
|
|
104
|
+
the inner one rendered inside `AuthQueryProvider` so it can reach
|
|
105
|
+
`useQueryClient()`. A new `applyUser` callback replaces every direct
|
|
106
|
+
`setUser` call and additionally seeds
|
|
107
|
+
`queryClient.setQueryData(authKeys.profile(), profile)`, so a screen's own
|
|
108
|
+
`useProfile()` reads the provider's already-resolved profile from cache
|
|
109
|
+
instead of firing a second identity request for one answer.
|
|
110
|
+
- Internal only: the tarball smoke test resolves the npm CLI on POSIX, and the
|
|
111
|
+
registry command fixture is aligned with `@mano8/astro-ui-m8` `1.5.0`.
|
|
112
|
+
|
|
9
113
|
## 2.2.0
|
|
10
114
|
|
|
11
115
|
Additive only; the supported backend contract stays `fa-auth-m8@2.0`, range
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/auth.ts"],"names":[],"mappings":"AACA,OAAO,EAAwD,KAAK,eAAe,EAAE,KAAK,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAMxI,wBAAsB,KAAK,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAc9E;AAED,wBAAsB,YAAY,IAAI,OAAO,CAAC,KAAK,CAAC,CAwBnD;AAED,wBAAsB,MAAM,IAAI,OAAO,CAAC,eAAe,CAAC,CAWvD;AAED,wBAAgB,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,CAO/C"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { request } from "../client.js";
|
|
2
2
|
import { ResponseMessageSchema, TokenSchema, UserPublicSchema } from "../schemas.js";
|
|
3
|
+
import { markSessionAbsent, markSessionPresent } from "../sessionHint.js";
|
|
3
4
|
import { clearToken, setToken } from "../tokenStore.js";
|
|
4
5
|
let refreshTokenPromise = null;
|
|
5
6
|
export async function login(username, password) {
|
|
@@ -11,6 +12,10 @@ export async function login(username, password) {
|
|
|
11
12
|
skipRefresh: true
|
|
12
13
|
});
|
|
13
14
|
setToken(token.access_token);
|
|
15
|
+
// Beside `setToken` on purpose: this is where a session starts existing for
|
|
16
|
+
// this browser, whoever called it. A host with its own sign-in UI built on
|
|
17
|
+
// these wrappers gets the same bookkeeping as `AuthProvider.login`.
|
|
18
|
+
markSessionPresent();
|
|
14
19
|
return token;
|
|
15
20
|
}
|
|
16
21
|
export async function refreshToken() {
|
|
@@ -23,6 +28,12 @@ export async function refreshToken() {
|
|
|
23
28
|
})
|
|
24
29
|
.then((token) => {
|
|
25
30
|
setToken(token.access_token);
|
|
31
|
+
// A refresh the service honoured proves the cookie is still good -
|
|
32
|
+
// including one issued by a sibling plugin through
|
|
33
|
+
// `installFaAuthBrowserAdapter`, which is the only auth call some of
|
|
34
|
+
// them ever make. Clearing here lets any of those recover a hint left
|
|
35
|
+
// by an earlier refusal.
|
|
36
|
+
markSessionPresent();
|
|
26
37
|
return token;
|
|
27
38
|
})
|
|
28
39
|
.finally(() => {
|
|
@@ -40,6 +51,7 @@ export async function logout() {
|
|
|
40
51
|
skipRefresh: true
|
|
41
52
|
});
|
|
42
53
|
clearToken();
|
|
54
|
+
markSessionAbsent();
|
|
43
55
|
return message;
|
|
44
56
|
}
|
|
45
57
|
export function testToken() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../../src/runtime/api/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,gBAAgB,EAAqD,MAAM,eAAe,CAAC;AACxI,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAExD,IAAI,mBAAmB,GAA0B,IAAI,CAAC;AAEtD,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,QAAgB,EAAE,QAAgB;IAC5D,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC;QAC1B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE;QAC5B,MAAM,EAAE,WAAW;QACnB,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,QAAQ,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAC7B,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAA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MAAM,EAAE,qBAAqB;QAC7B,IAAI,EAAE,IAAI;QACV,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,UAAU,EAAE,CAAC;IACb,iBAAiB,EAAE,CAAC;IACpB,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,oBAAoB;QAC1B,MAAM,EAAE,gBAAgB;QACxB,IAAI,EAAE,IAAI;KACX,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/oauth.ts"],"names":[],"mappings":"AACA,OAAO,EAA8D,KAAK,sBAAsB,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../../src/runtime/api/oauth.ts"],"names":[],"mappings":"AACA,OAAO,EAA8D,KAAK,sBAAsB,EAAE,KAAK,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAUrJ,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEvD;AAED,wBAAgB,gBAAgB,IAAI,MAAM,GAAG,IAAI,CAIhD;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAMvF;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAQ9H;AAED,wBAAsB,kBAAkB,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAgB7I"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { request } from "../client.js";
|
|
2
2
|
import { GoogleExchangeResponseSchema, GoogleLoginUrlResponseSchema } from "../schemas.js";
|
|
3
|
+
import { markSessionPresent } from "../sessionHint.js";
|
|
3
4
|
const VERIFIER_KEY = "fa-auth-m8:pkce-verifier";
|
|
4
5
|
function base64Url(bytes) {
|
|
5
6
|
const values = String.fromCharCode(...new Uint8Array(bytes));
|
|
@@ -29,13 +30,21 @@ export function getGoogleLoginUrl(params) {
|
|
|
29
30
|
skipRefresh: true
|
|
30
31
|
});
|
|
31
32
|
}
|
|
32
|
-
export function exchangeGoogleCode(body) {
|
|
33
|
-
|
|
33
|
+
export async function exchangeGoogleCode(body) {
|
|
34
|
+
const exchanged = await request({
|
|
34
35
|
method: "POST",
|
|
35
36
|
path: "/google-api/exchange/",
|
|
36
37
|
body,
|
|
37
38
|
schema: GoogleExchangeResponseSchema,
|
|
38
39
|
skipRefresh: true
|
|
39
40
|
});
|
|
41
|
+
// A completed exchange establishes this browser's session. Recorded here
|
|
42
|
+
// rather than in a callback view because a consumer may complete the flow
|
|
43
|
+
// with its own UI on this wrapper (fa-ui-m8 does) and then hard-navigate,
|
|
44
|
+
// never touching `AuthProvider.login`; without this, a hint left by an
|
|
45
|
+
// earlier refused refresh would make the destination page skip its
|
|
46
|
+
// bootstrap and render a freshly signed-in user as signed out.
|
|
47
|
+
markSessionPresent();
|
|
48
|
+
return exchanged;
|
|
40
49
|
}
|
|
41
50
|
//# sourceMappingURL=oauth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../../src/runtime/api/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,4BAA4B,EAAE,4BAA4B,EAA4D,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":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zF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC;AACpD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAA2D;IAC3F,OAAO,OAAO,CAAC;QACb,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,wBAAwB;QAC9B,KAAK,EAAE,MAAM;QACb,MAAM,EAAE,4BAA4B;QACpC,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,IAAmE;IAC1G,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC;QAC9B,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,uBAAuB;QAC7B,IAAI;QACJ,MAAM,EAAE,4BAA4B;QACpC,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,yEAAyE;IACzE,0EAA0E;IAC1E,0EAA0E;IAC1E,uEAAuE;IACvE,mEAAmE;IACnE,+DAA+D;IAC/D,kBAAkB,EAAE,CAAC;IACrB,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -22,6 +22,17 @@
|
|
|
22
22
|
* These are client-side display predicates. The backend remains the authority;
|
|
23
23
|
* mirroring its rules here only stops the UI from showing privileged surfaces
|
|
24
24
|
* the server would refuse.
|
|
25
|
+
*
|
|
26
|
+
* **This module is shared with the rest of the plugin fleet.** `./authorization`
|
|
27
|
+
* is the one subpath of this package a sibling business plugin may import: the
|
|
28
|
+
* fleet's `no-cross-plugin-import` gate (`C12`) exempts that exact specifier so
|
|
29
|
+
* `RBAC-06` — one role hierarchy across the fleet — is met by an import rather
|
|
30
|
+
* than by a copy each plugin has to pin with a test. The exemption is
|
|
31
|
+
* conditional on this file staying pure, and the `authorization-purity` gate in
|
|
32
|
+
* `scripts/verify-fleet-gates.mjs` enforces it in all four plugins: it walks
|
|
33
|
+
* this module's import closure and fails on React, on any bare dependency other
|
|
34
|
+
* than `zod`, or on any read of a runtime global. Keep it framework-neutral and
|
|
35
|
+
* effect-free — anything else here breaks every sibling plugin's build.
|
|
25
36
|
*/
|
|
26
37
|
import { type RoleType } from "./schemas.js";
|
|
27
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../../src/runtime/authorization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../../src/runtime/authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7D;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,QAAQ,EAA2B,CAAC;AAiBzE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,GAAG,OAAO,CAKrF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAI1F;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,GAAG,OAAO,CAIpF"}
|
|
@@ -22,6 +22,17 @@
|
|
|
22
22
|
* These are client-side display predicates. The backend remains the authority;
|
|
23
23
|
* mirroring its rules here only stops the UI from showing privileged surfaces
|
|
24
24
|
* the server would refuse.
|
|
25
|
+
*
|
|
26
|
+
* **This module is shared with the rest of the plugin fleet.** `./authorization`
|
|
27
|
+
* is the one subpath of this package a sibling business plugin may import: the
|
|
28
|
+
* fleet's `no-cross-plugin-import` gate (`C12`) exempts that exact specifier so
|
|
29
|
+
* `RBAC-06` — one role hierarchy across the fleet — is met by an import rather
|
|
30
|
+
* than by a copy each plugin has to pin with a test. The exemption is
|
|
31
|
+
* conditional on this file staying pure, and the `authorization-purity` gate in
|
|
32
|
+
* `scripts/verify-fleet-gates.mjs` enforces it in all four plugins: it walks
|
|
33
|
+
* this module's import closure and fails on React, on any bare dependency other
|
|
34
|
+
* than `zod`, or on any read of a runtime global. Keep it framework-neutral and
|
|
35
|
+
* effect-free — anything else here breaks every sibling plugin's build.
|
|
25
36
|
*/
|
|
26
37
|
import { RoleTypeSchema } from "./schemas.js";
|
|
27
38
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../src/runtime/authorization.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"authorization.js","sourceRoot":"","sources":["../../../src/runtime/authorization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,cAAc,EAAiB,MAAM,cAAc,CAAC;AAE7D;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB,cAAc,CAAC,OAAO,CAAC;AAEzE,wDAAwD;AACxD,MAAM,eAAe,GAAa,YAAY,CAAC;AAE/C;;;;;;;GAOG;AACH,SAAS,WAAW,CAAC,IAAc;IACjC,OAAO,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACtC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAAC,WAAqB,EAAE,YAAsB;IAC1E,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACnD,MAAM,QAAQ,GAAG,aAAa,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACrD,IAAI,OAAO,KAAK,CAAC,CAAC,IAAI,QAAQ,KAAK,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,OAAO,OAAO,IAAI,QAAQ,CAAC;AAC7B,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,4BAA4B,CAAC,IAAc,EAAE,WAAoB;IAC/E,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACrC,IAAI,IAAI,KAAK,eAAe;QAAE,OAAO,WAAW,KAAK,IAAI,CAAC;IAC1D,OAAO,WAAW,KAAK,KAAK,CAAC;AAC/B,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAc,EAAE,WAAoB;IACzE,OAAO,4BAA4B,CAAC,IAAI,EAAE,WAAW,CAAC;WACjD,IAAI,KAAK,eAAe;WACxB,WAAW,KAAK,IAAI,CAAC;AAC5B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/runtime/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/runtime/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAOxB,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEnF,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAC9B,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAC;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ5C;AAqCD,wBAAsB,OAAO,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAuDvE"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getAuthConfig } from "./config.js";
|
|
2
2
|
import { ApiError, normalizeFastApiError, UnauthenticatedError } from "./errors.js";
|
|
3
|
+
import { markSessionPresent } from "./sessionHint.js";
|
|
3
4
|
import { getToken, runRefresh, setToken } from "./tokenStore.js";
|
|
4
5
|
import { TokenSchema } from "./schemas.js";
|
|
5
6
|
export * from "./api/index.js";
|
|
@@ -40,6 +41,13 @@ async function refreshAccessToken() {
|
|
|
40
41
|
if (!response.ok)
|
|
41
42
|
return null;
|
|
42
43
|
const token = TokenSchema.parse(await response.json());
|
|
44
|
+
// A rotation the service honoured proves the cookie is still good, so a
|
|
45
|
+
// stale "no session" hint must not survive it - otherwise a tab that
|
|
46
|
+
// refreshed successfully here would still skip its bootstrap on the next
|
|
47
|
+
// page load. Only the success path: this returns `null` for *any* non-ok
|
|
48
|
+
// response, so it cannot tell a 401 from a 500 and must never record the
|
|
49
|
+
// negative. See sessionHint.ts.
|
|
50
|
+
markSessionPresent();
|
|
43
51
|
return token.access_token;
|
|
44
52
|
}
|
|
45
53
|
export async function request(options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/runtime/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CA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IAAI,CAAC,CAAC;YACf,MAAM,IAAI,oBAAoB,CAAC,uCAAuC,CAAC,CAAC;QAC1E,CAAC;IACH,CAAC;IAED,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,QAAQ,CAAC,IAAI,CAAC,CAAC;YACf,MAAM,IAAI,oBAAoB,EAAE,CAAC;QACnC,CAAC;QACD,MAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,uBAAuB,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/E,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,SAAc,CAAC;IACnD,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../src/runtime/react/AuthProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthProvider.d.ts","sourceRoot":"","sources":["../../../../src/runtime/react/AuthProvider.tsx"],"names":[],"mappings":"AACA,OAAO,EAAwE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7G,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAKhD,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IACnE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,EAAE,MAAM,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,CAAC;CAC1C,CAAC;AAkEF,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAgB,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAE,+BAQrJ;AAwHD,wBAAgB,OAAO,IAAI,gBAAgB,CAI1C"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient } from "@tanstack/react-query";
|
|
2
3
|
import { createContext, useCallback, useContext, useEffect, useMemo, useState } from "react";
|
|
3
4
|
import { configureAuth } from "../config.js";
|
|
4
5
|
import { login as apiLogin, logout as apiLogout, refreshToken } from "../api/auth.js";
|
|
5
6
|
import { getProfile } from "../api/profile.js";
|
|
6
7
|
import { AUTH_REVOCATION_EVENT } from "../authEvents.js";
|
|
8
|
+
import { ApiError } from "../errors.js";
|
|
9
|
+
import { authKeys } from "../queryKeys.js";
|
|
10
|
+
import { isSessionKnownAbsent, markSessionAbsent, markSessionPresent } from "../sessionHint.js";
|
|
11
|
+
import { runRefresh, setToken } from "../tokenStore.js";
|
|
7
12
|
import { AuthQueryProvider } from "./AuthQueryProvider.js";
|
|
8
13
|
const AuthContext = createContext(null);
|
|
9
14
|
const AUTH_SESSION_EVENT = "fa-auth-m8:session";
|
|
@@ -20,16 +25,42 @@ function bootstrapSession() {
|
|
|
20
25
|
const now = Date.now();
|
|
21
26
|
if (bootstrapFailureUntil > now)
|
|
22
27
|
return Promise.resolve(null);
|
|
28
|
+
// A prior bootstrap already confirmed this browser has no session: skip
|
|
29
|
+
// the refresh call outright rather than making another one fa-auth-m8 has
|
|
30
|
+
// no cookie to answer. See sessionHint.ts for why this is a negative-only
|
|
31
|
+
// hint and not a read of the actual (HttpOnly) cookie.
|
|
32
|
+
if (isSessionKnownAbsent())
|
|
33
|
+
return Promise.resolve(null);
|
|
23
34
|
if (!bootstrapSessionPromise) {
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
// Routed through the shared `runRefresh` guard so a page mounting this
|
|
36
|
+
// bootstrap alongside client.ts's own 401-triggered refresh (over one
|
|
37
|
+
// expired token) issues at most one rotation, not two: whichever call
|
|
38
|
+
// reaches `runRefresh` first performs the request, the other piggybacks
|
|
39
|
+
// on its result. `refreshToken()` keeps its own single-flight guard for
|
|
40
|
+
// callers that use it directly; nesting it under `runRefresh` here only
|
|
41
|
+
// adds the cross-path coordination `runRefresh` exists for.
|
|
42
|
+
bootstrapSessionPromise = runRefresh(() => refreshToken().then((token) => token.access_token))
|
|
43
|
+
.then((accessToken) => {
|
|
44
|
+
setToken(accessToken);
|
|
45
|
+
return getProfile();
|
|
46
|
+
})
|
|
26
47
|
.then((profile) => {
|
|
27
48
|
bootstrapFailureUntil = 0;
|
|
49
|
+
markSessionPresent();
|
|
28
50
|
emitAuthSession(profile);
|
|
29
51
|
return profile;
|
|
30
52
|
})
|
|
31
53
|
.catch((err) => {
|
|
32
54
|
bootstrapFailureUntil = Date.now() + BOOTSTRAP_FAILURE_COOLDOWN_MS;
|
|
55
|
+
// Only a 401 proves there is no session. A 500, a timeout or an
|
|
56
|
+
// offline load says nothing about the cookie, and the hint has no
|
|
57
|
+
// expiry - recording "no session" from one of those would make every
|
|
58
|
+
// later load skip the refresh and leave a validly signed-in user
|
|
59
|
+
// looking signed out until they logged in by hand. Those keep only
|
|
60
|
+
// the short `bootstrapFailureUntil` cooldown above, which lapses and
|
|
61
|
+
// retries on its own, exactly as before this hint existed.
|
|
62
|
+
if (err instanceof ApiError && err.status === 401)
|
|
63
|
+
markSessionAbsent();
|
|
33
64
|
throw err;
|
|
34
65
|
})
|
|
35
66
|
.finally(() => {
|
|
@@ -41,13 +72,28 @@ function bootstrapSession() {
|
|
|
41
72
|
export function AuthProvider({ children, config, bootstrap = true }) {
|
|
42
73
|
if (config)
|
|
43
74
|
configureAuth(config);
|
|
75
|
+
return (_jsx(AuthQueryProvider, { children: _jsx(AuthProviderInner, { bootstrap: bootstrap, children: children }) }));
|
|
76
|
+
}
|
|
77
|
+
function AuthProviderInner({ children, bootstrap }) {
|
|
78
|
+
const queryClient = useQueryClient();
|
|
44
79
|
const [user, setUser] = useState(null);
|
|
45
80
|
const [loading, setLoading] = useState(bootstrap);
|
|
46
81
|
const [error, setError] = useState(null);
|
|
82
|
+
// The identity lookup a screen's own `useProfile()` runs is a separate
|
|
83
|
+
// react-query cache entry from this state; without seeding it here, a
|
|
84
|
+
// screen mounting both ends up making two `me` requests for the one
|
|
85
|
+
// answer this provider already has. Every place that learns the true
|
|
86
|
+
// profile - bootstrap, login, reload, the cross-provider session event,
|
|
87
|
+
// revocation - routes through this so `useProfile()` reads it as already
|
|
88
|
+
// fresh instead of refetching.
|
|
89
|
+
const applyUser = useCallback((profile) => {
|
|
90
|
+
setUser(profile);
|
|
91
|
+
queryClient.setQueryData(authKeys.profile(), profile);
|
|
92
|
+
}, [queryClient]);
|
|
47
93
|
useEffect(() => {
|
|
48
94
|
const onSession = (event) => {
|
|
49
95
|
const nextUser = event.detail?.user ?? null;
|
|
50
|
-
|
|
96
|
+
applyUser(nextUser);
|
|
51
97
|
setError(null);
|
|
52
98
|
setLoading(false);
|
|
53
99
|
};
|
|
@@ -55,20 +101,20 @@ export function AuthProvider({ children, config, bootstrap = true }) {
|
|
|
55
101
|
return () => {
|
|
56
102
|
window.removeEventListener(AUTH_SESSION_EVENT, onSession);
|
|
57
103
|
};
|
|
58
|
-
}, []);
|
|
104
|
+
}, [applyUser]);
|
|
59
105
|
const reload = useCallback(async () => {
|
|
60
106
|
try {
|
|
61
107
|
const profile = await getProfile();
|
|
62
|
-
|
|
108
|
+
applyUser(profile);
|
|
63
109
|
setError(null);
|
|
64
110
|
return profile;
|
|
65
111
|
}
|
|
66
112
|
catch (err) {
|
|
67
|
-
|
|
113
|
+
applyUser(null);
|
|
68
114
|
setError(err);
|
|
69
115
|
return null;
|
|
70
116
|
}
|
|
71
|
-
}, []);
|
|
117
|
+
}, [applyUser]);
|
|
72
118
|
useEffect(() => {
|
|
73
119
|
if (!bootstrap)
|
|
74
120
|
return;
|
|
@@ -77,13 +123,13 @@ export function AuthProvider({ children, config, bootstrap = true }) {
|
|
|
77
123
|
bootstrapSession()
|
|
78
124
|
.then((profile) => {
|
|
79
125
|
if (!cancelled) {
|
|
80
|
-
|
|
126
|
+
applyUser(profile);
|
|
81
127
|
setError(null);
|
|
82
128
|
}
|
|
83
129
|
})
|
|
84
130
|
.catch((err) => {
|
|
85
131
|
if (!cancelled) {
|
|
86
|
-
|
|
132
|
+
applyUser(null);
|
|
87
133
|
setError(err);
|
|
88
134
|
}
|
|
89
135
|
})
|
|
@@ -94,7 +140,7 @@ export function AuthProvider({ children, config, bootstrap = true }) {
|
|
|
94
140
|
return () => {
|
|
95
141
|
cancelled = true;
|
|
96
142
|
};
|
|
97
|
-
}, [bootstrap,
|
|
143
|
+
}, [bootstrap, applyUser]);
|
|
98
144
|
// AA-11: `revocation_enqueued: true` means the backend has already revoked the
|
|
99
145
|
// target principal's sessions and is propagating an authorization-generation
|
|
100
146
|
// bump. When that principal is the signed-in one, the claims held here are
|
|
@@ -118,21 +164,23 @@ export function AuthProvider({ children, config, bootstrap = true }) {
|
|
|
118
164
|
};
|
|
119
165
|
}, [reload, user?.id]);
|
|
120
166
|
const login = useCallback(async (username, password) => {
|
|
167
|
+
// `apiLogin` / `apiLogout` own the session hint (see sessionHint.ts), so
|
|
168
|
+
// it is deliberately not written again here.
|
|
121
169
|
await apiLogin(username, password);
|
|
122
170
|
const profile = await getProfile();
|
|
123
171
|
bootstrapFailureUntil = 0;
|
|
124
|
-
|
|
172
|
+
applyUser(profile);
|
|
125
173
|
setError(null);
|
|
126
174
|
emitAuthSession(profile);
|
|
127
175
|
return profile;
|
|
128
|
-
}, []);
|
|
176
|
+
}, [applyUser]);
|
|
129
177
|
const logout = useCallback(async () => {
|
|
130
178
|
await apiLogout();
|
|
131
|
-
|
|
179
|
+
applyUser(null);
|
|
132
180
|
emitAuthSession(null);
|
|
133
|
-
}, []);
|
|
181
|
+
}, [applyUser]);
|
|
134
182
|
const value = useMemo(() => ({ user, loading, error, login, logout, reload }), [user, loading, error, login, logout, reload]);
|
|
135
|
-
return
|
|
183
|
+
return _jsx(AuthContext.Provider, { value: value, children: children });
|
|
136
184
|
}
|
|
137
185
|
export function useAuth() {
|
|
138
186
|
const context = useContext(AuthContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthProvider.js","sourceRoot":"","sources":["../../../../src/runtime/react/AuthProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC7G,OAAO,EAAE,aAAa,EAA0B,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,IAAI,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAA6B,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AuthProvider.js","sourceRoot":"","sources":["../../../../src/runtime/react/AuthProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AAC7G,OAAO,EAAE,aAAa,EAA0B,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,KAAK,IAAI,QAAQ,EAAE,MAAM,IAAI,SAA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CAAC,CAAC;QAChB,eAAe,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,MAAM,KAAK,GAAG,OAAO,CAAmB,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAChJ,OAAO,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAwB,CAAC;AAC/E,CAAC;AAED,MAAM,UAAU,OAAO;IACrB,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAC1E,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort local record of "this browser is known to have no session",
|
|
3
|
+
* used only to decide whether `AuthProvider`'s bootstrap should skip the
|
|
4
|
+
* refresh call it would otherwise make unconditionally on every page load.
|
|
5
|
+
*
|
|
6
|
+
* This is not a security boundary and never gates anything the identity
|
|
7
|
+
* service itself decides. The actual session lives in `fa-auth-m8`'s
|
|
8
|
+
* `refresh_token` cookie, which that service sets `HttpOnly`
|
|
9
|
+
* (`auth_user_service/routes/login.py`), so this runtime cannot read it -
|
|
10
|
+
* and, `fa-auth-m8` behaviour being out of scope, does not work around that.
|
|
11
|
+
*
|
|
12
|
+
* The hint therefore only ever records a *negative*: cleared (unknown /
|
|
13
|
+
* possibly present) by default and whenever a session is established, set
|
|
14
|
+
* only when the service has actually refused a refresh with a `401`, or on
|
|
15
|
+
* logout. An unset hint always attempts the refresh, exactly as this runtime
|
|
16
|
+
* behaved before the hint existed, so a browser carrying a still-valid cookie
|
|
17
|
+
* is never signed out by a guess; only a browser already shown to have no
|
|
18
|
+
* session skips the next attempt. A transient failure (a `500`, an offline
|
|
19
|
+
* load) must never set it, since it has no expiry. `runRefresh` and the API
|
|
20
|
+
* client's own `401` handling remain the real authority.
|
|
21
|
+
*
|
|
22
|
+
* Written from `api/auth.ts` and `api/oauth.ts` - beside `setToken` /
|
|
23
|
+
* `clearToken`, at the points that actually establish or destroy the session
|
|
24
|
+
* - so every consumer is covered, including a host that builds its own
|
|
25
|
+
* sign-in UI on the API wrappers instead of mounting `AuthProvider`.
|
|
26
|
+
*
|
|
27
|
+
* Because those are core sign-in paths, every access is guarded: a runtime
|
|
28
|
+
* with no Web Storage (this package's own node-environment tests, a non-DOM
|
|
29
|
+
* consumer) or one that refuses access to it (storage disabled in an
|
|
30
|
+
* embedded frame) must lose the optimisation, never the sign-in.
|
|
31
|
+
*/
|
|
32
|
+
export declare function isSessionKnownAbsent(): boolean;
|
|
33
|
+
export declare function markSessionAbsent(): void;
|
|
34
|
+
export declare function markSessionPresent(): void;
|
|
35
|
+
//# sourceMappingURL=sessionHint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionHint.d.ts","sourceRoot":"","sources":["../../../src/runtime/sessionHint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAQH,wBAAgB,oBAAoB,IAAI,OAAO,CAQ9C;AAED,wBAAgB,iBAAiB,IAAI,IAAI,CAMxC;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAQzC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best-effort local record of "this browser is known to have no session",
|
|
3
|
+
* used only to decide whether `AuthProvider`'s bootstrap should skip the
|
|
4
|
+
* refresh call it would otherwise make unconditionally on every page load.
|
|
5
|
+
*
|
|
6
|
+
* This is not a security boundary and never gates anything the identity
|
|
7
|
+
* service itself decides. The actual session lives in `fa-auth-m8`'s
|
|
8
|
+
* `refresh_token` cookie, which that service sets `HttpOnly`
|
|
9
|
+
* (`auth_user_service/routes/login.py`), so this runtime cannot read it -
|
|
10
|
+
* and, `fa-auth-m8` behaviour being out of scope, does not work around that.
|
|
11
|
+
*
|
|
12
|
+
* The hint therefore only ever records a *negative*: cleared (unknown /
|
|
13
|
+
* possibly present) by default and whenever a session is established, set
|
|
14
|
+
* only when the service has actually refused a refresh with a `401`, or on
|
|
15
|
+
* logout. An unset hint always attempts the refresh, exactly as this runtime
|
|
16
|
+
* behaved before the hint existed, so a browser carrying a still-valid cookie
|
|
17
|
+
* is never signed out by a guess; only a browser already shown to have no
|
|
18
|
+
* session skips the next attempt. A transient failure (a `500`, an offline
|
|
19
|
+
* load) must never set it, since it has no expiry. `runRefresh` and the API
|
|
20
|
+
* client's own `401` handling remain the real authority.
|
|
21
|
+
*
|
|
22
|
+
* Written from `api/auth.ts` and `api/oauth.ts` - beside `setToken` /
|
|
23
|
+
* `clearToken`, at the points that actually establish or destroy the session
|
|
24
|
+
* - so every consumer is covered, including a host that builds its own
|
|
25
|
+
* sign-in UI on the API wrappers instead of mounting `AuthProvider`.
|
|
26
|
+
*
|
|
27
|
+
* Because those are core sign-in paths, every access is guarded: a runtime
|
|
28
|
+
* with no Web Storage (this package's own node-environment tests, a non-DOM
|
|
29
|
+
* consumer) or one that refuses access to it (storage disabled in an
|
|
30
|
+
* embedded frame) must lose the optimisation, never the sign-in.
|
|
31
|
+
*/
|
|
32
|
+
const STORAGE_KEY = "fa-auth-m8:no-session";
|
|
33
|
+
function store() {
|
|
34
|
+
return typeof localStorage === "undefined" ? null : localStorage;
|
|
35
|
+
}
|
|
36
|
+
export function isSessionKnownAbsent() {
|
|
37
|
+
try {
|
|
38
|
+
return store()?.getItem(STORAGE_KEY) === "1";
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
// Unreadable storage is "unknown", which attempts the refresh - the safe
|
|
42
|
+
// direction, and the behaviour that predates this hint.
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function markSessionAbsent() {
|
|
47
|
+
try {
|
|
48
|
+
store()?.setItem(STORAGE_KEY, "1");
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Losing the write only costs one refused refresh on the next load.
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function markSessionPresent() {
|
|
55
|
+
try {
|
|
56
|
+
store()?.removeItem(STORAGE_KEY);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Losing the clear is the dangerous direction, so it is deliberately the
|
|
60
|
+
// one an unreadable store also fails into: `isSessionKnownAbsent` returns
|
|
61
|
+
// false when it cannot read, so the refresh is still attempted.
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=sessionHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sessionHint.js","sourceRoot":"","sources":["../../../src/runtime/sessionHint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAE5C,SAAS,KAAK;IACZ,OAAO,OAAO,YAAY,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC;QACH,OAAO,KAAK,EAAE,EAAE,OAAO,CAAC,WAAW,CAAC,KAAK,GAAG,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;QACzE,wDAAwD;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,IAAI,CAAC;QACH,KAAK,EAAE,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,oEAAoE;IACtE,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,IAAI,CAAC;QACH,KAAK,EAAE,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAAC,MAAM,CAAC;QACP,yEAAyE;QACzE,0EAA0E;QAC1E,gEAAgE;IAClE,CAAC;AACH,CAAC"}
|