castle-web-sdk 0.4.23 → 0.4.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/README.md CHANGED
@@ -4,8 +4,10 @@
4
4
  platform — for example, a deck can save per-player data, post and read
5
5
  scores on a leaderboard, or get a server-synced time for daily content.
6
6
 
7
- Comes with `castle-web init`. Import what you need from
8
- `castle-web-sdk`:
7
+ Comes with every deck: the SDK is a file of the `base` kit each deck
8
+ imports (`imports/castle.base/sdk/`), and the bare specifier resolves
9
+ there — nothing to install, and no deck `package.json` names it. Import
10
+ what you need from `castle-web-sdk`:
9
11
 
10
12
  ```js
11
13
  import { setup, initCard, Storage, Leaderboard } from "castle-web-sdk";
@@ -255,7 +257,10 @@ const dailyPuzzle = (date.daysSinceCastleEpoch % 30) + 1;
255
257
  Returns the signed-in player. Throws `CastleError`
256
258
  (`LOGIN_REQUIRED`) when nobody is signed in.
257
259
 
258
- The returned `CastleUser` has `userId`, `username`, and `isActive`.
260
+ The returned `CastleUser` has `userId`, `username`, `isAnonymous`, and `isActive`.
261
+ Anonymous accounts are real logins with generated `anonymous-user-...` names;
262
+ check `isAnonymous` before accepting writes into anything other players see,
263
+ such as a shared gallery.
259
264
 
260
265
  ```js
261
266
  const me = await User.getCurrent();
@@ -136,6 +136,7 @@ export interface CommandResult {
136
136
  user: {
137
137
  userId: string;
138
138
  username: string;
139
+ isAnonymous?: boolean;
139
140
  } | null;
140
141
  };
141
142
  "time.getServerTime": {
package/dist/user.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface CastleUser {
2
2
  userId: string;
3
3
  username: string;
4
+ isAnonymous: boolean;
4
5
  isActive: boolean;
5
6
  }
6
7
  export interface CastleUserApi {
package/dist/user.js CHANGED
@@ -24,9 +24,13 @@ async function fetchCurrentUser() {
24
24
  operation,
25
25
  });
26
26
  }
27
+ const username = requiredString(user.username, "user.username", operation);
27
28
  return {
28
29
  userId: requiredString(user.userId, "user.userId", operation),
29
- username: requiredString(user.username, "user.username", operation),
30
+ username,
31
+ // A host that predates the flag omits it; anonymous account usernames are
32
+ // always minted as `anonymous-user-<uuid>`, so the prefix is the fallback.
33
+ isAnonymous: user.isAnonymous === true || username.toLowerCase().startsWith("anonymous-user-"),
30
34
  isActive: true,
31
35
  };
32
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-sdk",
3
- "version": "0.4.23",
3
+ "version": "0.4.24",
4
4
  "type": "module",
5
5
  "main": "dist/castle.js",
6
6
  "types": "dist/castle.d.ts",