@rydr/game-sdk 8.10.0 → 8.11.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.
@@ -6,6 +6,60 @@
6
6
  * name, and the physics metrics it explicitly requested. This is the privacy
7
7
  * boundary that makes third-party games safe.
8
8
  */
9
+ /**
10
+ * What CONTENT this rider may see, as a ladder: `free` < `beta` < `all_access`, each rung
11
+ * containing the one below it.
12
+ *
13
+ * | Tier | The rider gets |
14
+ * |---|---|
15
+ * | `free` | the free experiences only |
16
+ * | `beta` | the free ones plus early access |
17
+ * | `all_access` | everything, including unpublished content |
18
+ *
19
+ * ## The platform states the fact, the game applies the policy
20
+ *
21
+ * Which of YOUR experiences are free is yours to decide, not the platform's: it knows nothing
22
+ * about your tracks, songs or levels, and a list of them kept platform-side would drift the first
23
+ * time someone shipped content without updating it. So the host says which tier the rider is on and
24
+ * your game decides what that unlocks. Same division as the FTP difficulty ladder: the platform
25
+ * hands over a calibrated fact, the game decides what to do with it.
26
+ *
27
+ * ## Fewer values than the platform has
28
+ *
29
+ * The platform also holds buckets meaning "cannot play at all" (waiting for a beta place, played at
30
+ * an event, access ended). None of them can appear here, because a game only ever runs for a rider
31
+ * who is already playing. Do not add branches for states that cannot arrive.
32
+ *
33
+ * ## Never compare it directly
34
+ *
35
+ * Use {@link tierAtLeast}. A bare `tier === "beta"` excludes `all_access` riders from content they
36
+ * are entitled to, silently, and the day a tier is inserted into the middle of the ladder every
37
+ * such comparison is wrong at once.
38
+ */
39
+ export type AccessTier = "free" | "beta" | "all_access";
40
+ /**
41
+ * What an ABSENT tier means, and why it is not the lowest one.
42
+ *
43
+ * The field is missing whenever an older host meets a newer game (the host simply does not send
44
+ * it). Reading that as `free` would strip content from fully entitled riders during any version
45
+ * skew, which is a worse failure than briefly showing someone one track too many. So absence means
46
+ * today's behaviour, which is `beta`.
47
+ *
48
+ * A compatibility default, not a policy: a host that HAS tiers always sends one.
49
+ */
50
+ export declare const DEFAULT_ACCESS_TIER: AccessTier;
51
+ /**
52
+ * Is this rider on `min` or better? The one way to read {@link AccessTier}.
53
+ *
54
+ * ```ts
55
+ * if (tierAtLeast(identity.accessTier, "beta")) showEarlyAccessTracks();
56
+ * ```
57
+ *
58
+ * An absent tier counts as {@link DEFAULT_ACCESS_TIER}, and an unrecognised one (a host newer than
59
+ * this SDK, sending a tier that did not exist when you built) counts the same way rather than
60
+ * throwing: a game mid-session should not crash because the ladder grew.
61
+ */
62
+ export declare function tierAtLeast(tier: AccessTier | undefined, min: AccessTier): boolean;
9
63
  export interface ScopedIdentity {
10
64
  /** Stable, opaque per-player id. Safe to use as a key; reveals no PII. */
11
65
  playerId: string;
@@ -24,5 +78,14 @@ export interface ScopedIdentity {
24
78
  * enforces auth via RLS on the admin role.
25
79
  */
26
80
  isAdmin?: boolean;
81
+ /**
82
+ * What content this rider is entitled to (see {@link AccessTier}). Read it with
83
+ * {@link tierAtLeast}, never by comparing it.
84
+ *
85
+ * A UI hint, exactly like {@link isAdmin}: it tells your game what to OFFER. Nothing stops a
86
+ * modified guest from ignoring it, so the day real money hangs on a tier the enforcement has to
87
+ * be server-side as well. Absent means {@link DEFAULT_ACCESS_TIER}.
88
+ */
89
+ accessTier?: AccessTier;
27
90
  }
28
91
  //# sourceMappingURL=identity.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/protocol/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/protocol/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;AAExD;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,EAAE,UAAmB,CAAC;AAStD;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,UAAU,GAAG,SAAS,EAAE,GAAG,EAAE,UAAU,GAAG,OAAO,CAGlF;AAED,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,QAAQ,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,WAAW,EAAE,MAAM,CAAC;IACpB,oCAAoC;IACpC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,6FAA6F;IAC7F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB"}
@@ -1,2 +1,41 @@
1
- export {};
1
+ /**
2
+ * The scoped identity a game receives — deliberately NOT the full player profile.
3
+ *
4
+ * The platform holds PII (real name, gender, year of birth, exact weight). A
5
+ * game only ever receives this redacted view: a stable opaque id, a display
6
+ * name, and the physics metrics it explicitly requested. This is the privacy
7
+ * boundary that makes third-party games safe.
8
+ */
9
+ /**
10
+ * What an ABSENT tier means, and why it is not the lowest one.
11
+ *
12
+ * The field is missing whenever an older host meets a newer game (the host simply does not send
13
+ * it). Reading that as `free` would strip content from fully entitled riders during any version
14
+ * skew, which is a worse failure than briefly showing someone one track too many. So absence means
15
+ * today's behaviour, which is `beta`.
16
+ *
17
+ * A compatibility default, not a policy: a host that HAS tiers always sends one.
18
+ */
19
+ export const DEFAULT_ACCESS_TIER = "beta";
20
+ /** Position on the ladder. Private on purpose: ask {@link tierAtLeast}, never a number. */
21
+ const TIER_RANK = {
22
+ free: 0,
23
+ beta: 1,
24
+ all_access: 2,
25
+ };
26
+ /**
27
+ * Is this rider on `min` or better? The one way to read {@link AccessTier}.
28
+ *
29
+ * ```ts
30
+ * if (tierAtLeast(identity.accessTier, "beta")) showEarlyAccessTracks();
31
+ * ```
32
+ *
33
+ * An absent tier counts as {@link DEFAULT_ACCESS_TIER}, and an unrecognised one (a host newer than
34
+ * this SDK, sending a tier that did not exist when you built) counts the same way rather than
35
+ * throwing: a game mid-session should not crash because the ladder grew.
36
+ */
37
+ export function tierAtLeast(tier, min) {
38
+ const have = TIER_RANK[tier] ?? TIER_RANK[DEFAULT_ACCESS_TIER];
39
+ return have >= TIER_RANK[min];
40
+ }
2
41
  //# sourceMappingURL=identity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/protocol/identity.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"identity.js","sourceRoot":"","sources":["../../src/protocol/identity.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkCH;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAe,MAAM,CAAC;AAEtD,2FAA2F;AAC3F,MAAM,SAAS,GAA+B;IAC5C,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,UAAU,EAAE,CAAC;CACd,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CAAC,IAA4B,EAAE,GAAe;IACvE,MAAM,IAAI,GAAG,SAAS,CAAC,IAAkB,CAAC,IAAI,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAC7E,OAAO,IAAI,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
@@ -9,5 +9,5 @@
9
9
  export declare const RYDR_PROTOCOL_VERSION: 31;
10
10
  /** Semver of this SDK build. Sent in the handshake for telemetry/debugging.
11
11
  * (Bumped to 2.0.0 by `npm version major` on release — see CHANGELOG [Unreleased].) */
12
- export declare const RYDR_SDK_VERSION = "8.10.0";
12
+ export declare const RYDR_SDK_VERSION = "8.11.0";
13
13
  //# sourceMappingURL=version.d.ts.map
@@ -196,5 +196,5 @@
196
196
  export const RYDR_PROTOCOL_VERSION = 31;
197
197
  /** Semver of this SDK build. Sent in the handshake for telemetry/debugging.
198
198
  * (Bumped to 2.0.0 by `npm version major` on release — see CHANGELOG [Unreleased].) */
199
- export const RYDR_SDK_VERSION = "8.10.0";
199
+ export const RYDR_SDK_VERSION = "8.11.0";
200
200
  //# sourceMappingURL=version.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rydr/game-sdk",
3
- "version": "8.10.0",
3
+ "version": "8.11.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/bdefrenne/rydr-game-sdk.git"