@clockgrove/assetgrove 0.0.0-stage → 0.3.2
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/LICENSE +21 -0
- package/README.md +277 -2
- package/dist/animation/commands.d.ts +180 -0
- package/dist/animation/commands.js +515 -0
- package/dist/animation/facing.d.ts +44 -0
- package/dist/animation/facing.js +100 -0
- package/dist/animation/fix.d.ts +136 -0
- package/dist/animation/fix.js +529 -0
- package/dist/animation/flicker.d.ts +44 -0
- package/dist/animation/flicker.js +117 -0
- package/dist/animation/halo.d.ts +72 -0
- package/dist/animation/halo.js +253 -0
- package/dist/animation/holes.d.ts +122 -0
- package/dist/animation/holes.js +262 -0
- package/dist/animation/preview.d.ts +38 -0
- package/dist/animation/preview.js +161 -0
- package/dist/animation/qa.d.ts +57 -0
- package/dist/animation/qa.js +418 -0
- package/dist/animation/run.d.ts +109 -0
- package/dist/animation/run.js +182 -0
- package/dist/animation/strip.d.ts +13 -0
- package/dist/animation/strip.js +41 -0
- package/dist/animation/template-choice.d.ts +75 -0
- package/dist/animation/template-choice.js +153 -0
- package/dist/animation/templates.d.ts +39 -0
- package/dist/animation/templates.js +333 -0
- package/dist/animation/types.d.ts +257 -0
- package/dist/animation/types.js +1 -0
- package/dist/approvals.d.ts +156 -0
- package/dist/approvals.js +369 -0
- package/dist/audio/aac.d.ts +61 -0
- package/dist/audio/aac.js +152 -0
- package/dist/audio/checks.d.ts +38 -0
- package/dist/audio/checks.js +254 -0
- package/dist/audio/delivery.d.ts +52 -0
- package/dist/audio/delivery.js +105 -0
- package/dist/audio/engine.d.ts +65 -0
- package/dist/audio/engine.js +164 -0
- package/dist/audio/handoff.d.ts +75 -0
- package/dist/audio/handoff.js +185 -0
- package/dist/audio/kinds.d.ts +6 -0
- package/dist/audio/kinds.js +315 -0
- package/dist/audio/loudness.d.ts +22 -0
- package/dist/audio/loudness.js +72 -0
- package/dist/audio/ogg.d.ts +27 -0
- package/dist/audio/ogg.js +65 -0
- package/dist/audio/operations.d.ts +20 -0
- package/dist/audio/operations.js +335 -0
- package/dist/audio/opus.d.ts +40 -0
- package/dist/audio/opus.js +108 -0
- package/dist/audio/profile.d.ts +200 -0
- package/dist/audio/profile.js +126 -0
- package/dist/audio/run.d.ts +83 -0
- package/dist/audio/run.js +192 -0
- package/dist/audio/vorbis-comments.d.ts +25 -0
- package/dist/audio/vorbis-comments.js +243 -0
- package/dist/audio/waveform.d.ts +13 -0
- package/dist/audio/waveform.js +52 -0
- package/dist/audio-parameters.d.ts +17 -0
- package/dist/audio-parameters.js +45 -0
- package/dist/audit/bar.d.ts +65 -0
- package/dist/audit/bar.js +97 -0
- package/dist/audit/members.d.ts +40 -0
- package/dist/audit/members.js +119 -0
- package/dist/bible-view.d.ts +10 -0
- package/dist/bible-view.js +122 -0
- package/dist/bible.d.ts +272 -0
- package/dist/bible.js +641 -0
- package/dist/budget.d.ts +119 -0
- package/dist/budget.js +227 -0
- package/dist/call-parameters.d.ts +71 -0
- package/dist/call-parameters.js +90 -0
- package/dist/calls.d.ts +145 -0
- package/dist/calls.js +788 -0
- package/dist/cli/main.d.ts +22 -0
- package/dist/cli/main.js +137 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +5 -0
- package/dist/commands/animation-qa.d.ts +1 -0
- package/dist/commands/animation-qa.js +240 -0
- package/dist/commands/apply.d.ts +12 -0
- package/dist/commands/apply.js +181 -0
- package/dist/commands/audit.d.ts +92 -0
- package/dist/commands/audit.js +555 -0
- package/dist/commands/bible.d.ts +1 -0
- package/dist/commands/bible.js +39 -0
- package/dist/commands/browse.d.ts +12 -0
- package/dist/commands/browse.js +113 -0
- package/dist/commands/card.d.ts +3 -0
- package/dist/commands/card.js +445 -0
- package/dist/commands/compare.d.ts +1 -0
- package/dist/commands/compare.js +90 -0
- package/dist/commands/confirm.d.ts +1 -0
- package/dist/commands/confirm.js +267 -0
- package/dist/commands/context.d.ts +43 -0
- package/dist/commands/context.js +115 -0
- package/dist/commands/deliver.d.ts +1 -0
- package/dist/commands/deliver.js +99 -0
- package/dist/commands/disclosure.d.ts +1 -0
- package/dist/commands/disclosure.js +80 -0
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +112 -0
- package/dist/commands/estimate.d.ts +2 -0
- package/dist/commands/estimate.js +80 -0
- package/dist/commands/extensions.d.ts +2 -0
- package/dist/commands/extensions.js +70 -0
- package/dist/commands/fix-frame.d.ts +1 -0
- package/dist/commands/fix-frame.js +206 -0
- package/dist/commands/generate-sheet.d.ts +1 -0
- package/dist/commands/generate-sheet.js +245 -0
- package/dist/commands/identity-check.d.ts +1 -0
- package/dist/commands/identity-check.js +110 -0
- package/dist/commands/identity-eval.d.ts +1 -0
- package/dist/commands/identity-eval.js +197 -0
- package/dist/commands/import.d.ts +7 -0
- package/dist/commands/import.js +472 -0
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +117 -0
- package/dist/commands/intake.d.ts +1 -0
- package/dist/commands/intake.js +56 -0
- package/dist/commands/labels.d.ts +1 -0
- package/dist/commands/labels.js +101 -0
- package/dist/commands/library.d.ts +9 -0
- package/dist/commands/library.js +711 -0
- package/dist/commands/lod.d.ts +1 -0
- package/dist/commands/lod.js +93 -0
- package/dist/commands/look-dev.d.ts +1 -0
- package/dist/commands/look-dev.js +148 -0
- package/dist/commands/materials.d.ts +1 -0
- package/dist/commands/materials.js +223 -0
- package/dist/commands/mcp.d.ts +1 -0
- package/dist/commands/mcp.js +53 -0
- package/dist/commands/migrate.d.ts +1 -0
- package/dist/commands/migrate.js +123 -0
- package/dist/commands/op.d.ts +5 -0
- package/dist/commands/op.js +114 -0
- package/dist/commands/ops.d.ts +1 -0
- package/dist/commands/ops.js +17 -0
- package/dist/commands/pick-batch.d.ts +24 -0
- package/dist/commands/pick-batch.js +343 -0
- package/dist/commands/pick.d.ts +48 -0
- package/dist/commands/pick.js +469 -0
- package/dist/commands/plan.d.ts +3 -0
- package/dist/commands/plan.js +156 -0
- package/dist/commands/recipe.d.ts +1 -0
- package/dist/commands/recipe.js +52 -0
- package/dist/commands/registry.d.ts +5 -0
- package/dist/commands/registry.js +121 -0
- package/dist/commands/render-sprite.d.ts +1 -0
- package/dist/commands/render-sprite.js +67 -0
- package/dist/commands/rendition.d.ts +1 -0
- package/dist/commands/rendition.js +56 -0
- package/dist/commands/request-change.d.ts +2 -0
- package/dist/commands/request-change.js +950 -0
- package/dist/commands/result.d.ts +34 -0
- package/dist/commands/result.js +237 -0
- package/dist/commands/review.d.ts +28 -0
- package/dist/commands/review.js +444 -0
- package/dist/commands/rig.d.ts +1 -0
- package/dist/commands/rig.js +74 -0
- package/dist/commands/runner.d.ts +45 -0
- package/dist/commands/runner.js +297 -0
- package/dist/commands/runs.d.ts +22 -0
- package/dist/commands/runs.js +159 -0
- package/dist/commands/search.d.ts +69 -0
- package/dist/commands/search.js +638 -0
- package/dist/commands/settings.d.ts +2 -0
- package/dist/commands/settings.js +284 -0
- package/dist/commands/spend.d.ts +2 -0
- package/dist/commands/spend.js +159 -0
- package/dist/commands/stage-source.d.ts +1 -0
- package/dist/commands/stage-source.js +58 -0
- package/dist/commands/stage.d.ts +9 -0
- package/dist/commands/stage.js +229 -0
- package/dist/commands/storage.d.ts +3 -0
- package/dist/commands/storage.js +200 -0
- package/dist/commands/turnaround.d.ts +1 -0
- package/dist/commands/turnaround.js +171 -0
- package/dist/commands/types.d.ts +195 -0
- package/dist/commands/types.js +7 -0
- package/dist/commands/vary.d.ts +2 -0
- package/dist/commands/vary.js +222 -0
- package/dist/commands/write-families.d.ts +14 -0
- package/dist/commands/write-families.js +158 -0
- package/dist/compare.d.ts +87 -0
- package/dist/compare.js +306 -0
- package/dist/confirm/delegation.d.ts +30 -0
- package/dist/confirm/delegation.js +31 -0
- package/dist/confirm/index.d.ts +84 -0
- package/dist/confirm/index.js +176 -0
- package/dist/confirm/mcp.d.ts +60 -0
- package/dist/confirm/mcp.js +253 -0
- package/dist/confirm/pending.d.ts +11 -0
- package/dist/confirm/pending.js +40 -0
- package/dist/confirm/prompt.d.ts +65 -0
- package/dist/confirm/prompt.js +68 -0
- package/dist/confirm/records.d.ts +17 -0
- package/dist/confirm/records.js +63 -0
- package/dist/contact.d.ts +80 -0
- package/dist/contact.js +224 -0
- package/dist/credentials.d.ts +170 -0
- package/dist/credentials.js +598 -0
- package/dist/dataflows.d.ts +32 -0
- package/dist/dataflows.js +42 -0
- package/dist/delivery.d.ts +89 -0
- package/dist/delivery.js +355 -0
- package/dist/disclosure.d.ts +84 -0
- package/dist/disclosure.js +397 -0
- package/dist/env.d.ts +90 -0
- package/dist/env.js +236 -0
- package/dist/errors.d.ts +90 -0
- package/dist/errors.js +105 -0
- package/dist/extension/api.d.ts +389 -0
- package/dist/extension/api.js +20 -0
- package/dist/extension/context.d.ts +9 -0
- package/dist/extension/context.js +60 -0
- package/dist/extension/helpers.d.ts +75 -0
- package/dist/extension/helpers.js +107 -0
- package/dist/extension/http.d.ts +32 -0
- package/dist/extension/http.js +104 -0
- package/dist/extension/setup.d.ts +53 -0
- package/dist/extension/setup.js +162 -0
- package/dist/extension/tools.d.ts +97 -0
- package/dist/extension/tools.js +235 -0
- package/dist/extensions/core.d.ts +7 -0
- package/dist/extensions/core.js +18 -0
- package/dist/extensions/errors.d.ts +22 -0
- package/dist/extensions/errors.js +34 -0
- package/dist/extensions/registry.d.ts +119 -0
- package/dist/extensions/registry.js +535 -0
- package/dist/extensions/version.d.ts +9 -0
- package/dist/extensions/version.js +57 -0
- package/dist/formats.d.ts +46 -0
- package/dist/formats.js +81 -0
- package/dist/frames.d.ts +58 -0
- package/dist/frames.js +80 -0
- package/dist/gateway/anthropic.d.ts +22 -0
- package/dist/gateway/anthropic.js +65 -0
- package/dist/gateway/elevenlabs.d.ts +36 -0
- package/dist/gateway/elevenlabs.js +192 -0
- package/dist/gateway/failure.d.ts +29 -0
- package/dist/gateway/failure.js +70 -0
- package/dist/gateway/openai-compatible.d.ts +20 -0
- package/dist/gateway/openai-compatible.js +76 -0
- package/dist/gateway/openai.d.ts +28 -0
- package/dist/gateway/openai.js +101 -0
- package/dist/gateway/provider.d.ts +380 -0
- package/dist/gateway/provider.js +5 -0
- package/dist/gateway/scripted.d.ts +252 -0
- package/dist/gateway/scripted.js +244 -0
- package/dist/gateway/stability.d.ts +38 -0
- package/dist/gateway/stability.js +232 -0
- package/dist/gateway/structured.d.ts +31 -0
- package/dist/gateway/structured.js +83 -0
- package/dist/gateway/tripo.d.ts +48 -0
- package/dist/gateway/tripo.js +374 -0
- package/dist/gateway/vercel.d.ts +52 -0
- package/dist/gateway/vercel.js +298 -0
- package/dist/generators/generator.d.ts +236 -0
- package/dist/generators/generator.js +12 -0
- package/dist/generators/image.d.ts +21 -0
- package/dist/generators/image.js +286 -0
- package/dist/generators/spec-schema.d.ts +29 -0
- package/dist/generators/spec-schema.js +21 -0
- package/dist/git-marker.d.ts +3 -0
- package/dist/git-marker.js +13 -0
- package/dist/gitlfs.d.ts +38 -0
- package/dist/gitlfs.js +171 -0
- package/dist/guard.d.ts +55 -0
- package/dist/guard.js +323 -0
- package/dist/handoff/current-profile.d.ts +48 -0
- package/dist/handoff/current-profile.js +127 -0
- package/dist/handoff/doctor.d.ts +26 -0
- package/dist/handoff/doctor.js +249 -0
- package/dist/handoff/mark-check.d.ts +17 -0
- package/dist/handoff/mark-check.js +66 -0
- package/dist/handoff/presets/aseprite-json.d.ts +5 -0
- package/dist/handoff/presets/aseprite-json.js +45 -0
- package/dist/handoff/presets/atlas-json.d.ts +44 -0
- package/dist/handoff/presets/atlas-json.js +195 -0
- package/dist/handoff/presets/atlas-pack.d.ts +14 -0
- package/dist/handoff/presets/atlas-pack.js +431 -0
- package/dist/handoff/presets/index.d.ts +273 -0
- package/dist/handoff/presets/index.js +58 -0
- package/dist/handoff/presets/manifest.d.ts +2 -0
- package/dist/handoff/presets/manifest.js +49 -0
- package/dist/handoff/usage.d.ts +27 -0
- package/dist/handoff/usage.js +159 -0
- package/dist/handoff.d.ts +345 -0
- package/dist/handoff.js +1221 -0
- package/dist/identity-eval.d.ts +156 -0
- package/dist/identity-eval.js +321 -0
- package/dist/identity.d.ts +293 -0
- package/dist/identity.js +675 -0
- package/dist/image/apply-style.d.ts +4 -0
- package/dist/image/apply-style.js +37 -0
- package/dist/image/digits.d.ts +5 -0
- package/dist/image/digits.js +40 -0
- package/dist/image/ktx2.d.ts +83 -0
- package/dist/image/ktx2.js +196 -0
- package/dist/image/raster.d.ts +23 -0
- package/dist/image/raster.js +77 -0
- package/dist/image/resample.d.ts +10 -0
- package/dist/image/resample.js +82 -0
- package/dist/image/webp.d.ts +17 -0
- package/dist/image/webp.js +323 -0
- package/dist/init.d.ts +132 -0
- package/dist/init.js +425 -0
- package/dist/inputs.d.ts +67 -0
- package/dist/inputs.js +151 -0
- package/dist/json.d.ts +7 -0
- package/dist/json.js +27 -0
- package/dist/keys.d.ts +34 -0
- package/dist/keys.js +198 -0
- package/dist/kind-schemas.d.ts +17 -0
- package/dist/kind-schemas.js +205 -0
- package/dist/library/actions.d.ts +76 -0
- package/dist/library/actions.js +212 -0
- package/dist/library/adopt.d.ts +177 -0
- package/dist/library/adopt.js +624 -0
- package/dist/library/canonical.d.ts +7 -0
- package/dist/library/canonical.js +29 -0
- package/dist/library/card.d.ts +138 -0
- package/dist/library/card.js +532 -0
- package/dist/library/credits.d.ts +70 -0
- package/dist/library/credits.js +222 -0
- package/dist/library/describe.d.ts +48 -0
- package/dist/library/describe.js +199 -0
- package/dist/library/diff.d.ts +26 -0
- package/dist/library/diff.js +208 -0
- package/dist/library/exact.d.ts +15 -0
- package/dist/library/exact.js +47 -0
- package/dist/library/extent.d.ts +56 -0
- package/dist/library/extent.js +205 -0
- package/dist/library/folder.d.ts +85 -0
- package/dist/library/folder.js +291 -0
- package/dist/library/labels.d.ts +29 -0
- package/dist/library/labels.js +112 -0
- package/dist/library/lfs.d.ts +42 -0
- package/dist/library/lfs.js +140 -0
- package/dist/library/maintain.d.ts +100 -0
- package/dist/library/maintain.js +750 -0
- package/dist/library/media-metadata.d.ts +19 -0
- package/dist/library/media-metadata.js +92 -0
- package/dist/library/paths.d.ts +7 -0
- package/dist/library/paths.js +65 -0
- package/dist/library/relations.d.ts +59 -0
- package/dist/library/relations.js +176 -0
- package/dist/library/review.d.ts +204 -0
- package/dist/library/review.js +545 -0
- package/dist/library/stale.d.ts +88 -0
- package/dist/library/stale.js +229 -0
- package/dist/library/suggestions.d.ts +37 -0
- package/dist/library/suggestions.js +146 -0
- package/dist/library/summary.d.ts +65 -0
- package/dist/library/summary.js +138 -0
- package/dist/library/undo.d.ts +18 -0
- package/dist/library/undo.js +141 -0
- package/dist/library/worklist.d.ts +42 -0
- package/dist/library/worklist.js +91 -0
- package/dist/library/write.d.ts +282 -0
- package/dist/library/write.js +790 -0
- package/dist/license.d.ts +67 -0
- package/dist/license.js +205 -0
- package/dist/limits.d.ts +51 -0
- package/dist/limits.js +100 -0
- package/dist/loop.d.ts +244 -0
- package/dist/loop.js +377 -0
- package/dist/material/core.d.ts +70 -0
- package/dist/material/core.js +238 -0
- package/dist/material/engine.d.ts +15 -0
- package/dist/material/engine.js +141 -0
- package/dist/material/flicker.d.ts +26 -0
- package/dist/material/flicker.js +71 -0
- package/dist/material/operations.d.ts +2 -0
- package/dist/material/operations.js +48 -0
- package/dist/material/pipeline.d.ts +51 -0
- package/dist/material/pipeline.js +431 -0
- package/dist/material/profile.d.ts +29 -0
- package/dist/material/profile.js +97 -0
- package/dist/material/rendition.d.ts +5 -0
- package/dist/material/rendition.js +76 -0
- package/dist/mcp.d.ts +72 -0
- package/dist/mcp.js +514 -0
- package/dist/media.d.ts +36 -0
- package/dist/media.js +46 -0
- package/dist/metadata.d.ts +61 -0
- package/dist/metadata.js +748 -0
- package/dist/model-declarations.d.ts +28 -0
- package/dist/model-declarations.js +14 -0
- package/dist/model3d/clip-map.d.ts +49 -0
- package/dist/model3d/clip-map.js +129 -0
- package/dist/model3d/core-checks.d.ts +61 -0
- package/dist/model3d/core-checks.js +278 -0
- package/dist/model3d/facing.d.ts +49 -0
- package/dist/model3d/facing.js +125 -0
- package/dist/model3d/generator.d.ts +19 -0
- package/dist/model3d/generator.js +482 -0
- package/dist/model3d/glb.d.ts +120 -0
- package/dist/model3d/glb.js +155 -0
- package/dist/model3d/handoff.d.ts +37 -0
- package/dist/model3d/handoff.js +131 -0
- package/dist/model3d/lod/chain.d.ts +50 -0
- package/dist/model3d/lod/chain.js +447 -0
- package/dist/model3d/lod/command.d.ts +38 -0
- package/dist/model3d/lod/command.js +377 -0
- package/dist/model3d/lod/qa.d.ts +36 -0
- package/dist/model3d/lod/qa.js +189 -0
- package/dist/model3d/lod/settings.d.ts +36 -0
- package/dist/model3d/lod/settings.js +137 -0
- package/dist/model3d/lod/simplify.d.ts +35 -0
- package/dist/model3d/lod/simplify.js +337 -0
- package/dist/model3d/lod/textures.d.ts +46 -0
- package/dist/model3d/lod/textures.js +190 -0
- package/dist/model3d/lookdev/command.d.ts +219 -0
- package/dist/model3d/lookdev/command.js +1795 -0
- package/dist/model3d/lookdev/edit.d.ts +44 -0
- package/dist/model3d/lookdev/edit.js +241 -0
- package/dist/model3d/lookdev/groom.d.ts +86 -0
- package/dist/model3d/lookdev/groom.js +462 -0
- package/dist/model3d/lookdev/markings.d.ts +98 -0
- package/dist/model3d/lookdev/markings.js +319 -0
- package/dist/model3d/lookdev/project.d.ts +100 -0
- package/dist/model3d/lookdev/project.js +721 -0
- package/dist/model3d/lookdev/settings.d.ts +65 -0
- package/dist/model3d/lookdev/settings.js +103 -0
- package/dist/model3d/lookdev/texels.d.ts +32 -0
- package/dist/model3d/lookdev/texels.js +192 -0
- package/dist/model3d/profile.d.ts +101 -0
- package/dist/model3d/profile.js +132 -0
- package/dist/model3d/prop.d.ts +29 -0
- package/dist/model3d/prop.js +317 -0
- package/dist/model3d/qa.d.ts +27 -0
- package/dist/model3d/qa.js +105 -0
- package/dist/model3d/render.d.ts +172 -0
- package/dist/model3d/render.js +791 -0
- package/dist/model3d/rig/build.d.ts +14 -0
- package/dist/model3d/rig/build.js +210 -0
- package/dist/model3d/rig/candidate.d.ts +50 -0
- package/dist/model3d/rig/candidate.js +132 -0
- package/dist/model3d/rig/command.d.ts +50 -0
- package/dist/model3d/rig/command.js +229 -0
- package/dist/model3d/rig/fit.d.ts +88 -0
- package/dist/model3d/rig/fit.js +568 -0
- package/dist/model3d/rig/gait.d.ts +105 -0
- package/dist/model3d/rig/gait.js +334 -0
- package/dist/model3d/rig/math.d.ts +27 -0
- package/dist/model3d/rig/math.js +92 -0
- package/dist/model3d/rig/motion.d.ts +26 -0
- package/dist/model3d/rig/motion.js +223 -0
- package/dist/model3d/rig/qa.d.ts +76 -0
- package/dist/model3d/rig/qa.js +357 -0
- package/dist/model3d/rig/rig.d.ts +55 -0
- package/dist/model3d/rig/rig.js +213 -0
- package/dist/model3d/rig/template.d.ts +195 -0
- package/dist/model3d/rig/template.js +456 -0
- package/dist/model3d/scene.d.ts +115 -0
- package/dist/model3d/scene.js +684 -0
- package/dist/model3d/views.d.ts +77 -0
- package/dist/model3d/views.js +190 -0
- package/dist/origin.d.ts +162 -0
- package/dist/origin.js +134 -0
- package/dist/paths.d.ts +53 -0
- package/dist/paths.js +240 -0
- package/dist/planning.d.ts +261 -0
- package/dist/planning.js +1470 -0
- package/dist/policy/blocklist.d.ts +28 -0
- package/dist/policy/blocklist.js +58 -0
- package/dist/policy/brief.d.ts +67 -0
- package/dist/policy/brief.js +110 -0
- package/dist/policy/cuts.d.ts +26 -0
- package/dist/policy/cuts.js +80 -0
- package/dist/policy/model.d.ts +69 -0
- package/dist/policy/model.js +202 -0
- package/dist/policy/text.d.ts +183 -0
- package/dist/policy/text.js +285 -0
- package/dist/postprocess.d.ts +68 -0
- package/dist/postprocess.js +302 -0
- package/dist/profile.d.ts +5 -0
- package/dist/profile.js +98 -0
- package/dist/project-rules.d.ts +54 -0
- package/dist/project-rules.js +105 -0
- package/dist/provenance-binding.d.ts +55 -0
- package/dist/provenance-binding.js +352 -0
- package/dist/providers/adapter.d.ts +176 -0
- package/dist/providers/adapter.js +418 -0
- package/dist/providers/index.d.ts +33 -0
- package/dist/providers/index.js +49 -0
- package/dist/providers/script.d.ts +13 -0
- package/dist/providers/script.js +65 -0
- package/dist/providers/set.d.ts +76 -0
- package/dist/providers/set.js +134 -0
- package/dist/pure-cbor.d.ts +1 -0
- package/dist/pure-cbor.js +8 -0
- package/dist/qa/stability.d.ts +215 -0
- package/dist/qa/stability.js +393 -0
- package/dist/qa/stability.json +32 -0
- package/dist/qa.d.ts +36 -0
- package/dist/qa.js +148 -0
- package/dist/reconcile.d.ts +111 -0
- package/dist/reconcile.js +416 -0
- package/dist/redact.d.ts +29 -0
- package/dist/redact.js +74 -0
- package/dist/regions.d.ts +49 -0
- package/dist/regions.js +113 -0
- package/dist/release-policy.d.ts +99 -0
- package/dist/release-policy.js +266 -0
- package/dist/request.d.ts +74 -0
- package/dist/request.js +249 -0
- package/dist/routes.d.ts +327 -0
- package/dist/routes.js +1166 -0
- package/dist/runs/dir.d.ts +33 -0
- package/dist/runs/dir.js +30 -0
- package/dist/runs/execute.d.ts +86 -0
- package/dist/runs/execute.js +422 -0
- package/dist/runs/journal.d.ts +150 -0
- package/dist/runs/journal.js +216 -0
- package/dist/runs/lock.d.ts +57 -0
- package/dist/runs/lock.js +322 -0
- package/dist/runs/plan.d.ts +261 -0
- package/dist/runs/plan.js +404 -0
- package/dist/search/near-match.d.ts +32 -0
- package/dist/search/near-match.js +86 -0
- package/dist/search/reader.d.ts +17 -0
- package/dist/search/reader.js +334 -0
- package/dist/search/sheet.d.ts +4 -0
- package/dist/search/sheet.js +28 -0
- package/dist/search/style-outliers.d.ts +77 -0
- package/dist/search/style-outliers.js +166 -0
- package/dist/settings-write.d.ts +78 -0
- package/dist/settings-write.js +374 -0
- package/dist/settings.d.ts +436 -0
- package/dist/settings.js +622 -0
- package/dist/shared-settings.d.ts +4 -0
- package/dist/shared-settings.js +24 -0
- package/dist/sheet/blobs.d.ts +33 -0
- package/dist/sheet/blobs.js +145 -0
- package/dist/sheet/generate.d.ts +71 -0
- package/dist/sheet/generate.js +278 -0
- package/dist/sheet/group.d.ts +20 -0
- package/dist/sheet/group.js +191 -0
- package/dist/sheet/import.d.ts +315 -0
- package/dist/sheet/import.js +832 -0
- package/dist/sheet/matte.d.ts +25 -0
- package/dist/sheet/matte.js +508 -0
- package/dist/sheet/media-import.d.ts +41 -0
- package/dist/sheet/media-import.js +118 -0
- package/dist/sheet/register.d.ts +17 -0
- package/dist/sheet/register.js +176 -0
- package/dist/sheet/slice.d.ts +73 -0
- package/dist/sheet/slice.js +912 -0
- package/dist/sheet/types.d.ts +225 -0
- package/dist/sheet/types.js +1 -0
- package/dist/source/aseprite.d.ts +14 -0
- package/dist/source/aseprite.js +124 -0
- package/dist/source/stage.d.ts +24 -0
- package/dist/source/stage.js +172 -0
- package/dist/spend.d.ts +220 -0
- package/dist/spend.js +436 -0
- package/dist/sprite/render.d.ts +22 -0
- package/dist/sprite/render.js +272 -0
- package/dist/storage.d.ts +135 -0
- package/dist/storage.js +405 -0
- package/dist/style.d.ts +19 -0
- package/dist/style.js +26 -0
- package/dist/template.d.ts +29 -0
- package/dist/template.js +98 -0
- package/dist/testing/aseprite.d.ts +54 -0
- package/dist/testing/aseprite.js +191 -0
- package/dist/testing/cli.d.ts +24 -0
- package/dist/testing/cli.js +91 -0
- package/dist/testing/conformance.d.ts +61 -0
- package/dist/testing/conformance.js +455 -0
- package/dist/testing/index.d.ts +23 -0
- package/dist/testing/index.js +15 -0
- package/dist/testing/mcp.d.ts +25 -0
- package/dist/testing/mcp.js +80 -0
- package/dist/testing/project.d.ts +81 -0
- package/dist/testing/project.js +215 -0
- package/dist/testing/samples.d.ts +42 -0
- package/dist/testing/samples.js +122 -0
- package/dist/transform/operations.d.ts +5 -0
- package/dist/transform/operations.js +320 -0
- package/dist/transform/raster-engine.d.ts +9 -0
- package/dist/transform/raster-engine.js +329 -0
- package/dist/transform/rendition.d.ts +65 -0
- package/dist/transform/rendition.js +317 -0
- package/dist/transform/run.d.ts +138 -0
- package/dist/transform/run.js +442 -0
- package/dist/transform/schema.d.ts +33 -0
- package/dist/transform/schema.js +73 -0
- package/dist/transform/types.d.ts +101 -0
- package/dist/transform/types.js +1 -0
- package/dist/tree/address.d.ts +18 -0
- package/dist/tree/address.js +59 -0
- package/dist/tree/list.d.ts +18 -0
- package/dist/tree/list.js +101 -0
- package/dist/tree/project.d.ts +61 -0
- package/dist/tree/project.js +145 -0
- package/dist/tree/read.d.ts +43 -0
- package/dist/tree/read.js +715 -0
- package/dist/tree/search.d.ts +20 -0
- package/dist/tree/search.js +44 -0
- package/dist/tree/serve.d.ts +79 -0
- package/dist/tree/serve.js +415 -0
- package/dist/tree/thumbs.d.ts +26 -0
- package/dist/tree/thumbs.js +134 -0
- package/dist/turnaround.d.ts +195 -0
- package/dist/turnaround.js +622 -0
- package/dist/types.d.ts +595 -0
- package/dist/types.js +1 -0
- package/package.json +112 -3
- package/policy/blocklist.json +47 -0
- package/policy/prompt-policy-cuts.json +15 -0
- package/skills/art-direction/SKILL.md +16 -0
- package/skills/art-direction/default.md +14 -0
- package/skills/art-direction/presets/cozy-storybook.md +121 -0
- package/skills/art-direction/presets/dark-gritty-isometric.md +121 -0
- package/skills/art-direction/presets/flat-cartoon-kids.md +121 -0
- package/skills/art-direction/references/bible-format.md +47 -0
- package/skills/assetgrove/SKILL.md +109 -0
- package/skills/assetgrove/references/commands.md +723 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C2PA content credentials (design section 6, assetgrove#251): a signed manifest in each PNG,
|
|
3
|
+
* JPEG and WebP hand-off writes, beside the IPTC mark. The manifest is built, embedded and read
|
|
4
|
+
* by the Content Authenticity Initiative's SDK (`@contentauth/c2pa-wasm`, c2pa-rs in
|
|
5
|
+
* WebAssembly); its signer callback must return a whole COSE_Sign1, which `@auth0/cose` builds.
|
|
6
|
+
* Assetgrove writes no JUMBF or COSE itself (docs/decisions.md).
|
|
7
|
+
*
|
|
8
|
+
* The signer is the developer's certificate and key from the developer settings
|
|
9
|
+
* (`contentCredentials`), or else a development certificate created once in the state directory.
|
|
10
|
+
*/
|
|
11
|
+
import { createHash, createPrivateKey, webcrypto, X509Certificate } from "node:crypto";
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import { fileURLToPath } from "node:url";
|
|
15
|
+
import * as asn1js from "asn1js";
|
|
16
|
+
import * as pkijs from "pkijs";
|
|
17
|
+
import "./pure-cbor.js";
|
|
18
|
+
import { initSync, WasmBuilder, WasmReader } from "@contentauth/c2pa-wasm";
|
|
19
|
+
import { hasC2paChunk, modelText } from "./metadata.js";
|
|
20
|
+
import { SettingsError } from "./errors.js";
|
|
21
|
+
/** The media types C2PA credentials are written into; `audio/mp4` is an AAC rendition (#553). */
|
|
22
|
+
const SIGNABLE = new Set(["image/png", "image/jpeg", "image/webp", "audio/wav", "audio/mp4"]);
|
|
23
|
+
/** The assertion that names the sha256 of the bytes a manifest was signed over. */
|
|
24
|
+
export const INPUT_ASSERTION = "org.clockgrove.assetgrove.input";
|
|
25
|
+
/** The development certificate's directory under the state directory. */
|
|
26
|
+
export const DEVELOPMENT_DIR = "content-credentials";
|
|
27
|
+
/** Validation codes that do not fail the check: no trust list is configured. */
|
|
28
|
+
const ACCEPTED_FAILURES = new Set(["signingCredential.untrusted"]);
|
|
29
|
+
/** What a result says when the local development certificate signed. */
|
|
30
|
+
export const DEVELOPMENT_SIGNER_WARNING = "signed with Assetgrove's local development certificate, which no C2PA trust list holds; set contentCredentials in the developer settings to sign with your own certificate";
|
|
31
|
+
/** Whether a media type is one C2PA credentials are written into. */
|
|
32
|
+
export function canCarryCredentials(mediaType) {
|
|
33
|
+
return SIGNABLE.has(mediaType);
|
|
34
|
+
}
|
|
35
|
+
/** The COSE algorithm of each signing algorithm, from the COSE SDK's own table. */
|
|
36
|
+
function coseAlg(algorithms, alg) {
|
|
37
|
+
const table = {
|
|
38
|
+
es256: algorithms.ES256,
|
|
39
|
+
es384: algorithms.ES384,
|
|
40
|
+
ps256: algorithms.PS256,
|
|
41
|
+
ed25519: algorithms.EdDSA,
|
|
42
|
+
};
|
|
43
|
+
return table[alg];
|
|
44
|
+
}
|
|
45
|
+
let loaded = false;
|
|
46
|
+
const BYTES = Symbol("bytes");
|
|
47
|
+
/** A Blob whose bytes the SDK can read synchronously in Node, through `FileReaderSync`. */
|
|
48
|
+
class BytesBlob extends Blob {
|
|
49
|
+
[BYTES];
|
|
50
|
+
constructor(bytes) {
|
|
51
|
+
super([bytes]);
|
|
52
|
+
this[BYTES] = bytes;
|
|
53
|
+
}
|
|
54
|
+
slice(start = 0, end = this[BYTES].length) {
|
|
55
|
+
return new BytesBlob(this[BYTES].subarray(start, end));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** Initialises the SDK once. The SDK reads a Blob with the browser's `FileReaderSync`. */
|
|
59
|
+
function sdk() {
|
|
60
|
+
if (loaded)
|
|
61
|
+
return;
|
|
62
|
+
const g = globalThis;
|
|
63
|
+
if (g["FileReaderSync"] === undefined) {
|
|
64
|
+
g["FileReaderSync"] = class {
|
|
65
|
+
readAsArrayBuffer(blob) {
|
|
66
|
+
const bytes = blob[BYTES];
|
|
67
|
+
if (bytes === undefined)
|
|
68
|
+
throw new TypeError("only in-memory bytes can be read");
|
|
69
|
+
// A copy: a Buffer's slice is a view onto its whole pool.
|
|
70
|
+
return new Uint8Array(bytes).buffer;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const wasm = fileURLToPath(import.meta.resolve("@contentauth/c2pa-wasm/c2pa.wasm"));
|
|
75
|
+
initSync({ module: readFileSync(wasm) });
|
|
76
|
+
loaded = true;
|
|
77
|
+
}
|
|
78
|
+
function algOf(key) {
|
|
79
|
+
const type = key.asymmetricKeyType;
|
|
80
|
+
if (type === "ed25519")
|
|
81
|
+
return "ed25519";
|
|
82
|
+
if (type === "rsa" || type === "rsa-pss")
|
|
83
|
+
return "ps256";
|
|
84
|
+
if (type === "ec") {
|
|
85
|
+
const curve = key.asymmetricKeyDetails?.namedCurve;
|
|
86
|
+
if (curve === "prime256v1" || curve === "P-256")
|
|
87
|
+
return "es256";
|
|
88
|
+
if (curve === "secp384r1" || curve === "P-384")
|
|
89
|
+
return "es384";
|
|
90
|
+
}
|
|
91
|
+
throw new SettingsError(`contentCredentials.privateKey is a ${type ?? "unknown"} key; use ECDSA P-256 or P-384, Ed25519 or RSA`);
|
|
92
|
+
}
|
|
93
|
+
function pemCertificates(pem) {
|
|
94
|
+
return [...pem.matchAll(/-----BEGIN CERTIFICATE-----([\s\S]*?)-----END CERTIFICATE-----/g)].map((m) => new Uint8Array(new X509Certificate(m[0]).raw));
|
|
95
|
+
}
|
|
96
|
+
function signerOf(chain, key, development) {
|
|
97
|
+
const leaf = new X509Certificate(chain[0]);
|
|
98
|
+
return {
|
|
99
|
+
key,
|
|
100
|
+
chain,
|
|
101
|
+
record: {
|
|
102
|
+
development,
|
|
103
|
+
certificateSha256: createHash("sha256").update(chain[0]).digest("hex"),
|
|
104
|
+
subject: leaf.subject.replaceAll("\n", ", "),
|
|
105
|
+
issuer: leaf.issuer.replaceAll("\n", ", "),
|
|
106
|
+
serialNumber: leaf.serialNumber,
|
|
107
|
+
alg: algOf(key),
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** The developer's signer, read from the files the developer settings name. */
|
|
112
|
+
export function settingsSigner(settings) {
|
|
113
|
+
let pem;
|
|
114
|
+
let keyPem;
|
|
115
|
+
try {
|
|
116
|
+
pem = readFileSync(settings.certificate, "utf8");
|
|
117
|
+
keyPem = readFileSync(settings.privateKey, "utf8");
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
throw new SettingsError(`contentCredentials: cannot read ${error.path ?? "a file"}`, { cause: error });
|
|
121
|
+
}
|
|
122
|
+
const chain = pemCertificates(pem);
|
|
123
|
+
if (chain.length === 0)
|
|
124
|
+
throw new SettingsError(`contentCredentials.certificate ${settings.certificate} holds no certificate`);
|
|
125
|
+
let key;
|
|
126
|
+
try {
|
|
127
|
+
key = createPrivateKey(keyPem);
|
|
128
|
+
}
|
|
129
|
+
catch (error) {
|
|
130
|
+
throw new SettingsError(`contentCredentials.privateKey ${settings.privateKey} is not a PEM private key`, { cause: error });
|
|
131
|
+
}
|
|
132
|
+
return signerOf(chain, key, false);
|
|
133
|
+
}
|
|
134
|
+
const pem = (label, der) => `-----BEGIN ${label}-----\n${Buffer.from(der)
|
|
135
|
+
.toString("base64")
|
|
136
|
+
.replace(/(.{64})/g, "$1\n")
|
|
137
|
+
.trimEnd()}\n-----END ${label}-----\n`;
|
|
138
|
+
function name(common) {
|
|
139
|
+
return new pkijs.RelativeDistinguishedNames({
|
|
140
|
+
typesAndValues: [
|
|
141
|
+
new pkijs.AttributeTypeAndValue({
|
|
142
|
+
type: "2.5.4.3",
|
|
143
|
+
value: new asn1js.Utf8String({ value: common }),
|
|
144
|
+
}),
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
const keyUsage = (bits, unused) => new pkijs.Extension({
|
|
149
|
+
extnID: "2.5.29.15",
|
|
150
|
+
critical: true,
|
|
151
|
+
extnValue: new asn1js.BitString({
|
|
152
|
+
valueHex: new Uint8Array([bits]).buffer,
|
|
153
|
+
unusedBits: unused,
|
|
154
|
+
}).toBER(false),
|
|
155
|
+
});
|
|
156
|
+
async function keyId(key) {
|
|
157
|
+
const spki = await webcrypto.subtle.exportKey("spki", key);
|
|
158
|
+
const info = new pkijs.PublicKeyInfo({ schema: asn1js.fromBER(spki).result });
|
|
159
|
+
return webcrypto.subtle.digest("SHA-1", info.subjectPublicKey.valueBlock.valueHexView);
|
|
160
|
+
}
|
|
161
|
+
async function certificate(input) {
|
|
162
|
+
const cert = new pkijs.Certificate();
|
|
163
|
+
cert.version = 2;
|
|
164
|
+
cert.serialNumber = new asn1js.Integer({ value: input.serial });
|
|
165
|
+
cert.issuer = name(input.issuer);
|
|
166
|
+
cert.subject = name(input.subject);
|
|
167
|
+
cert.notBefore.value = new Date(input.now.getTime() - 24 * 3600 * 1000);
|
|
168
|
+
cert.notAfter.value = new Date(input.now.getTime() + 10 * 365 * 24 * 3600 * 1000);
|
|
169
|
+
const basic = new pkijs.BasicConstraints({ cA: input.ca });
|
|
170
|
+
cert.extensions = [
|
|
171
|
+
new pkijs.Extension({
|
|
172
|
+
extnID: "2.5.29.19",
|
|
173
|
+
critical: true,
|
|
174
|
+
extnValue: basic.toSchema().toBER(false),
|
|
175
|
+
}),
|
|
176
|
+
// keyCertSign and cRLSign for the CA, digitalSignature for the signer.
|
|
177
|
+
input.ca ? keyUsage(0x06, 1) : keyUsage(0x80, 7),
|
|
178
|
+
new pkijs.Extension({
|
|
179
|
+
extnID: "2.5.29.14",
|
|
180
|
+
extnValue: new asn1js.OctetString({ valueHex: await keyId(input.publicKey) }).toBER(false),
|
|
181
|
+
}),
|
|
182
|
+
];
|
|
183
|
+
if (!input.ca) {
|
|
184
|
+
cert.extensions.push(new pkijs.Extension({
|
|
185
|
+
extnID: "2.5.29.37",
|
|
186
|
+
extnValue: new pkijs.ExtKeyUsage({ keyPurposes: ["1.3.6.1.5.5.7.3.4"] })
|
|
187
|
+
.toSchema()
|
|
188
|
+
.toBER(false),
|
|
189
|
+
}), new pkijs.Extension({
|
|
190
|
+
extnID: "2.5.29.35",
|
|
191
|
+
extnValue: new pkijs.AuthorityKeyIdentifier({
|
|
192
|
+
keyIdentifier: new asn1js.OctetString({ valueHex: await keyId(input.issuerKey) }),
|
|
193
|
+
})
|
|
194
|
+
.toSchema()
|
|
195
|
+
.toBER(false),
|
|
196
|
+
}));
|
|
197
|
+
}
|
|
198
|
+
await cert.subjectPublicKeyInfo.importKey(input.publicKey, pkijs.getCrypto(true));
|
|
199
|
+
await cert.sign(input.signingKey, "SHA-256", pkijs.getCrypto(true));
|
|
200
|
+
return new Uint8Array(cert.toSchema(true).toBER(false));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The local development signer: a CA and a signer certificate (c2pa-rs refuses a self-signed
|
|
204
|
+
* signer), ECDSA P-256, created once under `<stateDir>/content-credentials/` and reused. The CA's
|
|
205
|
+
* certificate is written beside them as `ca.pem`, so a reader can be told to trust it.
|
|
206
|
+
*/
|
|
207
|
+
export async function developmentSigner(stateDir) {
|
|
208
|
+
const dir = join(stateDir, DEVELOPMENT_DIR);
|
|
209
|
+
const chainPath = join(dir, "chain.pem");
|
|
210
|
+
const keyPath = join(dir, "signer.key");
|
|
211
|
+
if (!existsSync(chainPath) || !existsSync(keyPath)) {
|
|
212
|
+
pkijs.setEngine("node", new pkijs.CryptoEngine({ name: "node", crypto: webcrypto }));
|
|
213
|
+
const alg = { name: "ECDSA", namedCurve: "P-256" };
|
|
214
|
+
const ca = await webcrypto.subtle.generateKey(alg, true, ["sign", "verify"]);
|
|
215
|
+
const signer = await webcrypto.subtle.generateKey(alg, true, ["sign", "verify"]);
|
|
216
|
+
const now = new Date();
|
|
217
|
+
const caName = "Assetgrove development CA (not trusted)";
|
|
218
|
+
const caDer = await certificate({
|
|
219
|
+
serial: 1,
|
|
220
|
+
subject: caName,
|
|
221
|
+
issuer: caName,
|
|
222
|
+
publicKey: ca.publicKey,
|
|
223
|
+
signingKey: ca.privateKey,
|
|
224
|
+
issuerKey: ca.publicKey,
|
|
225
|
+
ca: true,
|
|
226
|
+
now,
|
|
227
|
+
});
|
|
228
|
+
const leafDer = await certificate({
|
|
229
|
+
serial: 2,
|
|
230
|
+
subject: "Assetgrove development signer (not trusted)",
|
|
231
|
+
issuer: caName,
|
|
232
|
+
publicKey: signer.publicKey,
|
|
233
|
+
signingKey: ca.privateKey,
|
|
234
|
+
issuerKey: ca.publicKey,
|
|
235
|
+
ca: false,
|
|
236
|
+
now,
|
|
237
|
+
});
|
|
238
|
+
const key = new Uint8Array(await webcrypto.subtle.exportKey("pkcs8", signer.privateKey));
|
|
239
|
+
mkdirSync(dir, { recursive: true });
|
|
240
|
+
writeFileSync(join(dir, "ca.pem"), pem("CERTIFICATE", caDer));
|
|
241
|
+
writeFileSync(`${keyPath}.tmp`, pem("PRIVATE KEY", key), { mode: 0o600 });
|
|
242
|
+
renameSync(`${keyPath}.tmp`, keyPath);
|
|
243
|
+
writeFileSync(`${chainPath}.tmp`, pem("CERTIFICATE", leafDer) + pem("CERTIFICATE", caDer));
|
|
244
|
+
renameSync(`${chainPath}.tmp`, chainPath);
|
|
245
|
+
}
|
|
246
|
+
const chain = pemCertificates(readFileSync(chainPath, "utf8"));
|
|
247
|
+
return signerOf(chain, createPrivateKey(readFileSync(keyPath, "utf8")), true);
|
|
248
|
+
}
|
|
249
|
+
/** The signer the developer settings choose: their certificate, else the development one. */
|
|
250
|
+
export async function resolveSigner(settings) {
|
|
251
|
+
return settings.contentCredentials
|
|
252
|
+
? settingsSigner(settings.contentCredentials)
|
|
253
|
+
: developmentSigner(settings.stateDir);
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* The signer `resolveSigner` would give, without creating anything: undefined when the settings
|
|
257
|
+
* name none and the development certificate does not exist yet. For a preview, which never writes.
|
|
258
|
+
*/
|
|
259
|
+
export async function existingSigner(settings) {
|
|
260
|
+
if (settings.contentCredentials)
|
|
261
|
+
return settingsSigner(settings.contentCredentials);
|
|
262
|
+
const dir = join(settings.stateDir, DEVELOPMENT_DIR);
|
|
263
|
+
if (!existsSync(join(dir, "chain.pem")) || !existsSync(join(dir, "signer.key")))
|
|
264
|
+
return undefined;
|
|
265
|
+
return developmentSigner(settings.stateDir);
|
|
266
|
+
}
|
|
267
|
+
const IPTC = "http://cv.iptc.org/newscodes/digitalsourcetype/";
|
|
268
|
+
/** The `c2pa.actions.v2` actions a claim records. */
|
|
269
|
+
function actions(claim) {
|
|
270
|
+
const models = modelText(claim.models);
|
|
271
|
+
const agent = models === undefined ? {} : { softwareAgent: { name: models } };
|
|
272
|
+
const source = claim.digitalSourceType === "undeclared" ? {} : { digitalSourceType: claim.digitalSourceType };
|
|
273
|
+
if (claim.original === undefined)
|
|
274
|
+
return [{ action: "c2pa.created", ...source, ...agent }];
|
|
275
|
+
return [
|
|
276
|
+
{ action: "c2pa.opened", parameters: { ingredientIds: ["original"] } },
|
|
277
|
+
{
|
|
278
|
+
action: "c2pa.edited",
|
|
279
|
+
description: "A person's hand edit of the AI-made original, adopted into the library",
|
|
280
|
+
digitalSourceType: `${IPTC}compositeWithTrainedAlgorithmicMedia`,
|
|
281
|
+
...agent,
|
|
282
|
+
},
|
|
283
|
+
];
|
|
284
|
+
}
|
|
285
|
+
/** The sha256 of bytes, as hex. */
|
|
286
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
287
|
+
/**
|
|
288
|
+
* COSE_Sign1 with a detached payload and a `pad` header that fills the reserved space exactly. The
|
|
289
|
+
* COSE SDK is imported here, on first use, so a process that signs nothing never loads it.
|
|
290
|
+
*/
|
|
291
|
+
async function coseSign(signer, claim, size) {
|
|
292
|
+
const { Algorithms, Headers, ProtectedHeaders, Sign1 } = await import("@auth0/cose");
|
|
293
|
+
const signed = await Sign1.sign(new ProtectedHeaders([
|
|
294
|
+
[Headers.Algorithm, coseAlg(Algorithms, signer.record.alg)],
|
|
295
|
+
[Headers.X5Chain, signer.chain.length === 1 ? signer.chain[0] : signer.chain],
|
|
296
|
+
]), undefined, claim, signer.key);
|
|
297
|
+
// The payload is detached (C2PA: the claim is the payload, carried beside the signature).
|
|
298
|
+
const encode = (pad) => new Sign1(
|
|
299
|
+
// The protected header exactly as signed.
|
|
300
|
+
signed.encodedProtectedHeaders, new Map([["pad", new Uint8Array(pad)]]), null, signed.signature).encode();
|
|
301
|
+
let pad = 0;
|
|
302
|
+
let out = encode(pad);
|
|
303
|
+
for (let i = 0; i < 4 && out.length !== size; i++) {
|
|
304
|
+
pad = Math.max(0, pad + size - out.length);
|
|
305
|
+
out = encode(pad);
|
|
306
|
+
}
|
|
307
|
+
if (out.length !== size)
|
|
308
|
+
throw new Error(`the COSE signature is ${out.length} bytes, not ${size}`);
|
|
309
|
+
return out;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Signs `bytes` with the manifest `definition` and `ingredients` (a C2PA manifest definition as
|
|
313
|
+
* the SDK's builder takes it); returns the signed bytes. `signCredentials` is Assetgrove's own
|
|
314
|
+
* manifest; this is the primitive under it.
|
|
315
|
+
*/
|
|
316
|
+
export async function signManifest(bytes, mediaType, definition, signer, ingredients = [], options = {}) {
|
|
317
|
+
sdk();
|
|
318
|
+
const builder = WasmBuilder.fromJson(JSON.stringify(definition));
|
|
319
|
+
try {
|
|
320
|
+
if (options.sidecar === true)
|
|
321
|
+
builder.setNoEmbed(true);
|
|
322
|
+
for (const ingredient of ingredients) {
|
|
323
|
+
await builder.addIngredientFromBlob(JSON.stringify(ingredient.definition), ingredient.mediaType, new BytesBlob(ingredient.bytes));
|
|
324
|
+
}
|
|
325
|
+
const size = signer.chain.reduce((n, der) => n + der.length, 0) + 4096;
|
|
326
|
+
const definitionOfSigner = {
|
|
327
|
+
alg: signer.record.alg,
|
|
328
|
+
reserveSize: size,
|
|
329
|
+
sign: async (data) => (await coseSign(signer, data, size)),
|
|
330
|
+
};
|
|
331
|
+
if (options.sidecar === true) {
|
|
332
|
+
// The asset is left as it is; the manifest store is returned, for a `.c2pa` sidecar.
|
|
333
|
+
const result = (await builder.signAndGetManifestBytes(definitionOfSigner, [], mediaType, new BytesBlob(bytes)));
|
|
334
|
+
return new Uint8Array(result.manifest);
|
|
335
|
+
}
|
|
336
|
+
const signed = await builder.sign(definitionOfSigner, [], mediaType, new BytesBlob(bytes));
|
|
337
|
+
return new Uint8Array(signed);
|
|
338
|
+
}
|
|
339
|
+
finally {
|
|
340
|
+
builder.free();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Whether `bytes` carry a C2PA manifest another tool made: a vendor's, not one Assetgrove signed
|
|
345
|
+
* (Assetgrove's own carries `INPUT_ASSERTION`). Only WAV is asked: the other signable types are
|
|
346
|
+
* staged unsigned.
|
|
347
|
+
*/
|
|
348
|
+
async function vendorManifest(bytes, mediaType) {
|
|
349
|
+
if (mediaType !== "audio/wav" || !hasC2paChunk(bytes))
|
|
350
|
+
return false;
|
|
351
|
+
const read = await readCredentials(bytes, mediaType);
|
|
352
|
+
return read !== undefined && read.inputSha256 === undefined;
|
|
353
|
+
}
|
|
354
|
+
/** Assetgrove's own manifest definition for `claim` over `bytes`. */
|
|
355
|
+
function ownDefinition(bytes, mediaType, claim, signer, version) {
|
|
356
|
+
return {
|
|
357
|
+
claim_generator_info: [{ name: "Assetgrove", version }],
|
|
358
|
+
title: claim.title,
|
|
359
|
+
format: mediaType,
|
|
360
|
+
assertions: [
|
|
361
|
+
{ label: "c2pa.actions.v2", data: { actions: actions(claim) } },
|
|
362
|
+
{
|
|
363
|
+
label: INPUT_ASSERTION,
|
|
364
|
+
data: {
|
|
365
|
+
sha256: sha256(bytes),
|
|
366
|
+
certificateSha256: signer.record.certificateSha256,
|
|
367
|
+
development: signer.record.development,
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
],
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/** Signs `bytes` (already IPTC-marked) with a manifest for `claim`; returns the signed bytes. */
|
|
374
|
+
export async function signCredentials(bytes, mediaType, claim, signer, version) {
|
|
375
|
+
const definition = ownDefinition(bytes, mediaType, claim, signer, version);
|
|
376
|
+
const ingredients = [];
|
|
377
|
+
if (claim.original) {
|
|
378
|
+
ingredients.push({
|
|
379
|
+
definition: { title: claim.original.title, relationship: "parentOf", label: "original" },
|
|
380
|
+
mediaType: claim.original.mediaType,
|
|
381
|
+
bytes: claim.original.bytes,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
else if (await vendorManifest(bytes, mediaType)) {
|
|
385
|
+
// A vendor's manifest in the source is replaced by ours; it stays as an ingredient. A
|
|
386
|
+
// manifest Assetgrove signed (a handed-off master fed back in) is only replaced.
|
|
387
|
+
ingredients.push({
|
|
388
|
+
definition: { title: `vendor ${claim.title}`, relationship: "componentOf", label: "vendor" },
|
|
389
|
+
mediaType,
|
|
390
|
+
bytes,
|
|
391
|
+
});
|
|
392
|
+
}
|
|
393
|
+
return signManifest(bytes, mediaType, definition, signer, ingredients);
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Reads and validates the active manifest of `bytes`; undefined when there is none. Offline: no
|
|
397
|
+
* OCSP or remote manifest fetch. `trustAnchors` (PEM) are certificates to trust.
|
|
398
|
+
*/
|
|
399
|
+
export async function readCredentials(bytes, mediaType, trustAnchors) {
|
|
400
|
+
sdk();
|
|
401
|
+
const context = {
|
|
402
|
+
verify: { ocsp_fetch: false, remote_manifest_fetch: false },
|
|
403
|
+
...(trustAnchors !== undefined && { trust: { trust_anchors: trustAnchors } }),
|
|
404
|
+
};
|
|
405
|
+
let reader;
|
|
406
|
+
try {
|
|
407
|
+
reader = await WasmReader.fromBytes(mediaType, bytes, JSON.stringify(context));
|
|
408
|
+
}
|
|
409
|
+
catch (error) {
|
|
410
|
+
if (/JumbfNotFound|ProvenanceMissing|NotFound/.test(String(error)))
|
|
411
|
+
return undefined;
|
|
412
|
+
return {
|
|
413
|
+
state: "Invalid",
|
|
414
|
+
failures: [{ code: "manifest.unreadable", explanation: String(error) }],
|
|
415
|
+
trusted: false,
|
|
416
|
+
actions: [],
|
|
417
|
+
ingredients: [],
|
|
418
|
+
signer: {},
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
try {
|
|
422
|
+
const store = JSON.parse(reader.json());
|
|
423
|
+
const manifest = store.manifests?.[store.active_manifest ?? ""];
|
|
424
|
+
if (manifest === undefined)
|
|
425
|
+
return undefined;
|
|
426
|
+
const results = store.validation_results?.activeManifest;
|
|
427
|
+
const failures = (results?.failure ?? store.validation_status ?? [])
|
|
428
|
+
.filter((f) => !ACCEPTED_FAILURES.has(f.code))
|
|
429
|
+
.map((f) => ({
|
|
430
|
+
code: f.code,
|
|
431
|
+
...(f.explanation !== undefined && { explanation: f.explanation }),
|
|
432
|
+
}));
|
|
433
|
+
const assertions = manifest.assertions ?? [];
|
|
434
|
+
const actionList = assertions
|
|
435
|
+
.filter((a) => a.label === "c2pa.actions.v2" || a.label === "c2pa.actions")
|
|
436
|
+
.flatMap((a) => Array.isArray(a.data?.["actions"]) ? a.data["actions"] : [])
|
|
437
|
+
.map((a) => ({
|
|
438
|
+
action: String(a["action"]),
|
|
439
|
+
...(typeof a["digitalSourceType"] === "string" && {
|
|
440
|
+
digitalSourceType: a["digitalSourceType"],
|
|
441
|
+
}),
|
|
442
|
+
...(typeof a["softwareAgent"]?.name === "string" && {
|
|
443
|
+
softwareAgent: a["softwareAgent"].name,
|
|
444
|
+
}),
|
|
445
|
+
}));
|
|
446
|
+
const own = assertions.find((a) => a.label === INPUT_ASSERTION)?.data ?? {};
|
|
447
|
+
const input = own["sha256"];
|
|
448
|
+
const certificate = own["certificateSha256"];
|
|
449
|
+
const info = manifest.signature_info ?? {};
|
|
450
|
+
return {
|
|
451
|
+
state: store.validation_state ?? "Invalid",
|
|
452
|
+
failures,
|
|
453
|
+
trusted: (results?.success ?? []).some((s) => s.code === "signingCredential.trusted"),
|
|
454
|
+
actions: actionList,
|
|
455
|
+
...(typeof input === "string" && { inputSha256: input }),
|
|
456
|
+
...(typeof certificate === "string" && { certificateSha256: certificate }),
|
|
457
|
+
...(typeof own["development"] === "boolean" && { development: own["development"] }),
|
|
458
|
+
ingredients: (manifest.ingredients ?? []).map((i) => ({
|
|
459
|
+
...(i.title !== undefined && { title: i.title }),
|
|
460
|
+
...(i.relationship !== undefined && { relationship: i.relationship }),
|
|
461
|
+
})),
|
|
462
|
+
signer: {
|
|
463
|
+
...(info.common_name !== undefined && { subject: info.common_name }),
|
|
464
|
+
...(info.issuer !== undefined && { issuer: info.issuer }),
|
|
465
|
+
...(info.cert_serial_number !== undefined && { serialNumber: info.cert_serial_number }),
|
|
466
|
+
},
|
|
467
|
+
};
|
|
468
|
+
}
|
|
469
|
+
finally {
|
|
470
|
+
reader.free();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
/** One problem with a written file's credentials; undefined when they hold. */
|
|
474
|
+
export async function credentialProblem(path, bytes, mediaType, expected) {
|
|
475
|
+
return problemOf(path, await readCredentials(bytes, mediaType), expected);
|
|
476
|
+
}
|
|
477
|
+
function problemOf(path, read, expected) {
|
|
478
|
+
if (read === undefined)
|
|
479
|
+
return { code: "credentials_missing", problem: `${path} lacks its C2PA content credentials` };
|
|
480
|
+
const binding = read.failures.find((f) => /^assertion\.(dataHash|bmffHash|boxesHash)\./.test(f.code));
|
|
481
|
+
if (binding)
|
|
482
|
+
return {
|
|
483
|
+
code: "credentials_mismatch",
|
|
484
|
+
problem: `${path}'s C2PA manifest does not match its bytes (${binding.code})`,
|
|
485
|
+
};
|
|
486
|
+
if (read.failures.length > 0 || read.state === "Invalid")
|
|
487
|
+
return {
|
|
488
|
+
code: "credentials_invalid",
|
|
489
|
+
problem: `${path}'s C2PA manifest is invalid (${read.failures.map((f) => f.code).join(", ") || read.state})`,
|
|
490
|
+
};
|
|
491
|
+
const wanted = expectedActions(expected);
|
|
492
|
+
const got = read.actions.map((a) => a.action);
|
|
493
|
+
const lastAction = read.actions.at(-1);
|
|
494
|
+
const models = modelText(expected.models);
|
|
495
|
+
if (got.join(",") !== wanted.join(",") ||
|
|
496
|
+
(expected.adopted !== true &&
|
|
497
|
+
expected.digitalSourceType !== "undeclared" &&
|
|
498
|
+
lastAction?.digitalSourceType !== expected.digitalSourceType) ||
|
|
499
|
+
(models !== undefined && lastAction?.softwareAgent !== models) ||
|
|
500
|
+
(expected.adopted === true && !read.ingredients.some((i) => i.relationship === "parentOf")))
|
|
501
|
+
return {
|
|
502
|
+
code: "credentials_invalid",
|
|
503
|
+
problem: `${path}'s C2PA manifest does not record ${wanted.join(" then ")} with the provenance's source type and models`,
|
|
504
|
+
};
|
|
505
|
+
return undefined;
|
|
506
|
+
}
|
|
507
|
+
function expectedActions(expected) {
|
|
508
|
+
return expected.adopted === true ? ["c2pa.opened", "c2pa.edited"] : ["c2pa.created"];
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* The bytes to write for a file: `existing` (the file already at the destination) when its
|
|
512
|
+
* manifest validates, was signed over these same `bytes` by the same certificate and records the
|
|
513
|
+
* same claim, so an unchanged asset keeps its bytes; else `bytes` newly signed.
|
|
514
|
+
*/
|
|
515
|
+
export async function credentialed(bytes, mediaType, claim, signer, version, existing) {
|
|
516
|
+
if (existing !== undefined) {
|
|
517
|
+
const read = await readCredentials(existing, mediaType).catch(() => undefined);
|
|
518
|
+
const problem = read === undefined
|
|
519
|
+
? "missing"
|
|
520
|
+
: await credentialProblem("", existing, mediaType, {
|
|
521
|
+
digitalSourceType: claim.digitalSourceType,
|
|
522
|
+
models: claim.models,
|
|
523
|
+
...(claim.original !== undefined && { adopted: true }),
|
|
524
|
+
});
|
|
525
|
+
if (read !== undefined &&
|
|
526
|
+
problem === undefined &&
|
|
527
|
+
read.inputSha256 === sha256(bytes) &&
|
|
528
|
+
read.certificateSha256 === signer.record.certificateSha256)
|
|
529
|
+
return existing;
|
|
530
|
+
}
|
|
531
|
+
return signCredentials(bytes, mediaType, claim, signer, version);
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* The media types whose C2PA manifest is a sidecar: c2pa-rs has no asset handler that embeds one
|
|
535
|
+
* in an Ogg, so an Ogg rendition carries `<stem>.c2pa` beside it (docs/PRD-audio.md, "Marks").
|
|
536
|
+
*/
|
|
537
|
+
const SIDECAR = new Set(["audio/ogg"]);
|
|
538
|
+
/** Whether a media type's credentials are a sidecar manifest rather than embedded. */
|
|
539
|
+
export function takesSidecar(mediaType) {
|
|
540
|
+
return SIDECAR.has(mediaType);
|
|
541
|
+
}
|
|
542
|
+
/** The C2PA sidecar's file name for an asset's: its stem and `.c2pa`. */
|
|
543
|
+
export function sidecarName(assetName) {
|
|
544
|
+
return `${assetName.replace(/\.[^./\\]+$/, "")}.c2pa`;
|
|
545
|
+
}
|
|
546
|
+
/** Signs a sidecar manifest store for `bytes` (already marked), which stay as they are. */
|
|
547
|
+
export async function signSidecarCredentials(bytes, mediaType, claim, signer, version) {
|
|
548
|
+
const definition = ownDefinition(bytes, mediaType, claim, signer, version);
|
|
549
|
+
return signManifest(bytes, mediaType, definition, signer, [], { sidecar: true });
|
|
550
|
+
}
|
|
551
|
+
/** The data-hash failure the SDK reports when it reads a sidecar without its asset. */
|
|
552
|
+
const SIDECAR_DATA_HASH = /^assertion\.dataHash\./;
|
|
553
|
+
/**
|
|
554
|
+
* Reads and validates a sidecar manifest store for the asset `bytes`; undefined when `manifest`
|
|
555
|
+
* holds none. c2pa-wasm reads a manifest store only on its own, so it checks the data hash over
|
|
556
|
+
* the store itself, not the asset; that result is set aside. The store binds the asset through
|
|
557
|
+
* Assetgrove's signed input assertion instead, whose sha256 must be the asset's
|
|
558
|
+
* (docs/decisions.md).
|
|
559
|
+
*/
|
|
560
|
+
export async function readSidecarCredentials(manifest, bytes, trustAnchors) {
|
|
561
|
+
const read = await readCredentials(manifest, "application/c2pa", trustAnchors);
|
|
562
|
+
if (read === undefined)
|
|
563
|
+
return undefined;
|
|
564
|
+
if (read.failures.some((f) => f.code === "manifest.unreadable"))
|
|
565
|
+
return read;
|
|
566
|
+
const failures = read.failures.filter((f) => !SIDECAR_DATA_HASH.test(f.code));
|
|
567
|
+
const asset = sha256(bytes);
|
|
568
|
+
if (read.inputSha256 !== asset)
|
|
569
|
+
failures.push({
|
|
570
|
+
code: "assertion.dataHash.mismatch",
|
|
571
|
+
explanation: `the sidecar was signed over sha256 ${read.inputSha256 ?? "(none named)"}, the asset is ${asset}`,
|
|
572
|
+
});
|
|
573
|
+
const state = failures.length === 0 && read.state === "Invalid" ? "Valid" : read.state;
|
|
574
|
+
return { ...read, state: failures.length > 0 ? "Invalid" : state, failures };
|
|
575
|
+
}
|
|
576
|
+
/** One problem with an asset's sidecar credentials; undefined when they hold. */
|
|
577
|
+
export async function sidecarCredentialProblem(path, manifest, bytes, expected) {
|
|
578
|
+
const read = manifest === undefined ? undefined : await readSidecarCredentials(manifest, bytes);
|
|
579
|
+
return problemOf(path, read, expected);
|
|
580
|
+
}
|
|
581
|
+
/** Whether an existing sidecar still holds for these bytes, this claim and this signer's certificate. */
|
|
582
|
+
export async function sidecarHolds(bytes, claim, signer, existing) {
|
|
583
|
+
const read = await readSidecarCredentials(existing, bytes).catch(() => undefined);
|
|
584
|
+
return (read !== undefined &&
|
|
585
|
+
read.certificateSha256 === signer.record.certificateSha256 &&
|
|
586
|
+
problemOf("", read, { digitalSourceType: claim.digitalSourceType, models: claim.models }) ===
|
|
587
|
+
undefined);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* The sidecar to write for an asset: `existing` when it validates, was signed over these same
|
|
591
|
+
* `bytes` by the same certificate and records the same claim, so an unchanged rendition keeps
|
|
592
|
+
* its sidecar; else a newly signed one.
|
|
593
|
+
*/
|
|
594
|
+
export async function sidecarCredentialed(bytes, mediaType, claim, signer, version, existing) {
|
|
595
|
+
if (existing !== undefined && (await sidecarHolds(bytes, claim, signer, existing)))
|
|
596
|
+
return existing;
|
|
597
|
+
return signSidecarCredentials(bytes, mediaType, claim, signer, version);
|
|
598
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where each configured operation's data goes (design section 13): the provider and host its route
|
|
3
|
+
* calls, the model vendor behind a gateway route, and the terms recorded for it. init shows it; the
|
|
4
|
+
* terms are recorded, not a licence.
|
|
5
|
+
*/
|
|
6
|
+
import type { Env } from "./env.ts";
|
|
7
|
+
import { type ProviderAdapter } from "./providers/adapter.ts";
|
|
8
|
+
import type { Settings } from "./settings.ts";
|
|
9
|
+
export interface RouteDataFlow {
|
|
10
|
+
operation: string;
|
|
11
|
+
providerId: string;
|
|
12
|
+
/** The host its calls reach; null for a provider that reaches none (the scripted one). */
|
|
13
|
+
host: string | null;
|
|
14
|
+
/** The model vendor behind a gateway route (the model id's prefix); null for a direct route. */
|
|
15
|
+
upstream: string | null;
|
|
16
|
+
/** The provider terms recorded for its (provider, model) pair; null when none are. */
|
|
17
|
+
providerTerms: string | null;
|
|
18
|
+
/** `local` when its data stays on this machine; null when no retention is recorded. */
|
|
19
|
+
retention: "local" | null;
|
|
20
|
+
}
|
|
21
|
+
/** The model vendor behind a gateway route (the model id's prefix); null for a direct route. */
|
|
22
|
+
export declare function upstreamOf(adapterId: string, model: string): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* One entry per operation the settings route (an operation no configured provider serves, or
|
|
25
|
+
* that several could and none is chosen, is left out), in the role table's order. Makes no call and reads no key.
|
|
26
|
+
*/
|
|
27
|
+
export declare function routeDataFlows(settings: Pick<Settings, "providers" | "roles" | "routes" | "path">, options?: {
|
|
28
|
+
env?: Env;
|
|
29
|
+
adapters?: readonly ProviderAdapter[];
|
|
30
|
+
/** Core's operation roles plus the loaded kinds' (`ExtensionRegistry.operations`). */
|
|
31
|
+
operations?: Readonly<Record<string, string>>;
|
|
32
|
+
}): RouteDataFlow[];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createProviders } from "./providers/adapter.js";
|
|
2
|
+
import { knownOperations, resolveRoute, RouteAmbiguousError, RouteUnavailableError, } from "./routes.js";
|
|
3
|
+
import { isLoopback } from "./settings.js";
|
|
4
|
+
/** The model vendor behind a gateway route (the model id's prefix); null for a direct route. */
|
|
5
|
+
export function upstreamOf(adapterId, model) {
|
|
6
|
+
const slash = model.indexOf("/");
|
|
7
|
+
return adapterId === "vercel-ai-gateway" && slash > 0 ? model.slice(0, slash) : null;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* One entry per operation the settings route (an operation no configured provider serves, or
|
|
11
|
+
* that several could and none is chosen, is left out), in the role table's order. Makes no call and reads no key.
|
|
12
|
+
*/
|
|
13
|
+
export function routeDataFlows(settings, options = {}) {
|
|
14
|
+
const configured = createProviders(settings, {
|
|
15
|
+
env: options.env ?? {},
|
|
16
|
+
...(options.adapters && { adapters: options.adapters }),
|
|
17
|
+
});
|
|
18
|
+
const flows = [];
|
|
19
|
+
for (const operation of knownOperations(settings, options.operations)) {
|
|
20
|
+
let route;
|
|
21
|
+
try {
|
|
22
|
+
route = resolveRoute(settings, operation, configured, options.operations);
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (error instanceof RouteUnavailableError || error instanceof RouteAmbiguousError)
|
|
26
|
+
continue;
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
const provider = configured.find((c) => c.id === route.provider);
|
|
30
|
+
const host = provider.provider.billing.hosts[0] ?? null;
|
|
31
|
+
const hostname = host === null ? null : new URL(`http://${host}`).hostname;
|
|
32
|
+
flows.push({
|
|
33
|
+
operation,
|
|
34
|
+
providerId: provider.id,
|
|
35
|
+
host,
|
|
36
|
+
upstream: upstreamOf(provider.adapter.id, route.model),
|
|
37
|
+
providerTerms: route.providerTerms ?? null,
|
|
38
|
+
retention: hostname === null || isLoopback(hostname) ? "local" : null,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return flows;
|
|
42
|
+
}
|