@chrona-city/ugc-kit 1.5.10 → 1.5.12
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/README.md +16 -0
- package/contracts/ugc/public-runtime/v1/README.md +40 -0
- package/contracts/ugc/public-runtime/v1/archive.mjs +4 -3
- package/contracts/ugc/public-runtime/v1/manifest.mjs +21 -10
- package/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json +60 -16
- package/contracts/ugc/public-runtime/v1/static-room-runtime.test.mjs +225 -0
- package/docs/harness-onboarding.md +6 -3
- package/docs/npm-creator.md +1 -1
- package/docs/runtime-download.md +69 -0
- package/lib/creator-api.mjs +10 -9
- package/lib/creator-contribution.mjs +1 -1
- package/lib/creator-onboarding.mjs +3 -2
- package/lib/creator-platform.mjs +4 -2
- package/lib/creator-project-update.mjs +4 -1
- package/lib/creator-session.mjs +6 -5
- package/lib/creator-toolchain-compat.mjs +6 -0
- package/lib/host-ipc/{distribution-node-support-contract → distribution-static-room-semantic-contract}/contracts/ugc/public-runtime/v1/manifest.mjs +21 -10
- package/lib/host-ipc/{distribution-node-support-contract → distribution-static-room-semantic-contract}/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json +60 -16
- package/lib/host-ipc/host-ipc.schema.json +18 -2
- package/lib/host-ipc/runtime-contract.mjs +5 -5
- package/lib/host-ipc/source-lock.json +9 -9
- package/lib/runtime-host-client.mjs +10 -4
- package/lib/runtime-host.mjs +3 -1
- package/lib/runtime-install.mjs +11 -3
- package/package.json +1 -1
- package/public-runtime.snapshot.lock.json +9 -5
- package/runtime-catalog.json +24 -8
- /package/lib/host-ipc/{distribution-node-support-contract → distribution-static-room-semantic-contract}/contracts/ugc/creator-source/v1/tool-package.schema.json +0 -0
- /package/lib/host-ipc/{distribution-node-support-contract → distribution-static-room-semantic-contract}/contracts/ugc/registry/v1/conformance/js/capability-resolver.mjs +0 -0
package/lib/creator-api.mjs
CHANGED
|
@@ -270,8 +270,8 @@ function creatorApi({ origin, allowLocalHttp = false, fetchImpl = globalThis.fet
|
|
|
270
270
|
if (signal?.aborted) fail('CREATOR_REQUEST_CANCELLED');
|
|
271
271
|
if (operationAdapter && credential !== undefined) fail('INVALID_CREATOR_CREDENTIAL');
|
|
272
272
|
if (!operationAdapter && (route.startsWith('/projects') || route.startsWith('/terminal/')) && credential === undefined) fail('INVALID_CREATOR_CREDENTIAL');
|
|
273
|
-
if (!operationAdapter && credential !== undefined && (!credential || credential.origin !== platform || !
|
|
274
|
-
||
|
|
273
|
+
if (!operationAdapter && credential !== undefined && (!credential || credential.origin !== platform || !positiveInteger(credential.expiresAtMs)
|
|
274
|
+
|| !/^ct_[a-f0-9]{32}\.[a-f0-9]{64}$/.test(credential.accessToken ?? ''))) fail('INVALID_CREATOR_CREDENTIAL');
|
|
275
275
|
const encoded = body === undefined ? undefined : JSON.stringify(body);
|
|
276
276
|
if (encoded && Buffer.byteLength(encoded) > bodyLimit) fail('CREATOR_REQUEST_TOO_LARGE');
|
|
277
277
|
let response, payload;
|
|
@@ -373,19 +373,20 @@ function creatorApi({ origin, allowLocalHttp = false, fetchImpl = globalThis.fet
|
|
|
373
373
|
const codeVerifier = randomBytes(32).toString('base64url');
|
|
374
374
|
const data = await request('POST', '/authorizations', { body: { deviceName, scopes: [...requestedScopes],
|
|
375
375
|
codeChallenge: createHash('sha256').update(codeVerifier).digest('base64url'), codeChallengeMethod: 'S256', ...(projectId ? { projectId } : {}) }, signal });
|
|
376
|
-
|
|
377
|
-
|
|
376
|
+
// Expiry is issued and enforced by the platform, not the device clock.
|
|
377
|
+
if (!id(data.authorizationId) || data.status !== 'pending' || !positiveInteger(data.expiresAtMs)
|
|
378
|
+
|| data.pollIntervalMs !== 2000) fail('INVALID_CREATOR_RESPONSE');
|
|
378
379
|
return { public: { authorizationId: data.authorizationId, authorizationUrl: `${platform}/creator/authorize?authorizationId=${data.authorizationId}`,
|
|
379
380
|
status: 'pending', expiresAtMs: data.expiresAtMs, pollIntervalMs: data.pollIntervalMs },
|
|
380
381
|
pending: { origin: platform, authorizationId: data.authorizationId, codeVerifier, requestedScopes: [...requestedScopes], projectId: projectId ?? '', expiresAtMs: data.expiresAtMs } };
|
|
381
382
|
},
|
|
382
383
|
async exchangeAuthorization(pending, { signal } = {}) {
|
|
383
384
|
if (!pending || pending.origin !== platform || !id(pending.authorizationId) || !/^[A-Za-z0-9_-]{43}$/.test(pending.codeVerifier ?? '')
|
|
384
|
-
|| !validScopes(pending.requestedScopes, pending.projectId) || !
|
|
385
|
+
|| !validScopes(pending.requestedScopes, pending.projectId) || !positiveInteger(pending.expiresAtMs)) fail('INVALID_AUTHORIZATION_SESSION');
|
|
385
386
|
const data = await request('POST', '/token', { body: { authorizationId: pending.authorizationId, codeVerifier: pending.codeVerifier }, signal });
|
|
386
387
|
if (data.tokenType !== 'Bearer' || !new RegExp(`^ct_${pending.authorizationId}\\.[a-f0-9]{64}$`).test(data.accessToken ?? '')
|
|
387
388
|
|| !validScopes(data.scopes, data.projectId) || data.scopes.some(s => !pending.requestedScopes.includes(s)) || data.projectId !== pending.projectId
|
|
388
|
-
|| !
|
|
389
|
+
|| !positiveInteger(data.expiresAtMs)) fail('INVALID_CREATOR_RESPONSE');
|
|
389
390
|
return { origin: platform, accessToken: data.accessToken, expiresAtMs: data.expiresAtMs, scopes: [...data.scopes], projectId: data.projectId };
|
|
390
391
|
},
|
|
391
392
|
async cancelAuthorization(pending, { signal } = {}) {
|
|
@@ -438,16 +439,16 @@ function creatorApi({ origin, allowLocalHttp = false, fetchImpl = globalThis.fet
|
|
|
438
439
|
|| data.sourceTreeHash !== hash(canonical(data.files)) || !exact(data.archive, ['format', 'sha256', 'bytes'])
|
|
439
440
|
|| data.archive.format !== 'zip-store-v1' || !digest(data.archive.sha256)
|
|
440
441
|
|| !Number.isSafeInteger(data.archive.bytes) || data.archive.bytes < 22 || data.archive.bytes > 73400320
|
|
441
|
-
|| data.chunkBytes !== 524288 || !
|
|
442
|
+
|| data.chunkBytes !== 524288 || !positiveInteger(data.expiresAtMs)) fail('INVALID_CREATOR_RESPONSE');
|
|
442
443
|
try { validateSourcePackageFiles(data.files); } catch { fail('INVALID_CREATOR_RESPONSE'); }
|
|
443
444
|
return structuredClone(data);
|
|
444
445
|
},
|
|
445
446
|
async getProjectSourceSnapshotChunk(projectId, snapshot, index, options) {
|
|
446
447
|
if (!snapshot || snapshot.projectId !== projectId || !id(snapshot.snapshotId)
|
|
447
448
|
|| !Number.isSafeInteger(index) || index < 0 || !Number.isSafeInteger(snapshot.archive?.bytes)
|
|
448
|
-
|| snapshot.archive.bytes < 22 || snapshot.archive.bytes > 73400320) fail('INVALID_SOURCE_SNAPSHOT_REQUEST');
|
|
449
|
+
|| snapshot.archive.bytes < 22 || snapshot.archive.bytes > 73400320 || !positiveInteger(snapshot.expiresAtMs)) fail('INVALID_SOURCE_SNAPSHOT_REQUEST');
|
|
449
450
|
const offset = index * 524288, remaining = snapshot.archive.bytes - offset;
|
|
450
|
-
if (remaining <= 0
|
|
451
|
+
if (remaining <= 0) fail('INVALID_SOURCE_SNAPSHOT_REQUEST');
|
|
451
452
|
const data = await request('GET', `${projectPath(projectId)}/source/snapshots/${snapshot.snapshotId}/chunks/${index}`,
|
|
452
453
|
{ ...options, responseLimit: 1048576 });
|
|
453
454
|
if (!exact(data, ['snapshotId', 'index', 'offset', 'bytes', 'dataBase64', 'archiveSha256', 'archiveBytes', 'complete'])
|
|
@@ -16,7 +16,7 @@ const scopes = ['projects:read', 'source:read', 'contributions:write'];
|
|
|
16
16
|
|
|
17
17
|
function access(credential, api, projectId) {
|
|
18
18
|
if (!projectPattern.test(projectId ?? '') || credential?.origin !== api.origin || credential.projectId !== projectId
|
|
19
|
-
|| !Number.isSafeInteger(credential.expiresAtMs) || credential.expiresAtMs <=
|
|
19
|
+
|| !Number.isSafeInteger(credential.expiresAtMs) || credential.expiresAtMs <= 0) fail('INVALID_CREATOR_CREDENTIAL');
|
|
20
20
|
const missingScopes = scopes.filter(scope => !credential.scopes?.includes(scope));
|
|
21
21
|
if (missingScopes.length) throw Object.assign(new Error('CREATOR_SESSION_SCOPE_REQUIRED'), { code: 'CREATOR_SESSION_SCOPE_REQUIRED', requiredScopes: scopes, missingScopes });
|
|
22
22
|
}
|
|
@@ -19,8 +19,9 @@ export async function beginCreatorOnboarding(options, { fetchImpl } = {}) {
|
|
|
19
19
|
const state = await inspectCreatorOnboarding(options);
|
|
20
20
|
if (state.authorization.phase === 'not-started') return beginCreatorSession({ directory: options.sessionDirectory,
|
|
21
21
|
origin: state.authorization.origin, allowLocalHttp: options.allowLocalHttp, requestedScopes: creatorAuthorizationScopes, fetchImpl });
|
|
22
|
-
|
|
23
|
-
if (state.authorization.phase === '
|
|
22
|
+
const validExpiry = Number.isSafeInteger(state.authorization.expiresAtMs) && state.authorization.expiresAtMs > 0;
|
|
23
|
+
if (state.authorization.phase === 'authorized' && validExpiry) return state;
|
|
24
|
+
if (state.authorization.phase === 'pending' && validExpiry) {
|
|
24
25
|
return { ...state, authorizationUrl: `${state.authorization.origin}/creator/authorize?authorizationId=${state.authorization.authorizationId}`, pollIntervalMs: 2000 };
|
|
25
26
|
}
|
|
26
27
|
throw failure('CREATOR_SESSION_RENEWAL_REQUIRED');
|
package/lib/creator-platform.mjs
CHANGED
|
@@ -44,7 +44,7 @@ export function readProjectDiscovery(data, creatorProjectId, credential) {
|
|
|
44
44
|
return structuredClone(data);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
export function readPlatformPreflight(data, projectId
|
|
47
|
+
export function readPlatformPreflight(data, projectId) {
|
|
48
48
|
const hashes = ['runtimeHash', 'resourcePolicyHash', 'capabilityRegistryHash', 'capabilitiesLockHash', 'effectivePolicyHash', 'policyHash'];
|
|
49
49
|
if (!exact(data, ['projectId', 'schemaVersion', 'revision', 'toolchain', ...hashes, 'capabilities', 'policyId', 'validUntilMs', 'observedAtMs', 'releaseEligibility'])
|
|
50
50
|
|| !project(projectId) || data.projectId !== projectId || data.schemaVersion !== '1.0.0' || !positive(data.revision)
|
|
@@ -70,7 +70,9 @@ export function readPlatformPreflight(data, projectId, now = Date.now()) {
|
|
|
70
70
|
|| (durable ? Object.hasOwn(e, 'expiresAtMs') && e.expiresAtMs !== 0
|
|
71
71
|
: !positive(e.expiresAtMs) || e.expiresAtMs <= data.observedAtMs)) fail('INVALID_CREATOR_RESPONSE');
|
|
72
72
|
} else if (!exact(e, ['eligible', 'reason']) || e.eligible !== false || e.reason !== 'TESTING_RELEASE_NOT_AUTHORIZED') fail('INVALID_CREATOR_RESPONSE');
|
|
73
|
-
|
|
73
|
+
// Both timestamps share the platform clock. Actual permission/expiry is
|
|
74
|
+
// rechecked by the platform on the operation; device time is not authority.
|
|
75
|
+
if (data.validUntilMs <= data.observedAtMs) fail('CREATOR_PREFLIGHT_EXPIRED');
|
|
74
76
|
return structuredClone(data);
|
|
75
77
|
}
|
|
76
78
|
|
|
@@ -124,7 +124,10 @@ async function assertPlatformFilesUnchanged(original, next, localToolchain) {
|
|
|
124
124
|
const metadata = JSON.parse(before);
|
|
125
125
|
const expected = name === 'chrona.toolchain.json' ? localToolchain : name === 'chrona.project.json'
|
|
126
126
|
? { ...metadata, kitVersion: localToolchain.version }
|
|
127
|
-
: { ...metadata,
|
|
127
|
+
: { ...metadata,
|
|
128
|
+
imports: { [localToolchain.sdk.shared]: `${localToolchain.package}/shared`,
|
|
129
|
+
[localToolchain.sdk.client]: `${localToolchain.package}/client` },
|
|
130
|
+
devDependencies: { [localToolchain.package]: localToolchain.version } };
|
|
128
131
|
if (canonical(expected) !== canonical(JSON.parse(after))) fail('SOURCE_UPDATE_OUTSIDE_CONTENT');
|
|
129
132
|
continue;
|
|
130
133
|
}
|
package/lib/creator-session.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export const creatorUploadScopes = Object.freeze(['source:read', 'submissions:wr
|
|
|
13
13
|
|
|
14
14
|
export function assertCreatorUploadAccess(credential, origin, projectId) {
|
|
15
15
|
if (credential?.origin !== origin || !Number.isSafeInteger(credential.expiresAtMs)
|
|
16
|
-
|| credential.expiresAtMs <=
|
|
16
|
+
|| credential.expiresAtMs <= 0 || !Array.isArray(credential.scopes)
|
|
17
17
|
|| !(credential.projectId === '' || /^[a-f0-9]{32}$/.test(credential.projectId ?? ''))
|
|
18
18
|
|| !/^ct_[a-f0-9]{32}\.[a-f0-9]{64}$/.test(credential.accessToken ?? '')) fail('INVALID_CREATOR_CREDENTIAL');
|
|
19
19
|
if (credential.projectId && credential.projectId !== projectId) fail('CREATOR_SESSION_PROJECT_MISMATCH');
|
|
@@ -25,7 +25,7 @@ export function assertCreatorUploadAccess(credential, origin, projectId) {
|
|
|
25
25
|
|
|
26
26
|
function uploadPreflight(state) {
|
|
27
27
|
const authorized = state.phase === 'authorized' && Number.isSafeInteger(state.credential?.expiresAtMs)
|
|
28
|
-
&& state.credential.expiresAtMs >
|
|
28
|
+
&& state.credential.expiresAtMs > 0 && state.credential.origin === state.origin;
|
|
29
29
|
const granted = authorized && Array.isArray(state.credential.scopes) ? state.credential.scopes : [];
|
|
30
30
|
const missingScopes = creatorUploadScopes.filter(scope => !granted.includes(scope));
|
|
31
31
|
return { status: !authorized ? 'not-authorized' : missingScopes.length ? 'missing-scopes' : 'scope-ready',
|
|
@@ -128,7 +128,8 @@ export async function completeCreatorSession(directory, { signal, fetchImpl, exp
|
|
|
128
128
|
return withSession(directory, async (state, save) => {
|
|
129
129
|
if (expectedOrigin !== undefined && state.origin !== expectedOrigin) fail('CREATOR_SESSION_ORIGIN_MISMATCH');
|
|
130
130
|
if (state.phase !== 'pending') fail('CREATOR_SESSION_NOT_PENDING');
|
|
131
|
-
|
|
131
|
+
const elapsed = Date.now() - state.lastAttemptAtMs;
|
|
132
|
+
if (elapsed >= 0 && elapsed < 2000) fail('CREATOR_AUTHORIZATION_POLL_EARLY');
|
|
132
133
|
const api = createCreatorApi({ origin: state.origin, allowLocalHttp: state.allowLocalHttp, fetchImpl });
|
|
133
134
|
state.phase = 'exchanging'; state.lastAttemptAtMs = Date.now(); await save();
|
|
134
135
|
try {
|
|
@@ -161,7 +162,7 @@ export async function inspectCreatorSession(directory, { expectedOrigin } = {})
|
|
|
161
162
|
export async function useCreatorSession(directory, action, { fetchImpl, expectedOrigin } = {}) {
|
|
162
163
|
return withSession(directory, async state => {
|
|
163
164
|
if (expectedOrigin !== undefined && state.origin !== expectedOrigin) fail('CREATOR_SESSION_ORIGIN_MISMATCH');
|
|
164
|
-
if (state.phase !== 'authorized' || !state.credential || state.credential.expiresAtMs <=
|
|
165
|
+
if (state.phase !== 'authorized' || !Number.isSafeInteger(state.credential?.expiresAtMs) || state.credential.expiresAtMs <= 0) fail('CREATOR_SESSION_NOT_AUTHORIZED');
|
|
165
166
|
return action(createCreatorApi({ origin: state.origin, allowLocalHttp: state.allowLocalHttp, fetchImpl }), structuredClone(state.credential));
|
|
166
167
|
});
|
|
167
168
|
}
|
|
@@ -222,7 +223,7 @@ export async function requestCreatorPreview(directory, projectId, jobId, payload
|
|
|
222
223
|
if (!/^job_[a-f0-9]{64}$/.test(jobId ?? '')) fail('INVALID_CREATOR_JOB_ID');
|
|
223
224
|
return withSession(directory, async (state, _save, root) => {
|
|
224
225
|
if (expectedOrigin !== undefined && state.origin !== expectedOrigin) fail('CREATOR_SESSION_ORIGIN_MISMATCH');
|
|
225
|
-
if (state.phase !== 'authorized' || !state.credential || state.credential.expiresAtMs <=
|
|
226
|
+
if (state.phase !== 'authorized' || !Number.isSafeInteger(state.credential?.expiresAtMs) || state.credential.expiresAtMs <= 0) fail('CREATOR_SESSION_NOT_AUTHORIZED');
|
|
226
227
|
if (state.credential.projectId && state.credential.projectId !== projectId) fail('CREATOR_SESSION_PROJECT_MISMATCH');
|
|
227
228
|
if (signal?.aborted) fail('CREATOR_REQUEST_CANCELLED');
|
|
228
229
|
const api = createCreatorApi({ origin: state.origin, allowLocalHttp: state.allowLocalHttp, fetchImpl });
|
|
@@ -61,6 +61,12 @@ export const registeredUpgradeSources = [{ schemaVersion: '1.0.0', package: '@ch
|
|
|
61
61
|
snapshotHash: 'sha256:2a150f290a642e1c72c9ac887cf787a916e4a1ee6f5e25b47f1d87467198285f',
|
|
62
62
|
sdk: { shared: '#chrona/shared', client: '#chrona/client' } },
|
|
63
63
|
{ schemaVersion: '1.0.0', package: '@chrona-city/ugc-kit', version: '1.5.9',
|
|
64
|
+
snapshotHash: 'sha256:1bc56acdc3fdac6999115526f804068c101dcc73ef5054eb2c2c3dc29e381af8',
|
|
65
|
+
sdk: { shared: '#chrona/shared', client: '#chrona/client' } },
|
|
66
|
+
{ schemaVersion: '1.0.0', package: '@chrona-city/ugc-kit', version: '1.5.10',
|
|
67
|
+
snapshotHash: 'sha256:1bc56acdc3fdac6999115526f804068c101dcc73ef5054eb2c2c3dc29e381af8',
|
|
68
|
+
sdk: { shared: '#chrona/shared', client: '#chrona/client' } },
|
|
69
|
+
{ schemaVersion: '1.0.0', package: '@chrona-city/ugc-kit', version: '1.5.11',
|
|
64
70
|
snapshotHash: 'sha256:1bc56acdc3fdac6999115526f804068c101dcc73ef5054eb2c2c3dc29e381af8',
|
|
65
71
|
sdk: { shared: '#chrona/shared', client: '#chrona/client' } }];
|
|
66
72
|
|
|
@@ -14,9 +14,10 @@ const toolVersion = v => typeof v === 'string' && /^(0|[1-9][0-9]*)\.(0|[1-9][0-
|
|
|
14
14
|
const bounded = (v, min, max) => Number.isSafeInteger(v) && v >= min && v <= max;
|
|
15
15
|
const roles = ['node', 'browser', 'sandbox', 'wasm', 'data', 'license'];
|
|
16
16
|
|
|
17
|
-
export function validRuntimePath(v, { document = false } = {}) {
|
|
18
|
-
const roomImplementation =
|
|
19
|
-
|
|
17
|
+
export function validRuntimePath(v, { document = false, staticRoom = false } = {}) {
|
|
18
|
+
const roomImplementation = typeof v === 'string' && (document
|
|
19
|
+
? /^node\/content-room-document-authority\/services\/game-worker\/src\/runtime\/content\/[A-Za-z0-9_-][A-Za-z0-9_.-]*\.js$/.test(v)
|
|
20
|
+
: staticRoom && /^node\/content-room-authority\/services\/game-worker\/src\/runtime\/content\/[A-Za-z0-9_-][A-Za-z0-9_.-]*\.js$/.test(v));
|
|
20
21
|
const localExecutionImplementation = document && typeof v === 'string'
|
|
21
22
|
&& /^node\/document-local-execution\/services\/ugc-pipeline\/src\/(?:document-local-execution|private-state-model|private-event-model|private-ecs-model|registry-release)\.mjs$/.test(v);
|
|
22
23
|
return typeof v === 'string' && v.length <= 512 && /^[A-Za-z0-9_@-][A-Za-z0-9_@.-]*(?:\/[A-Za-z0-9_@-][A-Za-z0-9_@.-]*)*$/.test(v)
|
|
@@ -27,12 +28,12 @@ export function validRuntimePath(v, { document = false } = {}) {
|
|
|
27
28
|
&& !/\.(?:pem|key|p12|pfx|glb|gltf)$/i.test(v) && !['runtime.zip', 'runtime-manifest.json'].includes(v.toLowerCase());
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
export function validateRuntimeFiles(files, { document = false } = {}) {
|
|
31
|
+
export function validateRuntimeFiles(files, { document = false, staticRoom = false } = {}) {
|
|
31
32
|
if (!Array.isArray(files) || !files.length || files.length > RUNTIME_LIMITS.files) fail('INVALID_RUNTIME_FILES');
|
|
32
33
|
let previous = '', total = 0;
|
|
33
34
|
const folded = new Set(), directories = new Set();
|
|
34
35
|
for (const f of files) {
|
|
35
|
-
if (!exact(f, ['path', 'bytes', 'sha256', 'role']) || !validRuntimePath(f.path, { document }) || f.path <= previous
|
|
36
|
+
if (!exact(f, ['path', 'bytes', 'sha256', 'role']) || !validRuntimePath(f.path, { document, staticRoom }) || f.path <= previous
|
|
36
37
|
|| !digest(f.sha256) || !bounded(f.bytes, 0, RUNTIME_LIMITS.fileBytes) || !roles.includes(f.role)) fail('INVALID_RUNTIME_FILES');
|
|
37
38
|
const parts = f.path.toLowerCase().split('/');
|
|
38
39
|
if (folded.has(parts.join('/')) || directories.has(parts.join('/')) || parts.some((_, i) => folded.has(parts.slice(0, i).join('/')))) fail('INVALID_RUNTIME_FILES');
|
|
@@ -101,12 +102,16 @@ export function validateRuntimeManifest(v) {
|
|
|
101
102
|
if (!exact(v, ['schemaVersion', 'kind', 'apiVersion', 'runtimeId', 'runtimeHash', 'executionTier', 'source', 'targets', 'compatibility', 'entrypoints', 'files', 'archive'])
|
|
102
103
|
|| !['1.0.0', '1.1.0'].includes(v.schemaVersion) || v.kind !== 'public-local-runtime' || v.apiVersion !== '1.0.0'
|
|
103
104
|
|| v.executionTier !== 'public-untrusted' || !/^runtime_[a-f0-9]{64}$/.test(v.runtimeId ?? '') || !digest(v.runtimeHash)) fail('INVALID_RUNTIME_MANIFEST');
|
|
104
|
-
validateRuntimeFiles(v.files, { document: v.schemaVersion === '1.1.0' });
|
|
105
105
|
const document = v.schemaVersion === '1.1.0';
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const
|
|
106
|
+
// Static Room is a distinct source closure, not Document or historical Flight.
|
|
107
|
+
// The exact source shape selects only its fixed implementation namespace.
|
|
108
|
+
const staticRoom = !document && exact(v.source, ['clientsCommitSha', 'publicNode', 'contentRoom']);
|
|
109
|
+
const sourceKeys = document ? ['publicNode', 'contentRoom', 'documentAuthority']
|
|
110
|
+
: staticRoom ? ['publicNode', 'contentRoom'] : ['publicNode', 'publicFlight'];
|
|
109
111
|
if (!exact(v.source, ['clientsCommitSha', ...sourceKeys]) || !commit(v.source.clientsCommitSha)) fail('INVALID_RUNTIME_SOURCE');
|
|
112
|
+
validateRuntimeFiles(v.files, { document, staticRoom });
|
|
113
|
+
const files = new Map(v.files.map(f => [f.path, f]));
|
|
114
|
+
const reference = (p, role) => validRuntimePath(p, { document, staticRoom }) && files.get(p)?.role === role;
|
|
110
115
|
for (const key of sourceKeys) {
|
|
111
116
|
const source = v.source[key];
|
|
112
117
|
if (!exact(source, ['commitSha', 'sourceHash', 'lockPath']) || !commit(source.commitSha) || !digest(source.sourceHash)
|
|
@@ -184,7 +189,13 @@ export function assertRuntimeTargetCompatibility(manifest, { target = { os: proc
|
|
|
184
189
|
export function assertRuntimeCompatibility(manifest, { target, expected } = {}) {
|
|
185
190
|
assertRuntimeTargetCompatibility(manifest, { target });
|
|
186
191
|
const row = { builderVersion: expected?.builderVersion, tool: expected?.tool, contracts: expected?.contracts };
|
|
187
|
-
|
|
192
|
+
const staticRoom = manifest.schemaVersion === '1.0.0' && exact(manifest.source, ['clientsCommitSha', 'publicNode', 'contentRoom']);
|
|
193
|
+
// Tool versions retain snapshot/report provenance. Only this validated static
|
|
194
|
+
// Room family matches the actual Builder/contracts/SDK interface instead.
|
|
195
|
+
if (!validContentRow(row, manifest.schemaVersion === '1.1.0') || !manifest.compatibility.content.some(r => staticRoom
|
|
196
|
+
? r.builderVersion === row.builderVersion && canonicalJson(r.contracts) === canonicalJson(row.contracts)
|
|
197
|
+
&& r.tool.packageName === row.tool.packageName && r.tool.kitSnapshotHash === row.tool.kitSnapshotHash
|
|
198
|
+
: canonicalJson(r) === canonicalJson(row))) fail('RUNTIME_CONTENT_INCOMPATIBLE');
|
|
188
199
|
return true;
|
|
189
200
|
}
|
|
190
201
|
|
|
@@ -82,6 +82,26 @@
|
|
|
82
82
|
"$ref": "#/$defs/source"
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"type": "object",
|
|
88
|
+
"additionalProperties": false,
|
|
89
|
+
"required": [
|
|
90
|
+
"clientsCommitSha",
|
|
91
|
+
"publicNode",
|
|
92
|
+
"contentRoom"
|
|
93
|
+
],
|
|
94
|
+
"properties": {
|
|
95
|
+
"clientsCommitSha": {
|
|
96
|
+
"$ref": "#/$defs/commit"
|
|
97
|
+
},
|
|
98
|
+
"publicNode": {
|
|
99
|
+
"$ref": "#/$defs/source"
|
|
100
|
+
},
|
|
101
|
+
"contentRoom": {
|
|
102
|
+
"$ref": "#/$defs/source"
|
|
103
|
+
}
|
|
104
|
+
}
|
|
85
105
|
}
|
|
86
106
|
]
|
|
87
107
|
},
|
|
@@ -649,24 +669,48 @@
|
|
|
649
669
|
"then": {
|
|
650
670
|
"properties": {
|
|
651
671
|
"source": {
|
|
652
|
-
"
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
"
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
672
|
+
"oneOf": [
|
|
673
|
+
{
|
|
674
|
+
"type": "object",
|
|
675
|
+
"additionalProperties": false,
|
|
676
|
+
"required": [
|
|
677
|
+
"clientsCommitSha",
|
|
678
|
+
"publicNode",
|
|
679
|
+
"publicFlight"
|
|
680
|
+
],
|
|
681
|
+
"properties": {
|
|
682
|
+
"clientsCommitSha": {
|
|
683
|
+
"$ref": "#/$defs/commit"
|
|
684
|
+
},
|
|
685
|
+
"publicNode": {
|
|
686
|
+
"$ref": "#/$defs/source"
|
|
687
|
+
},
|
|
688
|
+
"publicFlight": {
|
|
689
|
+
"$ref": "#/$defs/source"
|
|
690
|
+
}
|
|
691
|
+
}
|
|
665
692
|
},
|
|
666
|
-
|
|
667
|
-
"
|
|
693
|
+
{
|
|
694
|
+
"type": "object",
|
|
695
|
+
"additionalProperties": false,
|
|
696
|
+
"required": [
|
|
697
|
+
"clientsCommitSha",
|
|
698
|
+
"publicNode",
|
|
699
|
+
"contentRoom"
|
|
700
|
+
],
|
|
701
|
+
"properties": {
|
|
702
|
+
"clientsCommitSha": {
|
|
703
|
+
"$ref": "#/$defs/commit"
|
|
704
|
+
},
|
|
705
|
+
"publicNode": {
|
|
706
|
+
"$ref": "#/$defs/source"
|
|
707
|
+
},
|
|
708
|
+
"contentRoom": {
|
|
709
|
+
"$ref": "#/$defs/source"
|
|
710
|
+
}
|
|
711
|
+
}
|
|
668
712
|
}
|
|
669
|
-
|
|
713
|
+
]
|
|
670
714
|
},
|
|
671
715
|
"compatibility": {
|
|
672
716
|
"type": "object",
|
|
@@ -57,14 +57,14 @@
|
|
|
57
57
|
"pattern": "^[A-Z][A-Z0-9_]{2,79}$"
|
|
58
58
|
},
|
|
59
59
|
"target": {
|
|
60
|
-
"$ref": "./distribution-
|
|
60
|
+
"$ref": "./distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json#/$defs/observedTarget"
|
|
61
61
|
},
|
|
62
62
|
"tool": {
|
|
63
63
|
"type": "object",
|
|
64
64
|
"additionalProperties": false,
|
|
65
65
|
"properties": {
|
|
66
66
|
"packageName": {
|
|
67
|
-
"$ref": "./distribution-
|
|
67
|
+
"$ref": "./distribution-static-room-semantic-contract/contracts/ugc/creator-source/v1/tool-package.schema.json"
|
|
68
68
|
},
|
|
69
69
|
"packageVersion": {
|
|
70
70
|
"$ref": "#/$defs/version"
|
|
@@ -344,6 +344,9 @@
|
|
|
344
344
|
},
|
|
345
345
|
{
|
|
346
346
|
"$ref": "#/$defs/inspectResultDocument"
|
|
347
|
+
},
|
|
348
|
+
{
|
|
349
|
+
"$ref": "#/$defs/inspectResultStaticRoom"
|
|
347
350
|
}
|
|
348
351
|
]
|
|
349
352
|
},
|
|
@@ -1119,6 +1122,19 @@
|
|
|
1119
1122
|
}
|
|
1120
1123
|
}
|
|
1121
1124
|
},
|
|
1125
|
+
"inspectResultStaticRoom": {
|
|
1126
|
+
"type": "object",
|
|
1127
|
+
"additionalProperties": false,
|
|
1128
|
+
"required": ["runtime", "publicNodeSourceHash", "contentRoomSourceHash", "clientsCommitSha", "target", "filesVerified"],
|
|
1129
|
+
"properties": {
|
|
1130
|
+
"runtime": { "$ref": "#/$defs/runtime" },
|
|
1131
|
+
"publicNodeSourceHash": { "$ref": "#/$defs/hash" },
|
|
1132
|
+
"contentRoomSourceHash": { "$ref": "#/$defs/hash" },
|
|
1133
|
+
"clientsCommitSha": { "$ref": "#/$defs/commit" },
|
|
1134
|
+
"target": { "$ref": "#/$defs/target" },
|
|
1135
|
+
"filesVerified": { "type": "integer", "minimum": 1, "maximum": 4096 }
|
|
1136
|
+
}
|
|
1137
|
+
},
|
|
1122
1138
|
"inspectResultDocument": {
|
|
1123
1139
|
"type": "object",
|
|
1124
1140
|
"additionalProperties": false,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import schema from './host-ipc.schema.json' with { type: 'json' }
|
|
2
|
-
import toolPackageSchema from './distribution-
|
|
3
|
-
import runtimeSchema from './distribution-
|
|
4
|
-
import { validateRuntimeTarget } from './distribution-
|
|
2
|
+
import toolPackageSchema from './distribution-static-room-semantic-contract/contracts/ugc/creator-source/v1/tool-package.schema.json' with { type: 'json' }
|
|
3
|
+
import runtimeSchema from './distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json' with { type: 'json' }
|
|
4
|
+
import { validateRuntimeTarget } from './distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/manifest.mjs'
|
|
5
5
|
|
|
6
6
|
export const hostIpcSchema = schema
|
|
7
7
|
export const canonicalRuntimeJson = value => {
|
|
@@ -14,8 +14,8 @@ const plain = value => value && typeof value === 'object' && !Array.isArray(valu
|
|
|
14
14
|
&& [Object.prototype, null].includes(Object.getPrototypeOf(value))
|
|
15
15
|
function check(value, rule, field) {
|
|
16
16
|
const invalid = () => fail('RUNTIME_CONTRACT_INVALID', field)
|
|
17
|
-
if (rule.$ref) return check(value, rule.$ref === './distribution-
|
|
18
|
-
? toolPackageSchema : rule.$ref === './distribution-
|
|
17
|
+
if (rule.$ref) return check(value, rule.$ref === './distribution-static-room-semantic-contract/contracts/ugc/creator-source/v1/tool-package.schema.json'
|
|
18
|
+
? toolPackageSchema : rule.$ref === './distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json#/$defs/observedTarget'
|
|
19
19
|
? runtimeSchema.$defs.observedTarget : schema.$defs[rule.$ref.slice(8)], field)
|
|
20
20
|
if (rule.oneOf) {
|
|
21
21
|
let matches = 0
|
|
@@ -2,32 +2,32 @@
|
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
3
|
"source": {
|
|
4
4
|
"repository": "Alterverse-tech/chrona-clients",
|
|
5
|
-
"commitSha": "
|
|
5
|
+
"commitSha": "d1bee3ed94a0a7be02323354b07c41c1bb4e0314",
|
|
6
6
|
"path": "tools/local-preview"
|
|
7
7
|
},
|
|
8
8
|
"artifacts": [
|
|
9
9
|
{
|
|
10
10
|
"path": "runtime-contract.mjs",
|
|
11
|
-
"sha256": "
|
|
11
|
+
"sha256": "208e67986175a88e5554cbf0f3abb70db696d790bf6ec0dca1ddc4c21c5cb42a"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"path": "host-ipc.schema.json",
|
|
15
|
-
"sha256": "
|
|
15
|
+
"sha256": "2f2d1260601b3b62f3fbf1e333c7c006c0abd5c4d3ba6783814400232ac90970"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
|
-
"path": "distribution-
|
|
18
|
+
"path": "distribution-static-room-semantic-contract/contracts/ugc/creator-source/v1/tool-package.schema.json",
|
|
19
19
|
"sha256": "b6af316222076800db26526cc2e75318513697405ae38b07ef40c57d36691a05"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
|
-
"path": "distribution-
|
|
23
|
-
"sha256": "
|
|
22
|
+
"path": "distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/manifest.mjs",
|
|
23
|
+
"sha256": "825be4852b3d635154a60a5e461d99c0ee60195ea5a2ef6527f8606b99bea030"
|
|
24
24
|
},
|
|
25
25
|
{
|
|
26
|
-
"path": "distribution-
|
|
27
|
-
"sha256": "
|
|
26
|
+
"path": "distribution-static-room-semantic-contract/contracts/ugc/public-runtime/v1/runtime-manifest.schema.json",
|
|
27
|
+
"sha256": "4edbaadcf489b68d4830aa68b2b12249ba8e06ff8f250f858767f66b41216c74"
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
"path": "distribution-
|
|
30
|
+
"path": "distribution-static-room-semantic-contract/contracts/ugc/registry/v1/conformance/js/capability-resolver.mjs",
|
|
31
31
|
"sha256": "66e3be28c8b9da7fb4e814e6a9263fe276cb2456a8ac9d295c2e9d9d785ddafd"
|
|
32
32
|
}
|
|
33
33
|
]
|
|
@@ -72,12 +72,18 @@ export function createRuntimeHostClient({ channel, installed, content, onStatus,
|
|
|
72
72
|
}
|
|
73
73
|
const result = value.result;
|
|
74
74
|
if (value.operation === 'inspect') {
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
let sourcesMatch;
|
|
76
|
+
if (installed.manifestSchemaVersion === '1.1.0') {
|
|
77
|
+
sourcesMatch = result.contentRoomSourceHash === installed.contentRoomSourceHash
|
|
77
78
|
&& result.documentAuthoritySourceHash === installed.documentAuthoritySourceHash
|
|
78
|
-
&& !Object.hasOwn(result, 'publicFlightSourceHash')
|
|
79
|
-
|
|
79
|
+
&& !Object.hasOwn(result, 'publicFlightSourceHash');
|
|
80
|
+
} else if (installed.manifestSchemaVersion === '1.0.0' && installed.contentRoomSourceHash !== undefined) {
|
|
81
|
+
sourcesMatch = result.contentRoomSourceHash === installed.contentRoomSourceHash
|
|
82
|
+
&& !Object.hasOwn(result, 'publicFlightSourceHash') && !Object.hasOwn(result, 'documentAuthoritySourceHash');
|
|
83
|
+
} else {
|
|
84
|
+
sourcesMatch = result.publicFlightSourceHash === installed.publicFlightSourceHash
|
|
80
85
|
&& !Object.hasOwn(result, 'contentRoomSourceHash') && !Object.hasOwn(result, 'documentAuthoritySourceHash');
|
|
86
|
+
}
|
|
81
87
|
if (!equal(result.runtime, runtime) || result.publicNodeSourceHash !== installed.publicNodeSourceHash
|
|
82
88
|
|| !sourcesMatch || result.clientsCommitSha !== installed.clientsCommitSha
|
|
83
89
|
|| !equal(result.target, installed.target) || result.filesVerified !== installed.filesVerified) throw error('RUNTIME_IPC_IDENTITY_MISMATCH');
|
package/lib/runtime-host.mjs
CHANGED
|
@@ -21,7 +21,9 @@ export async function verifyHostIpcSnapshot() {
|
|
|
21
21
|
'contracts/ugc/public-runtime/v1/runtime-manifest.schema.json',
|
|
22
22
|
'contracts/ugc/registry/v1/conformance/js/capability-resolver.mjs'
|
|
23
23
|
].map(name => `distribution-node-support-contract/${name}`)];
|
|
24
|
-
const
|
|
24
|
+
const staticRoom = support.map(name => name.replace(/^distribution-node-support-contract\//, 'distribution-static-room-contract/'));
|
|
25
|
+
const semanticRoom = support.map(name => name.replace(/^distribution-node-support-contract\//, 'distribution-static-room-semantic-contract/'));
|
|
26
|
+
const names = [legacy, current, support, staticRoom, semanticRoom].find(names => Array.isArray(lock.artifacts)
|
|
25
27
|
&& JSON.stringify(lock.artifacts.map(row => row.path)) === JSON.stringify(names));
|
|
26
28
|
if (lock.schemaVersion !== '1.0.0' || lock.source?.repository !== 'Alterverse-tech/chrona-clients' || lock.source.path !== 'tools/local-preview'
|
|
27
29
|
|| !/^[a-f0-9]{40}$/.test(lock.source.commitSha ?? '') || !names) throw error('HOST_IPC_SNAPSHOT_MISMATCH');
|
package/lib/runtime-install.mjs
CHANGED
|
@@ -45,6 +45,7 @@ export async function verifyPublicRuntimeSnapshot() {
|
|
|
45
45
|
const names = ['README.md', 'archive.mjs', 'format-fixture.mjs', 'golden.json', 'manifest.mjs', 'runtime-lock.schema.json', 'runtime-manifest.schema.json', 'runtime.test.mjs', 'vectors.json'];
|
|
46
46
|
if (lock.artifacts?.some(f => f.path === `${base}/document-runtime.test.mjs`)) names.push('document-runtime.test.mjs');
|
|
47
47
|
if (lock.artifacts?.some(f => f.path === `${base}/target-compatibility.test.mjs`)) names.push('target-compatibility.test.mjs');
|
|
48
|
+
if (lock.artifacts?.some(f => f.path === `${base}/static-room-runtime.test.mjs`)) names.push('static-room-runtime.test.mjs');
|
|
48
49
|
names.sort();
|
|
49
50
|
const dependency = 'contracts/ugc/creator-source/v1/tool-package.schema.json';
|
|
50
51
|
const manifestBytes = await readBounded(path.join(kit, base, 'manifest.mjs'), 1048576, { privateFile: false });
|
|
@@ -129,9 +130,16 @@ export async function inspectInstalledRuntime({ installationDirectory, lock, tru
|
|
|
129
130
|
const manifest = verifyRuntimeManifest(bytes, lock.manifest.sha256);
|
|
130
131
|
const identity = verifyRuntimePair(manifest, lock, expected, { allowLocalHttp });
|
|
131
132
|
await verifyTree(installationDirectory, manifest, bytes, signal);
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
let sources;
|
|
134
|
+
if (manifest.schemaVersion === '1.1.0') {
|
|
135
|
+
sources = await inspectDocumentPrograms(installationDirectory, manifest, signal);
|
|
136
|
+
} else if (manifest.source.contentRoom !== undefined) {
|
|
137
|
+
// The authority Reader and full installed tree have already been checked.
|
|
138
|
+
sources = { manifestSchemaVersion: manifest.schemaVersion,
|
|
139
|
+
contentRoomSourceHash: manifest.source.contentRoom.sourceHash };
|
|
140
|
+
} else {
|
|
141
|
+
sources = { publicFlightSourceHash: manifest.source.publicFlight.sourceHash };
|
|
142
|
+
}
|
|
135
143
|
return { ...identity, installationDirectory, installed: true, executable: false, filesVerified: manifest.files.length,
|
|
136
144
|
publicNodeSourceHash: manifest.source.publicNode.sourceHash, ...sources,
|
|
137
145
|
clientsCommitSha: manifest.source.clientsCommitSha,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": "1.0.0",
|
|
3
3
|
"source": {
|
|
4
4
|
"repository": "ChronaWorld/chrona-services",
|
|
5
|
-
"commitSha": "
|
|
5
|
+
"commitSha": "34906beca4047c710991c3d4da5cd58718e72fc2",
|
|
6
6
|
"path": "contracts/ugc/public-runtime/v1"
|
|
7
7
|
},
|
|
8
8
|
"artifacts": [
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
"path": "contracts/ugc/public-runtime/v1/README.md",
|
|
15
|
-
"sha256": "
|
|
15
|
+
"sha256": "e9e869811991c350cfc4eeeb2dcd636a89f6b4da9139b3db6e19e692ffe26702"
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
"path": "contracts/ugc/public-runtime/v1/archive.mjs",
|
|
19
|
-
"sha256": "
|
|
19
|
+
"sha256": "92e851d3b871781922461ec5b2cf2f03024b47cc5cdb78750d91cf8abc097405"
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
"path": "contracts/ugc/public-runtime/v1/document-runtime.test.mjs",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"path": "contracts/ugc/public-runtime/v1/manifest.mjs",
|
|
35
|
-
"sha256": "
|
|
35
|
+
"sha256": "825be4852b3d635154a60a5e461d99c0ee60195ea5a2ef6527f8606b99bea030"
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"path": "contracts/ugc/public-runtime/v1/runtime-lock.schema.json",
|
|
@@ -40,12 +40,16 @@
|
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"path": "contracts/ugc/public-runtime/v1/runtime-manifest.schema.json",
|
|
43
|
-
"sha256": "
|
|
43
|
+
"sha256": "4edbaadcf489b68d4830aa68b2b12249ba8e06ff8f250f858767f66b41216c74"
|
|
44
44
|
},
|
|
45
45
|
{
|
|
46
46
|
"path": "contracts/ugc/public-runtime/v1/runtime.test.mjs",
|
|
47
47
|
"sha256": "e7b23ac3dde5588a0e175ec220a79426ea7dafd4953150f253dba50a75c8cb76"
|
|
48
48
|
},
|
|
49
|
+
{
|
|
50
|
+
"path": "contracts/ugc/public-runtime/v1/static-room-runtime.test.mjs",
|
|
51
|
+
"sha256": "4c615ed0cc90fd0e21ea7882c9fecc921cd2ceca4beb6055d233cbad16d14367"
|
|
52
|
+
},
|
|
49
53
|
{
|
|
50
54
|
"path": "contracts/ugc/public-runtime/v1/target-compatibility.test.mjs",
|
|
51
55
|
"sha256": "c85565b0c431d29d28561e4d3cc5a5de412cc0039a4aeb27a01374890216044d"
|