@molecule/app-bonds-default-react 1.1.2 → 1.1.3

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-16T23:54:35.164Z
6
+ Generated: 2026-10-18T09:50:35.607Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-bonds-default-react
@@ -131,7 +131,7 @@ apps shipped byte-identically. Apps pass their own `authConfig`
131
131
 
132
132
  ```typescript
133
133
  function createDefaultAuthClient(authConfig: AuthClientConfig): {
134
- authClient: AuthClient<TUser>
134
+ authClient: AuthClient<TUser, TRegister>
135
135
  setupAuthDefault: () => void
136
136
  }
137
137
  ```
@@ -149,9 +149,16 @@ on setup, then listens for auth events to keep them aligned, and holds
149
149
  requests until the session restore settles so a page effect that fetches
150
150
  viewer-dependent data on mount cannot race it (see {@link registerAuthGate}).
151
151
 
152
+ The hydrated token is delivered through `@molecule/app-http`'s token source, not
153
+ through a client read at setup: the scaffold wires auth BEFORE http, so a client
154
+ read here is the unbonded fallback and the restored session's token would land on a
155
+ client nothing sends through (xr-molecule-flash-m156 — a reload sent every request
156
+ with no `Authorization` header). The source is applied to the client WHENEVER it is
157
+ bonded, so setup order no longer decides whether the first request is authorized.
158
+
152
159
  ```typescript
153
160
  function createDefaultAuthClientWithHttpSync(authConfig: AuthClientConfig): {
154
- authClient: AuthClient<TUser>
161
+ authClient: AuthClient<TUser, TRegister>
155
162
  setupAuthDefault: () => void
156
163
  }
157
164
  ```
@@ -174,7 +181,7 @@ mount cannot race it and answer for an anonymous viewer.
174
181
  function createDefaultAuthClientWithFetchClient(
175
182
  authConfig: AuthClientConfig,
176
183
  fetchClientOptions: { baseURL: string; withCredentials?: boolean },
177
- ): { authClient: AuthClient<TUser>; setupAuthDefault: () => void }
184
+ ): { authClient: AuthClient<TUser, TRegister>; setupAuthDefault: () => void }
178
185
  ```
179
186
 
180
187
  #### `bootstrapApp(opts)`
package/dist/auth.d.ts CHANGED
@@ -65,9 +65,13 @@ export declare function createDefaultHttpClientWithAuthBearer(opts: {
65
65
  * export const { authClient, setupAuthDefault } =
66
66
  * createDefaultAuthClient(authConfig)
67
67
  * ```
68
+ *
69
+ * `TRegister` is the app's own registration fields (`{ username: string }` for a
70
+ * RealWorld-shaped API), passed on to `@molecule/app-auth`'s factory so
71
+ * `authClient.register({ username, email, password })` type-checks with no cast.
68
72
  */
