@molecule/app-auth 1.3.1 → 1.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/README.md CHANGED
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-17T07:07:31.667Z
6
+ Generated: 2026-10-17T22:19:09.079Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-auth
@@ -17,6 +17,61 @@ client; `setClient`/`getClient` bond it; `login`/`logout`/`register`/
17
17
  bindings (e.g. `AuthProvider`/`useAuth` in `@molecule/app-react`) wrap the
18
18
  same client.
19
19
 
20
+ **In a scaffolded app, wire it by hand — the sandbox cannot run `mlcl add`.**
21
+ The package is already installed; create the client once at startup with
22
+ `setClient(createJWTAuthClient({ baseURL, authScheme: 'Token', storage:
23
+ createBrowserStorageAdapter() }))`, or `createDefaultAuthClient(authConfig)`
24
+ from `@molecule/app-bonds-default-react` (which also registers
25
+ `whenRestored()` as the HTTP gate), call `initialize()`, and read the session
26
+ through `MoleculeProvider`/`useAuth()` in a React app.
27
+
28
+ **`initialize()` restores the session BEFORE the first render, and no
29
+ hand-rolled token store may replace it.** With the token AND user in the
30
+ store the restore is synchronous and costs no request; with an httpOnly
31
+ session cookie the API sets at login it restores through
32
+ `currentUserEndpoint` (default `/users/me`). `AuthClientConfig.storage` is
33
+ the config field that decides which route a reload takes. A store written
34
+ beside the client answers requests before its own restore settles: the first
35
+ authenticated page renders signed-out, and its 401 signs the user out for
36
+ good.
37
+
38
+ **Never fetch viewer-dependent data before the restore settles.** A
39
+ component effect that runs on mount fires while `initialize()` is still
40
+ restoring, so its request leaves without the `Authorization` header and the
41
+ server answers for an anonymous viewer — a followed user renders "Follow", a
42
+ saved item renders unsaved. On localhost the restore usually wins this race;
43
+ over the network it does not, so the bug appears only on the deployed URL.
44
+ Gate the fetch on the auth state being settled (`state.initialized`), or let
45
+ the HTTP client do it: `@molecule/app-bonds-default-react` registers
46
+ `whenRestored()` as the gate so every request waits for the restore.
47
+
48
+ **`getState().status` is the session state to render, in one value.**
49
+ `'loading'` (no decision yet) → `'authenticated'` / `'unauthenticated'`, and
50
+ `'unavailable'` when a stored session exists but the server could not confirm it.
51
+ `validateSession()` is the background re-check that produces the last two: call
52
+ it after the first render — a 4xx clears the token (`'unauthenticated'`), a
53
+ network failure or 5xx KEEPS it (`'unavailable'`, retryable). Do not build a
54
+ `validating`/`unavailable` flag beside the client: a second module-level state
55
+ plus its own listener set is a second session store, and it drifts from the
56
+ client's.
57
+
58
+ **A token another tool reads at its own key is a CONFIG field, not a mirror.**
59
+ An e2e suite or host page that expects `localStorage.jwtToken` (the RealWorld
60
+ specs do) is satisfied by `tokenKey: 'jwtToken'` with
61
+ `storage: createBrowserStorageAdapter()`; writing the token into that key from a
62
+ subscription beside the client is a second store. In React, `useAuth()` from
63
+ `@molecule/app-react` returns the client's `state` (with `status`), `user` and
64
+ `isAuthenticated`; the token is `useAuthClient().getAccessToken()`.
65
+
66
+ **A store that registers its own gate must exempt the restore's own request.**
67
+ This client restores with `fetch`, so the gate registered over it never holds
68
+ the restore. A store that restores THROUGH the bonded HTTP client and
69
+ registers that restore as the gate (`setAuthGate(() => store.whenSettled())`)
70
+ waits on itself unless the restore's request passes `skipAuthGate: true` —
71
+ otherwise the gate holds the very request it is waiting for, and every
72
+ request it holds stalls until the gate times out. See
73
+ `RequestConfig.skipAuthGate` in `@molecule/app-http`.
74
+
20
75
  > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
21
76
  > It is written to be read by coding agents as much as by people, and is generated from this
22
77
  > package's source — edit `src/index.ts` JSDoc, not this file.
