@cripty2001/utils 0.0.222 → 0.0.224

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.
@@ -18,7 +18,10 @@ function Button({ onClick, children, className }) {
18
18
  await p;
19
19
  }
20
20
  })()
21
- .catch(e => setError(e instanceof Error ? e.message : "Unknown error"))
21
+ .catch(e => {
22
+ console.trace("Caught error in button", e);
23
+ setError(e instanceof Error ? e.message : "Unknown error");
24
+ })
22
25
  .finally(() => setLoading(false));
23
26
  };
24
27
  return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col h-full w-full gap-2", children: [(0, jsx_runtime_1.jsx)("div", { onClick: handleClick, className: className, style: {
package/llms/appserver.md CHANGED
@@ -131,6 +131,29 @@ handler: async (input, auth) => {
131
131
  }
132
132
  ```
133
133
 
134
+ ### [Example] Recommended OIDC integration pattern (oidc-spa)
135
+
136
+ `Client` deliberately doesn't fetch or refresh tokens — that's the OIDC library's job. To stay logged in indefinitely, **proactively** push fresh tokens into the Client whenever your OIDC library renews them, then bind a UI overlay to `client.loggedIn` for the unrecoverable case.
137
+
138
+ Two-line proactive renewal (using `oidc-spa`):
139
+
140
+ ```ts
141
+ const oidc = await createOidc({ /* … */ });
142
+
143
+ if (oidc.isUserLoggedIn) {
144
+ const { idToken } = await oidc.getTokens();
145
+ await client.login(idToken);
146
+
147
+ // Re-push every time the underlying library refreshes the session.
148
+ oidc.subscribeToTokensChange(({ idToken }) => {
149
+ void client.login(idToken);
150
+ });
151
+ }
152
+
153
+ ```
154
+
155
+ This works because Client logged in status only changes when an api report an auth error, this mean that as long as the latest set token is valid, the api will never report an auth error.
156
+
134
157
  ---
135
158
 
136
159
  ## 7. Error handling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cripty2001/utils",
3
- "version": "0.0.222",
3
+ "version": "0.0.224",
4
4
  "description": "Internal Set of utils. If you need them use them, otherwise go to the next package ;)",
5
5
  "homepage": "https://github.com/cripty2001/utils#readme",
6
6
  "bugs": {