@molecule/app-react 1.11.0 → 2.0.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-25T09:04:08.240Z
6
+ Generated: 2026-10-25T20:03:36.228Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-react
@@ -250,9 +250,12 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
250
250
  confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
251
251
  /**
252
252
  * Updates the current user's profile.
253
- * Returns the saved response. If the session is explicitly replaced or ended
254
- * while the request is pending, that response does not replace the current
255
- * session's user or persisted cache.
253
+ * Returns the saved profile: the answer applied onto the signed-in user field
254
+ * by field, with or without an `id` — a field it carries replaces the value
255
+ * (`null` clears it), one it omits or leaves `undefined` is kept, so a field
256
+ * cleared by omission must arrive as `null`. A non-object answer is returned
257
+ * as it came. An answer for a replaced or ended session leaves the current one
258
+ * untouched.
256
259
  */
257
260
  updateProfile(data: Partial<T>): Promise<T>;
258
261
  /**
@@ -308,9 +311,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
308
311
  * Resolves when the session restore started by `initialize()` has settled — the point
309
312
  * after which the client knows whether this visitor is signed in.
310
313
  *
311
- * Resolves IMMEDIATELY when no restore is in flight: before `initialize()` is ever
312
- * called, and after it has finished. A restore that failed resolves too (it settled the
313
- * question), so an HTTP client can await this before every request without risking one
314
314
  // … truncated — the full declaration is in node_modules/@molecule/app-react/dist
315
315
  ```
316
316
 
@@ -518,12 +518,50 @@ interface HttpClient {
518
518
  addErrorInterceptor(interceptor: ErrorInterceptor): () => void
519
519
  /**
520
520
  * Sets the authorization token.
521
+ *
522
+ * A static token: every request carries it until the next `setAuthToken` call. A client
523
+ * that has a {@link HttpClient.setAuthTokenResolver | resolver} (registered through
524
+ * `@molecule/app-http`'s `setAuthTokenSource`) ignores this value when it assembles a
525
+ * request — the resolver IS the session, and reading it per request is what keeps a
526
+ * session adopted without an auth event from sending the previous account's bearer. Once
527
+ * the resolver is removed, the static token is sent again.
521
528
  */
522
529
  setAuthToken(token: string | null): void
523
530
  /**
524
- * Returns the current authorization token, or `null` if not set.
531
+ * Returns the token the client applies to its next request: the resolver's answer when one
532
+ * is registered, else the static token from `setAuthToken`.
525
533
  */
526
534
  getAuthToken(): string | null
535
+ /**
536
+ * Registers the LIVE token resolver every request of this client reads, or clears it with
537
+ * `null`.
538
+ *
539
+ * `@molecule/app-http`'s `setAuthTokenSource()` calls this on every client it bonds, and the
540
+ * client MUST consult the resolver again each time it assembles a request (and report it from
541
+ * `getAuthToken()`). A session can change with no auth event and no observable state change —
542
+ * `authClient.setSession()` with the same profile data, or the OAuth callback's
543
+ * `setAccessToken()` — so a token pushed only at bond time or on `login`/`logout` events
544
+ * leaves every later request carrying the PREVIOUS session's bearer while the UI shows the
545
+ * new one.
546
+ *
547
+ * The resolved token takes the static token's place, with the same precedence: an
548
+ * `Authorization` header passed per request or in the client's default headers wins over it
549
+ * exactly where it won over a static token in this transport.
550
+ *
551
+ * A resolver that returns `null` (or `undefined`) means "this session has no body token": the
552
+ * request carries no `Authorization` header of the client's own. A cookie-session API issues
553
+ * no bearer, and the server prefers the header over the fresh cookie, so a kept bearer
554
+ * authenticates as the prior — possibly deleted — session.
555
+ *
556
+ * Optional, so an implementation written against the previous interface still conforms.
557
+ * `setAuthTokenSource()` follows such a client through a request interceptor instead, pushing
558
+ * the source with `setAuthToken` before each request: that request carries the change only
559
+ * when the transport applies its token after running its interceptors, so a transport that
560
+ * applies it earlier sends a session adopted mid-page from the following request on.
561
+ *
562
+ * @param resolver - Returns the current access token (or null/undefined), or `null` to clear.
563
+ */
564
+ setAuthTokenResolver?(resolver: AuthTokenResolver | null): void
527
565
  /**
528
566
  * Registers a handler for authentication errors (401).
529
567
  *
@@ -1418,7 +1456,7 @@ interface UseAuthResult<
1418
1456
  *
1419
1457
  * `setUser` alone does NOT sign the client in, and `setAccessToken` changes
1420
1458
  * storage only — using those two for a caller-issued session leaves every
1421
- * `authenticated` read signed out (xr-molecule-flash-m178).
1459
+ * `authenticated` read signed out.
1422
1460
  */
1423
1461
  setSession: AuthClient<T>['setSession']
1424
1462
  isAuthenticated: boolean
@@ -3148,7 +3186,7 @@ const PreviewContext: Context<PreviewProvider | null>
3148
3186
 
3149
3187
  Peer dependencies:
3150
3188
 
3151
- - `@molecule/app-auth` ^1.0.1 || ^2.0.0
3189
+ - `@molecule/app-auth` ^3.0.0
3152
3190
  - `@molecule/app-ai-models` ^1.0.1
3153
3191
  - `@molecule/app-forms` ^1.0.1
3154
3192
  - `@molecule/app-utilities` ^1.0.1
package/dist/types.d.ts CHANGED
@@ -161,7 +161,7 @@ export interface UseAuthResult<T = unknown, TRegister extends RegisterExtraShape
161
161
  *
162
162
  * `setUser` alone does NOT sign the client in, and `setAccessToken` changes
163
163
  * storage only — using those two for a caller-issued session leaves every
164
- * `authenticated` read signed out (xr-molecule-flash-m178).
164
+ * `authenticated` read signed out.
165
165
  */
166
166
  setSession: AuthClient<T>['setSession'];
167
167
  isAuthenticated: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-react",
3
- "version": "1.11.0",
3
+ "version": "2.0.0",
4
4
  "description": "React framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,7 +23,7 @@
23
23
  "node": ">=20"
24
24
  },
25
25
  "peerDependencies": {
26
- "@molecule/app-auth": "^1.0.1 || ^2.0.0",
26
+ "@molecule/app-auth": "^3.0.0",
27
27
  "@molecule/app-ai-models": "^1.0.1",
28
28
  "@molecule/app-forms": "^1.0.1",
29
29
  "@molecule/app-utilities": "^1.0.1",
@@ -61,7 +61,7 @@
61
61
  },
62
62
  "devDependencies": {
63
63
  "@molecule/app-ai-models": "1.4.3",
64
- "@molecule/app-bonds-default-react": "2.0.0",
64
+ "@molecule/app-bonds-default-react": "3.0.0",
65
65
  "@molecule/app-i18n": "1.1.0",
66
66
  "@testing-library/dom": "10.4.2",
67
67
  "@testing-library/react": "16.3.3",