@@ -244,6 +299,12 @@ Reactive authentication state snapshot (initialized, authenticated, user, loadin
244
299
 
245
300
  ```typescript
246
301
  interface AuthState<T = UserProfile> {
302
+ /**
303
+ * The session's state as one value — render from this instead of combining
304
+ * `initialized`/`authenticated`/`loading`. See {@link AuthStatus}.
305
+ */
306
+ status: AuthStatus
307
+
247
308
  /**
248
309
  * Whether auth state has been initialized.
249
310
  */
@@ -366,6 +427,27 @@ interface AuthClient<T = UserProfile> {
366
427
  */
367
428
  initialize(): Promise<void>
368
429
 
430
+ /**
431
+ * Re-checks a restored session against the server, in the background — the
432
+ * boot-time validation an app with a stored token needs when a revoked or
433
+ * expired token must sign the user out. Call it AFTER the first render
434
+ * (`initialize()` restores synchronously from storage; this costs one request).
435
+ *
436
+ * - The server confirms the user: the session is refreshed and {@link AuthState.status}
437
+ * stays `'authenticated'`.
438
+ * - The server answers 4xx: the token is dead — the stored session is cleared and
439
+ * the status becomes `'unauthenticated'`.
440
+ * - The server cannot answer (network failure or 5xx): the session is KEPT and the
441
+ * status becomes `'unavailable'`, so the app can retry instead of signing the
442
+ * user out over a bad connection.
443
+ *
444
+ * Do not hand-write this beside the client: a parallel token/user store for a
445
+ * "validating"/"unavailable" flag is the race this method removes.
446
+ *
447
+ * Optional: a provider with no restorable session has nothing to validate.
448
+ */
449
+ validateSession?(): Promise<void>
450
+
369
451
  /**
370
452
  * Resolves when the session restore started by `initialize()` has settled — the point
371
453
  * after which the client knows whether this visitor is signed in.
@@ -479,6 +561,18 @@ interface AuthClientConfig {
479
561
  */
480
562
  storagePrefix?: string
481
563
 
564
+ /**
565
+ * The EXACT `StorageAdapter` key the access token is written under (default
566
+ * `${storagePrefix}accessToken`).
567
+ *
568
+ * Set it when something outside this package reads the token at its own key —
569
+ * an e2e suite's contract (RealWorld's specs read `localStorage.jwtToken`), a
570
+ * second library, a host page — instead of mirroring the token into
571
+ * `localStorage` beside the client. The refresh token and the cached user keep
572
+ * the prefix.
573
+ */
574
+ tokenKey?: string
575
+
482
576
  /**
483
577
  * Scheme of the `Authorization` header the access token is sent with:
484
578
  * `Bearer` (default), or e.g. `Token` for an API that reads
@@ -621,6 +715,24 @@ Which Web Storage area {@link createBrowserStorageAdapter} persists to:
621
715
  type BrowserStorageKind = 'local' | 'session'
622
716
  ```
623
717
 
718
+ #### `AuthStatus`
719
+
720
+ The single value an app renders the session from — the four states every auth
721
+ UI needs, derived from {@link AuthState} so no caller has to combine
722
+ `initialized`/`authenticated`/`loading`/`error` itself.
723
+
724
+ - `'loading'`: no decision yet (before `initialize()` settles, or an auth
725
+ operation is in flight).
726
+ - `'authenticated'`: a session exists.
727
+ - `'unauthenticated'`: the client settled the question and nobody is signed in.
728
+ - `'unavailable'`: a stored session exists but the server could not confirm it
729
+ (a network or 5xx failure in {@link AuthClient.validateSession}); the session
730
+ is KEPT and the app can say "reconnecting" instead of signing the user out.
731
+
732
+ ```typescript
733
+ type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated' | 'unavailable'
734
+ ```
735
+
624
736
  #### `AuthEvent`
625
737
 
626
738
  Auth event types.
@@ -648,6 +760,13 @@ type AuthEventListener = (event: AuthEvent) => void
648
760
 
649
761
  The auth client's `StorageAdapter` over the browser's Web Storage.
650
762
 
763
+ **The restore it enables costs NO request — never block the first paint on one.** With the
764
+ token AND the user in the store, `initialize()` restores the authenticated state synchronously
765
+ (`whenRestored()` is already resolved on the first render); render from it, and validate the
766
+ token as a background request — never in front of the first render. A page that waits on its
767
+ own `/me` call pays a round trip on EVERY navigation (xr-molecule-flash-m122: a 1–5 s restore
768
+ window, eight `waitForURL` timeouts).
769
+
651
770
  Pass it as `AuthClientConfig.storage` to keep the session across a page reload:
652
771
  the client's default (`'memory'`) is lost on reload, and re-establishing the
653
772
  session then needs a credential that survived — this adapter, or an httpOnly
@@ -665,15 +784,15 @@ const authClient = createJWTAuthClient({
665
784
  The scaffold's `authConfig` already passes it, so a scaffolded app survives a
666
785
  reload out of the box; each of these replaces that default:
667
786
 
668
- ```ts
787
+ ````ts
669
788
  storage: 'memory' // memory only: pair it with an httpOnly cookie session
670
789
  storage: createBrowserStorageAdapter({ kind: 'session' }) // survives a reload, dies with the tab
671
- storage: { getItem: (k) => …, setItem: (k, v) => …, removeItem: (k) => … } // your own
672
- ```
790
+
791
+ *(description truncated — read the full text in `node_modules/@molecule/app-auth/dist/browser-storage.d.ts`.)*
673
792
 
674
793
  ```typescript
675
794
  function createBrowserStorageAdapter(options?: BrowserStorageAdapterOptions): StorageAdapter
676
- ```
795
+ ````
677
796
 
678
797
  - `options` — Which Web Storage area to use, or a store to use directly.
679
798
 
@@ -725,17 +844,22 @@ function hasClient(): boolean
725
844
 
726
845
  **Returns:** `true` if an auth client is bonded.
727
846
 
728
- #### `createTokenStorage(storage, prefix)`
847
+ #### `createTokenStorage(storage, prefix, tokenKey)`
729
848
 
730
849
  Creates a token storage implementation backed by either in-memory
731
850
  storage or a custom `StorageAdapter`.
732
851
 
733
852
  ```typescript
734
- function createTokenStorage(storage?: StorageAdapter | 'memory', prefix?: string): TokenStorage
853
+ function createTokenStorage(
854
+ storage?: StorageAdapter | 'memory',
855
+ prefix?: string,
856
+ tokenKey?: string,
857
+ ): TokenStorage
735
858
  ```
736
859
 
737
860
  - `storage` — `'memory'` for in-memory storage (lost on refresh), or a `StorageAdapter` for persistent storage.
738
861
  - `prefix` — Key prefix for storage items (default: `'molecule:auth:'`).
862
+ - `tokenKey` — Exact key for the access token (default `${prefix}accessToken`), for a store another tool reads at its own key.
739
863
 
740
864
  **Returns:** A `TokenStorage` instance.
741
865
 
@@ -855,38 +979,10 @@ Peer dependencies:
855
979
  (`setClient(createJWTAuthClient({ authScheme: 'Token', … }))` in the auth bond), not
856
980
  properties of a client that already exists. Do not hand-write an auth client for a spec
857
981
  like RealWorld.
858
- - **Whether a reload keeps the user signed in is `AuthClientConfig.storage`,
859
- and one of the two routes must be wired.** The client's own default is
860
- `'memory'`, which is lost on reload, so a session survives one only by
861
- having a credential that survived: (1) `storage: createBrowserStorageAdapter()`
862
- — the browser's `localStorage`, what a scaffolded app's `authConfig` passes
863
- (see `@molecule/app-auth`'s `createBrowserStorageAdapter` for the trade: Web
864
- Storage is script-readable, so an XSS can steal the token), or (2) an
865
- httpOnly session cookie the API sets at login, which `initialize()` restores
866
- through `currentUserEndpoint` (default `/users/me`) — the stronger option
867
- wherever the API supports it, and what `@molecule/api-resource-user` issues.
868
- Wire `initialize()` once at startup either way. Do NOT hand-roll a token
869
- store beside the client for this: it is a config field.
870
982
  - **Endpoint defaults must match your API's real routes** (`/auth/login`,
871
983
  `/auth/register`, `/auth/refresh`, `/users/logout`, `/users/me`, …).
872
984
  Align them via `createJWTAuthClient({ baseURL, ...endpoints })` — never by
873
985
  hand-editing fetch calls in components.
874
- - **Do not fetch viewer-dependent data before the restore settles.** A component
875
- effect that runs on mount fires while `initialize()` is still restoring, so its
876
- request leaves without the `Authorization` header and the server answers for an
877
- anonymous viewer — a followed user renders "Follow", a saved item renders unsaved.
878
- On localhost the restore usually wins this race; over the network it does not, so
879
- the bug appears only on the deployed URL. Two ways out: gate the fetch on the auth
880
- state being settled (`state.initialized`), or let the HTTP client do it — bond the
881
- auth client through `@molecule/app-bonds-default-react`, which registers
882
- `whenRestored()` as the http gate so every request waits for the restore.
883
- - **Your own session store's gate must exempt its restore's own request.** This client
884
- restores with `fetch`, so the gate registered over it never holds the restore. A store
885
- that restores THROUGH the bonded HTTP client and registers that restore as the gate
886
- (`setAuthGate(() => store.whenSettled())`) waits on itself unless the restore's request
887
- passes `skipAuthGate: true` — otherwise the gate holds the very request it is waiting
888
- for, and every request it holds stalls until the gate times out. See
889
- `RequestConfig.skipAuthGate` in `@molecule/app-http`.
890
986
  - Client-side auth state is UX only — the server enforces authorization on
891
987
  every request; hiding a screen is not protection.
892
988
 
@@ -31,6 +31,13 @@ export interface BrowserStorageAdapterOptions {
31
31
  /**
32
32
  * The auth client's `StorageAdapter` over the browser's Web Storage.
33
33
  *
34
+ * **The restore it enables costs NO request — never block the first paint on one.** With the
35
+ * token AND the user in the store, `initialize()` restores the authenticated state synchronously
36
+ * (`whenRestored()` is already resolved on the first render); render from it, and validate the
37
+ * token as a background request — never in front of the first render. A page that waits on its
38
+ * own `/me` call pays a round trip on EVERY navigation (xr-molecule-flash-m122: a 1–5 s restore
39
+ * window, eight `waitForURL` timeouts).
40
+ *
34
41
  * Pass it as `AuthClientConfig.storage` to keep the session across a page reload:
35
42
  * the client's default (`'memory'`) is lost on reload, and re-establishing the
36
43
  * session then needs a credential that survived — this adapter, or an httpOnly
@@ -1 +1 @@
1
- {"version":3,"file":"browser-storage.d.ts","sourceRoot":"","sources":["../src/browser-storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAA;AAEpD,4EAA4E;AAC5E,MAAM,WAAW,4BAA4B;IAC3C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAA;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAS,4BAAiC,KACzC,cA6EF,CAAA"}
1
+ {"version":3,"file":"browser-storage.d.ts","sourceRoot":"","sources":["../src/browser-storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAEhD;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,GAAG,SAAS,CAAA;AAEpD,4EAA4E;AAC5E,MAAM,WAAW,4BAA4B;IAC3C;;;;;;OAMG;IACH,IAAI,CAAC,EAAE,kBAAkB,CAAA;IACzB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;CACzB;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;AACH,eAAO,MAAM,2BAA2B,GACtC,UAAS,4BAAiC,KACzC,cA6EF,CAAA"}
@@ -22,6 +22,13 @@ const warn = (message, error) => {
22
22
  /**
23
23
  * The auth client's `StorageAdapter` over the browser's Web Storage.
24
24
  *
25
+ * **The restore it enables costs NO request — never block the first paint on one.** With the
26
+ * token AND the user in the store, `initialize()` restores the authenticated state synchronously
27
+ * (`whenRestored()` is already resolved on the first render); render from it, and validate the
28
+ * token as a background request — never in front of the first render. A page that waits on its
29
+ * own `/me` call pays a round trip on EVERY navigation (xr-molecule-flash-m122: a 1–5 s restore
30
+ * window, eight `waitForURL` timeouts).
31
+ *
25
32
  * Pass it as `AuthClientConfig.storage` to keep the session across a page reload:
26
33
  * the client's default (`'memory'`) is lost on reload, and re-establishing the
27
34
  * session then needs a credential that survived — this adapter, or an httpOnly
@@ -1 +1 @@
1
- {"version":3,"file":"browser-storage.js","sourceRoot":"","sources":["../src/browser-storage.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AA8BhD,gFAAgF;AAChF,MAAM,IAAI,GAAG,CAAC,OAAe,EAAE,KAAe,EAAQ,EAAE;IACtD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,IAAI,KAAK,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;;YACxC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;IACtC,CAAC;IAAC,OAAO,MAAM,EAAE,CAAC;QAChB,2EAA2E;QAC3E,2EAA2E;QAC3E,wBAAwB;IAC1B,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,C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AO,MAAM,mBAAmB,GAAI,CAAC,SAAS,WAAW,GAAG,WAAW,EACrE,SAAQ,gBAAqB,KAC5B,UAAU,CAAC,CAAC,CAudd,CAAA"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAUhB,WAAW,EACZ,MAAM,YAAY,CAAA;AA4CnB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,WAAW,GAAG,WAAW,EACrE,SAAQ,gBAAqB,KAC5B,UAAU,CAAC,CAAC,CAuiBd,CAAA"}
package/dist/client.js CHANGED
@@ -62,7 +62,7 @@ const clearSessionHintCookie = () => {
62
62
  export const createJWTAuthClient = (config = {}) => {
63
63
  const { baseURL = '', loginEndpoint = '/auth/login', logoutEndpoint = '/users/logout', registerEndpoint = '/auth/register', refreshEndpoint = '/auth/refresh', profileEndpoint = '/auth/profile', forgotPasswordEndpoint = '/auth/password/reset', resetPasswordEndpoint = '/auth/password/reset/confirm', changePasswordEndpoint = '/auth/password/change', currentUserEndpoint = '/users/me', storagePrefix = 'molecule:auth:', storage = 'memory', shouldRestoreUser, autoRefresh = true, refreshBuffer = 60, } = config;
64
64
  const logger = getLogger('auth');
65
- const tokenStorage = createTokenStorage(storage, storagePrefix);
65
+ const tokenStorage = createTokenStorage(storage, storagePrefix, config.tokenKey);
66
66
  const stateListeners = new Set();
67
67
  const eventListeners = new Set();
68
68
  let refreshTimer = null;
@@ -72,6 +72,7 @@ export const createJWTAuthClient = (config = {}) => {
72
72
  // already sees the restore and its HTTP requests wait for it (`whenRestored`).
73
73
  let restoreInFlight = null;
74
74
  let state = {
75
+ status: 'loading',
75
76
  initialized: false,
76
77
  authenticated: false,
77
78
  user: null,
@@ -84,8 +85,26 @@ export const createJWTAuthClient = (config = {}) => {
84
85
  const emitEvent = (event) => {
85
86
  eventListeners.forEach((listener) => listener(event));
86
87
  };
88
+ /**
89
+ * The status an update implies. `'unavailable'` is sticky until something
90
+ * actually decides the session (a login/logout, a successful validation, or a
91
+ * 4xx that cleared the token): a later `setState({ error })` must not turn
92
+ * "the server did not answer" into "nobody is signed in".
93
+ */
94
+ const deriveStatus = (next, explicit) => {
95
+ if (explicit)
96
+ return explicit;
97
+ if (next.authenticated)
98
+ return 'authenticated';
99
+ if (next.loading || !next.initialized)
100
+ return 'loading';
101
+ if (state.status === 'unavailable' && tokenStorage.getAccessToken())
102
+ return 'unavailable';
103
+ return 'unauthenticated';
104
+ };
87
105
  const setState = (updates) => {
88
- state = { ...state, ...updates };
106
+ const next = { ...state, ...updates };
107
+ state = { ...next, status: deriveStatus(next, updates.status) };
89
108
  notify();
90
109
  };
91
110
  const scheduleRefresh = () => {
@@ -138,7 +157,12 @@ export const createJWTAuthClient = (config = {}) => {
138
157
  const body = await response.json().catch(() => ({}));
139
158
  const key = body.errorKey ?? 'auth.error.requestFailed';
140
159
  const fallback = body.error ?? body.message ?? 'Request failed';
141
- throw new I18nError(key, undefined, fallback);
160
+ const failure = new I18nError(key, undefined, fallback);
161
+ // The HTTP status, so a caller can tell "this token is dead" (4xx) from
162
+ // "the server did not answer" (5xx) — `validateSession` keeps the session
163
+ // on the latter and clears it on the former.
164
+ failure.status = response.status;
165
+ throw failure;
142
166
  }
143
167
  const data = await response.json();
144
168
  // Compatibility shim: many @molecule/api-resource-* handlers (notably
@@ -315,6 +339,8 @@ export const createJWTAuthClient = (config = {}) => {
315
339
  loading: false,
316
340
  authenticated: false,
317
341
  user: null,
342
+ // An explicit sign-out settles the question, whatever came before.
343
+ status: 'unauthenticated',
318
344
  });
319
345
  logger.debug('User logged out');
320
346
  emitEvent({ type: 'logout' });
@@ -426,6 +452,64 @@ export const createJWTAuthClient = (config = {}) => {
426
452
  // unauthenticated instead (the same outcome as not waiting at all).
427
453
  return restoreInFlight ? restoreInFlight.catch(() => undefined) : Promise.resolve();
428
454
  },
455
+ async validateSession() {
456
+ const token = tokenStorage.getAccessToken();
457
+ if (!token) {
458
+ setState({
459
+ initialized: true,
460
+ authenticated: false,
461
+ user: null,
462
+ status: 'unauthenticated',
463
+ });
464
+ return;
465
+ }
466
+ try {
467
+ // `fetchAPI` sends the stored token, so this asks the server "is this
468
+ // session still valid?" — the background check `initialize()` does not do
469
+ // (it restores from storage without a request by design).
470
+ const result = await fetchAPI(currentUserEndpoint, { method: 'GET' });
471
+ const user = (result?.user ?? tokenStorage.getUser());
472
+ if (user) {
473
+ tokenStorage.setUser(user);
474
+ setState({
475
+ initialized: true,
476
+ authenticated: true,
477
+ user,
478
+ status: 'authenticated',
479
+ error: null,
480
+ });
481
+ }
482
+ else {
483
+ tokenStorage.clear();
484
+ setState({
485
+ initialized: true,
486
+ authenticated: false,
487
+ user: null,
488
+ status: 'unauthenticated',
489
+ });
490
+ }
491
+ }
492
+ catch (error) {
493
+ const httpStatus = error.status;
494
+ if (httpStatus !== undefined && httpStatus >= 400 && httpStatus < 500) {
495
+ // The token is dead (revoked, expired, a reset database): drop the
496
+ // session rather than keep sending a header the server refuses.
497
+ tokenStorage.clear();
498
+ setState({
499
+ initialized: true,
500
+ authenticated: false,
501
+ user: null,
502
+ status: 'unauthenticated',
503
+ });
504
+ return;
505
+ }
506
+ // The server could not answer. Keep the session so a later reload or a
507
+ // retry can restore it; say so with `unavailable` instead of signing the
508
+ // user out over a network failure.
509
+ const message = error instanceof Error ? error.message : 'Session could not be confirmed';
510
+ setState({ status: 'unavailable', error: message });
511
+ }
512
+ },
429
513
  subscribe(callback) {
430
514
  stateListeners.add(callback);
431
515
  return () => stateListeners.delete(callback);
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEhD,OAAO,EAAE,kBAAk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AAK,CAAC,OAAO,CAAC,CAAC,CAAC,gCAAgC,CAAA;gBACzF,QAAQ,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAA;YACrD,CAAC;QACH,CAAC;QAED,SAAS,CAAC,QAAuC;YAC/C,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC5B,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC9C,CAAC;QAED,YAAY,CAAC,QAAuC;YAClD,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC5B,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC9C,CAAC;QAED,QAAQ;YACN,OAAO,YAAY,CAAC,cAAc,EAAE,CAAA;QACtC,CAAC;QAED,gBAAgB,CAAC,QAA2B;YAC1C,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;YAC5B,OAAO,GAAG,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;QAC9C,CAAC;QAED,OAAO;YACL,IAAI,YAAY,EAAE,CAAC;gBACjB,YAAY,CAAC,YAAY,CAAC,CAAA;gBAC1B,YAAY,GAAG,IAAI,CAAA;YACrB,CAAC;YACD,cAAc,CAAC,KAAK,EAAE,CAAA;YACtB,cAAc,CAAC,KAAK,EAAE,CAAA;QACxB,CAAC;KACF,CAAA;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -8,6 +8,61 @@
8
8
  * bindings (e.g. `AuthProvider`/`useAuth` in `@molecule/app-react`) wrap the
9
9
  * same client.
10
10
  *
11
+ * **In a scaffolded app, wire it by hand — the sandbox cannot run `mlcl add`.**
12
+ * The package is already installed; create the client once at startup with
13
+ * `setClient(createJWTAuthClient({ baseURL, authScheme: 'Token', storage:
14
+ * createBrowserStorageAdapter() }))`, or `createDefaultAuthClient(authConfig)`
15
+ * from `@molecule/app-bonds-default-react` (which also registers
16
+ * `whenRestored()` as the HTTP gate), call `initialize()`, and read the session
17
+ * through `MoleculeProvider`/`useAuth()` in a React app.
18
+ *
19
+ * **`initialize()` restores the session BEFORE the first render, and no
20
+ * hand-rolled token store may replace it.** With the token AND user in the
21
+ * store the restore is synchronous and costs no request; with an httpOnly
22
+ * session cookie the API sets at login it restores through
23
+ * `currentUserEndpoint` (default `/users/me`). `AuthClientConfig.storage` is
24
+ * the config field that decides which route a reload takes. A store written
25
+ * beside the client answers requests before its own restore settles: the first
26
+ * authenticated page renders signed-out, and its 401 signs the user out for
27
+ * good.
28
+ *
29
+ * **Never fetch viewer-dependent data before the restore settles.** A
30
+ * component effect that runs on mount fires while `initialize()` is still
31
+ * restoring, so its request leaves without the `Authorization` header and the
32
+ * server answers for an anonymous viewer — a followed user renders "Follow", a
33
+ * saved item renders unsaved. On localhost the restore usually wins this race;
34
+ * over the network it does not, so the bug appears only on the deployed URL.
35
+ * Gate the fetch on the auth state being settled (`state.initialized`), or let
36
+ * the HTTP client do it: `@molecule/app-bonds-default-react` registers
37
+ * `whenRestored()` as the gate so every request waits for the restore.
38
+ *
39
+ * **`getState().status` is the session state to render, in one value.**
40
+ * `'loading'` (no decision yet) → `'authenticated'` / `'unauthenticated'`, and
41
+ * `'unavailable'` when a stored session exists but the server could not confirm it.
42
+ * `validateSession()` is the background re-check that produces the last two: call
43
+ * it after the first render — a 4xx clears the token (`'unauthenticated'`), a
44
+ * network failure or 5xx KEEPS it (`'unavailable'`, retryable). Do not build a
45
+ * `validating`/`unavailable` flag beside the client: a second module-level state
46
+ * plus its own listener set is a second session store, and it drifts from the
47
+ * client's.
48
+ *
49
+ * **A token another tool reads at its own key is a CONFIG field, not a mirror.**
50
+ * An e2e suite or host page that expects `localStorage.jwtToken` (the RealWorld
51
+ * specs do) is satisfied by `tokenKey: 'jwtToken'` with
52
+ * `storage: createBrowserStorageAdapter()`; writing the token into that key from a
53
+ * subscription beside the client is a second store. In React, `useAuth()` from
54
+ * `@molecule/app-react` returns the client's `state` (with `status`), `user` and
55
+ * `isAuthenticated`; the token is `useAuthClient().getAccessToken()`.
56
+ *
57
+ * **A store that registers its own gate must exempt the restore's own request.**
58
+ * This client restores with `fetch`, so the gate registered over it never holds
59
+ * the restore. A store that restores THROUGH the bonded HTTP client and
60
+ * registers that restore as the gate (`setAuthGate(() => store.whenSettled())`)
61
+ * waits on itself unless the restore's request passes `skipAuthGate: true` —
62
+ * otherwise the gate holds the very request it is waiting for, and every
63
+ * request it holds stalls until the gate times out. See
64
+ * `RequestConfig.skipAuthGate` in `@molecule/app-http`.
65
+ *
11
66
  * @remarks
12
67
  * - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
13
68
  * login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
@@ -17,38 +72,10 @@
17
72
  * (`setClient(createJWTAuthClient({ authScheme: 'Token', … }))` in the auth bond), not
18
73
  * properties of a client that already exists. Do not hand-write an auth client for a spec
19
74
  * like RealWorld.
20
- * - **Whether a reload keeps the user signed in is `AuthClientConfig.storage`,
21
- * and one of the two routes must be wired.** The client's own default is
22
- * `'memory'`, which is lost on reload, so a session survives one only by
23
- * having a credential that survived: (1) `storage: createBrowserStorageAdapter()`
24
- * — the browser's `localStorage`, what a scaffolded app's `authConfig` passes
25
- * (see `@molecule/app-auth`'s `createBrowserStorageAdapter` for the trade: Web
26
- * Storage is script-readable, so an XSS can steal the token), or (2) an
27
- * httpOnly session cookie the API sets at login, which `initialize()` restores
28
- * through `currentUserEndpoint` (default `/users/me`) — the stronger option
29
- * wherever the API supports it, and what `@molecule/api-resource-user` issues.
30
- * Wire `initialize()` once at startup either way. Do NOT hand-roll a token
31
- * store beside the client for this: it is a config field.
32
75
  * - **Endpoint defaults must match your API's real routes** (`/auth/login`,
33
76
  * `/auth/register`, `/auth/refresh`, `/users/logout`, `/users/me`, …).
34
77
  * Align them via `createJWTAuthClient({ baseURL, ...endpoints })` — never by
35
78
  * hand-editing fetch calls in components.
36
- * - **Do not fetch viewer-dependent data before the restore settles.** A component
37
- * effect that runs on mount fires while `initialize()` is still restoring, so its
38
- * request leaves without the `Authorization` header and the server answers for an
39
- * anonymous viewer — a followed user renders "Follow", a saved item renders unsaved.
40
- * On localhost the restore usually wins this race; over the network it does not, so
41
- * the bug appears only on the deployed URL. Two ways out: gate the fetch on the auth
42
- * state being settled (`state.initialized`), or let the HTTP client do it — bond the
43
- * auth client through `@molecule/app-bonds-default-react`, which registers
44
- * `whenRestored()` as the http gate so every request waits for the restore.
45
- * - **Your own session store's gate must exempt its restore's own request.** This client
46
- * restores with `fetch`, so the gate registered over it never holds the restore. A store
47
- * that restores THROUGH the bonded HTTP client and registers that restore as the gate
48
- * (`setAuthGate(() => store.whenSettled())`) waits on itself unless the restore's request
49
- * passes `skipAuthGate: true` — otherwise the gate holds the very request it is waiting
50
- * for, and every request it holds stalls until the gate times out. See
51
- * `RequestConfig.skipAuthGate` in `@molecule/app-http`.
52
79
  * - Client-side auth state is UX only — the server enforces authorization on
53
80
  * every request; hiding a screen is not protection.
54
81
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8IG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -8,6 +8,61 @@
8
8
  * bindings (e.g. `AuthProvider`/`useAuth` in `@molecule/app-react`) wrap the
9
9
  * same client.
10
10
  *
11
+ * **In a scaffolded app, wire it by hand — the sandbox cannot run `mlcl add`.**
12
+ * The package is already installed; create the client once at startup with
13
+ * `setClient(createJWTAuthClient({ baseURL, authScheme: 'Token', storage:
14
+ * createBrowserStorageAdapter() }))`, or `createDefaultAuthClient(authConfig)`
15
+ * from `@molecule/app-bonds-default-react` (which also registers
16
+ * `whenRestored()` as the HTTP gate), call `initialize()`, and read the session
17
+ * through `MoleculeProvider`/`useAuth()` in a React app.
18
+ *
19
+ * **`initialize()` restores the session BEFORE the first render, and no
20
+ * hand-rolled token store may replace it.** With the token AND user in the
21
+ * store the restore is synchronous and costs no request; with an httpOnly
22
+ * session cookie the API sets at login it restores through
23
+ * `currentUserEndpoint` (default `/users/me`). `AuthClientConfig.storage` is
24
+ * the config field that decides which route a reload takes. A store written
25
+ * beside the client answers requests before its own restore settles: the first
26
+ * authenticated page renders signed-out, and its 401 signs the user out for
27
+ * good.
28
+ *
29
+ * **Never fetch viewer-dependent data before the restore settles.** A
30
+ * component effect that runs on mount fires while `initialize()` is still
31
+ * restoring, so its request leaves without the `Authorization` header and the
32
+ * server answers for an anonymous viewer — a followed user renders "Follow", a
33
+ * saved item renders unsaved. On localhost the restore usually wins this race;
34
+ * over the network it does not, so the bug appears only on the deployed URL.
35
+ * Gate the fetch on the auth state being settled (`state.initialized`), or let
36
+ * the HTTP client do it: `@molecule/app-bonds-default-react` registers
37
+ * `whenRestored()` as the gate so every request waits for the restore.
38
+ *
39
+ * **`getState().status` is the session state to render, in one value.**
40
+ * `'loading'` (no decision yet) → `'authenticated'` / `'unauthenticated'`, and
41
+ * `'unavailable'` when a stored session exists but the server could not confirm it.
42
+ * `validateSession()` is the background re-check that produces the last two: call
43
+ * it after the first render — a 4xx clears the token (`'unauthenticated'`), a
44
+ * network failure or 5xx KEEPS it (`'unavailable'`, retryable). Do not build a
45
+ * `validating`/`unavailable` flag beside the client: a second module-level state
46
+ * plus its own listener set is a second session store, and it drifts from the
47
+ * client's.
48
+ *
49
+ * **A token another tool reads at its own key is a CONFIG field, not a mirror.**
50
+ * An e2e suite or host page that expects `localStorage.jwtToken` (the RealWorld
51
+ * specs do) is satisfied by `tokenKey: 'jwtToken'` with
52
+ * `storage: createBrowserStorageAdapter()`; writing the token into that key from a
53
+ * subscription beside the client is a second store. In React, `useAuth()` from
54
+ * `@molecule/app-react` returns the client's `state` (with `status`), `user` and
55
+ * `isAuthenticated`; the token is `useAuthClient().getAccessToken()`.
56
+ *
57
+ * **A store that registers its own gate must exempt the restore's own request.**
58
+ * This client restores with `fetch`, so the gate registered over it never holds
59
+ * the restore. A store that restores THROUGH the bonded HTTP client and
60
+ * registers that restore as the gate (`setAuthGate(() => store.whenSettled())`)
61
+ * waits on itself unless the restore's request passes `skipAuthGate: true` —
62
+ * otherwise the gate holds the very request it is waiting for, and every
63
+ * request it holds stalls until the gate times out. See
64
+ * `RequestConfig.skipAuthGate` in `@molecule/app-http`.
65
+ *
11
66
  * @remarks
12
67
  * - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
13
68
  * login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
@@ -17,38 +72,10 @@
17
72
  * (`setClient(createJWTAuthClient({ authScheme: 'Token', … }))` in the auth bond), not
18
73
  * properties of a client that already exists. Do not hand-write an auth client for a spec
19
74
  * like RealWorld.
20
- * - **Whether a reload keeps the user signed in is `AuthClientConfig.storage`,
21
- * and one of the two routes must be wired.** The client's own default is
22
- * `'memory'`, which is lost on reload, so a session survives one only by
23
- * having a credential that survived: (1) `storage: createBrowserStorageAdapter()`
24
- * — the browser's `localStorage`, what a scaffolded app's `authConfig` passes
25
- * (see `@molecule/app-auth`'s `createBrowserStorageAdapter` for the trade: Web
26
- * Storage is script-readable, so an XSS can steal the token), or (2) an
27
- * httpOnly session cookie the API sets at login, which `initialize()` restores
28
- * through `currentUserEndpoint` (default `/users/me`) — the stronger option
29
- * wherever the API supports it, and what `@molecule/api-resource-user` issues.
30
- * Wire `initialize()` once at startup either way. Do NOT hand-roll a token
31
- * store beside the client for this: it is a config field.
32
75
  * - **Endpoint defaults must match your API's real routes** (`/auth/login`,
33
76
  * `/auth/register`, `/auth/refresh`, `/users/logout`, `/users/me`, …).
34
77
  * Align them via `createJWTAuthClient({ baseURL, ...endpoints })` — never by
35
78
  * hand-editing fetch calls in components.
36
- * - **Do not fetch viewer-dependent data before the restore settles.** A component
37
- * effect that runs on mount fires while `initialize()` is still restoring, so its
38
- * request leaves without the `Authorization` header and the server answers for an
39
- * anonymous viewer — a followed user renders "Follow", a saved item renders unsaved.
40
- * On localhost the restore usually wins this race; over the network it does not, so
41
- * the bug appears only on the deployed URL. Two ways out: gate the fetch on the auth
42
- * state being settled (`state.initialized`), or let the HTTP client do it — bond the
43
- * auth client through `@molecule/app-bonds-default-react`, which registers
44
- * `whenRestored()` as the http gate so every request waits for the restore.
45
- * - **Your own session store's gate must exempt its restore's own request.** This client
46
- * restores with `fetch`, so the gate registered over it never holds the restore. A store
47
- * that restores THROUGH the bonded HTTP client and registers that restore as the gate
48
- * (`setAuthGate(() => store.whenSettled())`) waits on itself unless the restore's request
49
- * passes `skipAuthGate: true` — otherwise the gate holds the very request it is waiting
50
- * for, and every request it holds stalls until the gate times out. See
51
- * `RequestConfig.skipAuthGate` in `@molecule/app-http`.
52
79
  * - Client-side auth state is UX only — the server enforces authorization on
53
80
  * every request; hiding a screen is not protection.
54
81
  *
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmHG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8IG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
package/dist/token.d.ts CHANGED
@@ -13,6 +13,8 @@ import type { StorageAdapter, TokenStorage } from './types.js';
13
13
  * @param storage - `'memory'` for in-memory storage (lost on refresh),
14
14
  * or a `StorageAdapter` for persistent storage.
15
15
  * @param prefix - Key prefix for storage items (default: `'molecule:auth:'`).
16
+ * @param tokenKey - Exact key for the access token (default `${prefix}accessToken`),
17
+ * for a store another tool reads at its own key.
16
18
  * @returns A `TokenStorage` instance.
17
19
  *
18
20
  * @example
@@ -25,7 +27,7 @@ import type { StorageAdapter, TokenStorage } from './types.js';
25
27
  * const storage = createTokenStorage(createBrowserStorageAdapter())
26
28
  * ```
27
29
  */
28
- export declare const createTokenStorage: (storage?: "memory" | StorageAdapter, prefix?: string) => TokenStorage;
30
+ export declare const createTokenStorage: (storage?: "memory" | StorageAdapter, prefix?: string, tokenKey?: string) => TokenStorage;
29
31
  /**
30
32
  * Parses a JWT token payload without verification (base64-decodes
31
33
  * the payload segment).
@@ -1 +1 @@
1
- {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAe,MAAM,YAAY,CAAA;AAE3E;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAS,QAAQ,GAAG,cAAyB,EAC7C,SAAQ,MAAyB,KAChC,YAoDF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,KAAG,CAAC,GAAG,IAWzE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,gBAAe,MAAU,KAAG,OAMzE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,IAI3D,CAAA"}
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAe,MAAM,YAAY,CAAA;AAE3E;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAS,QAAQ,GAAG,cAAyB,EAC7C,SAAQ,MAAyB,EACjC,WAAW,MAAM,KAChB,YAsEF,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,GAAI,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,MAAM,KAAG,CAAC,GAAG,IAWzE,CAAA;AAED;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,gBAAe,MAAU,KAAG,OAMzE,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAAI,OAAO,MAAM,KAAG,MAAM,GAAG,IAI3D,CAAA"}
package/dist/token.js CHANGED
@@ -12,6 +12,8 @@
12
12
  * @param storage - `'memory'` for in-memory storage (lost on refresh),
13
13
  * or a `StorageAdapter` for persistent storage.
14
14
  * @param prefix - Key prefix for storage items (default: `'molecule:auth:'`).
15
+ * @param tokenKey - Exact key for the access token (default `${prefix}accessToken`),
16
+ * for a store another tool reads at its own key.
15
17
  * @returns A `TokenStorage` instance.
16
18
  *
17
19
  * @example
@@ -24,13 +26,14 @@
24
26
  * const storage = createTokenStorage(createBrowserStorageAdapter())
25
27
  * ```
26
28
  */
27
- export const createTokenStorage = (storage = 'memory', prefix = 'molecule:auth:') => {
29
+ export const createTokenStorage = (storage = 'memory', prefix = 'molecule:auth:', tokenKey) => {
28
30
  const memoryStore = {};
29
31
  // Determine storage adapter
30
32
  let adapter = null;
31
33
  if (typeof storage === 'object') {
32
34
  adapter = storage;
33
35
  }
36
+ const accessTokenKey = () => tokenKey ?? `${prefix}accessToken`;
34
37
  const get = (key) => {
35
38
  if (adapter) {
36
39
  return adapter.getItem(prefix + key);
@@ -50,9 +53,27 @@ export const createTokenStorage = (storage = 'memory', prefix = 'molecule:auth:'
50
53
  memoryStore[key] = value;
51
54
  }
52
55
  };
56
+ // The access token can live under an exact key (`tokenKey`) that another tool
57
+ // reads; the refresh token and the cached user always use the prefix.
58
+ const getTokenValue = () => {
59
+ if (adapter)
60
+ return adapter.getItem(accessTokenKey());
61
+ return memoryStore.accessToken ?? null;
62
+ };
63
+ const setTokenValue = (value) => {
64
+ if (adapter) {
65
+ if (value === null)
66
+ adapter.removeItem(accessTokenKey());
67
+ else
68
+ adapter.setItem(accessTokenKey(), value);
69
+ }
70
+ else {
71
+ memoryStore.accessToken = value;
72
+ }
73
+ };
53
74
  return {
54
- getAccessToken: () => get('accessToken'),
55
- setAccessToken: (token) => set('accessToken', token),
75
+ getAccessToken: getTokenValue,
76
+ setAccessToken: setTokenValue,
56
77
  getRefreshToken: () => get('refreshToken'),
57
78
  setRefreshToken: (token) => set('refreshToken', token),
58
79
  getUser: () => {
@@ -71,7 +92,7 @@ export const createTokenStorage = (storage = 'memory', prefix = 'molecule:auth:'
71
92
  set('user', user ? JSON.stringify(user) : null);
72
93
  },
73
94
  clear: () => {
74
- set('accessToken', null);
95
+ setTokenValue(null);
75
96
  set('refreshToken', null);
76
97
  set('user', null);
77
98
  },
package/dist/token.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,UAAqC,QAAQ,EAC7C,SAAiB,gBAAgB,EACnB,EAAE;IAChB,MAAM,WAAW,GAAkC,EAAE,CAAA;IAErD,4BAA4B;IAC5B,IAAI,OAAO,GAA0B,IAAI,CAAA;IACzC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,GAAG,OAAO,CAAA;IACnB,CAAC;IAED,MAAM,GAAG,GAAG,CAAC,GAAW,EAAiB,EAAE;QACzC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAA;QACtC,CAAC;QACD,OAAO,WAAW,CAAC,GAAG,CAAC,IAAI,IAAI,CAAA;IACjC,CAAC,CAAA;IAED,MAAM,GAAG,GAAG,CAAC,GAAW,EAAE,KAAoB,EAAQ,EAAE;QACtD,IAAI,OAAO,EAAE,CAAC;YACZ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,OAAO,CAAC,UAAU,CAAC,MAAM,GAAG,GAAG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AE;IACjE,MAAM,OAAO,GAAG,QAAQ,CAAmB,KAAK,CAAC,CAAA;IACjD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG;QAAE,OAAO,IAAI,CAAA;IACzC,OAAO,OAAO,CAAC,GAAG,GAAG,IAAI,CAAA;AAC3B,CAAC,CAAA"}
package/dist/types.d.ts CHANGED
@@ -127,10 +127,29 @@ export interface PasswordResetConfirm {
127
127
  */
128
128
  password: string;
129
129
  }
130
+ /**
131
+ * The single value an app renders the session from — the four states every auth
132
+ * UI needs, derived from {@link AuthState} so no caller has to combine
133
+ * `initialized`/`authenticated`/`loading`/`error` itself.
134
+ *
135
+ * - `'loading'`: no decision yet (before `initialize()` settles, or an auth
136
+ * operation is in flight).
137
+ * - `'authenticated'`: a session exists.
138
+ * - `'unauthenticated'`: the client settled the question and nobody is signed in.
139
+ * - `'unavailable'`: a stored session exists but the server could not confirm it
140
+ * (a network or 5xx failure in {@link AuthClient.validateSession}); the session
141
+ * is KEPT and the app can say "reconnecting" instead of signing the user out.
142
+ */
143
+ export type AuthStatus = 'loading' | 'authenticated' | 'unauthenticated' | 'unavailable';
130
144
  /**
131
145
  * Reactive authentication state snapshot (initialized, authenticated, user, loading, and error).
132
146
  */
133
147
  export interface AuthState<T = UserProfile> {
148
+ /**
149
+ * The session's state as one value — render from this instead of combining
150
+ * `initialized`/`authenticated`/`loading`. See {@link AuthStatus}.
151
+ */
152
+ status: AuthStatus;
134
153
  /**
135
154
  * Whether auth state has been initialized.
136
155
  */
@@ -250,6 +269,26 @@ export interface AuthClient<T = UserProfile> {
250
269
  * Initializes auth state (e.g., from stored tokens).
251
270
  */
252
271
  initialize(): Promise<void>;
272
+ /**
273
+ * Re-checks a restored session against the server, in the background — the
274
+ * boot-time validation an app with a stored token needs when a revoked or
275
+ * expired token must sign the user out. Call it AFTER the first render
276
+ * (`initialize()` restores synchronously from storage; this costs one request).
277
+ *
278
+ * - The server confirms the user: the session is refreshed and {@link AuthState.status}
279
+ * stays `'authenticated'`.
280
+ * - The server answers 4xx: the token is dead — the stored session is cleared and
281
+ * the status becomes `'unauthenticated'`.
282
+ * - The server cannot answer (network failure or 5xx): the session is KEPT and the
283
+ * status becomes `'unavailable'`, so the app can retry instead of signing the
284
+ * user out over a bad connection.
285
+ *
286
+ * Do not hand-write this beside the client: a parallel token/user store for a
287
+ * "validating"/"unavailable" flag is the race this method removes.
288
+ *
289
+ * Optional: a provider with no restorable session has nothing to validate.
290
+ */
291
+ validateSession?(): Promise<void>;
253
292
  /**
254
293
  * Resolves when the session restore started by `initialize()` has settled — the point
255
294
  * after which the client knows whether this visitor is signed in.
@@ -342,6 +381,17 @@ export interface AuthClientConfig {
342
381
  * Storage key prefix.
343
382
  */
344
383
  storagePrefix?: string;
384
+ /**
385
+ * The EXACT `StorageAdapter` key the access token is written under (default
386
+ * `${storagePrefix}accessToken`).
387
+ *
388
+ * Set it when something outside this package reads the token at its own key —
389
+ * an e2e suite's contract (RealWorld's specs read `localStorage.jwtToken`), a
390
+ * second library, a host page — instead of mirroring the token into
391
+ * `localStorage` beside the client. The refresh token and the cached user keep
392
+ * the prefix.
393
+ */
394
+ tokenKey?: string;
345
395
  /**
346
396
  * Scheme of the `Authorization` header the access token is sent with:
347
397
  * `Bearer` (default), or e.g. `Token` for an API that reads
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAA;IAEV;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,M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AAK,OAAO,CAAA;IAElD;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACH,qBAAqB,CAAC,EAAE,MAAM,CAAA;IAE9B;;OAEG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAE/B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;IAEzB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,cAAc,IAAI,MAAM,GAAG,IAAI,CAAA;IAC/B,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC1C,eAAe,IAAI,MAAM,GAAG,IAAI,CAAA;IAChC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAA;IAC3C,OAAO,CAAC,CAAC,GAAG,WAAW,KAAK,CAAC,GAAG,IAAI,CAAA;IACpC,OAAO,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,EAAE,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;IAC9C,KAAK,IAAI,IAAI,CAAA;CACd"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-auth",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "Client-side authentication interface for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",