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 +8 -3
- package/dist/commands.d.ts +1 -0
- package/dist/user.d.ts +1 -0
- package/dist/user.js +5 -1
- package/package.json +1 -1
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
|
|
8
|
-
`castle
|
|
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();
|
package/dist/commands.d.ts
CHANGED
package/dist/user.d.ts
CHANGED
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
|
|
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
|
}
|