@molecule/app-auth 1.2.1 → 1.3.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 +174 -42
- package/dist/browser-storage.d.ts +89 -0
- package/dist/browser-storage.d.ts.map +1 -0
- package/dist/browser-storage.js +163 -0
- package/dist/browser-storage.js.map +1 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +52 -30
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +49 -19
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -19
- package/dist/index.js.map +1 -1
- package/dist/token.d.ts +4 -9
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +4 -9
- package/dist/token.js.map +1 -1
- package/dist/types.d.ts +50 -17
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,15 +3,11 @@ 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-
|
|
6
|
+
Generated: 2026-10-17T00:26:05.724Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-auth
|
|
10
10
|
|
|
11
|
-
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
-
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
-
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
-
|
|
15
11
|
Client-side authentication interface for molecule.dev.
|
|
16
12
|
|
|
17
13
|
Provides a unified auth API that works across different auth strategies
|
|
@@ -21,6 +17,10 @@ client; `setClient`/`getClient` bond it; `login`/`logout`/`register`/
|
|
|
21
17
|
bindings (e.g. `AuthProvider`/`useAuth` in `@molecule/app-react`) wrap the
|
|
22
18
|
same client.
|
|
23
19
|
|
|
20
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
21
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
22
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
23
|
+
|
|
24
24
|
## Quick Start
|
|
25
25
|
|
|
26
26
|
```typescript
|
|
@@ -50,6 +50,30 @@ npm install @molecule/app-auth @molecule/app-bond @molecule/app-i18n @molecule/a
|
|
|
50
50
|
|
|
51
51
|
### Interfaces
|
|
52
52
|
|
|
53
|
+
#### `BrowserStorageAdapterOptions`
|
|
54
|
+
|
|
55
|
+
How {@link createBrowserStorageAdapter} picks the store it writes to.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
interface BrowserStorageAdapterOptions {
|
|
59
|
+
/**
|
|
60
|
+
* The Web Storage area to persist to (default `'local'`).
|
|
61
|
+
*
|
|
62
|
+
* `'session'` is the narrower choice: a reload keeps the session, closing the
|
|
63
|
+
* tab ends it. Pick it when the app only has to survive navigations within one
|
|
64
|
+
* session — which is all a `page.reload()` asks for.
|
|
65
|
+
*/
|
|
66
|
+
kind?: BrowserStorageKind
|
|
67
|
+
/**
|
|
68
|
+
* A store to use instead of resolving `window.localStorage` /
|
|
69
|
+
* `window.sessionStorage` (a test double, a namespaced wrapper, or the
|
|
70
|
+
* `Storage` object another library exposes). Anything with `getItem`/
|
|
71
|
+
* `setItem`/`removeItem` does.
|
|
72
|
+
*/
|
|
73
|
+
storage?: StorageAdapter
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
53
77
|
#### `UserProfile`
|
|
54
78
|
|
|
55
79
|
User profile information.
|
|
@@ -342,6 +366,28 @@ interface AuthClient<T = UserProfile> {
|
|
|
342
366
|
*/
|
|
343
367
|
initialize(): Promise<void>
|
|
344
368
|
|
|
369
|
+
/**
|
|
370
|
+
* Resolves when the session restore started by `initialize()` has settled — the point
|
|
371
|
+
* after which the client knows whether this visitor is signed in.
|
|
372
|
+
*
|
|
373
|
+
* Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
|
|
374
|
+
* called, and after it has finished. A restore that failed resolves too (it settled the
|
|
375
|
+
* question), so an HTTP client can await this before every request without risking one
|
|
376
|
+
* held forever. That is what makes the fetch-before-restore race impossible: a page that
|
|
377
|
+
* fetches viewer-dependent data on mount waits here instead of going out anonymously
|
|
378
|
+
* (see `setAuthGate` in `@molecule/app-http`).
|
|
379
|
+
*
|
|
380
|
+
* Optional: a provider that restores no session has nothing to wait for. Without it, an
|
|
381
|
+
* HTTP client bonded to that provider sends first-paint requests unauthenticated.
|
|
382
|
+
*
|
|
383
|
+
* A provider whose restore sends a request THROUGH the gated HTTP client must send that
|
|
384
|
+
* request with `skipAuthGate: true` (`RequestConfig` in `@molecule/app-http`): the gate
|
|
385
|
+
* waits on this promise, so holding the restore's own request makes the gate wait on
|
|
386
|
+
* itself and stalls every request it holds until it times out. `createJWTAuthClient`'s
|
|
387
|
+
* restore does not need it — it uses `fetch`, not the bonded client.
|
|
388
|
+
*/
|
|
389
|
+
whenRestored?(): Promise<void>
|
|
390
|
+
|
|
345
391
|
/**
|
|
346
392
|
* Subscribes to auth state changes.
|
|
347
393
|
*/
|
|
@@ -421,10 +467,10 @@ interface AuthClientConfig {
|
|
|
421
467
|
|
|
422
468
|
/**
|
|
423
469
|
* Current-user endpoint for session restore (default `/users/me`). Called by
|
|
424
|
-
* `initialize()` with credentials to re-establish the session
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
*
|
|
470
|
+
* `initialize()` with credentials to re-establish the session after a full page
|
|
471
|
+
* load when the token did not survive the reload itself — i.e. when `storage` is
|
|
472
|
+
* `'memory'` and the API sets an httpOnly session cookie. Must return the user
|
|
473
|
+
* (as `user` or `props`).
|
|
428
474
|
*/
|
|
429
475
|
currentUserEndpoint?: string
|
|
430
476
|
|
|
@@ -460,23 +506,35 @@ interface AuthClientConfig {
|
|
|
460
506
|
mapAuthResponse?: (data: unknown) => AuthResult<UserProfile>
|
|
461
507
|
|
|
462
508
|
/**
|
|
463
|
-
*
|
|
464
|
-
*
|
|
465
|
-
*
|
|
509
|
+
* Where the access/refresh token and the cached user are kept — the field that
|
|
510
|
+
* decides whether a page reload keeps the user signed in.
|
|
511
|
+
*
|
|
512
|
+
* - `'memory'` (the client's default): a process-local store, lost on reload.
|
|
513
|
+
* Correct when the API sets an httpOnly session cookie, which `initialize()`
|
|
514
|
+
* then restores through {@link AuthClientConfig.currentUserEndpoint} — the
|
|
515
|
+
* strongest configuration, because no script can read the cookie.
|
|
516
|
+
* - a `StorageAdapter`: the token survives the reload itself. The browser
|
|
517
|
+
* adapter is `createBrowserStorageAdapter()` (from `@molecule/app-auth`), and it
|
|
518
|
+
* is what the scaffold's `authConfig` passes. A bearer token in Web Storage is
|
|
519
|
+
* readable by any script on the origin, so an XSS can steal it; see that
|
|
520
|
+
* function's `@remarks` for the trade and for the cookie alternative.
|
|
521
|
+
*
|
|
522
|
+
* Any adapter with `getItem`/`setItem`/`removeItem` works — the methods are
|
|
523
|
+
* SYNCHRONOUS, so the async `@molecule/app-storage` provider
|
|
524
|
+
* (`getProvider()`, whose `get()` returns a Promise) is NOT one: wrap the
|
|
525
|
+
* `Storage` object it was built on (`createBrowserStorageAdapter({ storage })`),
|
|
526
|
+
* or store a different way.
|
|
466
527
|
*
|
|
467
528
|
* @example
|
|
468
529
|
* ```typescript
|
|
469
|
-
*
|
|
470
|
-
* storage: 'memory'
|
|
530
|
+
* import { createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
471
531
|
*
|
|
472
|
-
* //
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
* storage: {
|
|
476
|
-
*
|
|
477
|
-
*
|
|
478
|
-
* removeItem: (key) => storageProvider.remove(key),
|
|
479
|
-
* }
|
|
532
|
+
* // A reload keeps the session (the scaffold's own default):
|
|
533
|
+
* storage: createBrowserStorageAdapter()
|
|
534
|
+
* // Only this tab's lifetime, at a narrower exposure than localStorage:
|
|
535
|
+
* storage: createBrowserStorageAdapter({ kind: 'session' })
|
|
536
|
+
* // An httpOnly cookie session instead — memory only, the stronger route:
|
|
537
|
+
* storage: 'memory'
|
|
480
538
|
* ```
|
|
481
539
|
*/
|
|
482
540
|
storage?: 'memory' | StorageAdapter
|
|
@@ -552,6 +610,16 @@ interface TokenStorage {
|
|
|
552
610
|
|
|
553
611
|
### Types
|
|
554
612
|
|
|
613
|
+
#### `BrowserStorageKind`
|
|
614
|
+
|
|
615
|
+
Which Web Storage area {@link createBrowserStorageAdapter} persists to:
|
|
616
|
+
`'local'` is `window.localStorage` (survives a reload AND the tab closing),
|
|
617
|
+
`'session'` is `window.sessionStorage` (survives a reload, dies with the tab).
|
|
618
|
+
|
|
619
|
+
```typescript
|
|
620
|
+
type BrowserStorageKind = 'local' | 'session'
|
|
621
|
+
```
|
|
622
|
+
|
|
555
623
|
#### `AuthEvent`
|
|
556
624
|
|
|
557
625
|
Auth event types.
|
|
@@ -575,6 +643,41 @@ type AuthEventListener = (event: AuthEvent) => void
|
|
|
575
643
|
|
|
576
644
|
### Functions
|
|
577
645
|
|
|
646
|
+
#### `createBrowserStorageAdapter(options)`
|
|
647
|
+
|
|
648
|
+
The auth client's `StorageAdapter` over the browser's Web Storage.
|
|
649
|
+
|
|
650
|
+
Pass it as `AuthClientConfig.storage` to keep the session across a page reload:
|
|
651
|
+
the client's default (`'memory'`) is lost on reload, and re-establishing the
|
|
652
|
+
session then needs a credential that survived — this adapter, or an httpOnly
|
|
653
|
+
session cookie the API sets (see the security note below).
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
import { createJWTAuthClient, createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
657
|
+
|
|
658
|
+
const authClient = createJWTAuthClient({
|
|
659
|
+
baseURL: '/api',
|
|
660
|
+
storage: createBrowserStorageAdapter(), // a reload keeps the user signed in
|
|
661
|
+
})
|
|
662
|
+
```
|
|
663
|
+
|
|
664
|
+
The scaffold's `authConfig` already passes it, so a scaffolded app survives a
|
|
665
|
+
reload out of the box; each of these replaces that default:
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
storage: 'memory' // memory only: pair it with an httpOnly cookie session
|
|
669
|
+
storage: createBrowserStorageAdapter({ kind: 'session' }) // survives a reload, dies with the tab
|
|
670
|
+
storage: { getItem: (k) => …, setItem: (k, v) => …, removeItem: (k) => … } // your own
|
|
671
|
+
```
|
|
672
|
+
|
|
673
|
+
```typescript
|
|
674
|
+
function createBrowserStorageAdapter(options?: BrowserStorageAdapterOptions): StorageAdapter
|
|
675
|
+
```
|
|
676
|
+
|
|
677
|
+
- `options` — Which Web Storage area to use, or a store to use directly.
|
|
678
|
+
|
|
679
|
+
**Returns:** A synchronous `StorageAdapter` bound to that store.
|
|
680
|
+
|
|
578
681
|
#### `createJWTAuthClient(config)`
|
|
579
682
|
|
|
580
683
|
Creates a simple JWT-based auth client.
|
|
@@ -627,7 +730,7 @@ Creates a token storage implementation backed by either in-memory
|
|
|
627
730
|
storage or a custom `StorageAdapter`.
|
|
628
731
|
|
|
629
732
|
```typescript
|
|
630
|
-
function createTokenStorage(storage?: 'memory'
|
|
733
|
+
function createTokenStorage(storage?: StorageAdapter | 'memory', prefix?: string): TokenStorage
|
|
631
734
|
```
|
|
632
735
|
|
|
633
736
|
- `storage` — `'memory'` for in-memory storage (lost on refresh), or a `StorageAdapter` for persistent storage.
|
|
@@ -746,19 +849,43 @@ Peer dependencies:
|
|
|
746
849
|
- **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
747
850
|
login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
748
851
|
token and user out of the answer (`(d) => ({ accessToken: d.user.token, user: d.user })`),
|
|
749
|
-
and `authScheme: 'Token'` sends `Authorization: Token <jwt
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
852
|
+
and `authScheme: 'Token'` sends `Authorization: Token <jwt>` — both are fields of the
|
|
853
|
+
`AuthClientConfig` the client is CONSTRUCTED with
|
|
854
|
+
(`setClient(createJWTAuthClient({ authScheme: 'Token', … }))` in the auth bond), not
|
|
855
|
+
properties of a client that already exists. Do not hand-write an auth client for a spec
|
|
856
|
+
like RealWorld.
|
|
857
|
+
- **Whether a reload keeps the user signed in is `AuthClientConfig.storage`,
|
|
858
|
+
and one of the two routes must be wired.** The client's own default is
|
|
859
|
+
`'memory'`, which is lost on reload, so a session survives one only by
|
|
860
|
+
having a credential that survived: (1) `storage: createBrowserStorageAdapter()`
|
|
861
|
+
— the browser's `localStorage`, what a scaffolded app's `authConfig` passes
|
|
862
|
+
(see `@molecule/app-auth`'s `createBrowserStorageAdapter` for the trade: Web
|
|
863
|
+
Storage is script-readable, so an XSS can steal the token), or (2) an
|
|
864
|
+
httpOnly session cookie the API sets at login, which `initialize()` restores
|
|
865
|
+
through `currentUserEndpoint` (default `/users/me`) — the stronger option
|
|
866
|
+
wherever the API supports it, and what `@molecule/api-resource-user` issues.
|
|
867
|
+
Wire `initialize()` once at startup either way. Do NOT hand-roll a token
|
|
868
|
+
store beside the client for this: it is a config field.
|
|
758
869
|
- **Endpoint defaults must match your API's real routes** (`/auth/login`,
|
|
759
870
|
`/auth/register`, `/auth/refresh`, `/users/logout`, `/users/me`, …).
|
|
760
871
|
Align them via `createJWTAuthClient({ baseURL, ...endpoints })` — never by
|
|
761
872
|
hand-editing fetch calls in components.
|
|
873
|
+
- **Do not fetch viewer-dependent data before the restore settles.** A component
|
|
874
|
+
effect that runs on mount fires while `initialize()` is still restoring, so its
|
|
875
|
+
request leaves without the `Authorization` header and the server answers for an
|
|
876
|
+
anonymous viewer — a followed user renders "Follow", a saved item renders unsaved.
|
|
877
|
+
On localhost the restore usually wins this race; over the network it does not, so
|
|
878
|
+
the bug appears only on the deployed URL. Two ways out: gate the fetch on the auth
|
|
879
|
+
state being settled (`state.initialized`), or let the HTTP client do it — bond the
|
|
880
|
+
auth client through `@molecule/app-bonds-default-react`, which registers
|
|
881
|
+
`whenRestored()` as the http gate so every request waits for the restore.
|
|
882
|
+
- **Your own session store's gate must exempt its restore's own request.** This client
|
|
883
|
+
restores with `fetch`, so the gate registered over it never holds the restore. A store
|
|
884
|
+
that restores THROUGH the bonded HTTP client and registers that restore as the gate
|
|
885
|
+
(`setAuthGate(() => store.whenSettled())`) waits on itself unless the restore's request
|
|
886
|
+
passes `skipAuthGate: true` — otherwise the gate holds the very request it is waiting
|
|
887
|
+
for, and every request it holds stalls until the gate times out. See
|
|
888
|
+
`RequestConfig.skipAuthGate` in `@molecule/app-http`.
|
|
762
889
|
- Client-side auth state is UX only — the server enforces authorization on
|
|
763
890
|
every request; hiding a screen is not protection.
|
|
764
891
|
|
|
@@ -788,22 +915,27 @@ by one. A box you can't check is an integration bug to fix — not a skip:
|
|
|
788
915
|
- [ ] Visiting a protected route while logged OUT redirects to login (the
|
|
789
916
|
guard reads `isAuthenticated()`), and after authenticating you land back on
|
|
790
917
|
the originally-requested screen rather than a generic home.
|
|
791
|
-
- [ ] The session survives a FULL page reload: after login, hard-reload →
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
918
|
+
- [ ] The session survives a FULL page reload: after login, hard-reload → you
|
|
919
|
+
stay signed in (the profile/sign-out UI a signed-in visitor sees is still
|
|
920
|
+
there), and you are NOT bounced to login. Which route does it is the app's
|
|
921
|
+
`AuthClientConfig.storage`: the scaffold's `createBrowserStorageAdapter()` keeps
|
|
922
|
+
the token in the browser, an httpOnly session cookie is restored by
|
|
923
|
+
`initialize()` through `currentUserEndpoint` (default `/users/me`). If the
|
|
924
|
+
app has neither — `storage` left at `'memory'` against an API that sets no
|
|
925
|
+
cookie — this box cannot be checked, and the fix is the config, not a token
|
|
926
|
+
store written beside the client.
|
|
797
927
|
- [ ] Password reset round-trips: `requestPasswordReset({ email })` then
|
|
798
928
|
`confirmPasswordReset({ token, password })` with the emailed token, after
|
|
799
929
|
which `login()` with the NEW password succeeds and the OLD password no
|
|
800
930
|
longer works.
|
|
801
931
|
- [ ] Authorization holds: a signed-in user only ever reads/edits their OWN
|
|
802
932
|
record (`getUser()` is the caller's profile, never another user's); the
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
933
|
+
token's storage is the deliberate choice `AuthClientConfig.storage` names —
|
|
934
|
+
if it is Web Storage (the scaffold default, which a reload requires when the
|
|
935
|
+
API sets no cookie), say so in the app's own words rather than leaving a
|
|
936
|
+
second, undocumented store beside it; and an expired/invalid token fails
|
|
937
|
+
closed — the app re-authenticates (`refresh()` or `logout()`), never
|
|
938
|
+
silently serving another user's data.
|
|
807
939
|
|
|
808
940
|
## Translations
|
|
809
941
|
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser `StorageAdapter` for the auth client's token storage.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import type { StorageAdapter } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Which Web Storage area {@link createBrowserStorageAdapter} persists to:
|
|
9
|
+
* `'local'` is `window.localStorage` (survives a reload AND the tab closing),
|
|
10
|
+
* `'session'` is `window.sessionStorage` (survives a reload, dies with the tab).
|
|
11
|
+
*/
|
|
12
|
+
export type BrowserStorageKind = 'local' | 'session';
|
|
13
|
+
/** How {@link createBrowserStorageAdapter} picks the store it writes to. */
|
|
14
|
+
export interface BrowserStorageAdapterOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The Web Storage area to persist to (default `'local'`).
|
|
17
|
+
*
|
|
18
|
+
* `'session'` is the narrower choice: a reload keeps the session, closing the
|
|
19
|
+
* tab ends it. Pick it when the app only has to survive navigations within one
|
|
20
|
+
* session — which is all a `page.reload()` asks for.
|
|
21
|
+
*/
|
|
22
|
+
kind?: BrowserStorageKind;
|
|
23
|
+
/**
|
|
24
|
+
* A store to use instead of resolving `window.localStorage` /
|
|
25
|
+
* `window.sessionStorage` (a test double, a namespaced wrapper, or the
|
|
26
|
+
* `Storage` object another library exposes). Anything with `getItem`/
|
|
27
|
+
* `setItem`/`removeItem` does.
|
|
28
|
+
*/
|
|
29
|
+
storage?: StorageAdapter;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The auth client's `StorageAdapter` over the browser's Web Storage.
|
|
33
|
+
*
|
|
34
|
+
* Pass it as `AuthClientConfig.storage` to keep the session across a page reload:
|
|
35
|
+
* the client's default (`'memory'`) is lost on reload, and re-establishing the
|
|
36
|
+
* session then needs a credential that survived — this adapter, or an httpOnly
|
|
37
|
+
* session cookie the API sets (see the security note below).
|
|
38
|
+
*
|
|
39
|
+
* ```ts
|
|
40
|
+
* import { createJWTAuthClient, createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
41
|
+
*
|
|
42
|
+
* const authClient = createJWTAuthClient({
|
|
43
|
+
* baseURL: '/api',
|
|
44
|
+
* storage: createBrowserStorageAdapter(), // a reload keeps the user signed in
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* The scaffold's `authConfig` already passes it, so a scaffolded app survives a
|
|
49
|
+
* reload out of the box; each of these replaces that default:
|
|
50
|
+
*
|
|
51
|
+
* ```ts
|
|
52
|
+
* storage: 'memory' // memory only: pair it with an httpOnly cookie session
|
|
53
|
+
* storage: createBrowserStorageAdapter({ kind: 'session' }) // survives a reload, dies with the tab
|
|
54
|
+
* storage: { getItem: (k) => …, setItem: (k, v) => …, removeItem: (k) => … } // your own
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* - **The trade, stated plainly.** A bearer token in Web Storage is readable by
|
|
59
|
+
* any script on the origin, so one XSS is one token theft — an account takeover
|
|
60
|
+
* for the token's whole lifetime, and `localStorage` keeps the copy after the
|
|
61
|
+
* tab closes. This is the model the RealWorld suite's own specs write
|
|
62
|
+
* (`localStorage.setItem('jwtToken', …)` before a reload) and the reason this
|
|
63
|
+
* adapter exists.
|
|
64
|
+
* - **An httpOnly cookie session is STRONGER, and is the first choice wherever
|
|
65
|
+
* your API supports it.** Script cannot read an httpOnly cookie, so an XSS
|
|
66
|
+
* cannot exfiltrate the credential; the token stays in memory and
|
|
67
|
+
* `initialize()` restores the session through `currentUserEndpoint`
|
|
68
|
+
* (`@molecule/api-resource-user` issues exactly this cookie — that is why the
|
|
69
|
+
* client's default is `'memory'`). If the API sets one, `storage: 'memory'` is
|
|
70
|
+
* the strongest configuration. If it does not and you cannot change it, keep
|
|
71
|
+
* the token's lifetime short and rotate it on refresh.
|
|
72
|
+
* - **`kind: 'session'` narrows the window** to the tab's lifetime at the cost of
|
|
73
|
+
* losing the session in a new tab; `'local'` is the default because a reload is
|
|
74
|
+
* the requirement it exists for, and a fresh tab is the same person.
|
|
75
|
+
* - **Unavailable storage degrades to memory; it never throws.** SSR (`window`
|
|
76
|
+
* undefined), a private/blocked store and a full quota all fall back to a
|
|
77
|
+
* process-local store — so a login still succeeds and the session simply does
|
|
78
|
+
* not survive the next page load. A warning names the failure. Do not read a
|
|
79
|
+
* successful `setItem` as a guarantee of persistence; a caller that needs one
|
|
80
|
+
* must probe the store itself.
|
|
81
|
+
* - **The keys are the client's own** (`storagePrefix`, default
|
|
82
|
+
* `molecule:auth:`, plus `accessToken` / `refreshToken` / `user`); this adapter
|
|
83
|
+
* adds no prefix and stores nothing of its own.
|
|
84
|
+
*
|
|
85
|
+
* @param options - Which Web Storage area to use, or a store to use directly.
|
|
86
|
+
* @returns A synchronous `StorageAdapter` bound to that store.
|
|
87
|
+
*/
|
|
88
|
+
export declare const createBrowserStorageAdapter: (options?: BrowserStorageAdapterOptions) => StorageAdapter;
|
|
89
|
+
//# sourceMappingURL=browser-storage.d.ts.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The browser `StorageAdapter` for the auth client's token storage.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { getLogger } from '@molecule/app-logger';
|
|
7
|
+
/** Best-effort logger: a missing logger bond must never break token storage. */
|
|
8
|
+
const warn = (message, error) => {
|
|
9
|
+
try {
|
|
10
|
+
const logger = getLogger('auth');
|
|
11
|
+
if (error === undefined)
|
|
12
|
+
logger.warn(message);
|
|
13
|
+
else
|
|
14
|
+
logger.warn(message, { error });
|
|
15
|
+
}
|
|
16
|
+
catch (_error) {
|
|
17
|
+
// No logger bonded (a bare unit test, an SSR boot before the app's bonds):
|
|
18
|
+
// logging is not this adapter's contract, and throwing here would take the
|
|
19
|
+
// session down with it.
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The auth client's `StorageAdapter` over the browser's Web Storage.
|
|
24
|
+
*
|
|
25
|
+
* Pass it as `AuthClientConfig.storage` to keep the session across a page reload:
|
|
26
|
+
* the client's default (`'memory'`) is lost on reload, and re-establishing the
|
|
27
|
+
* session then needs a credential that survived — this adapter, or an httpOnly
|
|
28
|
+
* session cookie the API sets (see the security note below).
|
|
29
|
+
*
|
|
30
|
+
* ```ts
|
|
31
|
+
* import { createJWTAuthClient, createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
32
|
+
*
|
|
33
|
+
* const authClient = createJWTAuthClient({
|
|
34
|
+
* baseURL: '/api',
|
|
35
|
+
* storage: createBrowserStorageAdapter(), // a reload keeps the user signed in
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* The scaffold's `authConfig` already passes it, so a scaffolded app survives a
|
|
40
|
+
* reload out of the box; each of these replaces that default:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* storage: 'memory' // memory only: pair it with an httpOnly cookie session
|
|
44
|
+
* storage: createBrowserStorageAdapter({ kind: 'session' }) // survives a reload, dies with the tab
|
|
45
|
+
* storage: { getItem: (k) => …, setItem: (k, v) => …, removeItem: (k) => … } // your own
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* - **The trade, stated plainly.** A bearer token in Web Storage is readable by
|
|
50
|
+
* any script on the origin, so one XSS is one token theft — an account takeover
|
|
51
|
+
* for the token's whole lifetime, and `localStorage` keeps the copy after the
|
|
52
|
+
* tab closes. This is the model the RealWorld suite's own specs write
|
|
53
|
+
* (`localStorage.setItem('jwtToken', …)` before a reload) and the reason this
|
|
54
|
+
* adapter exists.
|
|
55
|
+
* - **An httpOnly cookie session is STRONGER, and is the first choice wherever
|
|
56
|
+
* your API supports it.** Script cannot read an httpOnly cookie, so an XSS
|
|
57
|
+
* cannot exfiltrate the credential; the token stays in memory and
|
|
58
|
+
* `initialize()` restores the session through `currentUserEndpoint`
|
|
59
|
+
* (`@molecule/api-resource-user` issues exactly this cookie — that is why the
|
|
60
|
+
* client's default is `'memory'`). If the API sets one, `storage: 'memory'` is
|
|
61
|
+
* the strongest configuration. If it does not and you cannot change it, keep
|
|
62
|
+
* the token's lifetime short and rotate it on refresh.
|
|
63
|
+
* - **`kind: 'session'` narrows the window** to the tab's lifetime at the cost of
|
|
64
|
+
* losing the session in a new tab; `'local'` is the default because a reload is
|
|
65
|
+
* the requirement it exists for, and a fresh tab is the same person.
|
|
66
|
+
* - **Unavailable storage degrades to memory; it never throws.** SSR (`window`
|
|
67
|
+
* undefined), a private/blocked store and a full quota all fall back to a
|
|
68
|
+
* process-local store — so a login still succeeds and the session simply does
|
|
69
|
+
* not survive the next page load. A warning names the failure. Do not read a
|
|
70
|
+
* successful `setItem` as a guarantee of persistence; a caller that needs one
|
|
71
|
+
* must probe the store itself.
|
|
72
|
+
* - **The keys are the client's own** (`storagePrefix`, default
|
|
73
|
+
* `molecule:auth:`, plus `accessToken` / `refreshToken` / `user`); this adapter
|
|
74
|
+
* adds no prefix and stores nothing of its own.
|
|
75
|
+
*
|
|
76
|
+
* @param options - Which Web Storage area to use, or a store to use directly.
|
|
77
|
+
* @returns A synchronous `StorageAdapter` bound to that store.
|
|
78
|
+
*/
|
|
79
|
+
export const createBrowserStorageAdapter = (options = {}) => {
|
|
80
|
+
const { kind = 'local', storage } = options;
|
|
81
|
+
// The fallback store: one Map per adapter, so an unusable Web Storage area
|
|
82
|
+
// still behaves like a store for the lifetime of the page.
|
|
83
|
+
const memory = new Map();
|
|
84
|
+
/** The store once it has answered, `null` while it is unusable (re-probed each call). */
|
|
85
|
+
let resolved;
|
|
86
|
+
/** The unusable-store warning is worth saying once, not on every token read. */
|
|
87
|
+
let warned = false;
|
|
88
|
+
const resolve = () => {
|
|
89
|
+
if (storage)
|
|
90
|
+
return storage;
|
|
91
|
+
if (resolved !== undefined && resolved !== null)
|
|
92
|
+
return resolved;
|
|
93
|
+
try {
|
|
94
|
+
const areas = globalThis;
|
|
95
|
+
const web = kind === 'session' ? areas.sessionStorage : areas.localStorage;
|
|
96
|
+
if (web) {
|
|
97
|
+
// A store can be PRESENT and still unusable (a blocked third-party
|
|
98
|
+
// context, a private mode): touching it throws, so probe before trusting it.
|
|
99
|
+
const probe = '__molecule_auth_probe__';
|
|
100
|
+
web.setItem(probe, probe);
|
|
101
|
+
web.removeItem(probe);
|
|
102
|
+
resolved = web;
|
|
103
|
+
return web;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
if (!warned) {
|
|
108
|
+
warned = true;
|
|
109
|
+
warn(`The ${kind} Web Storage area is not usable; keeping auth tokens in memory`, error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// Not cached: a store that appears later (the app booting before its DOM is
|
|
113
|
+
// ready) is still picked up by the next call.
|
|
114
|
+
return null;
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
getItem: (key) => {
|
|
118
|
+
const store = resolve();
|
|
119
|
+
if (!store)
|
|
120
|
+
return memory.get(key) ?? null;
|
|
121
|
+
try {
|
|
122
|
+
// A write that fell back to memory (a full or blocked store) is still
|
|
123
|
+
// this session's value: the store simply never received it.
|
|
124
|
+
return store.getItem(key) ?? memory.get(key) ?? null;
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
warn('Reading a stored auth value failed; falling back to memory', error);
|
|
128
|
+
return memory.get(key) ?? null;
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
setItem: (key, value) => {
|
|
132
|
+
const store = resolve();
|
|
133
|
+
if (!store) {
|
|
134
|
+
memory.set(key, value);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
try {
|
|
138
|
+
store.setItem(key, value);
|
|
139
|
+
memory.delete(key);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
// A quota-full or blocked store must not fail a login: keep the value for
|
|
143
|
+
// this page's lifetime and say so. The session is lost on reload, which is
|
|
144
|
+
// the state the app was in before this adapter existed.
|
|
145
|
+
warn('Storing an auth value failed; keeping it in memory for this page', error);
|
|
146
|
+
memory.set(key, value);
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
removeItem: (key) => {
|
|
150
|
+
memory.delete(key);
|
|
151
|
+
const store = resolve();
|
|
152
|
+
if (!store)
|
|
153
|
+
return;
|
|
154
|
+
try {
|
|
155
|
+
store.removeItem(key);
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
warn('Clearing a stored auth value failed', error);
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
//# sourceMappingURL=browser-storage.js.map
|
|
@@ -0,0 +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,CACzC,UAAwC,EAAE,EAC1B,EAAE;IAClB,MAAM,EAAE,IAAI,GAAG,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAC3C,2EAA2E;IAC3E,2DAA2D;IAC3D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,yFAAyF;IACzF,IAAI,QAA2C,CAAA;IAC/C,gFAAgF;IAChF,IAAI,MAAM,GAAG,KAAK,CAAA;IAElB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[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAShB,WAAW,EACZ,MAAM,YAAY,CAAA;AA4CnB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,WAAW,GAAG,WAAW,EACrE,SAAQ,gBAAqB,KAC5B,UAAU,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAShB,WAAW,EACZ,MAAM,YAAY,CAAA;AA4CnB;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC,SAAS,WAAW,GAAG,WAAW,EACrE,SAAQ,gBAAqB,KAC5B,UAAU,CAAC,CAAC,CAudd,CAAA"}
|
package/dist/client.js
CHANGED
|
@@ -66,6 +66,11 @@ export const createJWTAuthClient = (config = {}) => {
|
|
|
66
66
|
const stateListeners = new Set();
|
|
67
67
|
const eventListeners = new Set();
|
|
68
68
|
let refreshTimer = null;
|
|
69
|
+
// [m95] The session restore `initialize()` started, or null when none is running.
|
|
70
|
+
// Assigned SYNCHRONOUSLY, before that call's first await, so a component effect
|
|
71
|
+
// running in the same tick (bootstrapApp calls initialize() and then renders)
|
|
72
|
+
// already sees the restore and its HTTP requests wait for it (`whenRestored`).
|
|
73
|
+
let restoreInFlight = null;
|
|
69
74
|
let state = {
|
|
70
75
|
initialized: false,
|
|
71
76
|
authenticated: false,
|
|
@@ -195,6 +200,41 @@ export const createJWTAuthClient = (config = {}) => {
|
|
|
195
200
|
}
|
|
196
201
|
return null;
|
|
197
202
|
};
|
|
203
|
+
// The body of `initialize()`, kept separate so the client can record the in-flight
|
|
204
|
+
// promise SYNCHRONOUSLY (see `restoreInFlight`): a caller that awaits `initialize()`
|
|
205
|
+
// still sees a rejection, while `whenRestored()` hands out a promise that resolves.
|
|
206
|
+
const initializeSession = async () => {
|
|
207
|
+
const token = tokenStorage.getAccessToken();
|
|
208
|
+
const user = tokenStorage.getUser();
|
|
209
|
+
if (token && user) {
|
|
210
|
+
if (!isTokenExpired(token)) {
|
|
211
|
+
setState({
|
|
212
|
+
initialized: true,
|
|
213
|
+
authenticated: true,
|
|
214
|
+
user,
|
|
215
|
+
});
|
|
216
|
+
scheduleRefresh();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
// Token expired, try to refresh
|
|
220
|
+
const refreshToken = tokenStorage.getRefreshToken();
|
|
221
|
+
if (refreshToken) {
|
|
222
|
+
try {
|
|
223
|
+
await client.refresh();
|
|
224
|
+
setState({ initialized: true });
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
logger.warn('Initial token refresh failed', err);
|
|
229
|
+
tokenStorage.clear();
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// [M1-1] Cookie-restore — this is what keeps a refresh / deep-link logged
|
|
234
|
+
// in under the in-memory-token model. See restoreFromSessionCookie above.
|
|
235
|
+
await restoreFromSessionCookie();
|
|
236
|
+
setState({ initialized: true });
|
|
237
|
+
};
|
|
198
238
|
const client = {
|
|
199
239
|
getState: () => state,
|
|
200
240
|
isAuthenticated: () => state.authenticated,
|
|
@@ -373,36 +413,18 @@ export const createJWTAuthClient = (config = {}) => {
|
|
|
373
413
|
});
|
|
374
414
|
},
|
|
375
415
|
async initialize() {
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
// Token expired, try to refresh
|
|
389
|
-
const refreshToken = tokenStorage.getRefreshToken();
|
|
390
|
-
if (refreshToken) {
|
|
391
|
-
try {
|
|
392
|
-
await this.refresh();
|
|
393
|
-
setState({ initialized: true });
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
catch (err) {
|
|
397
|
-
logger.warn('Initial token refresh failed', err);
|
|
398
|
-
tokenStorage.clear();
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
// [M1-1] Cookie-restore — this is what keeps a refresh / deep-link logged
|
|
403
|
-
// in under the in-memory-token model. See restoreFromSessionCookie above.
|
|
404
|
-
await restoreFromSessionCookie();
|
|
405
|
-
setState({ initialized: true });
|
|
416
|
+
// Record BEFORE awaiting, so a component effect that runs in the same tick as
|
|
417
|
+
// this call (bootstrapApp calls initialize() and then renders) already sees a
|
|
418
|
+
// restore in flight and holds its requests for it (see whenRestored below).
|
|
419
|
+
const inFlight = initializeSession();
|
|
420
|
+
restoreInFlight = inFlight;
|
|
421
|
+
await inFlight;
|
|
422
|
+
},
|
|
423
|
+
whenRestored() {
|
|
424
|
+
// Resolve, never reject: this is awaited before every authenticated request, so a
|
|
425
|
+
// restore that failed must not turn into a rejected request — the request goes out
|
|
426
|
+
// unauthenticated instead (the same outcome as not waiting at all).
|
|
427
|
+
return restoreInFlight ? restoreInFlight.catch(() => undefined) : Promise.resolve();
|
|
406
428
|
},
|
|
407
429
|
subscribe(callback) {
|
|
408
430
|
stateListeners.add(callback);
|
package/dist/client.js.map
CHANGED
|
@@ -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,kBAAkB,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAenF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,uBAAuB,GAAG,GAAY,EAAE;IAC5C,IAAI,CAAC;QACH,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,IA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C,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
|
@@ -12,19 +12,43 @@
|
|
|
12
12
|
* - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
13
13
|
* login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
14
14
|
* token and user out of the answer (`(d) => ({ accessToken: d.user.token, user: d.user })`),
|
|
15
|
-
* and `authScheme: 'Token'` sends `Authorization: Token <jwt
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
15
|
+
* and `authScheme: 'Token'` sends `Authorization: Token <jwt>` — both are fields of the
|
|
16
|
+
* `AuthClientConfig` the client is CONSTRUCTED with
|
|
17
|
+
* (`setClient(createJWTAuthClient({ authScheme: 'Token', … }))` in the auth bond), not
|
|
18
|
+
* properties of a client that already exists. Do not hand-write an auth client for a spec
|
|
19
|
+
* 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.
|
|
24
32
|
* - **Endpoint defaults must match your API's real routes** (`/auth/login`,
|
|
25
33
|
* `/auth/register`, `/auth/refresh`, `/users/logout`, `/users/me`, …).
|
|
26
34
|
* Align them via `createJWTAuthClient({ baseURL, ...endpoints })` — never by
|
|
27
35
|
* 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`.
|
|
28
52
|
* - Client-side auth state is UX only — the server enforces authorization on
|
|
29
53
|
* every request; hiding a screen is not protection.
|
|
30
54
|
*
|
|
@@ -66,25 +90,31 @@
|
|
|
66
90
|
* - [ ] Visiting a protected route while logged OUT redirects to login (the
|
|
67
91
|
* guard reads `isAuthenticated()`), and after authenticating you land back on
|
|
68
92
|
* the originally-requested screen rather than a generic home.
|
|
69
|
-
* - [ ] The session survives a FULL page reload: after login, hard-reload →
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
93
|
+
* - [ ] The session survives a FULL page reload: after login, hard-reload → you
|
|
94
|
+
* stay signed in (the profile/sign-out UI a signed-in visitor sees is still
|
|
95
|
+
* there), and you are NOT bounced to login. Which route does it is the app's
|
|
96
|
+
* `AuthClientConfig.storage`: the scaffold's `createBrowserStorageAdapter()` keeps
|
|
97
|
+
* the token in the browser, an httpOnly session cookie is restored by
|
|
98
|
+
* `initialize()` through `currentUserEndpoint` (default `/users/me`). If the
|
|
99
|
+
* app has neither — `storage` left at `'memory'` against an API that sets no
|
|
100
|
+
* cookie — this box cannot be checked, and the fix is the config, not a token
|
|
101
|
+
* store written beside the client.
|
|
75
102
|
* - [ ] Password reset round-trips: `requestPasswordReset({ email })` then
|
|
76
103
|
* `confirmPasswordReset({ token, password })` with the emailed token, after
|
|
77
104
|
* which `login()` with the NEW password succeeds and the OLD password no
|
|
78
105
|
* longer works.
|
|
79
106
|
* - [ ] Authorization holds: a signed-in user only ever reads/edits their OWN
|
|
80
107
|
* record (`getUser()` is the caller's profile, never another user's); the
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
108
|
+
* token's storage is the deliberate choice `AuthClientConfig.storage` names —
|
|
109
|
+
* if it is Web Storage (the scaffold default, which a reload requires when the
|
|
110
|
+
* API sets no cookie), say so in the app's own words rather than leaving a
|
|
111
|
+
* second, undocumented store beside it; and an expired/invalid token fails
|
|
112
|
+
* closed — the app re-authenticates (`refresh()` or `logout()`), never
|
|
113
|
+
* silently serving another user's data.
|
|
85
114
|
*
|
|
86
115
|
* @module
|
|
87
116
|
*/
|
|
117
|
+
export * from './browser-storage.js';
|
|
88
118
|
export * from './client.js';
|
|
89
119
|
export * from './provider.js';
|
|
90
120
|
export * from './token.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
package/dist/index.js
CHANGED
|
@@ -12,19 +12,43 @@
|
|
|
12
12
|
* - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
13
13
|
* login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
14
14
|
* token and user out of the answer (`(d) => ({ accessToken: d.user.token, user: d.user })`),
|
|
15
|
-
* and `authScheme: 'Token'` sends `Authorization: Token <jwt
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
15
|
+
* and `authScheme: 'Token'` sends `Authorization: Token <jwt>` — both are fields of the
|
|
16
|
+
* `AuthClientConfig` the client is CONSTRUCTED with
|
|
17
|
+
* (`setClient(createJWTAuthClient({ authScheme: 'Token', … }))` in the auth bond), not
|
|
18
|
+
* properties of a client that already exists. Do not hand-write an auth client for a spec
|
|
19
|
+
* 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.
|
|
24
32
|
* - **Endpoint defaults must match your API's real routes** (`/auth/login`,
|
|
25
33
|
* `/auth/register`, `/auth/refresh`, `/users/logout`, `/users/me`, …).
|
|
26
34
|
* Align them via `createJWTAuthClient({ baseURL, ...endpoints })` — never by
|
|
27
35
|
* 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`.
|
|
28
52
|
* - Client-side auth state is UX only — the server enforces authorization on
|
|
29
53
|
* every request; hiding a screen is not protection.
|
|
30
54
|
*
|
|
@@ -66,25 +90,31 @@
|
|
|
66
90
|
* - [ ] Visiting a protected route while logged OUT redirects to login (the
|
|
67
91
|
* guard reads `isAuthenticated()`), and after authenticating you land back on
|
|
68
92
|
* the originally-requested screen rather than a generic home.
|
|
69
|
-
* - [ ] The session survives a FULL page reload: after login, hard-reload →
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
93
|
+
* - [ ] The session survives a FULL page reload: after login, hard-reload → you
|
|
94
|
+
* stay signed in (the profile/sign-out UI a signed-in visitor sees is still
|
|
95
|
+
* there), and you are NOT bounced to login. Which route does it is the app's
|
|
96
|
+
* `AuthClientConfig.storage`: the scaffold's `createBrowserStorageAdapter()` keeps
|
|
97
|
+
* the token in the browser, an httpOnly session cookie is restored by
|
|
98
|
+
* `initialize()` through `currentUserEndpoint` (default `/users/me`). If the
|
|
99
|
+
* app has neither — `storage` left at `'memory'` against an API that sets no
|
|
100
|
+
* cookie — this box cannot be checked, and the fix is the config, not a token
|
|
101
|
+
* store written beside the client.
|
|
75
102
|
* - [ ] Password reset round-trips: `requestPasswordReset({ email })` then
|
|
76
103
|
* `confirmPasswordReset({ token, password })` with the emailed token, after
|
|
77
104
|
* which `login()` with the NEW password succeeds and the OLD password no
|
|
78
105
|
* longer works.
|
|
79
106
|
* - [ ] Authorization holds: a signed-in user only ever reads/edits their OWN
|
|
80
107
|
* record (`getUser()` is the caller's profile, never another user's); the
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
108
|
+
* token's storage is the deliberate choice `AuthClientConfig.storage` names —
|
|
109
|
+
* if it is Web Storage (the scaffold default, which a reload requires when the
|
|
110
|
+
* API sets no cookie), say so in the app's own words rather than leaving a
|
|
111
|
+
* second, undocumented store beside it; and an expired/invalid token fails
|
|
112
|
+
* closed — the app re-authenticates (`refresh()` or `logout()`), never
|
|
113
|
+
* silently serving another user's data.
|
|
85
114
|
*
|
|
86
115
|
* @module
|
|
87
116
|
*/
|
|
117
|
+
export * from './browser-storage.js';
|
|
88
118
|
export * from './client.js';
|
|
89
119
|
export * from './provider.js';
|
|
90
120
|
export * from './token.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
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"}
|
package/dist/token.d.ts
CHANGED
|
@@ -17,17 +17,12 @@ import type { StorageAdapter, TokenStorage } from './types.js';
|
|
|
17
17
|
*
|
|
18
18
|
* @example
|
|
19
19
|
* ```typescript
|
|
20
|
-
* // In-memory storage (default)
|
|
20
|
+
* // In-memory storage (the client's default)
|
|
21
21
|
* const storage = createTokenStorage('memory')
|
|
22
22
|
*
|
|
23
|
-
* //
|
|
24
|
-
* import {
|
|
25
|
-
* const
|
|
26
|
-
* const storage = createTokenStorage({
|
|
27
|
-
* getItem: (key) => provider.get(key),
|
|
28
|
-
* setItem: (key, value) => provider.set(key, value),
|
|
29
|
-
* removeItem: (key) => provider.remove(key),
|
|
30
|
-
* })
|
|
23
|
+
* // The browser's persistent storage — a reload keeps the session
|
|
24
|
+
* import { createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
25
|
+
* const storage = createTokenStorage(createBrowserStorageAdapter())
|
|
31
26
|
* ```
|
|
32
27
|
*/
|
|
33
28
|
export declare const createTokenStorage: (storage?: "memory" | StorageAdapter, prefix?: string) => TokenStorage;
|
package/dist/token.d.ts.map
CHANGED
|
@@ -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
|
|
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"}
|
package/dist/token.js
CHANGED
|
@@ -16,17 +16,12 @@
|
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* ```typescript
|
|
19
|
-
* // In-memory storage (default)
|
|
19
|
+
* // In-memory storage (the client's default)
|
|
20
20
|
* const storage = createTokenStorage('memory')
|
|
21
21
|
*
|
|
22
|
-
* //
|
|
23
|
-
* import {
|
|
24
|
-
* const
|
|
25
|
-
* const storage = createTokenStorage({
|
|
26
|
-
* getItem: (key) => provider.get(key),
|
|
27
|
-
* setItem: (key, value) => provider.set(key, value),
|
|
28
|
-
* removeItem: (key) => provider.remove(key),
|
|
29
|
-
* })
|
|
22
|
+
* // The browser's persistent storage — a reload keeps the session
|
|
23
|
+
* import { createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
24
|
+
* const storage = createTokenStorage(createBrowserStorageAdapter())
|
|
30
25
|
* ```
|
|
31
26
|
*/
|
|
32
27
|
export const createTokenStorage = (storage = 'memory', prefix = 'molecule:auth:') => {
|
package/dist/token.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.js","sourceRoot":"","sources":["../src/token.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH
|
|
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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AACzB,CAAC,CAAA;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAa,EAAiB,EAAE;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
|
@@ -250,6 +250,27 @@ export interface AuthClient<T = UserProfile> {
|
|
|
250
250
|
* Initializes auth state (e.g., from stored tokens).
|
|
251
251
|
*/
|
|
252
252
|
initialize(): Promise<void>;
|
|
253
|
+
/**
|
|
254
|
+
* Resolves when the session restore started by `initialize()` has settled — the point
|
|
255
|
+
* after which the client knows whether this visitor is signed in.
|
|
256
|
+
*
|
|
257
|
+
* Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
|
|
258
|
+
* called, and after it has finished. A restore that failed resolves too (it settled the
|
|
259
|
+
* question), so an HTTP client can await this before every request without risking one
|
|
260
|
+
* held forever. That is what makes the fetch-before-restore race impossible: a page that
|
|
261
|
+
* fetches viewer-dependent data on mount waits here instead of going out anonymously
|
|
262
|
+
* (see `setAuthGate` in `@molecule/app-http`).
|
|
263
|
+
*
|
|
264
|
+
* Optional: a provider that restores no session has nothing to wait for. Without it, an
|
|
265
|
+
* HTTP client bonded to that provider sends first-paint requests unauthenticated.
|
|
266
|
+
*
|
|
267
|
+
* A provider whose restore sends a request THROUGH the gated HTTP client must send that
|
|
268
|
+
* request with `skipAuthGate: true` (`RequestConfig` in `@molecule/app-http`): the gate
|
|
269
|
+
* waits on this promise, so holding the restore's own request makes the gate wait on
|
|
270
|
+
* itself and stalls every request it holds until it times out. `createJWTAuthClient`'s
|
|
271
|
+
* restore does not need it — it uses `fetch`, not the bonded client.
|
|
272
|
+
*/
|
|
273
|
+
whenRestored?(): Promise<void>;
|
|
253
274
|
/**
|
|
254
275
|
* Subscribes to auth state changes.
|
|
255
276
|
*/
|
|
@@ -311,10 +332,10 @@ export interface AuthClientConfig {
|
|
|
311
332
|
profileEndpoint?: string;
|
|
312
333
|
/**
|
|
313
334
|
* Current-user endpoint for session restore (default `/users/me`). Called by
|
|
314
|
-
* `initialize()` with credentials to re-establish the session
|
|
315
|
-
*
|
|
316
|
-
*
|
|
317
|
-
*
|
|
335
|
+
* `initialize()` with credentials to re-establish the session after a full page
|
|
336
|
+
* load when the token did not survive the reload itself — i.e. when `storage` is
|
|
337
|
+
* `'memory'` and the API sets an httpOnly session cookie. Must return the user
|
|
338
|
+
* (as `user` or `props`).
|
|
318
339
|
*/
|
|
319
340
|
currentUserEndpoint?: string;
|
|
320
341
|
/**
|
|
@@ -345,23 +366,35 @@ export interface AuthClientConfig {
|
|
|
345
366
|
*/
|
|
346
367
|
mapAuthResponse?: (data: unknown) => AuthResult<UserProfile>;
|
|
347
368
|
/**
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
369
|
+
* Where the access/refresh token and the cached user are kept — the field that
|
|
370
|
+
* decides whether a page reload keeps the user signed in.
|
|
371
|
+
*
|
|
372
|
+
* - `'memory'` (the client's default): a process-local store, lost on reload.
|
|
373
|
+
* Correct when the API sets an httpOnly session cookie, which `initialize()`
|
|
374
|
+
* then restores through {@link AuthClientConfig.currentUserEndpoint} — the
|
|
375
|
+
* strongest configuration, because no script can read the cookie.
|
|
376
|
+
* - a `StorageAdapter`: the token survives the reload itself. The browser
|
|
377
|
+
* adapter is `createBrowserStorageAdapter()` (from `@molecule/app-auth`), and it
|
|
378
|
+
* is what the scaffold's `authConfig` passes. A bearer token in Web Storage is
|
|
379
|
+
* readable by any script on the origin, so an XSS can steal it; see that
|
|
380
|
+
* function's `@remarks` for the trade and for the cookie alternative.
|
|
381
|
+
*
|
|
382
|
+
* Any adapter with `getItem`/`setItem`/`removeItem` works — the methods are
|
|
383
|
+
* SYNCHRONOUS, so the async `@molecule/app-storage` provider
|
|
384
|
+
* (`getProvider()`, whose `get()` returns a Promise) is NOT one: wrap the
|
|
385
|
+
* `Storage` object it was built on (`createBrowserStorageAdapter({ storage })`),
|
|
386
|
+
* or store a different way.
|
|
351
387
|
*
|
|
352
388
|
* @example
|
|
353
389
|
* ```typescript
|
|
354
|
-
*
|
|
355
|
-
* storage: 'memory'
|
|
390
|
+
* import { createBrowserStorageAdapter } from '@molecule/app-auth'
|
|
356
391
|
*
|
|
357
|
-
* //
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
* storage: {
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
* removeItem: (key) => storageProvider.remove(key),
|
|
364
|
-
* }
|
|
392
|
+
* // A reload keeps the session (the scaffold's own default):
|
|
393
|
+
* storage: createBrowserStorageAdapter()
|
|
394
|
+
* // Only this tab's lifetime, at a narrower exposure than localStorage:
|
|
395
|
+
* storage: createBrowserStorageAdapter({ kind: 'session' })
|
|
396
|
+
* // An httpOnly cookie session instead — memory only, the stronger route:
|
|
397
|
+
* storage: 'memory'
|
|
365
398
|
* ```
|
|
366
399
|
*/
|
|
367
400
|
storage?: 'memory' | StorageAdapter;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -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,MAAM,EAAE,OAAO,CAAC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