@volter/world-runtime 2.0.29 → 2.0.30

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.
@@ -26,7 +26,7 @@ import { getActiveWorldStore, withAncestryLock, captureHistory, historyAtInstant
26
26
  // to `.volter/token` and `.volter/token.read` (0600).
27
27
  // One writer per world by construction: the doors run in this process, serialized per twin.
28
28
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
29
- import { blobDigest, openSealedAt, getActiveBlobStore, loadCheck, mirrorShellUnder, readTwinRequestJournal, serveHttp, TWIN_PREFIX_HEADER, validateRemoteOrigin } from '@volter/world-core';
29
+ import { assertSafeChangesetName, blobDigest, openSealedAt, getActiveBlobStore, loadCheck, mirrorShellUnder, readTwinRequestJournal, serveHttp, TWIN_PREFIX_HEADER, validateRemoteOrigin } from '@volter/world-core';
30
30
  import { APP_READ_ENDPOINT_ENV } from "./init.js";
31
31
  import { grantOf, presentedSecrets, sameSecret, spentPasses, verifyPass } from '@volter/world-access';
32
32
  import { createHash } from 'node:crypto';
@@ -1687,6 +1687,9 @@ export class WorldDoors {
1687
1687
  * door and the path transport both come here.
1688
1688
  */
1689
1689
  export async function landChangeset(name, worldRoot, instance, changeset, expected = {}) {
1690
+ // the name addresses the file the changeset is kept in: a name with a separator or a traversal would write anywhere in
1691
+ // the World's store (its token, its credentials), so it is refused before anything lands
1692
+ assertSafeChangesetName(typeof changeset.name === 'string' ? changeset.name : '');
1690
1693
  const receipts = [];
1691
1694
  const checks = await loadWorldChecks(worldRoot);
1692
1695
  const stateOf = (twin) => stateServiceOf(join(instance.dirs.data, twin), twin);
@@ -1744,7 +1747,10 @@ export async function landChangeset(name, worldRoot, instance, changeset, expect
1744
1747
  receipts.push({ actionId: id, twin, status: 'landed', at: worldNow() });
1745
1748
  }
1746
1749
  }
1747
- const path = join(worldChangesetsDir(name, worldRoot), `${changeset.name}.json`);
1750
+ const dir = worldChangesetsDir(name, worldRoot);
1751
+ const path = join(dir, `${changeset.name}.json`);
1752
+ if (dirname(path) !== dir)
1753
+ throw new Error(`Invalid changeset name: ${JSON.stringify(changeset.name)}`);
1748
1754
  const store = getActiveWorldStore();
1749
1755
  if (!store.exists(path))
1750
1756
  store.write(path, `${JSON.stringify(changeset, null, 2)}\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/world-runtime",
3
- "version": "2.0.29",
3
+ "version": "2.0.30",
4
4
  "description": "World configs for twins: boot named local runtimes, allocate ports, generate world.env/instance.json, and run apps against fake-key twin worlds.",
5
5
  "keywords": [
6
6
  "twin",
@@ -26,7 +26,7 @@ import { getActiveWorldStore, withAncestryLock, captureHistory, historyAtInstant
26
26
  // to `.volter/token` and `.volter/token.read` (0600).
27
27
  // One writer per world by construction: the doors run in this process, serialized per twin.
28
28
  import { chmodSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync , rmSync} from 'node:fs';
29
- import { blobDigest, openSealedAt, getActiveBlobStore, loadCheck, mirrorShellUnder, readTwinRequestJournal, serveHttp, TWIN_PREFIX_HEADER, validateRemoteOrigin, type SealedCredential, type TwinStreamConnection, type TwinStreamSink } from '@volter/world-core';
29
+ import { assertSafeChangesetName, blobDigest, openSealedAt, getActiveBlobStore, loadCheck, mirrorShellUnder, readTwinRequestJournal, serveHttp, TWIN_PREFIX_HEADER, validateRemoteOrigin, type SealedCredential, type TwinStreamConnection, type TwinStreamSink } from '@volter/world-core';
30
30
  import { APP_READ_ENDPOINT_ENV } from './init.ts';
31
31
  import { grantOf, presentedSecrets, sameSecret, spentPasses, verifyPass, type TrustedIssuer, type WorldCredentials } from '@volter/world-access';
32
32
  import { createHash } from 'node:crypto';
@@ -1436,6 +1436,9 @@ export class WorldDoors {
1436
1436
  * door and the path transport both come here.
1437
1437
  */
1438
1438
  export async function landChangeset(name: string, worldRoot: string, instance: WorldLayout, changeset: Changeset, expected: Record<string, HistoryReference> = {}): Promise<Array<{ actionId: string; twin: string } & Receipt>> {
1439
+ // the name addresses the file the changeset is kept in: a name with a separator or a traversal would write anywhere in
1440
+ // the World's store (its token, its credentials), so it is refused before anything lands
1441
+ assertSafeChangesetName(typeof changeset.name === 'string' ? changeset.name : '');
1439
1442
  const receipts: Array<{ actionId: string; twin: string } & Receipt> = [];
1440
1443
  const checks = await loadWorldChecks(worldRoot);
1441
1444
  const stateOf = (twin: string): string => stateServiceOf(join(instance.dirs.data, twin), twin);
@@ -1481,7 +1484,9 @@ export async function landChangeset(name: string, worldRoot: string, instance: W
1481
1484
  for (const id of landedIds) receipts.push({ actionId: id, twin, status: 'landed', at: worldNow() });
1482
1485
  }
1483
1486
  }
1484
- const path = join(worldChangesetsDir(name, worldRoot), `${changeset.name}.json`);
1487
+ const dir = worldChangesetsDir(name, worldRoot);
1488
+ const path = join(dir, `${changeset.name}.json`);
1489
+ if (dirname(path) !== dir) throw new Error(`Invalid changeset name: ${JSON.stringify(changeset.name)}`);
1485
1490
  const store = getActiveWorldStore();
1486
1491
  if (!store.exists(path)) store.write(path, `${JSON.stringify(changeset, null, 2)}\n`);
1487
1492
  return receipts;