cli: waybetter store build|sign|verify, the store catalog JSON Schema

Moved from wayBetter for X (scripts/build-store.mjs, scripts/sign-store.mjs) into the `waybetter`
npm package, generic over the app:

- bin/waybetter.mjs + cli/store.mjs. `build --config <store.config.mjs>`: the config names its app
  and returns its items (metadata, file path + bytes, optional preview); build replaces only that
  app's items in the shared catalog (other apps' items and files stay), removes files only its old
  items used, fills url/sha256/size/apps, and validates the whole catalog with the rules apps apply
  natively before anything is written. `sign` (and `sign --init`: create the key once, 0600, never
  overwritten) signs the exact catalog bytes; `verify` checks the signature with any listed public
  key (rotation) and the catalog rules. The private key is never printed, copied or moved; --key
  defaults to $WAYBETTER_STORE_KEY. pluginHeader() for configs.
- store-catalog.schema.json (format 2, `apps` per item), exported with the CLI module.
- Tests: multi-app builds in one folder, refusals (bad items, duplicates, paths outside the folder,
  hosts), schema vs CLI rules, sign/verify round trip incl. rotation and tampering, no key
  material printed. jsonSchema.mjs learns minItems, uniqueItems and allOf.
This commit is contained in:
CRTkafa 2026-09-29 04:12:38 +00:00
parent 74e06e5e15
commit ae82f6ba57
7 changed files with 518 additions and 4 deletions

View file

@ -11,9 +11,10 @@
],
"scripts": {
"typecheck": "tsc -p tsconfig.json && tsc -p packages/create-waybetter/tsconfig.json",
"test": "bun run test:ts && bun run test:rust && bun run test:create",
"test": "bun run test:ts && bun run test:rust && bun run test:create && bun run test:cli",
"test:ts": "node --test packages/runtime/tests/*.test.ts packages/shell/tests/*.test.ts",
"test:create": "node --test packages/create-waybetter/tests/*.test.mjs",
"test:cli": "node --test packages/waybetter/tests/*.test.mjs",
"test:rust": "cargo test --manifest-path crates/waybetter-host/Cargo.toml --locked --features net",
"check:tauri": "cargo check --manifest-path crates/waybetter-host/Cargo.toml --features tauri,net",
"build": "bun run typecheck && cargo build --manifest-path crates/waybetter-host/Cargo.toml --locked",