@vibechain/os 0.2.1 → 0.4.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/AGENTS.md +110 -201
- package/README.md +78 -7
- package/SECURITY.md +22 -3
- package/dist/app-runtime.d.ts +1 -1
- package/dist/app-runtime.js +11 -3
- package/dist/bundle.js +10 -0
- package/dist/canvas.d.ts +40 -0
- package/dist/canvas.js +41 -0
- package/dist/cli.js +1 -1
- package/dist/listing.d.ts +35 -0
- package/dist/listing.js +56 -0
- package/dist/loop.d.ts +34 -0
- package/dist/loop.js +47 -0
- package/dist/manifest.d.ts +70 -1
- package/dist/manifest.js +117 -9
- package/dist/preview-ui.js +1 -1
- package/dist/scaffold.js +20 -7
- package/dist/testing.d.ts +29 -0
- package/dist/testing.js +49 -0
- package/examples/paw-beat/README.md +50 -0
- package/examples/paw-beat/cat.ts +129 -0
- package/examples/paw-beat/game.ts +151 -0
- package/examples/paw-beat/index.html +65 -0
- package/examples/paw-beat/main.ts +243 -0
- package/examples/paw-beat/music.ts +123 -0
- package/examples/paw-beat/store/icon.png +0 -0
- package/examples/paw-beat/store/screenshot-1.webp +0 -0
- package/examples/paw-beat/store/screenshot-2.webp +0 -0
- package/examples/paw-beat/vibemarket.json +21 -0
- package/examples/vibexp-app/README.md +19 -3
- package/examples/vibexp-app/store/icon.png +0 -0
- package/examples/vibexp-app/store/screenshot-1.png +0 -0
- package/examples/vibexp-app/vibemarket.json +21 -1
- package/package.json +19 -2
- package/examples/chonk-stack/card-slice.ts +0 -17
- package/examples/chonk-stack/cat3d.ts +0 -57
- package/examples/chonk-stack/game.css +0 -174
- package/examples/chonk-stack/index.html +0 -32
- package/examples/chonk-stack/main.ts +0 -149
- package/examples/chonk-stack/model.ts +0 -40
- package/examples/chonk-stack/renderer.ts +0 -263
- package/examples/chonk-stack/skins.ts +0 -47
- package/examples/chonk-stack/vibemarket.json +0 -21
- package/examples/collection-room/index.html +0 -3
- package/examples/collection-room/main.ts +0 -31
- package/examples/collection-room/vibemarket.json +0 -12
- package/examples/tsconfig.json +0 -4
package/AGENTS.md
CHANGED
|
@@ -1,218 +1,127 @@
|
|
|
1
|
-
#
|
|
1
|
+
# VibeStore app author contract — @vibechain/os 0.4.1
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
bounded app-owned checkpoints and a score-only `game.finish({score})` signal; it has no profile, inventory, Steam/native,
|
|
8
|
-
wallet, purchase or reward authority. The existing Market-game contract below
|
|
9
|
-
continues to apply to collection games using `connectGameSdk()`; do not infer
|
|
10
|
-
those permissions for an OS app. Public app publication remains disabled.
|
|
3
|
+
This is the contract for people and agents building apps for VibeStore, the app
|
|
4
|
+
store inside VibeMarket OS. Read it with [README.md](README.md) (API, helpers and
|
|
5
|
+
the listing table) and [SECURITY.md](SECURITY.md) (sandbox and limits). The public
|
|
6
|
+
guide is https://vibechain.com/os/docs.
|
|
11
7
|
|
|
12
|
-
|
|
13
|
-
Build an ordinary static web game. Deliver a ZIP of **built output**, not source,
|
|
14
|
-
node_modules, a server, or an install script. React, vanilla TypeScript and canvas
|
|
15
|
-
renderers all work. Use relative asset paths (`base: './'` in Vite). No remote
|
|
16
|
-
scripts, fonts, APIs, workers or wallet libraries. Bundle your dependencies/assets.
|
|
8
|
+
## What you build
|
|
17
9
|
|
|
18
|
-
|
|
10
|
+
An ordinary static web app: a game, a tool or a desktop toy. You submit a ZIP of
|
|
11
|
+
**built output**, not source, `node_modules`, a server or an install script.
|
|
12
|
+
Vanilla TypeScript, canvas, WebGL and engine builds all work. Bundle every
|
|
13
|
+
dependency and asset, and use relative paths (`base: './'` in Vite). No remote
|
|
14
|
+
scripts, fonts, images or APIs: the app can load only its own files.
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
## Start
|
|
21
17
|
|
|
22
18
|
```sh
|
|
23
|
-
|
|
19
|
+
npx --yes @vibechain/os@0.4.1 init my-app
|
|
20
|
+
cd my-app
|
|
21
|
+
npm install
|
|
22
|
+
npm run build
|
|
23
|
+
npm run dev
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
`os init` writes Stamp Club, a complete starter whose `vibemarket.json` is already
|
|
27
|
+
a schema version 2 listing with placeholder text and pictures. Replace the
|
|
28
|
+
fields its README lists before submitting; an unchanged starter is rejected at
|
|
29
|
+
review. `examples/paw-beat` in this package is a complete 3D game with a real
|
|
30
|
+
listing.
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
pnpm install --frozen-lockfile
|
|
30
|
-
pnpm review
|
|
31
|
-
pnpm build
|
|
32
|
-
pnpm pack --out /tmp/vibechain-os-0.2.1.tgz
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
In an independent game project, install that tarball:
|
|
36
|
-
|
|
37
|
-
```sh
|
|
38
|
-
npm install /tmp/vibechain-os-0.2.1.tgz
|
|
39
|
-
npm install --save-dev typescript esbuild
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
The tarball contains `examples/collection-room`. Copy its three files into your
|
|
43
|
-
project to start. Build `main.ts` with
|
|
44
|
-
`npx esbuild main.ts --bundle --format=esm --target=es2022 --outfile=dist/game.js`,
|
|
45
|
-
and copy `index.html` and `vibemarket.json` into `dist/`. Type-check your game with
|
|
46
|
-
strict TypeScript. Do not import VibeMarket host files or depend on a repo alias.
|
|
32
|
+
## The app API
|
|
47
33
|
|
|
48
34
|
```ts
|
|
49
|
-
import {
|
|
50
|
-
const
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const stop = sdk.inventory.onChanged(() => { /* re-fetch inventory */ });
|
|
58
|
-
// On teardown: stop(); sdk.destroy();
|
|
35
|
+
import { connectVibeMarketApp } from "@vibechain/os";
|
|
36
|
+
const app = await connectVibeMarketApp();
|
|
37
|
+
const saved = await app.checkpoint.read(); // null on first open
|
|
38
|
+
await app.checkpoint.write({ level: 2 }); // resolves after the host accepts it
|
|
39
|
+
app.lifecycle.onChanged(({ active, width, height }) => { /* pause when inactive, resize */ });
|
|
40
|
+
await app.ready(); // remove the host's loading state
|
|
41
|
+
// At the end of a game: await app.game.finish({ score: 42 });
|
|
42
|
+
window.addEventListener("pagehide", () => app.destroy(), { once: true });
|
|
59
43
|
```
|
|
60
44
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
`
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
`
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
"version": "1.0.0-test.1",
|
|
113
|
-
"name": "My Cat Game",
|
|
114
|
-
"tagline": "Collect a cat. Take it for a spin.",
|
|
115
|
-
"category": "Collect · customize · play",
|
|
116
|
-
"entry": "index.html",
|
|
117
|
-
"permissions": ["profile.get", "catalog.list", "inventory.get", "packs.buy", "packs.open", "cards.reveal", "cards.collect"],
|
|
118
|
-
"collectionId": "REPLACE_WITH_A_REAL_MARKET_COLLECTION_ID"
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Use `collectionId: null` for unbound free play; omit trading permissions in that
|
|
123
|
-
case. This release binds **one collection** per version. Get its exact ID from
|
|
124
|
-
the market catalog/developer collection selector; do not invent one. All game
|
|
125
|
-
and rail access is filtered to that collection. A missing/retired collection
|
|
126
|
-
shows an unavailable state; it does not silently bind another one. The local
|
|
127
|
-
operator approves the declared collection and permissions when publishing.
|
|
128
|
-
Changing either requires a new version. Public developer ownership approval is
|
|
129
|
-
not implemented in the local adapter.
|
|
130
|
-
|
|
131
|
-
Supported assets: HTML, JS/MJS, CSS, JSON, PNG/JPEG/WebP/GIF/AVIF/SVG/ICO, WOFF/
|
|
132
|
-
WOFF2/TTF/OTF, MP3/OGG/WAV, MP4/WebM, WASM/BIN/TXT. Max 20 MiB compressed,
|
|
133
|
-
64 MiB expanded, 16 MiB/file, 256 ZIP entries. No symlinks, encrypted files,
|
|
134
|
-
traversal, duplicate/case-colliding names, absolute paths or hidden paths.
|
|
135
|
-
Use ASCII filenames and normal subdirectories. WASM must run without threads;
|
|
136
|
-
workers/SharedArrayBuffer and arbitrary network access are unavailable.
|
|
137
|
-
|
|
138
|
-
```sh
|
|
139
|
-
npx vibemarket-game pack dist my-cat-game.zip
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Local test → publish → rollback
|
|
143
|
-
|
|
144
|
-
Run the host from its verified checkout using its existing local stack. Use
|
|
145
|
-
`http://127.0.0.1:<port>/market/games?manage=1` (localhost also works). In the host's
|
|
146
|
-
`vibechain/` directory run `pnpm games:publisher-token`; paste that local operator
|
|
147
|
-
credential into Developer Studio. Do not commit/share this token. Upload the ZIP,
|
|
148
|
-
inspect permissions and collection, preview, then select **Publish to dev**.
|
|
149
|
-
Uploading never publishes automatically. Draft links are unlisted bearer links;
|
|
150
|
-
anyone with the link on the same computer can preview. They are not multi-user
|
|
151
|
-
private previews or authenticated sharing links.
|
|
152
|
-
|
|
153
|
-
CLI uses exactly the same endpoints:
|
|
45
|
+
That is the whole facade: readiness, lifecycle, a bounded checkpoint and one
|
|
46
|
+
score. Checkpoints are plain JSON of at most 32 KiB, kept in host memory only
|
|
47
|
+
while the window is open. `game.finish` takes one integer score from 0 to
|
|
48
|
+
1,000,000,000, once per open window; the host owns the results screen and the
|
|
49
|
+
score grants nothing. Optional helpers: `@vibechain/os/loop` (fixed-step loop
|
|
50
|
+
that pauses when inactive), `@vibechain/os/canvas` (canvas sizing and WebGL
|
|
51
|
+
context loss) and `@vibechain/os/testing` (an in-memory host for unit tests).
|
|
52
|
+
|
|
53
|
+
## What an app cannot do
|
|
54
|
+
|
|
55
|
+
An app has no access to the player's account, session, profile, Steam ID,
|
|
56
|
+
handle or balance; no inventory, wallets, purchases, trades, Cash, XP or
|
|
57
|
+
rewards; no network requests to vibechain.com APIs or other servers; no saves
|
|
58
|
+
that outlive the open window; no multiplayer or leaderboards; and no access to
|
|
59
|
+
the desktop page, other apps, Steam commands or native IPC. Requests for any of
|
|
60
|
+
these end the app's session. Never ask players to type secrets into your app.
|
|
61
|
+
|
|
62
|
+
## Manifest and listing
|
|
63
|
+
|
|
64
|
+
`vibemarket.json` sits at the root of the build. VibeStore accepts only schema
|
|
65
|
+
version 2, with every field required and unknown fields refused at every level:
|
|
66
|
+
|
|
67
|
+
- `schemaVersion: 2`, `sdkVersion: 1`, `category: "vibexp-app"`,
|
|
68
|
+
`permissions: []`, `collectionId: null`.
|
|
69
|
+
- `id`: lowercase letters, digits and single hyphens, at most 60 characters;
|
|
70
|
+
the first accepted submission claims it. `version`: semver, each submitted
|
|
71
|
+
once. `name` (60) and `tagline` (160). `entry`: the HTML file.
|
|
72
|
+
- `window`: `width` 320–1600 and `height` 200–1200 CSS pixels, `resizable`.
|
|
73
|
+
- `store.icon`: a PNG in the bundle, exactly 256 x 256, at most 256 KiB.
|
|
74
|
+
- `store.screenshots`: 1–4 PNG, JPEG or WebP files in the bundle, at most
|
|
75
|
+
1 MiB each, contents matching the extension, none the icon.
|
|
76
|
+
- `store.description`: 40–2,000 characters of plain text (line breaks allowed).
|
|
77
|
+
- `store.category`: `game`, `tool` or `toy`.
|
|
78
|
+
- `store.rating`: `violence` and `language` each `none`, `mild` or `strong`;
|
|
79
|
+
`mature` true or false. Rate honestly.
|
|
80
|
+
- `store.support`: an `https://` URL or an email address, at most 200
|
|
81
|
+
characters, shown to players and reviewers.
|
|
82
|
+
|
|
83
|
+
`os preview` and `os pack` run these checks locally. `parseManifest`
|
|
84
|
+
(`@vibechain/os/manifest`) and `checkListing` (`@vibechain/os/listing`) run them
|
|
85
|
+
in your own tools.
|
|
86
|
+
|
|
87
|
+
## Bundle rules
|
|
88
|
+
|
|
89
|
+
At most 256 entries, 16 MiB per file, 64 MiB expanded and a 20 MiB ZIP. ASCII
|
|
90
|
+
paths in normal subdirectories: no absolute or hidden paths, traversal,
|
|
91
|
+
symlinks, encrypted entries, or names that differ only by letter case. File
|
|
92
|
+
types: HTML, JS/MJS, CSS, JSON, PNG/JPEG/WebP/GIF/AVIF/ICO, WOFF/WOFF2/TTF/OTF,
|
|
93
|
+
MP3/OGG/WAV, MP4/WebM, WASM/BIN/TXT. **No SVG** anywhere, because it is a
|
|
94
|
+
document format that can carry script. Workers, `SharedArrayBuffer` and
|
|
95
|
+
threaded WASM are unavailable.
|
|
154
96
|
|
|
155
97
|
```sh
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
npx vibemarket-game upload my-cat-game.zip
|
|
159
|
-
npx vibemarket-game list
|
|
160
|
-
npx vibemarket-game publish my-cat-game 1.0.0-test.1 1
|
|
161
|
-
# Last argument = latest registry revision returned by list/upload; never guess.
|
|
162
|
-
npx vibemarket-game rollback my-cat-game 1.0.0-test.1 3
|
|
98
|
+
npm run build # the starter: type-check, bundle, then os assets copies HTML, manifest and store images
|
|
99
|
+
npm run pack # os pack dist app.zip
|
|
163
100
|
```
|
|
164
101
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
Local desktop browser/device emulation works; physical-phone/LAN previews need
|
|
192
|
-
a separately configured isolated runtime host and are not supported yet.
|
|
193
|
-
All publisher APIs and uploaded runtimes return 404 outside development. This is
|
|
194
|
-
not a public upload service. To enable public publishing, replace the local
|
|
195
|
-
adapter with authenticated developer/collection approval, object storage/CDN on
|
|
196
|
-
a separate registrable domain, transactional version registry, quotas, malware
|
|
197
|
-
review and revocation. Keep this bundle, version and SDK contract unchanged.
|
|
198
|
-
|
|
199
|
-
### Player links
|
|
200
|
-
|
|
201
|
-
Published games open at `/market/games/<manifest.id>`. Upload returns a draft
|
|
202
|
-
URL at that same path with `?preview=<version-key>`; keep the key to reopen that
|
|
203
|
-
exact version. Do not generate `?play=<id>` URLs. Existing query-style links
|
|
204
|
-
redirect for compatibility.
|
|
205
|
-
|
|
206
|
-
### Cosmetic entitlements (Chonk reference)
|
|
207
|
-
|
|
208
|
-
Read `inventory.get()` and offer equip controls only for cards whose `state` is
|
|
209
|
-
`collected`. A revealed/sealed card is not an equipped collectible. Subscribe to
|
|
210
|
-
`inventory.onChanged` and revalidate every displayed page; revoke a skin when
|
|
211
|
-
its ownership disappears. Render names as text. Never derive race odds, payouts,
|
|
212
|
-
or ownership from local storage. Chonk After Hours maps the five rarity indices
|
|
213
|
-
to five matching model palettes; foil changes no race advantage.
|
|
214
|
-
|
|
215
|
-
Ship wardrobe thumbnails inside your bundle. The Chonk packaging command copies
|
|
216
|
-
its five product images and rewrites their paths, so it works under the same
|
|
217
|
-
no-external-network policy as every uploaded game. The host records development
|
|
218
|
-
views and successful SDK boots separately; games cannot assign counter values.
|
|
102
|
+
## Submit, review and publication
|
|
103
|
+
|
|
104
|
+
1. Open VibeMarket OS in a web browser and sign in with Steam. Submitting needs
|
|
105
|
+
a Steam account; new versions of an app must come from the account that
|
|
106
|
+
first submitted it.
|
|
107
|
+
2. Open **VibeStore**, go to **Submit**, choose `app.zip` and submit it for
|
|
108
|
+
review. Refusals are explained there in plain words.
|
|
109
|
+
3. Vibechain staff review every version: they read the listing, look at the
|
|
110
|
+
file list and run the app in a sandboxed window. There is no automatic
|
|
111
|
+
approval and no promised review time. A rejection comes with a note; fix the
|
|
112
|
+
problem and submit a new version number.
|
|
113
|
+
4. **Approval is publication.** An approved version's files are copied to public
|
|
114
|
+
IPFS, and removing or revoking the app later does not recall that copy.
|
|
115
|
+
Submit only what you are willing to publish permanently. Staff choose which
|
|
116
|
+
approved version is live.
|
|
117
|
+
|
|
118
|
+
Apps open in the browser version of VibeMarket OS. The Steam client shows a
|
|
119
|
+
notice with a link instead of opening them, and the mobile apps do not run them.
|
|
120
|
+
|
|
121
|
+
## Market-game API (not for VibeStore apps)
|
|
122
|
+
|
|
123
|
+
The package still exports `connectGameSdk()`, `watchInventory()` and the schema
|
|
124
|
+
version 1 manifest with permissions and a `collectionId`. They exist for
|
|
125
|
+
Vibechain's own collection games and are not available to VibeStore apps:
|
|
126
|
+
VibeStore refuses any manifest with permissions or a collection, and an app
|
|
127
|
+
that calls them gets no economy access.
|
package/README.md
CHANGED
|
@@ -5,19 +5,19 @@ Build games, tools and desktop apps for VibeMarket OS with TypeScript. Start wit
|
|
|
5
5
|
## Quickstart
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
|
-
npx --yes @vibechain/os@0.
|
|
8
|
+
npx --yes @vibechain/os@0.4.1 init my-app
|
|
9
9
|
cd my-app
|
|
10
10
|
npm install
|
|
11
11
|
npm run build
|
|
12
12
|
npm run dev
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Open the printed `http://127.0.0.1:PORT` address. Stamp Club is a complete starter: start a round, add stamps, minimize and restore, then finish to see the host's result screen. Play again starts a fresh round. Host-accepted state survives suspension in the same open window. Reset clears it. Rebuild and restart the immutable preview after changes. `npm run pack` creates `app.zip`
|
|
15
|
+
Open the printed `http://127.0.0.1:PORT` address. Stamp Club is a complete starter: start a round, add stamps, minimize and restore, then finish to see the host's result screen. Play again starts a fresh round. Host-accepted state survives suspension in the same open window. Reset clears it. Rebuild and restart the immutable preview after changes. `npm run pack` creates `app.zip`, ready to submit to VibeStore: the starter's `vibemarket.json` is already a complete listing, with placeholder text and pictures you must replace first (its README lists the fields; an unchanged starter is rejected at review).
|
|
16
16
|
|
|
17
17
|
The starter includes TypeScript and esbuild and pins your SDK version. To install from a downloaded SDK archive, supply its absolute path to npm and the initializer:
|
|
18
18
|
|
|
19
19
|
```sh
|
|
20
|
-
npm exec --yes --package=/absolute/path/vibechain-os-0.
|
|
20
|
+
npm exec --yes --package=/absolute/path/vibechain-os-0.4.1.tgz -- os init my-app /absolute/path/vibechain-os-0.4.1.tgz
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
That explicit fallback keeps a `file:` archive dependency; retain the archive for later reinstalls. Use a supported Node.js release: `^22.23.4`, `^24.22.1` or `^26.12.1`.
|
|
@@ -41,7 +41,47 @@ window.addEventListener("pagehide", () => app.destroy(), { once: true });
|
|
|
41
41
|
|
|
42
42
|
Checkpoint is a base app capability, separate from Market permissions. It accepts only the same app's bounded JSON: ≤32 KiB UTF-8, depth8, ≤2,048 nodes, ≤64 keys/object, ≤256 items/array and ≤8KiB/string. State lives in trusted host memory, scoped to the open installation/version/identity/window; it is cleared on close, revoke, package/identity change or the controller's absolute 15-minute expiry. Suspension does not extend that lifetime. There is no arbitrary namespace, disk storage, account data or browser-restart guarantee. `write()` resolves after acknowledgement; an accepted snapshot can be restored even if that acknowledgement was interrupted.
|
|
43
43
|
|
|
44
|
-
Manifest: use
|
|
44
|
+
Manifest: use `sdkVersion: 1`, category `vibexp-app`, `permissions: []` and `collectionId: null`, with `schemaVersion: 2` and a store listing (below). Schema version 1, without a listing, still runs in the preview but cannot be submitted. App methods are deliberately limited to readiness, checkpoints and the score-only completion signal. Raw requests for profile, inventory, rewards, purchases, Steam, native IPC or wallet operations terminate this app session. Existing Market games continue using `connectGameSdk()` with their existing permissions and host transaction review.
|
|
45
|
+
|
|
46
|
+
## Game helpers (since 0.3.0)
|
|
47
|
+
|
|
48
|
+
Two optional imports for canvas, WebGL and engine-based games. Both follow the host lifecycle, so a game stops drawing when its window is not active.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { connectVibeMarketApp } from "@vibechain/os";
|
|
52
|
+
import { createLoop } from "@vibechain/os/loop";
|
|
53
|
+
import { fitCanvas } from "@vibechain/os/canvas";
|
|
54
|
+
|
|
55
|
+
const app = await connectVibeMarketApp();
|
|
56
|
+
const canvas = document.querySelector("canvas")!;
|
|
57
|
+
fitCanvas(app, canvas, { onResize: ({ width, height }) => renderer.setSize(width, height, false) });
|
|
58
|
+
const loop = createLoop(app, { update: stepMs => world.step(stepMs), render: alpha => renderer.draw(alpha) });
|
|
59
|
+
await app.ready();
|
|
60
|
+
window.addEventListener("pagehide", () => { loop.stop(); app.destroy(); }, { once: true });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`createLoop` runs a fixed-timestep simulation (default 60 steps per second, at most 5 catch-up steps per frame) and renders once per animation frame. It pauses while the app is inactive and discards that time instead of simulating it on return. `fitCanvas` sizes the canvas backing store from the host surface with the device pixel ratio capped (default 2, and at most 3840 x 2160 pixels), resizes only when the size changes, and keeps a lost WebGL context restorable through `onContextLost` and `onContextRestored`.
|
|
64
|
+
|
|
65
|
+
### Testing your game
|
|
66
|
+
|
|
67
|
+
`@vibechain/os/testing` is an in-memory stand-in for the host, so game logic can be unit-tested without a browser:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
import { createFakeApp } from "@vibechain/os/testing";
|
|
71
|
+
|
|
72
|
+
const host = createFakeApp({ checkpoint: { stamps: 3 } });
|
|
73
|
+
const game = await startGame(host.app); // your code, given the app instead of connecting
|
|
74
|
+
host.setLifecycle({ active: false }); // as if the window was minimized
|
|
75
|
+
expect(game.paused).toBe(true);
|
|
76
|
+
await game.end();
|
|
77
|
+
expect(host.finished).toEqual({ score: 3 });
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
It applies the real checkpoint, score and lifecycle validation and the single-shot completion rule. It has no time limit or request budget, so still run the preview before you ship.
|
|
81
|
+
|
|
82
|
+
### A complete 3D example
|
|
83
|
+
|
|
84
|
+
`examples/paw-beat` in this package is a small 3D rhythm game built on these helpers with Three.js: a procedural dancing cat, a synthesized song, a saved personal best and a reported score. Its README has the build commands.
|
|
45
85
|
|
|
46
86
|
## Intro, loading and results
|
|
47
87
|
|
|
@@ -57,9 +97,40 @@ await app.game.finish({ score: 42 });
|
|
|
57
97
|
|
|
58
98
|
Completion does not grant Cash, XP, inventory or a wallet action. The local preview and collection host report score only. An approved host may show an existing Cash award only after its own registered game policy and server reward flow confirm it; the frame cannot select a reward amount or supply proof of payment. Older hosts may not understand this additive method; use a matching 0.2.x host/preview.
|
|
59
99
|
|
|
100
|
+
## Listing in VibeStore
|
|
101
|
+
|
|
102
|
+
VibeStore is the app store inside VibeMarket OS. You submit from its **Submit** tab, and every version is reviewed by a person before it is listed. The requirements below are checked at submission. An app is listed with manifest schema version 2: version 1 plus two required objects.
|
|
103
|
+
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"schemaVersion": 2, "sdkVersion": 1, "id": "my-app", "version": "1.0.0", "name": "My App", "tagline": "One line about it.",
|
|
107
|
+
"category": "vibexp-app", "entry": "index.html", "permissions": [], "collectionId": null,
|
|
108
|
+
"window": { "width": 960, "height": 600, "resizable": true },
|
|
109
|
+
"store": {
|
|
110
|
+
"icon": "store/icon.png", "screenshots": ["store/screenshot-1.webp"],
|
|
111
|
+
"description": "At least forty characters of plain text about the app.", "category": "game",
|
|
112
|
+
"rating": { "violence": "none", "language": "none", "mature": false }, "support": "https://example.com/help"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
| Field | Requirement |
|
|
118
|
+
|---|---|
|
|
119
|
+
| `window` | `width` 320 to 1600 and `height` 200 to 1200 whole CSS pixels, `resizable` true or false. The window opens at this size. |
|
|
120
|
+
| `store.icon` | A `.png` file in the bundle, exactly 256 x 256 pixels and at most 256 KiB. |
|
|
121
|
+
| `store.screenshots` | 1 to 4 different `.png`, `.jpg`, `.jpeg` or `.webp` files in the bundle, none of them the icon, each at most 1 MiB, with contents that match the extension. |
|
|
122
|
+
| `store.description` | Plain text, 40 to 2,000 characters after trimming. Line breaks are allowed; other control characters are not. Shown as text, never as HTML. |
|
|
123
|
+
| `store.category` | `game`, `tool` or `toy`. |
|
|
124
|
+
| `store.rating` | `violence` and `language` each `none`, `mild` or `strong`, and `mature` true or false. Rate honestly. |
|
|
125
|
+
| `store.support` | An `https://` URL without a user name or password, or an email address, at most 200 characters. Players and reviewers see it. |
|
|
126
|
+
|
|
127
|
+
A version 2 bundle may not contain SVG files anywhere, because SVG is a document format that can carry script; use PNG or WebP. The bundle limits in [SECURITY.md](SECURITY.md) still apply, and the submitted ZIP is at most 20 MiB. Unknown fields are refused at every level. `os pack` and `os preview` run the same manifest and image checks, so a listing problem shows up locally first. To validate in your own tools, `@vibechain/os/manifest` exports `parseManifest` and the bounds, and `@vibechain/os/listing` exports `checkListing`, `pngSize` and `imageKind`, which work on plain `Uint8Array` bytes in Node or a browser.
|
|
128
|
+
|
|
129
|
+
`examples/paw-beat` and the `os init` starter are complete version 2 listings.
|
|
130
|
+
|
|
60
131
|
## Publishing status
|
|
61
132
|
|
|
62
|
-
|
|
133
|
+
Publish by submitting your packed ZIP from the VibeStore **Submit** tab in VibeMarket OS; see [Publish](https://vibechain.com/os/docs#publish) and [Review](https://vibechain.com/os/docs#review). Installing the SDK does not list your app. An approved version is archived to public IPFS, so approval is publication: removing an app from VibeStore later does not recall that copy. Third-party apps open in the browser version of VibeMarket OS; the Steam client does not run them yet. The app API does not grant native, inventory, payment or reward access. Existing Market games continue to use their separate permissioned API.
|
|
63
134
|
|
|
64
135
|
See the [SDK docs](https://vibechain.com/os/docs) for the app API and [SECURITY.md](SECURITY.md) for the sandbox and resource limits.
|
|
65
136
|
|
|
@@ -70,10 +141,10 @@ pnpm install --frozen-lockfile
|
|
|
70
141
|
pnpm review
|
|
71
142
|
pnpm build
|
|
72
143
|
pnpm check:package
|
|
73
|
-
pnpm release:preview --version 0.
|
|
144
|
+
pnpm release:preview --version 0.4.1
|
|
74
145
|
```
|
|
75
146
|
|
|
76
|
-
`pnpm build` emits JavaScript/declarations plus one bundled preview host UI.
|
|
147
|
+
`pnpm build` emits JavaScript/declarations plus one bundled preview host UI. Only `examples/paw-beat` and `examples/vibexp-app` are published. The store images of both examples are generated by scripts in `tools/` (not published), which drive headless, muted Chromium through Playwright. Read [SECURITY.md](SECURITY.md) before integrating any untrusted app.
|
|
77
148
|
|
|
78
149
|
## License
|
|
79
150
|
|
package/SECURITY.md
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
# VibeMarket OS app security and resource contract
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
These are bounded browser host controls, not a certification that arbitrary web code is safe. They grant no host identity or economy access. Native shells are refused. Store submission and review are checked by the VibeStore service, not by this package, and are not described here as open.
|
|
4
|
+
|
|
5
|
+
## Host admission
|
|
6
|
+
|
|
7
|
+
`appRuntimeRefusal` decides whether a window may mount an app frame at all; `mountAppFrame` refuses to start without it. It admits exactly two kinds of host, both as the top-level window:
|
|
8
|
+
|
|
9
|
+
| Host | Admitted |
|
|
10
|
+
|---|---|
|
|
11
|
+
| Local developer preview | `http://127.0.0.1` or `http://localhost`, any port |
|
|
12
|
+
| VibeMarket OS website | `https://vibechain.com` or `https://www.vibechain.com`, default port only |
|
|
13
|
+
|
|
14
|
+
Every other origin is refused, including other `https` hosts and subdomains, plain `http` to the production names and any explicit port on them. A framed host is refused. Known native bridge markers (`__VM_STEAM__`, `__TAURI_INTERNALS__`, `__TAURI__`, `vibeNative`, `ReactNativeWebView`) and embedded user agents (Tauri, Electron, VibeSteam, VibeMarketDesktop, Android `wv`) are refused on every host. Admission is a refusal policy: the absence of a marker does not certify an unknown webview.
|
|
15
|
+
|
|
16
|
+
## Runtime origins
|
|
17
|
+
|
|
18
|
+
- **Local preview.** `os preview` serves the parent page from `127.0.0.1` and the app from a different host, `localhost`, on the same port.
|
|
19
|
+
- **vibechain.com.** Apps are served by the website on the same origin as the desktop, under `/os/runtime/external/<appId>/<versionKey>/<file>`, where `versionKey` names one immutable version. There is no separate app domain. On the same origin exactly one thing keeps an app's HTML from running as `vibechain.com` with the player's session: the sandbox, which gives the document an opaque origin. The website's runtime route is therefore required to send `Content-Security-Policy: sandbox allow-scripts` on every response under that path, to serve HTML only to frame requests, to answer errors as plain text, to use fixed content types with `nosniff`, and to ignore and never set cookies. Those controls live in the website, not in this package, and this package cannot enforce them. What remains after them: browsers may run an app in the same process as the desktop, and the protection depends on those headers being right on every response. A separate registrable domain would be stronger; moving to one later is a routing change.
|
|
20
|
+
|
|
21
|
+
`mountAppFrame` accepts the bootstrap only from its own frame's window with origin `null`, on both hosts. If a response ever arrived without the sandbox, the app would not be able to connect to the host, but its code would already have run with the site's origin; the connection check is not a substitute for the header.
|
|
4
22
|
|
|
5
23
|
## Boundary
|
|
6
24
|
|
|
7
|
-
- App code executes in
|
|
25
|
+
- App code executes in an iframe with `sandbox="allow-scripts"`, without `allow-same-origin`, top navigation, popups, forms or downloads. Runtime HTTP CSP also carries `sandbox allow-scripts`, including direct visits. The host checks its browser/native policy before creating a frame. Never inject third-party JavaScript into the desktop React realm or a privileged native webview.
|
|
8
26
|
- Admission binds the exact iframe WindowProxy, opaque origin `null`, one unpredictable 128-bit URL challenge, then a private MessagePort with a fresh 128-bit session. `null` is not an identity by itself. Bootstrap is ≤256-byte JSON and ≤32 messages from that child; unrelated windows receive no port. The global listener is removed after connection.
|
|
9
27
|
- The additive app codec uses bounded JSON on the existing channel/envelope/port transport. Legacy Market messages stay unchanged. Wrong session, replayed IDs, unknown methods, invalid schemas, malformed/oversized messages and quota exhaustion close the port. No implicit Market permissions are inherited.
|
|
10
28
|
- Close, navigation, minimize, app focus loss, hidden document, identity or package change revoke the active generation. Minimize/focus loss preserves only the same app's host-accepted bounded checkpoint. Restore creates a fresh iframe, challenge and session. Host focus uses desktop policy, not the browser `blur` event caused by focusing the child itself.
|
|
@@ -23,6 +41,7 @@ This is a bounded local browser development adapter, not a certification that ar
|
|
|
23
41
|
| Absolute controller lifetime / readiness | 15minutes across suspension and remounts /15seconds |
|
|
24
42
|
| App-side request wait | 10seconds |
|
|
25
43
|
| Built bundle | Existing256 total entries, 16MiB/file, 64MiB expanded; ZIP20MiB |
|
|
44
|
+
| Schema version 2 bundle | No SVG files; store icon a 256 x 256 PNG ≤256KiB; 1–4 screenshots ≤1MiB each, signature matching the extension |
|
|
26
45
|
| First Desk adapter | One open third-party app controller and at most one untrusted iframe |
|
|
27
46
|
|
|
28
47
|
The local preview snapshots admitted files once using bounded no-follow file-handle reads, then serves only that immutable in-memory map and exact fixed host assets. It has no URL proxy, arbitrary filesystem route, write route or credential. Local filesystem authoring is not the public upload trust boundary; the existing ZIP validator remains responsible for untrusted uploads. The preview requires `127.0.0.1` for the parent and a different `localhost` runtime host, validates Host headers, never auto-opens a browser, and closes owned connections on shutdown.
|
|
@@ -33,4 +52,4 @@ The browser allocates structured-clone data before host validation. Message byte
|
|
|
33
52
|
|
|
34
53
|
CSP restricts fetches, assets, workers and embedding, but does not universally prevent a sandboxed app navigating its own frame to an external URL. Navigation revokes the session after load; a request may already have occurred. Do not describe this as a network firewall or supply secrets that require one. Known native bridge markers and embedded user agents are denied; their absence does not certify unknown webviews. Actual native IPC provenance tests are required before native admission.
|
|
35
54
|
|
|
36
|
-
|
|
55
|
+
Listing third-party apps relies on controls outside this package: publisher authentication, employee review of every version, immutable version digests, revocation, network and abuse budgets, install scope and adversarial tests. The listing checks in this package (`parseManifest`, `checkListing`, the SVG refusal) validate a bundle's shape; they do not review its behaviour. Scores/checkpoints are untrusted client claims. Rewards, inventory grants and payments require separate server-authoritative, replay-safe, idempotent and capped verification; they are not implemented by this app API.
|
package/dist/app-runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Admission policy for
|
|
1
|
+
/** Admission policy for browser hosts; marker absence is not native certification. */
|
|
2
2
|
export declare function appRuntimeRefusal(host: Window): string | null;
|
package/dist/app-runtime.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
const LOCAL_HOSTS = ["127.0.0.1", "localhost"];
|
|
2
|
+
const PRODUCTION_HOSTS = ["vibechain.com", "www.vibechain.com"];
|
|
3
|
+
/** The local developer preview over http on any port, or the VibeMarket OS website over https on its default port. */
|
|
4
|
+
function admittedHost({ protocol, hostname, port }) {
|
|
5
|
+
if (protocol === "http:")
|
|
6
|
+
return LOCAL_HOSTS.includes(hostname);
|
|
7
|
+
return protocol === "https:" && PRODUCTION_HOSTS.includes(hostname) && port === "";
|
|
8
|
+
}
|
|
9
|
+
/** Admission policy for browser hosts; marker absence is not native certification. */
|
|
2
10
|
export function appRuntimeRefusal(host) {
|
|
3
|
-
if (
|
|
4
|
-
return "Third-party apps are available only in the local browser developer preview.";
|
|
11
|
+
if (!admittedHost(host.location))
|
|
12
|
+
return "Third-party apps are available only on vibechain.com and in the local browser developer preview.";
|
|
5
13
|
if (host.top !== host.self)
|
|
6
14
|
return "Third-party apps require a top-level browser host.";
|
|
7
15
|
if (["__VM_STEAM__", "__TAURI_INTERNALS__", "__TAURI__", "vibeNative", "ReactNativeWebView"].some(key => key in host)
|
package/dist/bundle.js
CHANGED
|
@@ -3,6 +3,7 @@ import { lstat, open, opendir, realpath } from "node:fs/promises";
|
|
|
3
3
|
import { constants } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { assetPath, GAME_LIMITS, parseManifest } from "./manifest.js";
|
|
6
|
+
import { checkListing } from "./listing.js";
|
|
6
7
|
const TYPES = {
|
|
7
8
|
html: "text/html; charset=utf-8", js: "text/javascript; charset=utf-8", mjs: "text/javascript; charset=utf-8",
|
|
8
9
|
css: "text/css; charset=utf-8", json: "application/json", png: "image/png", jpg: "image/jpeg", jpeg: "image/jpeg",
|
|
@@ -74,6 +75,15 @@ export async function readBuiltBundle(directory) {
|
|
|
74
75
|
const manifest = parseManifest(JSON.parse(new TextDecoder().decode(input)));
|
|
75
76
|
if (!files[manifest.entry])
|
|
76
77
|
throw Error("Manifest entry is missing from the app bundle.");
|
|
78
|
+
if (manifest.schemaVersion === 2) {
|
|
79
|
+
// SVG is a document format that can carry script; schema version 2 bundles are served by the store runtime.
|
|
80
|
+
const svg = Object.keys(files).sort(compareAssetNames).find(file => assetType(file) === TYPES.svg);
|
|
81
|
+
if (svg)
|
|
82
|
+
throw Error(`Schema version 2 apps cannot contain SVG files; convert ${svg} to PNG or WebP.`);
|
|
83
|
+
const listing = checkListing(manifest, files);
|
|
84
|
+
if (!listing.ok)
|
|
85
|
+
throw Error(`Store listing (${listing.code}): ${listing.message}`);
|
|
86
|
+
}
|
|
77
87
|
files["vibemarket.json"] = new TextEncoder().encode(JSON.stringify(manifest));
|
|
78
88
|
const digest = createHash("sha256");
|
|
79
89
|
for (const [file, bytes] of Object.entries(files).sort(([a], [b]) => compareAssetNames(a, b)))
|
package/dist/canvas.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { LifecycleSource } from "./loop.ts";
|
|
2
|
+
export interface CanvasFit {
|
|
3
|
+
/** Backing-store size in device pixels. */
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
/** The pixel ratio actually applied, after both caps. */
|
|
7
|
+
pixelRatio: number;
|
|
8
|
+
}
|
|
9
|
+
export interface FitOptions {
|
|
10
|
+
/** Highest device pixel ratio to render at, 1 to 4. Default: 2. */
|
|
11
|
+
maxPixelRatio?: number;
|
|
12
|
+
/** Highest backing-store area in pixels; the ratio is lowered to fit. Default: 3840 x 2160. */
|
|
13
|
+
maxPixels?: number;
|
|
14
|
+
/** Called after the backing store changed size. Resize the viewport and camera here. */
|
|
15
|
+
onResize?(fit: Readonly<CanvasFit>): void;
|
|
16
|
+
/** WebGL context was lost. Stop drawing; GPU resources are gone. */
|
|
17
|
+
onContextLost?(): void;
|
|
18
|
+
/** WebGL context is back. Recreate GPU resources. */
|
|
19
|
+
onContextRestored?(): void;
|
|
20
|
+
}
|
|
21
|
+
export interface FitTarget {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
addEventListener(type: string, listener: (event: Event) => void): void;
|
|
25
|
+
removeEventListener(type: string, listener: (event: Event) => void): void;
|
|
26
|
+
}
|
|
27
|
+
export interface FittedCanvas {
|
|
28
|
+
/** The last applied size, or null until the host has reported a surface size. */
|
|
29
|
+
current(): Readonly<CanvasFit> | null;
|
|
30
|
+
stop(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Keep a canvas backing store matched to the host surface, with the pixel ratio capped
|
|
34
|
+
* so a high-density display cannot multiply the fill cost. The canvas is resized (and so
|
|
35
|
+
* cleared) only when the computed size actually changes. Style the canvas to fill the
|
|
36
|
+
* app; this sets only its `width` and `height`.
|
|
37
|
+
*/
|
|
38
|
+
export declare function fitCanvas(app: LifecycleSource, canvas: FitTarget, options?: FitOptions, view?: {
|
|
39
|
+
devicePixelRatio: number;
|
|
40
|
+
}): FittedCanvas;
|