scorezilla 0.5.0 → 0.5.1
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/API.md +22 -11
- package/CHANGELOG.md +10 -1
- package/dist/{errors-maldlTY-.d.ts → errors-8qzE40-2.d.ts} +1 -1
- package/dist/{errors-DuRShuw9.d.cts → errors-Bu084BD9.d.cts} +1 -1
- package/dist/headless.cjs +6 -2
- package/dist/headless.cjs.map +1 -1
- package/dist/headless.d.cts +1 -1
- package/dist/headless.d.ts +1 -1
- package/dist/headless.js +6 -2
- package/dist/headless.js.map +1 -1
- package/dist/index.cjs +7 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/server.js +1 -1
- package/dist/{types-C6VO4OWP.d.cts → types-BxxzS_pF.d.cts} +19 -1
- package/dist/{types-C6VO4OWP.d.ts → types-BxxzS_pF.d.ts} +19 -1
- package/package.json +1 -1
package/API.md
CHANGED
|
@@ -111,17 +111,22 @@ Violations throw a plain `Error` (not `ScorezillaError`) before any network call
|
|
|
111
111
|
|
|
112
112
|
#### Errors
|
|
113
113
|
|
|
114
|
-
| Code | Status | Meaning
|
|
115
|
-
| -------------------------------- | ------ |
|
|
116
|
-
| `unauthorized` | 401 | Invalid `publicKey`.
|
|
117
|
-
| `forbidden` | 403 | Key is not bound to this `boardId`.
|
|
118
|
-
| `
|
|
119
|
-
| `
|
|
120
|
-
| `
|
|
121
|
-
| `
|
|
122
|
-
| `
|
|
123
|
-
| `
|
|
124
|
-
| `
|
|
114
|
+
| Code | Status | Meaning |
|
|
115
|
+
| -------------------------------- | ------ | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
116
|
+
| `unauthorized` | 401 | Invalid `publicKey`. |
|
|
117
|
+
| `forbidden` | 403 | Key is not bound to this `boardId`. |
|
|
118
|
+
| `origin_not_allowed` | 403 | Request `Origin` is not in the board's allowlist (configured in the dashboard). Gates browser submits only — server-to-server calls send no `Origin`. |
|
|
119
|
+
| `player_banned` | 403 | The player is on this board's denylist (banned by the game owner). |
|
|
120
|
+
| `turnstile_required` | 403 | The board requires a Cloudflare Turnstile token and none was sent. |
|
|
121
|
+
| `turnstile_failed` | 403 | The supplied Turnstile token failed verification. |
|
|
122
|
+
| `turnstile_hostname_mismatch` | 403 | The Turnstile token was solved on an origin not allowed for this game. |
|
|
123
|
+
| `not_found` | 404 | Board doesn't exist. |
|
|
124
|
+
| `out_of_bounds` | 422 | Score outside the board's `[minScore, maxScore]`. `error.reason` is `'below_min'` or `'above_max'`; `error.bound` is the limit. |
|
|
125
|
+
| `rate_limited` | 429 | Throttled. `error.retryAfter` (seconds), `error.layer`. |
|
|
126
|
+
| `invalid_input` / `invalid_json` | 400 | Malformed body. |
|
|
127
|
+
| `network_error` | 0 | Could not reach the API. |
|
|
128
|
+
| `timeout` | 0 | Request exceeded `timeoutMs`. |
|
|
129
|
+
| `aborted` | 0 | Caller-provided `AbortSignal` fired. |
|
|
125
130
|
|
|
126
131
|
### `getLeaderboard`
|
|
127
132
|
|
|
@@ -154,6 +159,12 @@ const { entries } = await sz.getLeaderboard({ boardId, top: 25 });
|
|
|
154
159
|
for (const e of entries) console.log(`${e.rank}. ${e.playerId}: ${e.score}`);
|
|
155
160
|
```
|
|
156
161
|
|
|
162
|
+
> **Read-path errors.** The read methods (`getLeaderboard`, `getPlayerRank`,
|
|
163
|
+
> `getWindowAround`) share the codes in the [`submitScore` table](#errors)
|
|
164
|
+
> (minus the submit-only ones), and add one: **`tenant_suspended`** (`402`) when
|
|
165
|
+
> the board's tenant is suspended. (On the submit path that same condition
|
|
166
|
+
> surfaces as `usage_cap_exceeded` with `reason: 'suspended'`.)
|
|
167
|
+
|
|
157
168
|
### `getPlayerRank`
|
|
158
169
|
|
|
159
170
|
`GET /v1/boards/:boardId/players/:playerId/rank`. "No entry yet" is a normal
|
package/CHANGELOG.md
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#66](https://github.com/isco-tec/scorezilla-js/pull/66) [`746d599`](https://github.com/isco-tec/scorezilla-js/commit/746d599880a347ca656b233a9241dc6b8cc68926) Thanks [@isco-tec](https://github.com/isco-tec)! - Add `turnstile_hostname_mismatch` to the `ScorezillaErrorCode` union — a 403 the API can return when a Turnstile token is solved on an origin not allowed for the game. It previously fell through the open union as an untyped string; now it's a first-class code (with JSDoc) and documented in the API reference alongside the other 403 codes.
|
|
8
|
+
|
|
9
|
+
- [#67](https://github.com/isco-tec/scorezilla-js/pull/67) [`2966433`](https://github.com/isco-tec/scorezilla-js/commit/2966433d66883fb3eee04596aefbba5d1677c436) Thanks [@isco-tec](https://github.com/isco-tec)! - Add `tenant_suspended` to the `ScorezillaErrorCode` union — a `402` the read paths (`getLeaderboard` / `getPlayerRank` / `getWindowAround`) return when the board's tenant is suspended. It previously fell through the open union as an untyped string; now it's typed (with JSDoc) and documented in the API reference. (On submit, the same condition still surfaces as `usage_cap_exceeded` with `reason: 'suspended'`.)
|
|
10
|
+
|
|
11
|
+
- [#62](https://github.com/isco-tec/scorezilla-js/pull/62) [`90b277a`](https://github.com/isco-tec/scorezilla-js/commit/90b277afb745c29fbdcca46cd6dbd14479229c2f) Thanks [@isco-tec](https://github.com/isco-tec)! - Add the newer server error codes to the `ScorezillaErrorCode` union so consumers get autocomplete + type-checking when branching on them: `player_banned`, `name_taken`, `board_archived`, `turnstile_required`, `turnstile_failed`, `origin_not_allowed`. (Runtime behavior is unchanged — the union's open tail already carried these strings at runtime.) The `submitScore` `@throws` JSDoc now lists `player_banned` and `name_taken` as possible outcomes.
|
|
12
|
+
|
|
3
13
|
## 0.5.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
6
16
|
|
|
7
17
|
- [#60](https://github.com/isco-tec/scorezilla-js/pull/60) [`20ccc50`](https://github.com/isco-tec/scorezilla-js/commit/20ccc50d0f37a491c309b2f47555c698c3ceaec2) Thanks [@isco-tec](https://github.com/isco-tec)! - Add the headless, never-throws client and cross-platform submit fields.
|
|
8
|
-
|
|
9
18
|
- **`scorezilla/headless`** — a new subpath exposing `createHeadlessClient(config)` with `submit(...) → { ok, rank, totalEntries, isPersonalBest } | null` and `getLeaderboard(...) → RankedEntry[]` that **never throw**: failures collapse to `null` / `[]`. This is the identical headless surface a host wraps so embedded game code never changes between platforms. Plus `isCrossOrigin(homeOrigin)` to detect cross-site embedding and decide whether the token path is needed.
|
|
10
19
|
- **`submitScore` / headless `submit`** now accept an optional **`name`** (public display name) and **`turnstileToken`** (the cross-origin token path); both are forwarded on the wire.
|
|
11
20
|
- **`RankedEntry`** now carries an optional **`name`** — the display name returned by the leaderboard read.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ScorezillaErrorCode, O as OutOfBoundsReason, U as UsageCapReason, B as BillingTier, A as ApiError } from './types-
|
|
1
|
+
import { S as ScorezillaErrorCode, O as OutOfBoundsReason, U as UsageCapReason, B as BillingTier, A as ApiError } from './types-BxxzS_pF.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SDK error type.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as ScorezillaErrorCode, O as OutOfBoundsReason, U as UsageCapReason, B as BillingTier, A as ApiError } from './types-
|
|
1
|
+
import { S as ScorezillaErrorCode, O as OutOfBoundsReason, U as UsageCapReason, B as BillingTier, A as ApiError } from './types-BxxzS_pF.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SDK error type.
|
package/dist/headless.cjs
CHANGED
|
@@ -656,7 +656,7 @@ function validateMetadata(metadata) {
|
|
|
656
656
|
}
|
|
657
657
|
var Scorezilla = class _Scorezilla {
|
|
658
658
|
/** The package version, injected at build time from `package.json`. */
|
|
659
|
-
static version = "0.5.
|
|
659
|
+
static version = "0.5.1";
|
|
660
660
|
#config;
|
|
661
661
|
#userAgent;
|
|
662
662
|
#authHeader;
|
|
@@ -696,7 +696,11 @@ var Scorezilla = class _Scorezilla {
|
|
|
696
696
|
* @throws {ScorezillaError} `unauthorized` (bad publicKey), `forbidden`
|
|
697
697
|
* (key not bound to this board), `not_found` (board doesn't exist),
|
|
698
698
|
* `out_of_bounds` (score outside board's min/max), `rate_limited`
|
|
699
|
-
* (Layer 2/3 throttle hit), `
|
|
699
|
+
* (Layer 2/3 throttle hit), `player_banned` (denylisted on this board),
|
|
700
|
+
* `name_taken` (display name held by another player), `turnstile_required`
|
|
701
|
+
* / `turnstile_failed` (Turnstile-gated board), `origin_not_allowed`
|
|
702
|
+
* (Origin not in the board's allowlist), `invalid_input`, `network_error`,
|
|
703
|
+
* `timeout`.
|
|
700
704
|
* @since 0.1.0
|
|
701
705
|
* @stability stable
|
|
702
706
|
*/
|