@auraindustry/aurajs 0.0.6 → 0.1.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.
- package/README.md +103 -7
- package/benchmarks/perf-thresholds.json +54 -0
- package/package.json +4 -7
- package/src/asset-pack.mjs +5 -1
- package/src/authored-project.mjs +1449 -0
- package/src/authored-runtime.mjs +2016 -0
- package/src/authoring/avatar-animation-graph.mjs +648 -0
- package/src/bin-integrity.mjs +272 -0
- package/src/build-contract/assets.mjs +130 -0
- package/src/build-contract/capabilities.mjs +116 -0
- package/src/build-contract/constants.mjs +6 -0
- package/src/build-contract/helpers.mjs +44 -0
- package/src/build-contract/web-templates.mjs +5993 -0
- package/src/build-contract.mjs +27 -2910
- package/src/bundler.mjs +188 -55
- package/src/cli.mjs +4825 -1512
- package/src/commands/project-authoring.mjs +434 -0
- package/src/config.mjs +27 -0
- package/src/conformance/cases/app-and-ui-runtime-cases.mjs +3309 -0
- package/src/conformance/cases/core-runtime-cases.mjs +1431 -0
- package/src/conformance/cases/index.mjs +11 -0
- package/src/conformance/cases/scene3d-and-media-cases.mjs +2094 -0
- package/src/conformance/cases/systems-and-gameplay-cases.mjs +1776 -0
- package/src/conformance/shared.mjs +27 -0
- package/src/conformance-runner.mjs +25 -13
- package/src/conformance.mjs +619 -4020
- package/src/cutscene.mjs +362 -5
- package/src/dev-cli-action.mjs +249 -0
- package/src/dev-cli-inspect.mjs +92 -0
- package/src/dev-cli-state.mjs +80 -0
- package/src/external-asset-cache.mjs +587 -0
- package/src/external-asset-policy.mjs +217 -0
- package/src/external-package-surface.mjs +206 -0
- package/src/game-action-runtime.mjs +869 -0
- package/src/game-state-runtime.mjs +206 -6
- package/src/headless-action.mjs +186 -0
- package/src/headless-test/runtime-animation.mjs +1173 -0
- package/src/headless-test/runtime-coordinator.mjs +1514 -0
- package/src/headless-test/runtime-primitives.mjs +320 -0
- package/src/headless-test/runtime-world.mjs +2253 -0
- package/src/headless-test.mjs +392 -4298
- package/src/host-binary.mjs +342 -14
- package/src/icon-discovery.mjs +64 -0
- package/src/make-catalog.mjs +109 -0
- package/src/make.mjs +197 -0
- package/src/package-integrity.mjs +586 -0
- package/src/perf-benchmark.mjs +353 -0
- package/src/postinstall.mjs +5 -5
- package/src/prefabs/index.mjs +34 -0
- package/src/prefabs/scene-serialization.mjs +184 -0
- package/src/project-importer.mjs +620 -0
- package/src/project-registry.mjs +24 -0
- package/src/publish-command.mjs +195 -0
- package/src/publish-env-example.mjs +83 -0
- package/src/publish-validation.mjs +708 -0
- package/src/retro/assets/compile.mjs +232 -0
- package/src/retro/backend-gba/authoring.mjs +1029 -0
- package/src/retro/backend-gba/rom.mjs +363 -0
- package/src/retro/backend-gbc/rom.mjs +85 -0
- package/src/retro/build.mjs +278 -0
- package/src/retro/cli/commands.mjs +292 -0
- package/src/retro/cli/templates.mjs +84 -0
- package/src/retro/diagnostics/catalog.mjs +110 -0
- package/src/retro/diagnostics/emit.mjs +72 -0
- package/src/retro/emulator/case-overlay.mjs +64 -0
- package/src/retro/emulator/discovery.mjs +158 -0
- package/src/retro/emulator/macos-case-overlay.swift +220 -0
- package/src/retro/emulator/profiles.mjs +146 -0
- package/src/retro/emulator/runner.mjs +289 -0
- package/src/retro/frontend/load-project.mjs +98 -0
- package/src/retro/index.mjs +30 -0
- package/src/retro/ir/build-ir.mjs +108 -0
- package/src/retro/runtime-gba/contract.mjs +151 -0
- package/src/retro/runtime-gbc/contract.mjs +117 -0
- package/src/retro/shared/span.mjs +26 -0
- package/src/retro/shared/targets.mjs +64 -0
- package/src/retro/validator/check-project.mjs +114 -0
- package/src/runtime-hotspot-audit.mjs +707 -0
- package/src/scaffold/config.mjs +1000 -0
- package/src/scaffold/fs.mjs +56 -0
- package/src/scaffold/layout.mjs +318 -0
- package/src/scaffold/project-docs.mjs +438 -0
- package/src/scaffold.mjs +93 -596
- package/src/scene-composition/index.mjs +326 -0
- package/src/scene-composition/runtime.mjs +751 -0
- package/src/self-hosted-assets.mjs +604 -0
- package/src/session-client.mjs +750 -0
- package/src/session-native-launcher.mjs +74 -0
- package/src/session-protocol.mjs +75 -0
- package/src/session-runtime.mjs +321 -0
- package/src/session-server.mjs +360 -0
- package/src/shader-kits/index.mjs +773 -0
- package/src/starter-content-registry.mjs +292 -0
- package/src/state-artifacts.mjs +662 -24
- package/src/state-dev-reload.mjs +99 -2
- package/src/terminal-ui.mjs +245 -0
- package/src/web-conformance.mjs +219 -0
- package/templates/create/2d/config/gameplay/shooter.config.js +26 -0
- package/templates/create/2d/content/gameplay/waves.json +26 -0
- package/templates/create/2d/content/registries/.gitkeep +1 -0
- package/templates/create/2d/docs/design/.gitkeep +1 -0
- package/templates/create/2d/docs/design/loop.md +5 -0
- package/templates/create/2d/prefabs/enemies.prefab.js +90 -0
- package/templates/create/2d/prefabs/enemy-basic.prefab.js +18 -0
- package/templates/create/2d/prefabs/player.prefab.js +36 -0
- package/templates/create/2d/prefabs/projectiles.prefab.js +35 -0
- package/templates/create/2d/scenes/boot.scene.js +12 -0
- package/templates/create/2d/scenes/gameplay.scene.js +230 -0
- package/templates/create/2d/scenes/menu.scene.js +9 -0
- package/templates/create/2d/src/main.js +6 -185
- package/templates/create/2d/src/runtime/app.js +49 -0
- package/templates/create/2d/src/runtime/capabilities.js +35 -0
- package/templates/create/2d/ui/hud.screen.js +40 -0
- package/templates/create/2d/ui/pause.screen.js +149 -0
- package/templates/create/2d/ui/settings.screen.js +347 -0
- package/templates/create/2d/ui/title.screen.js +13 -0
- package/templates/create/2d-adventure/aura.config.json +28 -0
- package/templates/create/2d-adventure/config/gameplay/adventure.config.js +14 -0
- package/templates/create/2d-adventure/content/gameplay/world.js +46 -0
- package/templates/create/2d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/2d-adventure/docs/design/loop.md +5 -0
- package/templates/create/2d-adventure/prefabs/player.prefab.js +54 -0
- package/templates/create/2d-adventure/prefabs/relic.prefab.js +38 -0
- package/templates/create/2d-adventure/prefabs/world.prefab.js +125 -0
- package/templates/create/2d-adventure/scenes/gameplay.scene.js +256 -0
- package/templates/create/2d-adventure/src/runtime/capabilities.js +34 -0
- package/templates/create/2d-adventure/ui/hud.screen.js +60 -0
- package/templates/create/2d-survivor/config/gameplay/survivor.config.js +33 -0
- package/templates/create/2d-survivor/content/gameplay/spawn-zones.json +29 -0
- package/templates/create/2d-survivor/content/registries/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/.gitkeep +1 -0
- package/templates/create/2d-survivor/docs/design/loop.md +5 -0
- package/templates/create/2d-survivor/prefabs/enemies.prefab.js +178 -0
- package/templates/create/2d-survivor/prefabs/enemy-swarm.prefab.js +18 -0
- package/templates/create/2d-survivor/prefabs/player.prefab.js +42 -0
- package/templates/create/2d-survivor/prefabs/projectiles.prefab.js +56 -0
- package/templates/create/2d-survivor/scenes/boot.scene.js +12 -0
- package/templates/create/2d-survivor/scenes/gameplay.scene.js +314 -0
- package/templates/create/2d-survivor/scenes/menu.scene.js +9 -0
- package/templates/create/2d-survivor/src/main.js +5 -332
- package/templates/create/2d-survivor/src/runtime/app.js +49 -0
- package/templates/create/2d-survivor/src/runtime/capabilities.js +35 -0
- package/templates/create/2d-survivor/ui/hud.screen.js +45 -0
- package/templates/create/2d-survivor/ui/title.screen.js +13 -0
- package/templates/create/3d/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d/content/gameplay/checkpoints.json +33 -0
- package/templates/create/3d/content/gameplay/course.js +40 -0
- package/templates/create/3d/content/registries/.gitkeep +1 -0
- package/templates/create/3d/docs/design/.gitkeep +1 -0
- package/templates/create/3d/docs/design/loop.md +5 -0
- package/templates/create/3d/prefabs/checkpoint.prefab.js +15 -0
- package/templates/create/3d/prefabs/player.prefab.js +204 -0
- package/templates/create/3d/prefabs/world.prefab.js +112 -0
- package/templates/create/3d/scenes/boot.scene.js +12 -0
- package/templates/create/3d/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d/scenes/gameplay.scene.js +292 -0
- package/templates/create/3d/src/main.js +6 -295
- package/templates/create/3d/src/runtime/app.js +49 -0
- package/templates/create/3d/src/runtime/capabilities.js +53 -0
- package/templates/create/3d/src/runtime/materials.js +34 -0
- package/templates/create/3d/src/runtime/state.js +39 -0
- package/templates/create/3d/ui/hud.screen.js +75 -0
- package/templates/create/3d/ui/pause.screen.js +166 -0
- package/templates/create/3d/ui/settings.screen.js +387 -0
- package/templates/create/3d-adventure/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-adventure/aura.config.json +28 -0
- package/templates/create/3d-adventure/config/gameplay/adventure.config.js +9 -0
- package/templates/create/3d-adventure/content/gameplay/course.js +62 -0
- package/templates/create/3d-adventure/content/registries/.gitkeep +1 -0
- package/templates/create/3d-adventure/docs/design/loop.md +5 -0
- package/templates/create/3d-adventure/prefabs/player.prefab.js +168 -0
- package/templates/create/3d-adventure/prefabs/relic.prefab.js +35 -0
- package/templates/create/3d-adventure/prefabs/world.prefab.js +119 -0
- package/templates/create/3d-adventure/scenes/gameplay.scene.js +358 -0
- package/templates/create/3d-adventure/src/runtime/capabilities.js +56 -0
- package/templates/create/3d-adventure/src/runtime/materials.js +39 -0
- package/templates/create/3d-adventure/src/runtime/state.js +31 -0
- package/templates/create/3d-adventure/ui/hud.screen.js +70 -0
- package/templates/create/3d-adventure/ui/pause.screen.js +437 -0
- package/templates/create/3d-collectathon/assets/models/starter-avatar.gltf +184 -0
- package/templates/create/3d-collectathon/config/gameplay/.gitkeep +1 -0
- package/templates/create/3d-collectathon/content/gameplay/collectibles.json +26 -0
- package/templates/create/3d-collectathon/content/gameplay/course.js +46 -0
- package/templates/create/3d-collectathon/content/registries/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/.gitkeep +1 -0
- package/templates/create/3d-collectathon/docs/design/loop.md +5 -0
- package/templates/create/3d-collectathon/prefabs/collectible.prefab.js +15 -0
- package/templates/create/3d-collectathon/prefabs/player.prefab.js +207 -0
- package/templates/create/3d-collectathon/prefabs/world.prefab.js +112 -0
- package/templates/create/3d-collectathon/scenes/boot.scene.js +12 -0
- package/templates/create/3d-collectathon/scenes/checkpoint.scene.js +9 -0
- package/templates/create/3d-collectathon/scenes/gameplay.scene.js +200 -0
- package/templates/create/3d-collectathon/src/main.js +5 -355
- package/templates/create/3d-collectathon/src/runtime/app.js +49 -0
- package/templates/create/3d-collectathon/src/runtime/capabilities.js +53 -0
- package/templates/create/3d-collectathon/src/runtime/materials.js +34 -0
- package/templates/create/3d-collectathon/src/runtime/state.js +27 -0
- package/templates/create/3d-collectathon/ui/hud.screen.js +66 -0
- package/templates/create/3d-collectathon/ui/pause.screen.js +13 -0
- package/templates/create/blank/config/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/gameplay/.gitkeep +1 -0
- package/templates/create/blank/content/registries/.gitkeep +1 -0
- package/templates/create/blank/docs/design/.gitkeep +1 -0
- package/templates/create/blank/docs/design/loop.md +5 -0
- package/templates/create/blank/prefabs/.gitkeep +1 -0
- package/templates/create/blank/scenes/.gitkeep +1 -0
- package/templates/create/blank/src/runtime/.gitkeep +1 -0
- package/templates/create/blank/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/audio/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/fonts/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/sprites/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/assets/starter/README.md +11 -0
- package/templates/create/deckbuilder-2d/assets/ui/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/aura.config.json +28 -0
- package/templates/create/deckbuilder-2d/config/gameplay/deckbuilder.config.js +26 -0
- package/templates/create/deckbuilder-2d/content/cards/guard.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/spark.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/cards/starter.deck.js +69 -0
- package/templates/create/deckbuilder-2d/content/cards/strike.card.js +19 -0
- package/templates/create/deckbuilder-2d/content/cards/survey.card.js +20 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.encounter.js +14 -0
- package/templates/create/deckbuilder-2d/content/encounters/training-battle.js +65 -0
- package/templates/create/deckbuilder-2d/content/enemies/training-automaton.enemy.js +48 -0
- package/templates/create/deckbuilder-2d/content/gameplay/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/content/registries/cards.registry.js +26 -0
- package/templates/create/deckbuilder-2d/content/registries/encounters.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/enemies.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/registries/relics.registry.js +20 -0
- package/templates/create/deckbuilder-2d/content/relics/ember-charm.relic.js +18 -0
- package/templates/create/deckbuilder-2d/docs/design/loop.md +12 -0
- package/templates/create/deckbuilder-2d/prefabs/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/scenes/boot.scene.js +84 -0
- package/templates/create/deckbuilder-2d/scenes/gameplay.scene.js +641 -0
- package/templates/create/deckbuilder-2d/src/components/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/main.js +17 -0
- package/templates/create/deckbuilder-2d/src/runtime/capabilities.js +22 -0
- package/templates/create/deckbuilder-2d/src/shared/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/src/systems/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/tests/smoke/.gitkeep +1 -0
- package/templates/create/deckbuilder-2d/ui/hud.screen.js +80 -0
- package/templates/create/deckbuilder-2d/ui/pause.screen.js +146 -0
- package/templates/create/deckbuilder-2d/ui/settings.screen.js +342 -0
- package/templates/create/local-multiplayer/aura.config.json +40 -0
- package/templates/create/local-multiplayer/config/gameplay/local-multiplayer.config.js +26 -0
- package/templates/create/local-multiplayer/content/gameplay/room-layout.js +13 -0
- package/templates/create/local-multiplayer/content/registries/.gitkeep +1 -0
- package/templates/create/local-multiplayer/docs/design/loop.md +14 -0
- package/templates/create/local-multiplayer/prefabs/player.prefab.js +99 -0
- package/templates/create/local-multiplayer/scenes/boot.scene.js +12 -0
- package/templates/create/local-multiplayer/scenes/gameplay.scene.js +443 -0
- package/templates/create/local-multiplayer/src/main.js +17 -0
- package/templates/create/local-multiplayer/src/runtime/capabilities.js +28 -0
- package/templates/create/local-multiplayer/ui/hud.screen.js +60 -0
- package/templates/create/shared/src/runtime/project-inspector.js +105 -0
- package/templates/create/shared/src/runtime/scene-flow.js +290 -0
- package/templates/create/shared/src/runtime/screen-shell.js +222 -0
- package/templates/create/shared/src/runtime/ui-forms.js +209 -0
- package/templates/create/shared/src/runtime/ui-settings.js +237 -0
- package/templates/create/shared/src/runtime/ui-theme.js +352 -0
- package/templates/create/shared/src/starter-utils/adventure-objectives.js +102 -0
- package/templates/create/shared/src/starter-utils/animation-2d.js +337 -0
- package/templates/create/shared/src/starter-utils/avatar-3d.js +404 -0
- package/templates/create/shared/src/starter-utils/combat-feedback-2d.js +320 -0
- package/templates/create/shared/src/starter-utils/core.js +39 -3
- package/templates/create/shared/src/starter-utils/index.js +8 -2
- package/templates/create/shared/src/starter-utils/platformer-3d.js +34 -3
- package/templates/create/shared/src/starter-utils/triggers.js +662 -0
- package/templates/create/shared/src/starter-utils/tween-2d.js +615 -0
- package/templates/create/video-cutscene/assets/video/.gitkeep +0 -0
- package/templates/create/video-cutscene/aura.config.json +28 -0
- package/templates/create/video-cutscene/config/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/gameplay/.gitkeep +0 -0
- package/templates/create/video-cutscene/content/registries/.gitkeep +0 -0
- package/templates/create/video-cutscene/docs/design/loop.md +22 -0
- package/templates/create/video-cutscene/prefabs/.gitkeep +0 -0
- package/templates/create/video-cutscene/scenes/boot.scene.js +11 -0
- package/templates/create/video-cutscene/scenes/cutscene.scene.js +113 -0
- package/templates/create/video-cutscene/scenes/gameplay.scene.js +50 -0
- package/templates/create/video-cutscene/src/main.js +17 -0
- package/templates/create/video-cutscene/src/runtime/app.js +52 -0
- package/templates/create/video-cutscene/src/runtime/capabilities.js +35 -0
- package/templates/create/video-cutscene/src/runtime/state.js +13 -0
- package/templates/create/video-cutscene/ui/.gitkeep +0 -0
- package/templates/create-bin/play.js +1187 -0
- package/templates/make/README.md +46 -0
- package/templates/make/catalog.json +51 -0
- package/templates/make/component/files/{{MAKE_NAME}}.component.js +20 -0
- package/templates/make/component/manifest.json +9 -0
- package/templates/make/data/files/{{MAKE_NAME}}.json +14 -0
- package/templates/make/data/manifest.json +9 -0
- package/templates/make/material/files/{{MAKE_NAME}}.material.json +17 -0
- package/templates/make/material/manifest.json +9 -0
- package/templates/make/prefab/files/{{MAKE_NAME}}.prefab.js +20 -0
- package/templates/make/prefab/manifest.json +9 -0
- package/templates/make/scene/files/{{MAKE_NAME}}.scene.js +31 -0
- package/templates/make/scene/manifest.json +9 -0
- package/templates/make/shader/files/{{MAKE_NAME}}.shader.js +23 -0
- package/templates/make/shader/manifest.json +9 -0
- package/templates/make/system/files/{{MAKE_NAME}}.system.js +15 -0
- package/templates/make/system/manifest.json +9 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.js +16 -0
- package/templates/make/ui-screen/files/{{MAKE_NAME}}.screen.json +23 -0
- package/templates/make/ui-screen/manifest.json +10 -0
- package/templates/make-starters/deckbuilder-2d/card/files/{{MAKE_NAME}}.card.js +22 -0
- package/templates/make-starters/deckbuilder-2d/card/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/catalog.json +34 -0
- package/templates/make-starters/deckbuilder-2d/encounter/files/{{MAKE_NAME}}.encounter.js +18 -0
- package/templates/make-starters/deckbuilder-2d/encounter/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/enemy/files/{{MAKE_NAME}}.enemy.js +28 -0
- package/templates/make-starters/deckbuilder-2d/enemy/manifest.json +9 -0
- package/templates/make-starters/deckbuilder-2d/relic/files/{{MAKE_NAME}}.relic.js +23 -0
- package/templates/make-starters/deckbuilder-2d/relic/manifest.json +9 -0
- package/templates/retro/platformer/README.md +10 -0
- package/templates/retro/platformer/assets/retro/assets.json +91 -0
- package/templates/retro/platformer/aura.config.json +7 -0
- package/templates/retro/platformer/package.json +5 -0
- package/templates/retro/platformer/src/main.js +40 -0
- package/templates/retro/puzzle-grid/README.md +10 -0
- package/templates/retro/puzzle-grid/assets/retro/assets.json +90 -0
- package/templates/retro/puzzle-grid/aura.config.json +7 -0
- package/templates/retro/puzzle-grid/package.json +5 -0
- package/templates/retro/puzzle-grid/src/main.js +29 -0
- package/templates/retro/tactics-grid/README.md +10 -0
- package/templates/retro/tactics-grid/assets/retro/assets.json +90 -0
- package/templates/retro/tactics-grid/aura.config.json +7 -0
- package/templates/retro/tactics-grid/package.json +5 -0
- package/templates/retro/tactics-grid/src/main.js +35 -0
- package/templates/retro/topdown-adventure/README.md +10 -0
- package/templates/retro/topdown-adventure/assets/retro/assets.json +95 -0
- package/templates/retro/topdown-adventure/aura.config.json +7 -0
- package/templates/retro/topdown-adventure/package.json +5 -0
- package/templates/retro/topdown-adventure/src/main.js +29 -0
- package/templates/skills/aurajs/SKILL.md +61 -5
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
import { createHash, createPrivateKey, createPublicKey, generateKeyPairSync, sign, verify } from 'node:crypto';
|
|
2
|
+
import { chmodSync, existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { dirname, join, relative, resolve } from 'node:path';
|
|
4
|
+
|
|
5
|
+
export const PACKAGE_INTEGRITY_SCHEMA = 'aurajs.package-integrity.v1';
|
|
6
|
+
export const PACKAGE_INTEGRITY_MANIFEST_PATH = 'aura.package-integrity.json';
|
|
7
|
+
export const PACKAGE_INTEGRITY_SIGNATURE_PATH = 'aura.package-integrity.sig';
|
|
8
|
+
export const PACKAGE_INTEGRITY_PUBLISH_FILES = [
|
|
9
|
+
PACKAGE_INTEGRITY_MANIFEST_PATH,
|
|
10
|
+
PACKAGE_INTEGRITY_SIGNATURE_PATH,
|
|
11
|
+
];
|
|
12
|
+
export const PACKAGE_INTEGRITY_PRIVATE_KEY_PATH = join('.aura', 'publish', 'package-signing-key.pem');
|
|
13
|
+
export const PACKAGE_INTEGRITY_PUBLIC_KEY_PATH = join('.aura', 'publish', 'package-signing-key.pub.pem');
|
|
14
|
+
export const PACKAGE_INTEGRITY_TRUST_STORE_PATH = join('published-game-signers.json');
|
|
15
|
+
|
|
16
|
+
export class PackageIntegrityError extends Error {
|
|
17
|
+
constructor(reasonCode, message, details = {}) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = 'PackageIntegrityError';
|
|
20
|
+
this.reasonCode = typeof reasonCode === 'string' && reasonCode.length > 0
|
|
21
|
+
? reasonCode
|
|
22
|
+
: 'package_integrity_failed';
|
|
23
|
+
this.details = details && typeof details === 'object' ? details : {};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeRelativePath(pathLike) {
|
|
28
|
+
return String(pathLike || '')
|
|
29
|
+
.trim()
|
|
30
|
+
.replace(/^[.][\\/]/, '')
|
|
31
|
+
.replaceAll('\\', '/');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function normalizeString(value) {
|
|
35
|
+
return typeof value === 'string' && value.trim().length > 0
|
|
36
|
+
? value.trim()
|
|
37
|
+
: null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function sha256Buffer(buffer) {
|
|
41
|
+
return createHash('sha256').update(buffer).digest('hex');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function sortKeysDeep(value) {
|
|
45
|
+
if (Array.isArray(value)) {
|
|
46
|
+
return value.map((entry) => sortKeysDeep(entry));
|
|
47
|
+
}
|
|
48
|
+
if (!value || typeof value !== 'object') {
|
|
49
|
+
return value;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const sorted = {};
|
|
53
|
+
for (const key of Object.keys(value).sort()) {
|
|
54
|
+
sorted[key] = sortKeysDeep(value[key]);
|
|
55
|
+
}
|
|
56
|
+
return sorted;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function stableSerialize(value, pretty = false) {
|
|
60
|
+
return JSON.stringify(sortKeysDeep(value), null, pretty ? 2 : 0);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function readJsonFile(path) {
|
|
64
|
+
try {
|
|
65
|
+
return JSON.parse(readFileSync(path, 'utf8'));
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw new PackageIntegrityError(
|
|
68
|
+
'package_integrity_json_invalid',
|
|
69
|
+
`Failed to parse ${path}: ${error.message}`,
|
|
70
|
+
{ path },
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function listHashedPackageFiles(root, current = root, acc = []) {
|
|
76
|
+
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
77
|
+
const fullPath = join(current, entry.name);
|
|
78
|
+
const relativePath = normalizeRelativePath(relative(root, fullPath));
|
|
79
|
+
|
|
80
|
+
if (relativePath === PACKAGE_INTEGRITY_MANIFEST_PATH || relativePath === PACKAGE_INTEGRITY_SIGNATURE_PATH) {
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (entry.isSymbolicLink()) {
|
|
85
|
+
throw new PackageIntegrityError(
|
|
86
|
+
'package_integrity_symlink_not_allowed',
|
|
87
|
+
`Published game package may not contain symlinks: ${relativePath}`,
|
|
88
|
+
{
|
|
89
|
+
path: relativePath,
|
|
90
|
+
},
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (entry.isDirectory()) {
|
|
95
|
+
listHashedPackageFiles(root, fullPath, acc);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (!entry.isFile()) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const buffer = readFileSync(fullPath);
|
|
104
|
+
acc.push({
|
|
105
|
+
path: relativePath,
|
|
106
|
+
size: buffer.length,
|
|
107
|
+
sha256: sha256Buffer(buffer),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
acc.sort((left, right) => left.path.localeCompare(right.path));
|
|
112
|
+
return acc;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function normalizeBinMap(projectPackage) {
|
|
116
|
+
if (typeof projectPackage?.bin === 'string' && projectPackage.bin.trim().length > 0) {
|
|
117
|
+
return {
|
|
118
|
+
[projectPackage.name?.split('/').pop() || 'game']: normalizeRelativePath(projectPackage.bin),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const normalized = {};
|
|
123
|
+
for (const key of Object.keys(projectPackage?.bin || {}).sort()) {
|
|
124
|
+
const value = projectPackage.bin[key];
|
|
125
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
normalized[key] = normalizeRelativePath(value);
|
|
129
|
+
}
|
|
130
|
+
return normalized;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function normalizeAuthoredMetadata(packageRoot) {
|
|
134
|
+
const configPath = resolve(packageRoot, 'aura.config.json');
|
|
135
|
+
if (!existsSync(configPath)) {
|
|
136
|
+
return {
|
|
137
|
+
identity: null,
|
|
138
|
+
window: null,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const config = readJsonFile(configPath);
|
|
143
|
+
const iconPath = normalizeString(config?.identity?.icon);
|
|
144
|
+
const normalizedIconPath = iconPath ? normalizeRelativePath(iconPath) : null;
|
|
145
|
+
const iconAbsolutePath = normalizedIconPath ? resolve(packageRoot, normalizedIconPath) : null;
|
|
146
|
+
const iconStats = iconAbsolutePath && existsSync(iconAbsolutePath) && lstatSync(iconAbsolutePath).isFile()
|
|
147
|
+
? readFileSync(iconAbsolutePath)
|
|
148
|
+
: null;
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
identity: {
|
|
152
|
+
name: normalizeString(config?.identity?.name),
|
|
153
|
+
version: normalizeString(config?.identity?.version),
|
|
154
|
+
executable: normalizeString(config?.identity?.executable),
|
|
155
|
+
icon: normalizedIconPath,
|
|
156
|
+
iconAsset: {
|
|
157
|
+
path: normalizedIconPath,
|
|
158
|
+
exists: Boolean(iconStats),
|
|
159
|
+
size: iconStats ? iconStats.length : null,
|
|
160
|
+
sha256: iconStats ? sha256Buffer(iconStats) : null,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
window: {
|
|
164
|
+
title: normalizeString(config?.window?.title),
|
|
165
|
+
},
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function normalizeBuildMetadata(buildMetadata = {}) {
|
|
170
|
+
const buildRoot = buildMetadata?.buildRoot ? resolve(buildMetadata.buildRoot) : null;
|
|
171
|
+
const iconOutputPath = normalizeString(buildMetadata?.icon?.outputPath);
|
|
172
|
+
const normalizedIconOutputPath = iconOutputPath ? normalizeRelativePath(iconOutputPath) : null;
|
|
173
|
+
const iconOutputAbsolutePath = buildRoot && normalizedIconOutputPath
|
|
174
|
+
? resolve(buildRoot, normalizedIconOutputPath)
|
|
175
|
+
: null;
|
|
176
|
+
const iconOutputBytes = iconOutputAbsolutePath && existsSync(iconOutputAbsolutePath) && lstatSync(iconOutputAbsolutePath).isFile()
|
|
177
|
+
? readFileSync(iconOutputAbsolutePath)
|
|
178
|
+
: null;
|
|
179
|
+
|
|
180
|
+
return {
|
|
181
|
+
buildTarget: normalizeString(buildMetadata?.buildTarget),
|
|
182
|
+
identity: {
|
|
183
|
+
name: normalizeString(buildMetadata?.identity?.name),
|
|
184
|
+
version: normalizeString(buildMetadata?.identity?.version),
|
|
185
|
+
windowTitle: normalizeString(buildMetadata?.identity?.windowTitle),
|
|
186
|
+
executableBaseName: normalizeString(buildMetadata?.identity?.executableBaseName),
|
|
187
|
+
executableFileName: normalizeString(buildMetadata?.identity?.executableFileName),
|
|
188
|
+
},
|
|
189
|
+
icon: {
|
|
190
|
+
configuredPath: normalizeString(buildMetadata?.icon?.configuredPath),
|
|
191
|
+
discoveredPath: normalizeString(buildMetadata?.icon?.discoveredPath),
|
|
192
|
+
resolvedPath: normalizeString(buildMetadata?.icon?.resolvedPath),
|
|
193
|
+
outputPath: normalizedIconOutputPath,
|
|
194
|
+
outputSha256: iconOutputBytes ? sha256Buffer(iconOutputBytes) : null,
|
|
195
|
+
status: normalizeString(buildMetadata?.icon?.status),
|
|
196
|
+
reasonCode: normalizeString(buildMetadata?.icon?.reasonCode),
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function buildManifestBody({ packageRoot, projectPackage, buildMetadata = null, signer }) {
|
|
202
|
+
const resolvedPackage = projectPackage || readJsonFile(resolve(packageRoot, 'package.json'));
|
|
203
|
+
return {
|
|
204
|
+
schema: PACKAGE_INTEGRITY_SCHEMA,
|
|
205
|
+
package: {
|
|
206
|
+
name: normalizeString(resolvedPackage?.name),
|
|
207
|
+
version: normalizeString(resolvedPackage?.version),
|
|
208
|
+
description: normalizeString(resolvedPackage?.description),
|
|
209
|
+
type: normalizeString(resolvedPackage?.type),
|
|
210
|
+
aurajsVersion: normalizeString(resolvedPackage?.dependencies?.['@auraindustry/aurajs']),
|
|
211
|
+
bin: normalizeBinMap(resolvedPackage),
|
|
212
|
+
},
|
|
213
|
+
publishedMetadata: {
|
|
214
|
+
authored: normalizeAuthoredMetadata(packageRoot),
|
|
215
|
+
build: normalizeBuildMetadata(buildMetadata),
|
|
216
|
+
},
|
|
217
|
+
signer: {
|
|
218
|
+
algorithm: 'ed25519',
|
|
219
|
+
publicKeyPem: signer.publicKeyPem,
|
|
220
|
+
fingerprint: signer.fingerprint,
|
|
221
|
+
},
|
|
222
|
+
files: listHashedPackageFiles(packageRoot),
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function ensureSignerKeyPair(projectRoot) {
|
|
227
|
+
const privateKeyPath = resolve(projectRoot, PACKAGE_INTEGRITY_PRIVATE_KEY_PATH);
|
|
228
|
+
const publicKeyPath = resolve(projectRoot, PACKAGE_INTEGRITY_PUBLIC_KEY_PATH);
|
|
229
|
+
|
|
230
|
+
if (!existsSync(privateKeyPath)) {
|
|
231
|
+
mkdirSync(dirname(privateKeyPath), { recursive: true });
|
|
232
|
+
const generated = generateKeyPairSync('ed25519', {
|
|
233
|
+
privateKeyEncoding: {
|
|
234
|
+
format: 'pem',
|
|
235
|
+
type: 'pkcs8',
|
|
236
|
+
},
|
|
237
|
+
publicKeyEncoding: {
|
|
238
|
+
format: 'pem',
|
|
239
|
+
type: 'spki',
|
|
240
|
+
},
|
|
241
|
+
});
|
|
242
|
+
writeFileSync(privateKeyPath, generated.privateKey, 'utf8');
|
|
243
|
+
writeFileSync(publicKeyPath, generated.publicKey, 'utf8');
|
|
244
|
+
if (process.platform !== 'win32') {
|
|
245
|
+
chmodSync(privateKeyPath, 0o600);
|
|
246
|
+
}
|
|
247
|
+
} else if (!existsSync(publicKeyPath)) {
|
|
248
|
+
const privateKeyPem = readFileSync(privateKeyPath, 'utf8');
|
|
249
|
+
const derivedPublicKey = createPublicKey(createPrivateKey(privateKeyPem))
|
|
250
|
+
.export({ format: 'pem', type: 'spki' })
|
|
251
|
+
.toString();
|
|
252
|
+
writeFileSync(publicKeyPath, derivedPublicKey, 'utf8');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const privateKeyPem = readFileSync(privateKeyPath, 'utf8');
|
|
256
|
+
const publicKeyPem = readFileSync(publicKeyPath, 'utf8');
|
|
257
|
+
const fingerprint = sha256Buffer(
|
|
258
|
+
createPublicKey(publicKeyPem).export({ format: 'der', type: 'spki' }),
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
privateKeyPath,
|
|
263
|
+
publicKeyPath,
|
|
264
|
+
privateKeyPem,
|
|
265
|
+
publicKeyPem,
|
|
266
|
+
fingerprint,
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function readManifestAndSignature(packageRoot) {
|
|
271
|
+
const manifestPath = resolve(packageRoot, PACKAGE_INTEGRITY_MANIFEST_PATH);
|
|
272
|
+
const signaturePath = resolve(packageRoot, PACKAGE_INTEGRITY_SIGNATURE_PATH);
|
|
273
|
+
if (!existsSync(manifestPath) || !existsSync(signaturePath)) {
|
|
274
|
+
throw new PackageIntegrityError(
|
|
275
|
+
'package_integrity_artifacts_missing',
|
|
276
|
+
`Published game package must include ${PACKAGE_INTEGRITY_MANIFEST_PATH} and ${PACKAGE_INTEGRITY_SIGNATURE_PATH}.`,
|
|
277
|
+
{
|
|
278
|
+
manifestPath,
|
|
279
|
+
signaturePath,
|
|
280
|
+
},
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const manifest = readJsonFile(manifestPath);
|
|
285
|
+
const signature = String(readFileSync(signaturePath, 'utf8') || '').trim();
|
|
286
|
+
if (!signature) {
|
|
287
|
+
throw new PackageIntegrityError(
|
|
288
|
+
'package_integrity_signature_missing',
|
|
289
|
+
`${PACKAGE_INTEGRITY_SIGNATURE_PATH} is empty.`,
|
|
290
|
+
{ signaturePath },
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
manifestPath,
|
|
296
|
+
signaturePath,
|
|
297
|
+
manifest,
|
|
298
|
+
signature,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
function assertManifestSignature(manifest, signature) {
|
|
303
|
+
if (manifest?.schema !== PACKAGE_INTEGRITY_SCHEMA) {
|
|
304
|
+
throw new PackageIntegrityError(
|
|
305
|
+
'package_integrity_schema_invalid',
|
|
306
|
+
`Expected ${PACKAGE_INTEGRITY_SCHEMA}, found ${manifest?.schema || '<missing>'}.`,
|
|
307
|
+
{
|
|
308
|
+
schema: manifest?.schema || null,
|
|
309
|
+
},
|
|
310
|
+
);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const publicKeyPem = normalizeString(manifest?.signer?.publicKeyPem);
|
|
314
|
+
const signerFingerprint = normalizeString(manifest?.signer?.fingerprint);
|
|
315
|
+
if (!publicKeyPem || !signerFingerprint) {
|
|
316
|
+
throw new PackageIntegrityError(
|
|
317
|
+
'package_integrity_signer_missing',
|
|
318
|
+
'Package integrity manifest is missing signer metadata.',
|
|
319
|
+
{},
|
|
320
|
+
);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const actualFingerprint = sha256Buffer(
|
|
324
|
+
createPublicKey(publicKeyPem).export({ format: 'der', type: 'spki' }),
|
|
325
|
+
);
|
|
326
|
+
if (actualFingerprint !== signerFingerprint) {
|
|
327
|
+
throw new PackageIntegrityError(
|
|
328
|
+
'package_integrity_signer_fingerprint_mismatch',
|
|
329
|
+
'Package integrity signer fingerprint does not match the embedded public key.',
|
|
330
|
+
{
|
|
331
|
+
expectedFingerprint: signerFingerprint,
|
|
332
|
+
actualFingerprint,
|
|
333
|
+
},
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const ok = verify(
|
|
338
|
+
null,
|
|
339
|
+
Buffer.from(stableSerialize(manifest)),
|
|
340
|
+
publicKeyPem,
|
|
341
|
+
Buffer.from(signature, 'base64'),
|
|
342
|
+
);
|
|
343
|
+
if (!ok) {
|
|
344
|
+
throw new PackageIntegrityError(
|
|
345
|
+
'package_integrity_signature_invalid',
|
|
346
|
+
'Package integrity signature verification failed.',
|
|
347
|
+
{
|
|
348
|
+
fingerprint: signerFingerprint,
|
|
349
|
+
},
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return {
|
|
354
|
+
publicKeyPem,
|
|
355
|
+
fingerprint: signerFingerprint,
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function loadTrustStore(trustRoot) {
|
|
360
|
+
if (!trustRoot) {
|
|
361
|
+
return {
|
|
362
|
+
storePath: null,
|
|
363
|
+
entries: {},
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const storePath = resolve(trustRoot, PACKAGE_INTEGRITY_TRUST_STORE_PATH);
|
|
368
|
+
if (!existsSync(storePath)) {
|
|
369
|
+
return {
|
|
370
|
+
storePath,
|
|
371
|
+
entries: {},
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
try {
|
|
376
|
+
return {
|
|
377
|
+
storePath,
|
|
378
|
+
entries: JSON.parse(readFileSync(storePath, 'utf8')) || {},
|
|
379
|
+
};
|
|
380
|
+
} catch (error) {
|
|
381
|
+
throw new PackageIntegrityError(
|
|
382
|
+
'package_integrity_trust_store_invalid',
|
|
383
|
+
`Failed to parse signer trust store at ${storePath}: ${error.message}`,
|
|
384
|
+
{
|
|
385
|
+
storePath,
|
|
386
|
+
},
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
function updateTrustStore({ trustRoot, packageName, signerFingerprint, packageVersion }) {
|
|
392
|
+
if (!trustRoot) {
|
|
393
|
+
return {
|
|
394
|
+
status: 'unchecked',
|
|
395
|
+
storePath: null,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const { storePath, entries } = loadTrustStore(trustRoot);
|
|
400
|
+
const existing = entries[packageName] || null;
|
|
401
|
+
if (existing?.signerFingerprint && existing.signerFingerprint !== signerFingerprint) {
|
|
402
|
+
throw new PackageIntegrityError(
|
|
403
|
+
'package_integrity_signer_changed',
|
|
404
|
+
`Published game signer changed for ${packageName}: expected ${existing.signerFingerprint}, got ${signerFingerprint}.`,
|
|
405
|
+
{
|
|
406
|
+
packageName,
|
|
407
|
+
packageVersion,
|
|
408
|
+
expectedFingerprint: existing.signerFingerprint,
|
|
409
|
+
actualFingerprint: signerFingerprint,
|
|
410
|
+
storePath,
|
|
411
|
+
},
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const now = new Date().toISOString();
|
|
416
|
+
const next = {
|
|
417
|
+
...entries,
|
|
418
|
+
[packageName]: {
|
|
419
|
+
signerFingerprint,
|
|
420
|
+
firstSeenAt: existing?.firstSeenAt || now,
|
|
421
|
+
lastSeenAt: now,
|
|
422
|
+
lastVersion: packageVersion || null,
|
|
423
|
+
},
|
|
424
|
+
};
|
|
425
|
+
mkdirSync(dirname(storePath), { recursive: true });
|
|
426
|
+
writeFileSync(storePath, `${JSON.stringify(next, null, 2)}\n`, 'utf8');
|
|
427
|
+
|
|
428
|
+
return {
|
|
429
|
+
status: existing ? 'trusted' : 'trusted_first_use',
|
|
430
|
+
storePath,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function assertFileInventory(manifestFiles, packageRoot) {
|
|
435
|
+
const actualFiles = listHashedPackageFiles(packageRoot);
|
|
436
|
+
const expectedByPath = new Map((manifestFiles || []).map((entry) => [entry.path, entry]));
|
|
437
|
+
const actualByPath = new Map(actualFiles.map((entry) => [entry.path, entry]));
|
|
438
|
+
|
|
439
|
+
const missing = [];
|
|
440
|
+
const mismatched = [];
|
|
441
|
+
for (const [path, expected] of expectedByPath) {
|
|
442
|
+
const actual = actualByPath.get(path);
|
|
443
|
+
if (!actual) {
|
|
444
|
+
missing.push(path);
|
|
445
|
+
continue;
|
|
446
|
+
}
|
|
447
|
+
if (actual.sha256 !== expected.sha256 || actual.size !== expected.size) {
|
|
448
|
+
mismatched.push({
|
|
449
|
+
path,
|
|
450
|
+
expected,
|
|
451
|
+
actual,
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const extra = actualFiles
|
|
457
|
+
.filter((entry) => !expectedByPath.has(entry.path))
|
|
458
|
+
.map((entry) => entry.path);
|
|
459
|
+
|
|
460
|
+
if (missing.length > 0 || mismatched.length > 0 || extra.length > 0) {
|
|
461
|
+
throw new PackageIntegrityError(
|
|
462
|
+
'package_integrity_file_mismatch',
|
|
463
|
+
'Published game package contents do not match the signed integrity manifest.',
|
|
464
|
+
{
|
|
465
|
+
missing,
|
|
466
|
+
extra,
|
|
467
|
+
mismatched,
|
|
468
|
+
},
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
return actualFiles;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function assertManifestMetadataMatchesInstalledPackage(manifest, packageRoot) {
|
|
476
|
+
const projectPackage = readJsonFile(resolve(packageRoot, 'package.json'));
|
|
477
|
+
const actualPackageMetadata = {
|
|
478
|
+
name: normalizeString(projectPackage?.name),
|
|
479
|
+
version: normalizeString(projectPackage?.version),
|
|
480
|
+
description: normalizeString(projectPackage?.description),
|
|
481
|
+
type: normalizeString(projectPackage?.type),
|
|
482
|
+
aurajsVersion: normalizeString(projectPackage?.dependencies?.['@auraindustry/aurajs']),
|
|
483
|
+
bin: normalizeBinMap(projectPackage),
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
if (stableSerialize(actualPackageMetadata) !== stableSerialize(manifest?.package || {})) {
|
|
487
|
+
throw new PackageIntegrityError(
|
|
488
|
+
'package_integrity_package_metadata_mismatch',
|
|
489
|
+
'Installed package.json metadata does not match the signed integrity manifest.',
|
|
490
|
+
{
|
|
491
|
+
expected: manifest?.package || null,
|
|
492
|
+
actual: actualPackageMetadata,
|
|
493
|
+
},
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
const actualAuthoredMetadata = normalizeAuthoredMetadata(packageRoot);
|
|
498
|
+
if (stableSerialize(actualAuthoredMetadata) !== stableSerialize(manifest?.publishedMetadata?.authored || {})) {
|
|
499
|
+
throw new PackageIntegrityError(
|
|
500
|
+
'package_integrity_authored_metadata_mismatch',
|
|
501
|
+
'Installed authored game metadata does not match the signed integrity manifest.',
|
|
502
|
+
{
|
|
503
|
+
expected: manifest?.publishedMetadata?.authored || null,
|
|
504
|
+
actual: actualAuthoredMetadata,
|
|
505
|
+
},
|
|
506
|
+
);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
export function writeSignedPackageIntegrityArtifacts({
|
|
511
|
+
packageRoot,
|
|
512
|
+
signerProjectRoot = packageRoot,
|
|
513
|
+
buildMetadata = null,
|
|
514
|
+
projectPackage = null,
|
|
515
|
+
} = {}) {
|
|
516
|
+
const resolvedPackageRoot = resolve(packageRoot || process.cwd());
|
|
517
|
+
const signer = ensureSignerKeyPair(resolve(signerProjectRoot || resolvedPackageRoot));
|
|
518
|
+
const manifest = buildManifestBody({
|
|
519
|
+
packageRoot: resolvedPackageRoot,
|
|
520
|
+
projectPackage,
|
|
521
|
+
buildMetadata,
|
|
522
|
+
signer,
|
|
523
|
+
});
|
|
524
|
+
const signature = sign(
|
|
525
|
+
null,
|
|
526
|
+
Buffer.from(stableSerialize(manifest)),
|
|
527
|
+
signer.privateKeyPem,
|
|
528
|
+
).toString('base64');
|
|
529
|
+
|
|
530
|
+
const manifestPath = resolve(resolvedPackageRoot, PACKAGE_INTEGRITY_MANIFEST_PATH);
|
|
531
|
+
const signaturePath = resolve(resolvedPackageRoot, PACKAGE_INTEGRITY_SIGNATURE_PATH);
|
|
532
|
+
writeFileSync(manifestPath, `${stableSerialize(manifest, true)}\n`, 'utf8');
|
|
533
|
+
writeFileSync(signaturePath, `${signature}\n`, 'utf8');
|
|
534
|
+
|
|
535
|
+
return {
|
|
536
|
+
manifestPath,
|
|
537
|
+
signaturePath,
|
|
538
|
+
schema: manifest.schema,
|
|
539
|
+
packageName: manifest.package.name,
|
|
540
|
+
packageVersion: manifest.package.version,
|
|
541
|
+
fileCount: manifest.files.length,
|
|
542
|
+
signerFingerprint: signer.fingerprint,
|
|
543
|
+
publishedMetadata: manifest.publishedMetadata,
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
export function verifySignedPackageIntegrity({
|
|
548
|
+
packageRoot,
|
|
549
|
+
expectedPackageName = null,
|
|
550
|
+
trustRoot = null,
|
|
551
|
+
} = {}) {
|
|
552
|
+
const resolvedPackageRoot = resolve(packageRoot || process.cwd());
|
|
553
|
+
const { manifestPath, signaturePath, manifest, signature } = readManifestAndSignature(resolvedPackageRoot);
|
|
554
|
+
const signer = assertManifestSignature(manifest, signature);
|
|
555
|
+
if (expectedPackageName && normalizeString(manifest?.package?.name) !== normalizeString(expectedPackageName)) {
|
|
556
|
+
throw new PackageIntegrityError(
|
|
557
|
+
'package_integrity_package_name_mismatch',
|
|
558
|
+
`Expected published package ${expectedPackageName}, found ${manifest?.package?.name || '<missing>'}.`,
|
|
559
|
+
{
|
|
560
|
+
expectedPackageName,
|
|
561
|
+
actualPackageName: manifest?.package?.name || null,
|
|
562
|
+
},
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
assertFileInventory(manifest?.files, resolvedPackageRoot);
|
|
567
|
+
assertManifestMetadataMatchesInstalledPackage(manifest, resolvedPackageRoot);
|
|
568
|
+
const trust = updateTrustStore({
|
|
569
|
+
trustRoot,
|
|
570
|
+
packageName: manifest.package.name,
|
|
571
|
+
packageVersion: manifest.package.version,
|
|
572
|
+
signerFingerprint: signer.fingerprint,
|
|
573
|
+
});
|
|
574
|
+
|
|
575
|
+
return {
|
|
576
|
+
reasonCode: 'package_integrity_ok',
|
|
577
|
+
manifestPath,
|
|
578
|
+
signaturePath,
|
|
579
|
+
packageName: manifest.package.name,
|
|
580
|
+
packageVersion: manifest.package.version,
|
|
581
|
+
signerFingerprint: signer.fingerprint,
|
|
582
|
+
trust,
|
|
583
|
+
fileCount: Array.isArray(manifest?.files) ? manifest.files.length : 0,
|
|
584
|
+
publishedMetadata: manifest.publishedMetadata || null,
|
|
585
|
+
};
|
|
586
|
+
}
|