@molecule/app-bonds-default-react 1.1.3 → 1.1.5
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 +12 -4
- package/dist/auth.d.ts +18 -4
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +14 -0
- package/package.json +5 -5
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-
|
|
6
|
+
Generated: 2026-10-19T21:59:14.074Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-bonds-default-react
|
|
@@ -130,7 +130,7 @@ apps shipped byte-identically. Apps pass their own `authConfig`
|
|
|
130
130
|
(which lives in `src/config.ts`).
|
|
131
131
|
|
|
132
132
|
```typescript
|
|
133
|
-
function createDefaultAuthClient(authConfig: AuthClientConfig): {
|
|
133
|
+
function createDefaultAuthClient(authConfig: AuthClientConfig<TUser>): {
|
|
134
134
|
authClient: AuthClient<TUser, TRegister>
|
|
135
135
|
setupAuthDefault: () => void
|
|
136
136
|
}
|
|
@@ -157,7 +157,7 @@ with no `Authorization` header). The source is applied to the client WHENEVER it
|
|
|
157
157
|
bonded, so setup order no longer decides whether the first request is authorized.
|
|
158
158
|
|
|
159
159
|
```typescript
|
|
160
|
-
function createDefaultAuthClientWithHttpSync(authConfig: AuthClientConfig): {
|
|
160
|
+
function createDefaultAuthClientWithHttpSync(authConfig: AuthClientConfig<TUser>): {
|
|
161
161
|
authClient: AuthClient<TUser, TRegister>
|
|
162
162
|
setupAuthDefault: () => void
|
|
163
163
|
}
|
|
@@ -170,6 +170,14 @@ given `baseURL` (so molecule pkg `useGet('/path')` calls hit
|
|
|
170
170
|
`${baseURL}/path` instead of the SPA's catch-all route), AND keeps
|
|
171
171
|
its bearer token in sync with auth events.
|
|
172
172
|
|
|
173
|
+
The auth client restores a stored token AND user SYNCHRONOUSLY, so the first
|
|
174
|
+
render is the signed-in UI — do not gate a protected page (or a provider of
|
|
175
|
+
yours) on a current-user request. This bond registers `whenRestored()` as the
|
|
176
|
+
HTTP gate, so requests still wait for the background restore/verification to
|
|
177
|
+
settle; only `useAuth().status === 'loading'` means "no decision yet"
|
|
178
|
+
(xr-molecule-flash-m177: a page that waited on its own `/me` paid a round trip
|
|
179
|
+
on every navigation).
|
|
180
|
+
|
|
173
181
|
Used by apps where molecule packages render pricing / billing /
|
|
174
182
|
other authed JSON-fetching screens that need both behaviors.
|
|
175
183
|
|
|
@@ -179,7 +187,7 @@ mount cannot race it and answer for an anonymous viewer.
|
|
|
179
187
|
|
|
180
188
|
```typescript
|
|
181
189
|
function createDefaultAuthClientWithFetchClient(
|
|
182
|
-
authConfig: AuthClientConfig
|
|
190
|
+
authConfig: AuthClientConfig<TUser>,
|
|
183
191
|
fetchClientOptions: { baseURL: string; withCredentials?: boolean },
|
|
184
192
|
): { authClient: AuthClient<TUser, TRegister>; setupAuthDefault: () => void }
|
|
185
193
|
```
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AuthClient, AuthClientConfig, UserProfile } from '@molecule/app-auth';
|
|
1
|
+
import type { AuthClient, AuthClientConfig, RegisterExtraShape, UserProfile } from '@molecule/app-auth';
|
|
2
2
|
import type { HttpClient } from '@molecule/app-http';
|
|
3
3
|
/**
|
|
4
4
|
* Builds the default fetch-based HTTP client + wires it into
|
|
@@ -69,8 +69,14 @@ export declare function createDefaultHttpClientWithAuthBearer(opts: {
|
|
|
69
69
|
* `TRegister` is the app's own registration fields (`{ username: string }` for a
|
|
70
70
|
* RealWorld-shaped API), passed on to `@molecule/app-auth`'s factory so
|
|
71
71
|
* `authClient.register({ username, email, password })` type-checks with no cast.
|
|
72
|
+
*
|
|
73
|
+
* `TUser` is the profile the app's pages read. Type the config with the SAME
|
|
74
|
+
* type (`const authConfig: AuthClientConfig<MyUser> = { … }`) so its
|
|
75
|
+
* `mapAuthResponse` is checked against `MyUser`: a mapper that omits a required
|
|
76
|
+
* custom field then fails at the `createDefaultAuthClient<MyUser>(authConfig)`
|
|
77
|
+
* call instead of shipping a signed-in page that reads `undefined`.
|
|
72
78
|
*/
|
|
73
|
-
export declare function createDefaultAuthClient<TUser extends UserProfile = UserProfile, TRegister extends
|
|
79
|
+
export declare function createDefaultAuthClient<TUser extends UserProfile = UserProfile, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>(authConfig: AuthClientConfig<TUser>): {
|
|
74
80
|
authClient: AuthClient<TUser, TRegister>;
|
|
75
81
|
setupAuthDefault: () => void;
|
|
76
82
|
};
|
|
@@ -93,7 +99,7 @@ export declare function createDefaultAuthClient<TUser extends UserProfile = User
|
|
|
93
99
|
* with no `Authorization` header). The source is applied to the client WHENEVER it is
|
|
94
100
|
* bonded, so setup order no longer decides whether the first request is authorized.
|
|
95
101
|
*/
|
|
96
|
-
export declare function createDefaultAuthClientWithHttpSync<TUser extends UserProfile = UserProfile, TRegister extends
|
|
102
|
+
export declare function createDefaultAuthClientWithHttpSync<TUser extends UserProfile = UserProfile, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>(authConfig: AuthClientConfig<TUser>): {
|
|
97
103
|
authClient: AuthClient<TUser, TRegister>;
|
|
98
104
|
setupAuthDefault: () => void;
|
|
99
105
|
};
|
|
@@ -103,6 +109,14 @@ export declare function createDefaultAuthClientWithHttpSync<TUser extends UserPr
|
|
|
103
109
|
* `${baseURL}/path` instead of the SPA's catch-all route), AND keeps
|
|
104
110
|
* its bearer token in sync with auth events.
|
|
105
111
|
*
|
|
112
|
+
* The auth client restores a stored token AND user SYNCHRONOUSLY, so the first
|
|
113
|
+
* render is the signed-in UI — do not gate a protected page (or a provider of
|
|
114
|
+
* yours) on a current-user request. This bond registers `whenRestored()` as the
|
|
115
|
+
* HTTP gate, so requests still wait for the background restore/verification to
|
|
116
|
+
* settle; only `useAuth().status === 'loading'` means "no decision yet"
|
|
117
|
+
* (xr-molecule-flash-m177: a page that waited on its own `/me` paid a round trip
|
|
118
|
+
* on every navigation).
|
|
119
|
+
*
|
|
106
120
|
* Used by apps where molecule packages render pricing / billing /
|
|
107
121
|
* other authed JSON-fetching screens that need both behaviors.
|
|
108
122
|
*
|
|
@@ -110,7 +124,7 @@ export declare function createDefaultAuthClientWithHttpSync<TUser extends UserPr
|
|
|
110
124
|
* {@link registerAuthGate}), so a page that fetches viewer-dependent data on
|
|
111
125
|
* mount cannot race it and answer for an anonymous viewer.
|
|
112
126
|
*/
|
|
113
|
-
export declare function createDefaultAuthClientWithFetchClient<TUser extends UserProfile = UserProfile, TRegister extends
|
|
127
|
+
export declare function createDefaultAuthClientWithFetchClient<TUser extends UserProfile = UserProfile, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>>(authConfig: AuthClientConfig<TUser>, fetchClientOptions: {
|
|
114
128
|
baseURL: string;
|
|
115
129
|
withCredentials?: boolean;
|
|
116
130
|
}): {
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAuCpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IACxD,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EA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AAC,GAAG,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EAEtE,UAAU,EAAE,gBAAgB,CAAC,KAAK,CAAC,EACnC,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
|
@@ -105,6 +105,12 @@ export function createDefaultHttpClientWithAuthBearer(opts) {
|
|
|
105
105
|
* `TRegister` is the app's own registration fields (`{ username: string }` for a
|
|
106
106
|
* RealWorld-shaped API), passed on to `@molecule/app-auth`'s factory so
|
|
107
107
|
* `authClient.register({ username, email, password })` type-checks with no cast.
|
|
108
|
+
*
|
|
109
|
+
* `TUser` is the profile the app's pages read. Type the config with the SAME
|
|
110
|
+
* type (`const authConfig: AuthClientConfig<MyUser> = { … }`) so its
|
|
111
|
+
* `mapAuthResponse` is checked against `MyUser`: a mapper that omits a required
|
|
112
|
+
* custom field then fails at the `createDefaultAuthClient<MyUser>(authConfig)`
|
|
113
|
+
* call instead of shipping a signed-in page that reads `undefined`.
|
|
108
114
|
*/
|
|
109
115
|
export function createDefaultAuthClient(authConfig) {
|
|
110
116
|
const authClient = createJWTAuthClient(authConfig);
|
|
@@ -168,6 +174,14 @@ export function createDefaultAuthClientWithHttpSync(authConfig) {
|
|
|
168
174
|
* `${baseURL}/path` instead of the SPA's catch-all route), AND keeps
|
|
169
175
|
* its bearer token in sync with auth events.
|
|
170
176
|
*
|
|
177
|
+
* The auth client restores a stored token AND user SYNCHRONOUSLY, so the first
|
|
178
|
+
* render is the signed-in UI — do not gate a protected page (or a provider of
|
|
179
|
+
* yours) on a current-user request. This bond registers `whenRestored()` as the
|
|
180
|
+
* HTTP gate, so requests still wait for the background restore/verification to
|
|
181
|
+
* settle; only `useAuth().status === 'loading'` means "no decision yet"
|
|
182
|
+
* (xr-molecule-flash-m177: a page that waited on its own `/me` paid a round trip
|
|
183
|
+
* on every navigation).
|
|
184
|
+
*
|
|
171
185
|
* Used by apps where molecule packages render pricing / billing /
|
|
172
186
|
* other authed JSON-fetching screens that need both behaviors.
|
|
173
187
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-bonds-default-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
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.5.
|
|
41
|
+
"@molecule/app-auth": "1.5.9",
|
|
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",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"@molecule/app-drag-drop-dndkit": "1.0.2",
|
|
51
51
|
"@molecule/app-fonts": "1.2.1",
|
|
52
52
|
"@molecule/app-fonts-arimo": "1.0.3",
|
|
53
|
-
"@molecule/app-http": "1.
|
|
53
|
+
"@molecule/app-http": "1.4.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",
|
|
57
57
|
"@molecule/app-keyboard-shortcuts-hotkeys": "1.0.2",
|
|
58
58
|
"@molecule/app-maps-leaflet": "1.0.2",
|
|
59
|
-
"@molecule/app-realtime": "1.0.
|
|
60
|
-
"@molecule/app-realtime-socketio": "1.0
|
|
59
|
+
"@molecule/app-realtime": "1.0.3",
|
|
60
|
+
"@molecule/app-realtime-socketio": "1.1.0",
|
|
61
61
|
"@molecule/app-routing": "1.0.3",
|
|
62
62
|
"@molecule/app-routing-react-router": "1.0.2",
|
|
63
63
|
"@molecule/app-state": "1.0.3",
|