@rydr/game-sdk 3.8.0 → 3.10.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.
@@ -1,79 +0,0 @@
1
- /**
2
- * Admin content backend — a low-level Bearer client for `shared` gamedata,
3
- * intended for the **platform owner's own** out-of-band tooling: a first-party
4
- * admin console on the shell's origin, a seed/migration script, CI. Code that
5
- * legitimately holds the `ADMIN_SECRET`.
6
- *
7
- * NOT for games or their editors. A game — and a game's editor, which is just
8
- * another guest the shell loads — never holds the secret. An editor is opened
9
- * inside the shell, gates on `session.identity.isAdmin`, and authors through
10
- * the session (`saveContent` / `deleteContent` / `getUploadUrl`); the shell
11
- * relays the authenticated write. See the "Build an in-game editor" guide in
12
- * the README. If you reach for this from inside a game you've broken the
13
- * security boundary — use the session instead.
14
- *
15
- * This factory wraps the generic gamedata party's HTTP contract for one
16
- * `gameId` so owner tooling doesn't hand-roll `fetch` + headers:
17
- *
18
- * - read (public): `GET {host}/parties/gamedata/{gameId}/shared/{collection}[/{id}]`
19
- * - write (Bearer): `PUT …/shared/{collection}/{id}` body `{ data, draft? }`
20
- * - delete(Bearer): `DELETE …/shared/{collection}/{id}`
21
- * - asset (Bearer): `POST …/{gameId}/asset/upload-url` → presigned R2 PUT
22
- *
23
- * SECURITY: `ADMIN_SECRET` is the platform owner's key (full write to any
24
- * game's shared content). Authoring-time only, entered at runtime, never
25
- * shipped to players and never bundled into a game or guest. Player-generated
26
- * content uses the SDK's public owner-write scope instead, not this backend.
27
- */
28
- /**
29
- * Build an {@link AdminContentBackend} for one game. Pure factory — no network
30
- * until a method is called. Every request carries the Bearer secret so the
31
- * editor can see drafts and perform writes.
32
- */
33
- export function createAdminContentBackend(opts) {
34
- const base = `${opts.host.replace(/\/$/, "")}/parties/gamedata/${opts.gameId}`;
35
- // Encode collection + id path segments so reserved chars (`:` `/` `@` …) survive
36
- // the round-trip; the gamedata party decodes them. Mirrors the shell's GameDataService.
37
- const enc = encodeURIComponent;
38
- const authHeaders = () => ({ Authorization: `Bearer ${opts.getSecret()}` });
39
- async function req(method, url, body) {
40
- const res = await fetch(url, {
41
- method,
42
- headers: { ...authHeaders(), ...(body !== undefined ? { "Content-Type": "application/json" } : {}) },
43
- body: body !== undefined ? JSON.stringify(body) : undefined,
44
- });
45
- if (!res.ok) {
46
- const detail = await res.text().catch(() => "");
47
- throw new Error(`[rydr-admin] ${method} ${url} → ${res.status} ${detail}`);
48
- }
49
- return (await res.json());
50
- }
51
- return {
52
- async list(collection) {
53
- const r = await req("GET", `${base}/shared/${enc(collection)}`);
54
- return r.docs ?? [];
55
- },
56
- async get(collection, id) {
57
- const r = await req("GET", `${base}/shared/${enc(collection)}/${enc(id)}`);
58
- return r.doc ?? null;
59
- },
60
- async save(collection, id, value, saveOpts) {
61
- await req("PUT", `${base}/shared/${enc(collection)}/${enc(id)}`, { data: value, draft: saveOpts?.draft });
62
- },
63
- async remove(collection, id) {
64
- await req("DELETE", `${base}/shared/${enc(collection)}/${enc(id)}`);
65
- },
66
- async uploadAsset({ collection, filename, contentType, body }) {
67
- const { uploadUrl, url } = await req("POST", `${base}/asset/upload-url`, { collection, filename });
68
- const put = await fetch(uploadUrl, {
69
- method: "PUT",
70
- headers: contentType ? { "Content-Type": contentType } : {},
71
- body: body,
72
- });
73
- if (!put.ok)
74
- throw new Error(`[rydr-admin] asset PUT → ${put.status}`);
75
- return { url };
76
- },
77
- };
78
- }
79
- //# sourceMappingURL=adminContent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"adminContent.js","sourceRoot":"","sources":["../../src/client/adminContent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AA6BH;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,IAAyB;IACjE,MAAM,IAAI,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,qBAAqB,IAAI,CAAC,MAAM,EAAE,C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