69
- export declare function createDefaultAuthClient<TUser extends UserProfile = UserProfile>(authConfig: AuthClientConfig): {
70
- authClient: AuthClient<TUser>;
73
+ export declare function createDefaultAuthClient<TUser extends UserProfile = UserProfile, TRegister extends Record<string, unknown> = Record<never, never>>(authConfig: AuthClientConfig): {
74
+ authClient: AuthClient<TUser, TRegister>;
71
75
  setupAuthDefault: () => void;
72
76
  };
73
77
  /**
@@ -81,9 +85,16 @@ export declare function createDefaultAuthClient<TUser extends UserProfile = User
81
85
  * on setup, then listens for auth events to keep them aligned, and holds
82
86
  * requests until the session restore settles so a page effect that fetches
83
87
  * viewer-dependent data on mount cannot race it (see {@link registerAuthGate}).
88
+ *
89
+ * The hydrated token is delivered through `@molecule/app-http`'s token source, not
90
+ * through a client read at setup: the scaffold wires auth BEFORE http, so a client
91
+ * read here is the unbonded fallback and the restored session's token would land on a
92
+ * client nothing sends through (xr-molecule-flash-m156 — a reload sent every request
93
+ * with no `Authorization` header). The source is applied to the client WHENEVER it is
94
+ * bonded, so setup order no longer decides whether the first request is authorized.
84
95
  */
85
- export declare function createDefaultAuthClientWithHttpSync<TUser extends UserProfile = UserProfile>(authConfig: AuthClientConfig): {
86
- authClient: AuthClient<TUser>;
96
+ export declare function createDefaultAuthClientWithHttpSync<TUser extends UserProfile = UserProfile, TRegister extends Record<string, unknown> = Record<never, never>>(authConfig: AuthClientConfig): {
97
+ authClient: AuthClient<TUser, TRegister>;
87
98
  setupAuthDefault: () => void;
88
99
  };
89
100
  /**
@@ -99,11 +110,11 @@ export declare function createDefaultAuthClientWithHttpSync<TUser extends UserPr
99
110
  * {@link registerAuthGate}), so a page that fetches viewer-dependent data on
100
111
  * mount cannot race it and answer for an anonymous viewer.
101
112
  */
102
- export declare function createDefaultAuthClientWithFetchClient<TUser extends UserProfile = UserProfile>(authConfig: AuthClientConfig, fetchClientOptions: {
113
+ export declare function createDefaultAuthClientWithFetchClient<TUser extends UserProfile = UserProfile, TRegister extends Record<string, unknown> = Record<never, never>>(authConfig: AuthClientConfig, fetchClientOptions: {
103
114
  baseURL: string;
104
115
  withCredentials?: boolean;
105
116
  }): {
106
- authClient: AuthClient<TUser>;
117
+ authClient: AuthClient<TUser, TRegister>;
107
118
  setupAuthDefault: () => void;
108
119
  };
109
120
  //# sourceMappingURL=auth.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEnF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAsCpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IACxD,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qCAAqC,CAAC,IAAI,EAAE;IAC1D,OAAO,EAAE,MAAM,CAAA;IACf,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG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G,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAEhE,UAAU,EAAE,gBAAgB,EAC5B,kBAAkB,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,GACjE;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;IACxC,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CA2BA"}
package/dist/auth.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createJWTAuthClient, setClient } from '@molecule/app-auth';
2
- import { createFetchClient, getClient as getHttpClient, setAuthGate, setClient as setHttpClient, } from '@molecule/app-http';
2
+ import { createFetchClient, getClient as getHttpClient, setAuthGate, setAuthTokenSource as setHttpAuthTokenSource, setClient as setHttpClient, } from '@molecule/app-http';
3
3
  /**
4
4
  * Holds every HTTP request until this auth client's session restore has settled.
5
5
  *
@@ -101,6 +101,10 @@ export function createDefaultHttpClientWithAuthBearer(opts) {
101
101
  * export const { authClient, setupAuthDefault } =
102
102
  * createDefaultAuthClient(authConfig)
103
103
  * ```
104
+ *
105
+ * `TRegister` is the app's own registration fields (`{ username: string }` for a
106
+ * RealWorld-shaped API), passed on to `@molecule/app-auth`'s factory so
107
+ * `authClient.register({ username, email, password })` type-checks with no cast.
104
108
  */
105
109
  export function createDefaultAuthClient(authConfig) {
106
110
  const authClient = createJWTAuthClient(authConfig);
@@ -120,6 +124,13 @@ export function createDefaultAuthClient(authConfig) {
120
124
  * on setup, then listens for auth events to keep them aligned, and holds
121
125
  * requests until the session restore settles so a page effect that fetches
122
126
  * viewer-dependent data on mount cannot race it (see {@link registerAuthGate}).
127
+ *
128
+ * The hydrated token is delivered through `@molecule/app-http`'s token source, not
129
+ * through a client read at setup: the scaffold wires auth BEFORE http, so a client
130
+ * read here is the unbonded fallback and the restored session's token would land on a
131
+ * client nothing sends through (xr-molecule-flash-m156 — a reload sent every request
132
+ * with no `Authorization` header). The source is applied to the client WHENEVER it is
133
+ * bonded, so setup order no longer decides whether the first request is authorized.
123
134
  */
124
135
  export function createDefaultAuthClientWithHttpSync(authConfig) {
125
136
  const authClient = createJWTAuthClient(authConfig);
@@ -130,10 +141,11 @@ export function createDefaultAuthClientWithHttpSync(authConfig) {
130
141
  // Requests made while the session is still restoring wait for it, so a page
131
142
  // effect that fetches viewer-dependent data on mount cannot race the restore.
132
143
  registerAuthGate(authClient);
133
- const initialToken = authClient.getAccessToken();
134
- if (initialToken) {
135
- getHttpClient().setAuthToken(initialToken);
136
- }
144
+ // Resolve the HTTP client per sync, never once here. `setClient` runs this
145
+ // source, so the token reaches the client the scaffold bonds later as well as
146
+ // one already bonded; a client kept from this moment would be the throwaway
147
+ // fallback the later `setHttpDefault()` replaces.
148
+ setHttpAuthTokenSource(() => authClient.getAccessToken());
137
149
  authClient.addEventListener((event) => {
138
150
  if (event.type === 'login' || event.type === 'register' || event.type === 'refresh') {
139
151
  // Mirror the auth client's token EXACTLY — including null. Cookie-session
@@ -172,13 +184,13 @@ export function createDefaultAuthClientWithFetchClient(authConfig, fetchClientOp
172
184
  baseURL: fetchClientOptions.baseURL,
173
185
  withCredentials: fetchClientOptions.withCredentials ?? true,
174
186
  });
187
+ // Registered BEFORE the bond: `setHttpClient` applies the restored session's
188
+ // token, and the same source reaches any client an app bonds later instead of
189
+ // this one (xr-molecule-flash-m156 — a client captured at setup cannot).
190
+ setHttpAuthTokenSource(() => authClient.getAccessToken());
175
191
  setHttpClient(httpClient);
176
192
  setClient(authClient);
177
193
  registerAuthGate(authClient);
178
- const initialToken = authClient.getAccessToken();
179
- if (initialToken) {
180
- httpClient.setAuthToken(initialToken);
181
- }
182
194
  authClient.addEventListener((event) => {
183
195
  if (event.type === 'login' || event.type === 'register' || event.type === 'refresh') {
184
196
  // Mirror the token exactly, including null — see the identical note in
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-bonds-default-react",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Default app-side bond wirings for React+Tailwind+react-router+localStorage+Arimo font+molecule icons. 5 setup functions consolidating 665 byte-identical per-app bond wiring files across the fleet.",
5
5
  "homepage": "https://www.molecule.dev/packages/app-bonds-default-react",
6
6
  "type": "module",
@@ -38,7 +38,7 @@
38
38
  "directory": "packages/app/infrastructure/bonds-default-react"
39
39
  },
40
40
  "devDependencies": {
41
- "@molecule/app-auth": "1.3.0",
41
+ "@molecule/app-auth": "1.5.2",
42
42
  "@molecule/app-charts-chartjs": "1.0.2",
43
43
  "@molecule/app-client-search": "1.0.2",
44
44
  "@molecule/app-client-search-minisearch": "1.0.3",
@@ -48,9 +48,9 @@
48
48
  "@molecule/app-command-palette-cmdk": "1.0.2",
49
49
  "@molecule/app-drag-drop": "1.0.2",
50
50
  "@molecule/app-drag-drop-dndkit": "1.0.2",
51
- "@molecule/app-fonts": "1.1.0",
52
- "@molecule/app-fonts-arimo": "1.0.2",
53
- "@molecule/app-http": "1.1.3",
51
+ "@molecule/app-fonts": "1.2.1",
52
+ "@molecule/app-fonts-arimo": "1.0.3",
53
+ "@molecule/app-http": "1.2.0",
54
54
  "@molecule/app-icons": "1.0.2",
55
55
  "@molecule/app-icons-molecule": "1.0.2",
56
56
  "@molecule/app-keyboard-shortcuts": "1.0.2",
@@ -65,7 +65,7 @@
65
65
  "@molecule/app-storage-localstorage": "1.0.2",
66
66
  "@molecule/app-theme": "1.0.3",
67
67
  "@molecule/app-theme-css-variables": "1.0.3",
68
- "@molecule/app-ui": "1.3.6",
68
+ "@molecule/app-ui": "1.3.7",
69
69
  "@molecule/app-ui-tailwind": "1.2.6",
70
70
  "@molecule/app-video-hls": "1.0.2",
71
71
  "@molecule/app-virtual-scroll": "1.0.2",