@hadoku/prefs-client 1.1.29 → 1.1.30

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.d.ts CHANGED
@@ -90,6 +90,12 @@ interface WhoamiResult {
90
90
  * means not verified, as the header's absence does.
91
91
  */
92
92
  verified?: true;
93
+ /**
94
+ * This browser is a TV (the edge's `isTvUserAgent`, on every answer, signed
95
+ * in or not): an app may start in its 10-foot layout. Present only as
96
+ * `true`, like `verified`.
97
+ */
98
+ tv?: true;
93
99
  }
94
100
  interface WhoamiOpts {
95
101
  /** Override the base URL for testing. Default: edge-router origin. */
package/dist/index.js CHANGED
@@ -125,14 +125,15 @@ var WHOAMI_GLOBAL = "__hadokuWhoami";
125
125
  var SESSION_SCOPE_PREFIX = "sess:";
126
126
  var UNSCOPED_ID = "unscoped";
127
127
  function adaptWhoami(body) {
128
+ const tv = body?.tv === true ? { tv: true } : {};
128
129
  if (!body || body.valid === false) {
129
- return { userId: ANON_USER_ID, userType: "public", scope: "anon" };
130
+ return { userId: ANON_USER_ID, userType: "public", scope: "anon", ...tv };
130
131
  }
131
132
  const userType = body.userType === "admin" || body.userType === "wife" || body.userType === "service" || body.userType === "friend" || body.userType === "member" || body.userType === "guest" || body.userType === "public" ? body.userType : "public";
132
133
  const name = typeof body.name === "string" ? body.name : null;
133
134
  const verified = body.verified === true ? { verified: true } : {};
134
135
  if (typeof body.userId === "string" && body.userId) {
135
- return { userId: body.userId, userType, name, scope: "user", ...verified };
136
+ return { userId: body.userId, userType, name, scope: "user", ...verified, ...tv };
136
137
  }
137
138
  if (typeof body.sessionId === "string" && body.sessionId) {
138
139
  return {
@@ -140,10 +141,11 @@ function adaptWhoami(body) {
140
141
  userType,
141
142
  name,
142
143
  scope: "session",
143
- ...verified
144
+ ...verified,
145
+ ...tv
144
146
  };
145
147
  }
146
- return { userId: UNSCOPED_ID, userType, name, scope: "none", ...verified };
148
+ return { userId: UNSCOPED_ID, userType, name, scope: "none", ...verified, ...tv };
147
149
  }
148
150
  var WHOAMI_TIMEOUT_MS = 3e3;
149
151
  async function fetchWhoamiRaw(url, userKey) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hadoku/prefs-client",
3
- "version": "1.1.29",
4
- "gitHead": "1a8adf4b1717bfa1bb9a18d7680d0fc7db2d7a5b",
3
+ "version": "1.1.30",
4
+ "gitHead": "ebe6f933a83bfe3f1957d23beba6edda1bb8c817",
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",