@molecule/app-bonds-default-react 1.1.0 → 1.1.1

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.
@@ -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;AAOpD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG;IACxD,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;GASG;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,SAAS,CAAA;CAC1C,GAAG;IACF,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAmBA;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAC7E,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EACzF,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,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,CAMA;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EACzF,UAAU,EAAE,gBAAgB,GAC3B;IACD,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CA2BA;AAED;;;;;;;;GAQG;AACH,wBAAgB,sCAAsC,CAAC,KAAK,SAAS,WAAW,GAAG,WAAW,EAC5F,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,CAAC,CAAA;IAC7B,gBAAgB,EAAE,MAAM,IAAI,CAAA;CAC7B,CA2BA"}
package/dist/auth.js CHANGED
@@ -1,5 +1,26 @@
1
1
  import { createJWTAuthClient, setClient } from '@molecule/app-auth';
2
- import { createFetchClient, getClient as getHttpClient, setClient as setHttpClient, } from '@molecule/app-http';
2
+ import { createFetchClient, getClient as getHttpClient, setAuthGate, setClient as setHttpClient, } from '@molecule/app-http';
3
+ /**
4
+ * Holds every HTTP request until this auth client's session restore has settled.
5
+ *
6
+ * Without it a page effect that fires on mount (fetching a profile's `following`
7
+ * flag, a feed, a `favorited` state) sends its request before `initialize()` has
8
+ * restored the session, so it leaves with no `Authorization` header and the server
9
+ * answers for an anonymous viewer. Localhost usually hides it — the restore wins
10
+ * the race against the first effect there — and the deployed URL exposes it, which
11
+ * is how X1 xr-molecule-flash-m95 spent ~25 min treating a "Follow" button on a
12
+ * followed user as database leftovers.
13
+ *
14
+ * `whenRestored()` resolves immediately when no restore is in flight, so a request
15
+ * made after boot never waits at all; it holds only while the restore is actually
16
+ * running. A provider without `whenRestored` (a bond that restores nothing) leaves
17
+ * requests ungated.
18
+ *
19
+ * @param authClient - The bonded auth client.
20
+ */
21
+ function registerAuthGate(authClient) {
22
+ setAuthGate(() => authClient.whenRestored?.() ?? Promise.resolve());
23
+ }
3
24
  /**
4
25
  * Builds the default fetch-based HTTP client + wires it into
5
26
  * `@molecule/app-http`. Replaces the per-app `bonds/http-default.ts`
@@ -91,6 +112,9 @@ export function createDefaultAuthClientWithHttpSync(authConfig) {
91
112
  authClient,
92
113
  setupAuthDefault: () => {
93
114
  setClient(authClient);
115
+ // Requests made while the session is still restoring wait for it, so a page
116
+ // effect that fetches viewer-dependent data on mount cannot race the restore.
117
+ registerAuthGate(authClient);
94
118
  const initialToken = authClient.getAccessToken();
95
119
  if (initialToken) {
96
120
  getHttpClient().setAuthToken(initialToken);
@@ -131,6 +155,7 @@ export function createDefaultAuthClientWithFetchClient(authConfig, fetchClientOp
131
155
  });
132
156
  setHttpClient(httpClient);
133
157
  setClient(authClient);
158
+ registerAuthGate(authClient);
134
159
  const initialToken = authClient.getAccessToken();
135
160
  if (initialToken) {
136
161
  httpClient.setAuthToken(initialToken);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-bonds-default-react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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.2.1",
41
+ "@molecule/app-auth": "1.2.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",
@@ -50,7 +50,7 @@
50
50
  "@molecule/app-drag-drop-dndkit": "1.0.2",
51
51
  "@molecule/app-fonts": "1.1.0",
52
52
  "@molecule/app-fonts-arimo": "1.0.2",
53
- "@molecule/app-http": "1.1.1",
53
+ "@molecule/app-http": "1.1.2",
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",