@hadoku/prefs-client 1.1.23 → 1.1.24
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/dist/index.js +7 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -131,22 +131,28 @@ function adaptWhoami(body) {
|
|
|
131
131
|
}
|
|
132
132
|
return { userId: UNSCOPED_ID, userType, name, scope: "none", ...verified };
|
|
133
133
|
}
|
|
134
|
+
var WHOAMI_TIMEOUT_MS = 3e3;
|
|
134
135
|
async function fetchWhoamiRaw(url, userKey) {
|
|
135
136
|
const headers = {};
|
|
136
137
|
if (userKey) {
|
|
137
138
|
headers["X-User-Key"] = userKey;
|
|
138
139
|
}
|
|
140
|
+
const ctrl = new AbortController();
|
|
141
|
+
const timer = setTimeout(() => ctrl.abort(), WHOAMI_TIMEOUT_MS);
|
|
139
142
|
try {
|
|
140
143
|
const resp = await fetch(url, {
|
|
141
144
|
method: "GET",
|
|
142
145
|
headers,
|
|
143
146
|
credentials: "include",
|
|
144
|
-
cache: "no-store"
|
|
147
|
+
cache: "no-store",
|
|
148
|
+
signal: ctrl.signal
|
|
145
149
|
});
|
|
146
150
|
if (!resp.ok) return null;
|
|
147
151
|
return await resp.json();
|
|
148
152
|
} catch {
|
|
149
153
|
return null;
|
|
154
|
+
} finally {
|
|
155
|
+
clearTimeout(timer);
|
|
150
156
|
}
|
|
151
157
|
}
|
|
152
158
|
function defaultWhoamiUrl() {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hadoku/prefs-client",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"gitHead": "
|
|
3
|
+
"version": "1.1.24",
|
|
4
|
+
"gitHead": "b8e1b3041aaaaf00f0944198eebcc1f9f1d39659",
|
|
5
5
|
"description": "Client SDK for the hadoku unified preferences store. Wraps /prefs/api/v1/* with localStorage caching, debounced writes, Zod-validated reads, and a usePrefs() React hook, plus match history, ratings and leaderboards for every game (./games), the one resolved avatar per user (./avatar), and the avatar cosmetics renderer (./cosmetics).",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|