@molecule/app-auth 3.2.0 → 3.2.2
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 +27 -1
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
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-11-
|
|
6
|
+
Generated: 2026-11-02T21:26:16.657Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-auth
|
|
@@ -55,6 +55,13 @@ createBrowserStorageAdapter() }))`, or `createDefaultAuthClient(authConfig)`
|
|
|
55
55
|
from `@molecule/app-bonds-default-react`, then call `initialize()`. The bond's
|
|
56
56
|
HTTP-sync variants also register `whenRestored()` as the request gate.
|
|
57
57
|
|
|
58
|
+
Sharing `tokenKey` with the bonded client does not make another context or
|
|
59
|
+
provider an adapter. A context with copied `user` and `status`, local token
|
|
60
|
+
helpers, or a separate restore effect is still a second session store, even
|
|
61
|
+
when it uses the same storage key. Keep view adapters and debug bridges beside
|
|
62
|
+
the bond, but have them read the bonded client or framework binding instead of
|
|
63
|
+
mirroring session state.
|
|
64
|
+
|
|
58
65
|
**`initialize()` restores a cached token AND user BEFORE the first render.**
|
|
59
66
|
That restore is synchronous and costs no request. Cookie-only and token-only
|
|
60
67
|
restoration need an asynchronous current-user request. An HttpOnly
|
|
@@ -1635,6 +1642,25 @@ Peer dependencies:
|
|
|
1635
1642
|
- `@molecule/app-i18n`
|
|
1636
1643
|
- `@molecule/app-logger`
|
|
1637
1644
|
|
|
1645
|
+
**Synchronous getters for application integrations.** Read the shared client
|
|
1646
|
+
synchronously when an integration needs the raw token, auth state and current user.
|
|
1647
|
+
These reads create no second store: `getAccessToken()`
|
|
1648
|
+
returns the token, `getState().status` includes `unavailable`, and `getUser()` reads
|
|
1649
|
+
the mapped profile. The configured `tokenKey` also applies to these getters.
|
|
1650
|
+
Keep an integration's response shape local; do not persist another token or user.
|
|
1651
|
+
|
|
1652
|
+
```typescript
|
|
1653
|
+
import { getClient } from '@molecule/app-auth'
|
|
1654
|
+
const readSession = () => {
|
|
1655
|
+
const client = getClient()
|
|
1656
|
+
return {
|
|
1657
|
+
status: client.getState().status,
|
|
1658
|
+
user: client.getUser(),
|
|
1659
|
+
accessToken: client.getAccessToken(),
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
```
|
|
1663
|
+
|
|
1638
1664
|
- **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
1639
1665
|
login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
1640
1666
|
token and user out of the answer — keeping the wire bearer OUT of the profile,
|
package/dist/index.d.ts
CHANGED
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
* from `@molecule/app-bonds-default-react`, then call `initialize()`. The bond's
|
|
46
46
|
* HTTP-sync variants also register `whenRestored()` as the request gate.
|
|
47
47
|
*
|
|
48
|
+
* Sharing `tokenKey` with the bonded client does not make another context or
|
|
49
|
+
* provider an adapter. A context with copied `user` and `status`, local token
|
|
50
|
+
* helpers, or a separate restore effect is still a second session store, even
|
|
51
|
+
* when it uses the same storage key. Keep view adapters and debug bridges beside
|
|
52
|
+
* the bond, but have them read the bonded client or framework binding instead of
|
|
53
|
+
* mirroring session state.
|
|
54
|
+
*
|
|
48
55
|
* **`initialize()` restores a cached token AND user BEFORE the first render.**
|
|
49
56
|
* That restore is synchronous and costs no request. Cookie-only and token-only
|
|
50
57
|
* restoration need an asynchronous current-user request. An HttpOnly
|
|
@@ -304,6 +311,25 @@
|
|
|
304
311
|
* `RequestConfig.skipAuthGate` in `@molecule/app-http`.
|
|
305
312
|
*
|
|
306
313
|
* @remarks
|
|
314
|
+
* **Synchronous getters for application integrations.** Read the shared client
|
|
315
|
+
* synchronously when an integration needs the raw token, auth state and current user.
|
|
316
|
+
* These reads create no second store: `getAccessToken()`
|
|
317
|
+
* returns the token, `getState().status` includes `unavailable`, and `getUser()` reads
|
|
318
|
+
* the mapped profile. The configured `tokenKey` also applies to these getters.
|
|
319
|
+
* Keep an integration's response shape local; do not persist another token or user.
|
|
320
|
+
*
|
|
321
|
+
* ```typescript
|
|
322
|
+
* import { getClient } from '@molecule/app-auth'
|
|
323
|
+
* const readSession = () => {
|
|
324
|
+
* const client = getClient()
|
|
325
|
+
* return {
|
|
326
|
+
* status: client.getState().status,
|
|
327
|
+
* user: client.getUser(),
|
|
328
|
+
* accessToken: client.getAccessToken(),
|
|
329
|
+
* }
|
|
330
|
+
* }
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
307
333
|
* - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
308
334
|
* login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
309
335
|
* token and user out of the answer — keeping the wire bearer OUT of the profile,
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0cG;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
|
@@ -45,6 +45,13 @@
|
|
|
45
45
|
* from `@molecule/app-bonds-default-react`, then call `initialize()`. The bond's
|
|
46
46
|
* HTTP-sync variants also register `whenRestored()` as the request gate.
|
|
47
47
|
*
|
|
48
|
+
* Sharing `tokenKey` with the bonded client does not make another context or
|
|
49
|
+
* provider an adapter. A context with copied `user` and `status`, local token
|
|
50
|
+
* helpers, or a separate restore effect is still a second session store, even
|
|
51
|
+
* when it uses the same storage key. Keep view adapters and debug bridges beside
|
|
52
|
+
* the bond, but have them read the bonded client or framework binding instead of
|
|
53
|
+
* mirroring session state.
|
|
54
|
+
*
|
|
48
55
|
* **`initialize()` restores a cached token AND user BEFORE the first render.**
|
|
49
56
|
* That restore is synchronous and costs no request. Cookie-only and token-only
|
|
50
57
|
* restoration need an asynchronous current-user request. An HttpOnly
|
|
@@ -304,6 +311,25 @@
|
|
|
304
311
|
* `RequestConfig.skipAuthGate` in `@molecule/app-http`.
|
|
305
312
|
*
|
|
306
313
|
* @remarks
|
|
314
|
+
* **Synchronous getters for application integrations.** Read the shared client
|
|
315
|
+
* synchronously when an integration needs the raw token, auth state and current user.
|
|
316
|
+
* These reads create no second store: `getAccessToken()`
|
|
317
|
+
* returns the token, `getState().status` includes `unavailable`, and `getUser()` reads
|
|
318
|
+
* the mapped profile. The configured `tokenKey` also applies to these getters.
|
|
319
|
+
* Keep an integration's response shape local; do not persist another token or user.
|
|
320
|
+
*
|
|
321
|
+
* ```typescript
|
|
322
|
+
* import { getClient } from '@molecule/app-auth'
|
|
323
|
+
* const readSession = () => {
|
|
324
|
+
* const client = getClient()
|
|
325
|
+
* return {
|
|
326
|
+
* status: client.getState().status,
|
|
327
|
+
* user: client.getUser(),
|
|
328
|
+
* accessToken: client.getAccessToken(),
|
|
329
|
+
* }
|
|
330
|
+
* }
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
307
333
|
* - **An API with its own auth envelope keeps this client.** `requestBody` wraps the
|
|
308
334
|
* login/register payload (`(kind, p) => ({ user: p })`), `mapAuthResponse` reads the
|
|
309
335
|
* token and user out of the answer — keeping the wire bearer OUT of the profile,
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0cG;AAEH,cAAc,sBAAsB,CAAA;AACpC,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA"}
|