@crowdedkingdoms/crowdyjs 13.9.0 → 14.1.0

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.
Files changed (84) hide show
  1. package/MIGRATION.md +44 -0
  2. package/README.md +68 -33
  3. package/dist/binary-relay.d.ts +1 -1
  4. package/dist/binary-relay.js +1 -1
  5. package/dist/client.d.ts +27 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +61 -2
  8. package/dist/crowdy-client.d.ts +29 -34
  9. package/dist/crowdy-client.d.ts.map +1 -1
  10. package/dist/crowdy-client.js +67 -40
  11. package/dist/datacenter-redirect.d.ts +49 -0
  12. package/dist/datacenter-redirect.d.ts.map +1 -0
  13. package/dist/datacenter-redirect.js +62 -0
  14. package/dist/domains/appAccess.d.ts +3 -3
  15. package/dist/domains/appAccess.d.ts.map +1 -1
  16. package/dist/domains/appAccess.js +16 -16
  17. package/dist/domains/apps.d.ts +4 -8
  18. package/dist/domains/apps.d.ts.map +1 -1
  19. package/dist/domains/apps.js +19 -23
  20. package/dist/domains/auth.d.ts +1 -1
  21. package/dist/domains/billing.d.ts +3 -3
  22. package/dist/domains/billing.d.ts.map +1 -1
  23. package/dist/domains/billing.js +9 -9
  24. package/dist/domains/controlPlane.d.ts +2 -2
  25. package/dist/domains/controlPlane.d.ts.map +1 -1
  26. package/dist/domains/controlPlane.js +4 -4
  27. package/dist/domains/discovery.d.ts +50 -0
  28. package/dist/domains/discovery.d.ts.map +1 -0
  29. package/dist/domains/discovery.js +35 -0
  30. package/dist/domains/marketplace.d.ts +4 -5
  31. package/dist/domains/marketplace.d.ts.map +1 -1
  32. package/dist/domains/marketplace.js +25 -26
  33. package/dist/domains/organizations.d.ts +3 -3
  34. package/dist/domains/organizations.d.ts.map +1 -1
  35. package/dist/domains/organizations.js +22 -22
  36. package/dist/domains/payments.d.ts +3 -3
  37. package/dist/domains/payments.d.ts.map +1 -1
  38. package/dist/domains/payments.js +11 -11
  39. package/dist/domains/platform.d.ts +5 -6
  40. package/dist/domains/platform.d.ts.map +1 -1
  41. package/dist/domains/platform.js +6 -7
  42. package/dist/domains/portal.d.ts +19 -2
  43. package/dist/domains/portal.d.ts.map +1 -1
  44. package/dist/domains/portal.js +12 -12
  45. package/dist/domains/quotas.d.ts +3 -3
  46. package/dist/domains/quotas.d.ts.map +1 -1
  47. package/dist/domains/quotas.js +8 -8
  48. package/dist/domains/serverStatus.d.ts +1 -2
  49. package/dist/domains/serverStatus.d.ts.map +1 -1
  50. package/dist/domains/serverStatus.js +1 -2
  51. package/dist/domains/sharedEnvironment.d.ts +3 -3
  52. package/dist/domains/sharedEnvironment.d.ts.map +1 -1
  53. package/dist/domains/sharedEnvironment.js +15 -15
  54. package/dist/domains/udp.d.ts +1 -1
  55. package/dist/domains/udp.js +1 -1
  56. package/dist/domains/usage.d.ts +2 -2
  57. package/dist/domains/usage.d.ts.map +1 -1
  58. package/dist/domains/usage.js +5 -5
  59. package/dist/domains/users.d.ts +1 -1
  60. package/dist/domains/users.js +1 -1
  61. package/dist/errors.d.ts +56 -0
  62. package/dist/errors.d.ts.map +1 -1
  63. package/dist/errors.js +64 -0
  64. package/dist/generated/graphql.d.ts +65 -16
  65. package/dist/generated/graphql.d.ts.map +1 -1
  66. package/dist/generated/graphql.js +1 -0
  67. package/dist/index.d.ts +13 -14
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +14 -17
  70. package/dist/kit/decks.d.ts +1 -1
  71. package/dist/kit/npcs.d.ts +2 -2
  72. package/dist/kit/npcs.d.ts.map +1 -1
  73. package/dist/kit/social.d.ts.map +1 -1
  74. package/dist/kit/worldsim.d.ts +1 -1
  75. package/dist/realtime.d.ts +26 -0
  76. package/dist/realtime.d.ts.map +1 -1
  77. package/dist/realtime.js +83 -0
  78. package/dist/rediscover.d.ts +7 -3
  79. package/dist/rediscover.d.ts.map +1 -1
  80. package/dist/rediscover.js +7 -3
  81. package/dist/session.d.ts +21 -0
  82. package/dist/session.d.ts.map +1 -1
  83. package/dist/session.js +23 -0
  84. package/package.json +1 -1
package/dist/session.js CHANGED
@@ -8,6 +8,10 @@ export class BrowserLocalStorageTokenStore {
8
8
  constructor(key = 'crowdyjs:token') {
9
9
  this.key = key;
10
10
  }
11
+ /** The key a game's app-scoped token belongs under. Per game, on purpose. */
12
+ static appKey(basePath) {
13
+ return `crowdyjs:app:${basePath}`;
14
+ }
11
15
  get() {
12
16
  if (typeof localStorage === 'undefined')
13
17
  return null;
@@ -24,6 +28,25 @@ export class BrowserLocalStorageTokenStore {
24
28
  localStorage.removeItem(this.key);
25
29
  }
26
30
  }
31
+ /**
32
+ * The key an IDENTITY session token belongs under: one per origin, shared by every
33
+ * game on it.
34
+ *
35
+ * WHY THIS EXISTS AS A NAMED CONSTANT. Games were storing their credential under
36
+ * `'crowdyjs:app:' + import.meta.env.BASE_URL` — the game's own PATH — so two games on
37
+ * `crowdy.games` had different keys on the SAME origin and could not see each other's
38
+ * login. What was stored was an app token anyway, which is per-game by definition, so
39
+ * there was nothing cross-app to share even if the key had matched. A player who
40
+ * signed in for one game was anonymous to the next and got bounced back to the portal.
41
+ *
42
+ * The schema split makes the fix structural rather than a workaround: the identity
43
+ * session token is now its own object with its own lifetime, so it belongs under one
44
+ * origin-wide key, while app tokens stay per-game. The storage split mirrors the
45
+ * database split.
46
+ *
47
+ * Deliberately NOT parameterised by BASE_URL. That parameter was the bug.
48
+ */
49
+ BrowserLocalStorageTokenStore.SESSION_KEY = 'crowdyjs:session';
27
50
  /**
28
51
  * In-memory token holder with change notifications and optional persistence via
29
52
  * a {@link TokenStore}. Setting the token fans out to every {@link onChange}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdedkingdoms/crowdyjs",
3
- "version": "13.9.0",
3
+ "version": "14.1.0",
4
4
  "description": "Browser-first Crowded Kingdoms SDK with GraphQL, realtime, and local Rust authoring support",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",