@1agh/maude 1.0.11 → 1.3.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 +3 -1
- package/apps/studio/acp/bridge.ts +18 -13
- package/apps/studio/acp/index.ts +43 -7
- package/apps/studio/acp/transcript-io.ts +394 -0
- package/apps/studio/acp/transcript.ts +103 -38
- package/apps/studio/annotations-layer.tsx +191 -116
- package/apps/studio/annotations-model.ts +39 -0
- package/apps/studio/annotations-sync.ts +50 -0
- package/apps/studio/api.ts +821 -55
- package/apps/studio/bin/_import-figma.mjs +57 -11
- package/apps/studio/bin/_seed-fixture.mjs +163 -0
- package/apps/studio/bin/annotate.mjs +3 -1
- package/apps/studio/bin/server-up.sh +17 -2
- package/apps/studio/canvas-edit.ts +391 -7
- package/apps/studio/canvas-imports.ts +89 -0
- package/apps/studio/canvas-lib.tsx +82 -18
- package/apps/studio/canvas-notice-message.ts +16 -0
- package/apps/studio/canvas-notifications.tsx +19 -0
- package/apps/studio/canvas-shell.tsx +57 -6
- package/apps/studio/client/app.jsx +943 -248
- package/apps/studio/client/apply-edit-request.ts +55 -0
- package/apps/studio/client/export-center.jsx +125 -67
- package/apps/studio/client/github.js +38 -1
- package/apps/studio/client/index-loader.ts +76 -0
- package/apps/studio/client/panels/CloudBar.jsx +52 -6
- package/apps/studio/client/panels/GitPanel.jsx +103 -0
- package/apps/studio/client/panels/OnboardingWizard.jsx +36 -7
- package/apps/studio/client/panels/RepoBranchSwitcher.jsx +92 -27
- package/apps/studio/client/panels/SourceConflictPanel.jsx +166 -0
- package/apps/studio/client/panels/SyncPanel.jsx +238 -4
- package/apps/studio/client/panels/TeamProjects.jsx +376 -0
- package/apps/studio/client/panels/file-deep-link-dialog.jsx +54 -0
- package/apps/studio/client/photo-knobs.jsx +3 -0
- package/apps/studio/client/report-bug.jsx +19 -1
- package/apps/studio/client/share-dialog.jsx +91 -0
- package/apps/studio/client/share-link.js +94 -0
- package/apps/studio/client/styles/3-shell-maude.css +69 -18
- package/apps/studio/client/styles/4-components.css +44 -1
- package/apps/studio/client/tree-row-menu.jsx +48 -3
- package/apps/studio/client/whats-new.jsx +26 -32
- package/apps/studio/cloud/endpoints.ts +132 -0
- package/apps/studio/collab/index.ts +4 -0
- package/apps/studio/collab/persistence.ts +137 -17
- package/apps/studio/collab/registry.ts +19 -21
- package/apps/studio/collab/room.ts +13 -2
- package/apps/studio/context.ts +59 -0
- package/apps/studio/debug-bundle.ts +13 -0
- package/apps/studio/dist/client.bundle.js +1911 -1879
- package/apps/studio/dist/runtime/.min-sizes.json +1 -0
- package/apps/studio/dist/runtime/sonner.js +1 -0
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/export-dialog.tsx +54 -0
- package/apps/studio/exporters/degraded.ts +19 -3
- package/apps/studio/exporters/ghostscript.ts +194 -0
- package/apps/studio/exporters/pdf-fonts.ts +261 -0
- package/apps/studio/exporters/pdf.ts +152 -3
- package/apps/studio/exporters/remote.ts +36 -1
- package/apps/studio/fs-watch.ts +45 -1
- package/apps/studio/http.ts +296 -19
- package/apps/studio/inspect.ts +19 -0
- package/apps/studio/managed-projects.ts +150 -0
- package/apps/studio/mem.ts +45 -9
- package/apps/studio/notifications.tsx +292 -0
- package/apps/studio/runtime-bundle.ts +2 -0
- package/apps/studio/server.ts +69 -6
- package/apps/studio/sync/accepted-cold-start.ts +225 -0
- package/apps/studio/sync/accepted-link.ts +320 -0
- package/apps/studio/sync/action-stage.ts +343 -0
- package/apps/studio/sync/agent.ts +104 -45
- package/apps/studio/sync/asset-push.ts +1 -47
- package/apps/studio/sync/cell-file-events.ts +3 -0
- package/apps/studio/sync/codec.ts +192 -34
- package/apps/studio/sync/cold-start-apply.ts +7 -0
- package/apps/studio/sync/cold-start.ts +118 -22
- package/apps/studio/sync/comment-identity.ts +68 -0
- package/apps/studio/sync/connection-state.ts +15 -1
- package/apps/studio/sync/ctl-provider.ts +15 -2
- package/apps/studio/sync/document-discovery.ts +81 -0
- package/apps/studio/sync/file-ledger.ts +117 -0
- package/apps/studio/sync/file-membership.ts +10 -2
- package/apps/studio/sync/file-plane.ts +926 -47
- package/apps/studio/sync/index.ts +1786 -36
- package/apps/studio/sync/journal-client.ts +13 -1
- package/apps/studio/sync/migrate-seed.ts +150 -22
- package/apps/studio/sync/poke.ts +4 -2
- package/apps/studio/sync/presentation.ts +311 -5
- package/apps/studio/sync/projection.ts +820 -23
- package/apps/studio/sync/repeated-module.ts +73 -0
- package/apps/studio/sync/retry-after.ts +169 -0
- package/apps/studio/sync/revision-barrier.ts +129 -0
- package/apps/studio/sync/seed-progress.ts +218 -0
- package/apps/studio/sync/seed-repair.ts +46 -0
- package/apps/studio/sync/source-merge.ts +100 -0
- package/apps/studio/sync/source-ops.ts +289 -0
- package/apps/studio/sync/source-recovery.ts +70 -0
- package/apps/studio/sync/source-validation.ts +56 -0
- package/apps/studio/sync/status.ts +201 -6
- package/apps/studio/sync/transaction-client.ts +460 -0
- package/apps/studio/sync/transport-error.ts +111 -0
- package/apps/studio/sync/writer-registry.ts +236 -0
- package/apps/studio/text-caret.ts +35 -0
- package/apps/studio/undo-hud.tsx +9 -87
- package/apps/studio/use-canvas-media-drop.tsx +4 -39
- package/apps/studio/whats-new.json +173 -0
- package/cli/bin/maude.mjs +2 -0
- package/cli/commands/codex.mjs +191 -0
- package/cli/commands/harness.mjs +1051 -0
- package/cli/commands/help.mjs +13 -0
- package/cli/lib/design-link.mjs +190 -2
- package/cli/lib/harness/capabilities.mjs +302 -0
- package/cli/lib/harness/codex-runtime.mjs +892 -0
- package/cli/lib/harness/compatibility.mjs +27 -0
- package/cli/lib/harness/discover-claude.mjs +1393 -0
- package/cli/lib/harness/managed-state.mjs +1296 -0
- package/cli/lib/harness/model.mjs +86 -0
- package/cli/lib/harness/secrets.mjs +390 -0
- package/cli/lib/harness/targets/codex.mjs +1141 -0
- package/cli/lib/harness/targets/opencode.mjs +807 -0
- package/cli/lib/harness/transaction.mjs +1099 -0
- package/cli/lib/hubs-config.mjs +35 -8
- package/cli/templates/harness/opencode/maude-projector.ts +58 -0
- package/docs/harness-capability-matrix.md +125 -0
- package/docs/harness-environment-projection.md +95 -0
- package/package.json +33 -9
- package/plugins/design/dependencies.json +3 -3
- package/plugins/design/templates/_shell.html +47 -0
- package/plugins/flow/.claude-plugin/config.schema.json +8 -0
- package/plugins/flow/dependencies.json +3 -3
- package/apps/studio/.ai/cache/_stats.json +0 -7
- package/apps/studio/bin/_agent-browser-safe.test.mjs +0 -165
- package/apps/studio/bin/_curl-local.test.mjs +0 -280
- package/apps/studio/bin/_pw-launch.test.mjs +0 -90
- package/apps/studio/bin/_smart-frames.test.mjs +0 -195
- package/apps/studio/bin/_transcribe.test.mjs +0 -80
- package/apps/studio/bun.lock +0 -928
- package/apps/studio/draw/test/animate.test.ts +0 -172
- package/apps/studio/draw/test/brush.test.ts +0 -213
- package/apps/studio/draw/test/composition.test.ts +0 -141
- package/apps/studio/draw/test/geometry.test.ts +0 -199
- package/apps/studio/draw/test/gradient.test.ts +0 -167
- package/apps/studio/draw/test/layout.test.ts +0 -120
- package/apps/studio/draw/test/morph.test.ts +0 -107
- package/apps/studio/draw/test/optimize.test.ts +0 -40
- package/apps/studio/draw/test/palette.test.ts +0 -123
- package/apps/studio/draw/test/primitives.test.ts +0 -129
- package/apps/studio/draw/test/serialize-animate.test.ts +0 -142
- package/apps/studio/draw/test/serialize.test.ts +0 -105
- package/apps/studio/figma/assets.test.ts +0 -464
- package/apps/studio/figma/client.test.ts +0 -395
- package/apps/studio/figma/codegen-client.test.ts +0 -276
- package/apps/studio/figma/codegen-fonts.test.ts +0 -103
- package/apps/studio/figma/codegen-values.test.ts +0 -179
- package/apps/studio/figma/comments-to-strokes.test.ts +0 -194
- package/apps/studio/figma/fig-decode.test.ts +0 -788
- package/apps/studio/figma/fig-differential.test.ts +0 -182
- package/apps/studio/figma/fig-translator.test.ts +0 -192
- package/apps/studio/figma/fig-vector.test.ts +0 -113
- package/apps/studio/figma/from-codegen.test.ts +0 -408
- package/apps/studio/figma/sanitize.test.ts +0 -325
- package/apps/studio/figma/tailwind-map.test.ts +0 -142
- package/apps/studio/figma/to-artboard.test.ts +0 -808
- package/apps/studio/figma/to-render.test.ts +0 -180
- package/apps/studio/figma/to-strokes-roundtrip.test.ts +0 -152
- package/apps/studio/figma/to-strokes.test.ts +0 -705
- package/apps/studio/figma/to-tokens.test.ts +0 -321
- package/apps/studio/figma/url.test.ts +0 -167
- package/apps/studio/footage/schema.test.ts +0 -287
- package/apps/studio/generation/adapters/groq.test.ts +0 -80
- package/apps/studio/generation/audio-library.test.ts +0 -95
- package/apps/studio/generation/captions.test.ts +0 -78
- package/apps/studio/generation/elevenlabs.test.ts +0 -223
- package/apps/studio/generation/gemini.test.ts +0 -350
- package/apps/studio/generation/jobs.test.ts +0 -128
- package/apps/studio/generation/keys.test.ts +0 -75
- package/apps/studio/generation/prefs.test.ts +0 -95
- package/apps/studio/generation/types.test.ts +0 -123
- package/apps/studio/generation/whisper-models.test.ts +0 -179
- package/apps/studio/test/_helpers.ts +0 -108
- package/apps/studio/test/acp-activity-endpoint.test.ts +0 -183
- package/apps/studio/test/acp-activity.test.ts +0 -154
- package/apps/studio/test/acp-ai-activity.test.ts +0 -182
- package/apps/studio/test/acp-attachment-serve.test.ts +0 -74
- package/apps/studio/test/acp-bootstrap-brief.test.ts +0 -178
- package/apps/studio/test/acp-branch-guard.test.ts +0 -123
- package/apps/studio/test/acp-bridge-lifetime.test.ts +0 -475
- package/apps/studio/test/acp-bridge.test.ts +0 -545
- package/apps/studio/test/acp-capabilities.test.ts +0 -123
- package/apps/studio/test/acp-caps-bridge.test.ts +0 -279
- package/apps/studio/test/acp-commands.test.ts +0 -119
- package/apps/studio/test/acp-elicitation-bridge.test.ts +0 -480
- package/apps/studio/test/acp-elicitation.test.ts +0 -251
- package/apps/studio/test/acp-env.test.ts +0 -95
- package/apps/studio/test/acp-mode-banner.test.ts +0 -45
- package/apps/studio/test/acp-origin-gate.test.ts +0 -160
- package/apps/studio/test/acp-permission-prompt.test.ts +0 -251
- package/apps/studio/test/acp-permission.test.ts +0 -278
- package/apps/studio/test/acp-plugin-bootstrap.test.ts +0 -89
- package/apps/studio/test/acp-session-allowed-tools.test.ts +0 -235
- package/apps/studio/test/acp-session-plugins.test.ts +0 -209
- package/apps/studio/test/acp-toolgroup.test.ts +0 -76
- package/apps/studio/test/acp-transcript-view.test.ts +0 -71
- package/apps/studio/test/acp-transcript.test.ts +0 -238
- package/apps/studio/test/acp-usage-bridge.test.ts +0 -141
- package/apps/studio/test/acp-usage.test.ts +0 -143
- package/apps/studio/test/acp-write-gate.test.ts +0 -323
- package/apps/studio/test/acp-write-scope.test.ts +0 -533
- package/apps/studio/test/active-state.test.ts +0 -186
- package/apps/studio/test/activity.test.ts +0 -189
- package/apps/studio/test/ai-activity.test.ts +0 -113
- package/apps/studio/test/annotate-write.test.ts +0 -1074
- package/apps/studio/test/annotation-strokes-command.test.ts +0 -166
- package/apps/studio/test/annotations-align.test.ts +0 -88
- package/apps/studio/test/annotations-api.test.ts +0 -145
- package/apps/studio/test/annotations-bindings.test.ts +0 -262
- package/apps/studio/test/annotations-draw-modifiers.test.ts +0 -206
- package/apps/studio/test/annotations-groups.test.ts +0 -231
- package/apps/studio/test/annotations-layer.test.ts +0 -1011
- package/apps/studio/test/annotations-roundtrip.test.ts +0 -663
- package/apps/studio/test/annotations-snap.test.ts +0 -135
- package/apps/studio/test/annotations-text-format.test.ts +0 -396
- package/apps/studio/test/artboard-activity-overlay.test.tsx +0 -56
- package/apps/studio/test/artboard-guides-overlay.test.tsx +0 -152
- package/apps/studio/test/artboard-hug-commit.test.ts +0 -36
- package/apps/studio/test/artboard-kinds.test.tsx +0 -83
- package/apps/studio/test/artboard-selection-attrs.test.ts +0 -69
- package/apps/studio/test/asset-api.test.ts +0 -149
- package/apps/studio/test/assets-s3.test.ts +0 -249
- package/apps/studio/test/binary-smoke.test.ts +0 -47
- package/apps/studio/test/boot-self-heal.test.ts +0 -87
- package/apps/studio/test/browse-posture.test.tsx +0 -107
- package/apps/studio/test/bundle-smoke.test.ts +0 -46
- package/apps/studio/test/camera-reveal.test.tsx +0 -173
- package/apps/studio/test/canvas-artifacts.test.ts +0 -125
- package/apps/studio/test/canvas-build-sandbox.test.ts +0 -69
- package/apps/studio/test/canvas-build.test.ts +0 -141
- package/apps/studio/test/canvas-create-api.test.ts +0 -676
- package/apps/studio/test/canvas-cursors.test.ts +0 -164
- package/apps/studio/test/canvas-edit.test.ts +0 -470
- package/apps/studio/test/canvas-freshness-deps.test.ts +0 -64
- package/apps/studio/test/canvas-header.test.ts +0 -127
- package/apps/studio/test/canvas-hide-chrome.test.ts +0 -88
- package/apps/studio/test/canvas-hmr-runtime.test.tsx +0 -114
- package/apps/studio/test/canvas-lib-inline.test.ts +0 -146
- package/apps/studio/test/canvas-lib-motion.test.ts +0 -131
- package/apps/studio/test/canvas-lib-resolver.test.ts +0 -111
- package/apps/studio/test/canvas-list-watch.test.ts +0 -388
- package/apps/studio/test/canvas-media-drop.test.ts +0 -187
- package/apps/studio/test/canvas-meta-api.test.ts +0 -707
- package/apps/studio/test/canvas-move-api.test.ts +0 -587
- package/apps/studio/test/canvas-origin-gate.test.ts +0 -417
- package/apps/studio/test/canvas-pipeline.test.ts +0 -180
- package/apps/studio/test/canvas-rects.test.ts +0 -198
- package/apps/studio/test/canvas-reorder.test.ts +0 -211
- package/apps/studio/test/canvas-route.test.ts +0 -179
- package/apps/studio/test/canvas-shell-base.test.ts +0 -107
- package/apps/studio/test/canvas-shell-build-error.test.ts +0 -52
- package/apps/studio/test/canvas-url.test.ts +0 -138
- package/apps/studio/test/canvas-wheel-delta.test.ts +0 -42
- package/apps/studio/test/canvas-zoom-floor.test.ts +0 -73
- package/apps/studio/test/capture-core.test.ts +0 -32
- package/apps/studio/test/capture-determinism-shape.test.ts +0 -135
- package/apps/studio/test/chat-attachments.test.ts +0 -117
- package/apps/studio/test/chat-context.test.ts +0 -129
- package/apps/studio/test/chat-markdown.test.tsx +0 -58
- package/apps/studio/test/clip-addressing.test.ts +0 -738
- package/apps/studio/test/clip-ops.test.ts +0 -922
- package/apps/studio/test/cloud-build.test.ts +0 -95
- package/apps/studio/test/cloud-connect-note.test.ts +0 -135
- package/apps/studio/test/cloud-endpoints.test.ts +0 -590
- package/apps/studio/test/cloud-history-hardening.test.ts +0 -165
- package/apps/studio/test/cloud-history-posture.test.ts +0 -230
- package/apps/studio/test/cloud-managed-save-surfaces.test.ts +0 -90
- package/apps/studio/test/cloud-renew.test.ts +0 -205
- package/apps/studio/test/cloud-session-role.test.ts +0 -161
- package/apps/studio/test/cloud-shell-surfaces.test.ts +0 -170
- package/apps/studio/test/cold-start-apply.test.ts +0 -303
- package/apps/studio/test/collab-annotations-bridge.test.ts +0 -55
- package/apps/studio/test/collab-awareness-bridge.test.ts +0 -223
- package/apps/studio/test/collab-bridge.test.ts +0 -79
- package/apps/studio/test/collab-loopback.test.ts +0 -63
- package/apps/studio/test/collab-origin-gate.test.ts +0 -323
- package/apps/studio/test/collab-protocol.test.ts +0 -146
- package/apps/studio/test/collab-readonly-gate.test.ts +0 -194
- package/apps/studio/test/collab-reseed-guard.test.ts +0 -78
- package/apps/studio/test/collab-room.test.ts +0 -188
- package/apps/studio/test/collab-session-survival.test.tsx +0 -176
- package/apps/studio/test/collab-stress.test.ts +0 -129
- package/apps/studio/test/comment-mount.test.ts +0 -97
- package/apps/studio/test/comment-relay-origin-gate.test.ts +0 -117
- package/apps/studio/test/comments-api.test.ts +0 -277
- package/apps/studio/test/comments-fs-rebroadcast.test.ts +0 -155
- package/apps/studio/test/comments-overlay.test.ts +0 -117
- package/apps/studio/test/compile-entry.test.ts +0 -133
- package/apps/studio/test/component-map.test.ts +0 -48
- package/apps/studio/test/config-projection.test.ts +0 -104
- package/apps/studio/test/config-reload.test.ts +0 -230
- package/apps/studio/test/config-version.test.ts +0 -88
- package/apps/studio/test/context-resolve-tokens.test.ts +0 -97
- package/apps/studio/test/convert-to-absolute.test.ts +0 -333
- package/apps/studio/test/credential-grammar.test.ts +0 -107
- package/apps/studio/test/csp-canvas-shell.test.ts +0 -62
- package/apps/studio/test/csrf-write-guard.test.ts +0 -141
- package/apps/studio/test/debug-bundle.test.ts +0 -105
- package/apps/studio/test/design-setup-readiness.test.ts +0 -155
- package/apps/studio/test/detach-component.test.ts +0 -94
- package/apps/studio/test/dns-rebinding-guard.test.ts +0 -101
- package/apps/studio/test/dom-selection.test.ts +0 -198
- package/apps/studio/test/dynamic-text-edit.test.ts +0 -162
- package/apps/studio/test/edit-css-occurrence.test.ts +0 -81
- package/apps/studio/test/edit-persistence.test.ts +0 -91
- package/apps/studio/test/edit-scope-api.test.ts +0 -119
- package/apps/studio/test/edit-source-command.test.ts +0 -142
- package/apps/studio/test/edit-suppress.test.ts +0 -170
- package/apps/studio/test/editing-presence.test.ts +0 -103
- package/apps/studio/test/element-resize.test.ts +0 -136
- package/apps/studio/test/element-structural-api.test.ts +0 -434
- package/apps/studio/test/element-structural-edit.test.ts +0 -750
- package/apps/studio/test/ensure-browser.test.ts +0 -92
- package/apps/studio/test/equal-spacing-detector.test.ts +0 -257
- package/apps/studio/test/export-assemble.test.ts +0 -53
- package/apps/studio/test/export-browser-lane.test.ts +0 -126
- package/apps/studio/test/export-capture-fidelity.test.ts +0 -146
- package/apps/studio/test/export-capture-hygiene.test.ts +0 -675
- package/apps/studio/test/export-center.test.tsx +0 -287
- package/apps/studio/test/export-e2e-lanes.test.ts +0 -857
- package/apps/studio/test/export-format-scope-coherence.test.ts +0 -89
- package/apps/studio/test/export-lane.test.ts +0 -245
- package/apps/studio/test/export-shim-multi-capture.test.ts +0 -83
- package/apps/studio/test/exporters/canva.test.ts +0 -63
- package/apps/studio/test/exporters/degraded-propagation.test.ts +0 -123
- package/apps/studio/test/exporters/endpoint.test.ts +0 -121
- package/apps/studio/test/exporters/history.test.ts +0 -107
- package/apps/studio/test/exporters/html.test.ts +0 -26
- package/apps/studio/test/exporters/jobs.test.ts +0 -342
- package/apps/studio/test/exporters/pdf.test.ts +0 -85
- package/apps/studio/test/exporters/png.test.ts +0 -103
- package/apps/studio/test/exporters/pptx-deck.test.ts +0 -112
- package/apps/studio/test/exporters/pptx.test.ts +0 -31
- package/apps/studio/test/exporters/pw-launch.test.ts +0 -49
- package/apps/studio/test/exporters/runtime.test.ts +0 -59
- package/apps/studio/test/exporters/scope.test.ts +0 -292
- package/apps/studio/test/exporters/svg.test.ts +0 -29
- package/apps/studio/test/exporters/unsupported-media.test.ts +0 -123
- package/apps/studio/test/exporters/zip.test.ts +0 -104
- package/apps/studio/test/fetch-asset-gate.test.ts +0 -189
- package/apps/studio/test/figjam-v3-model.test.ts +0 -342
- package/apps/studio/test/figma-explode.test.ts +0 -438
- package/apps/studio/test/figma-provenance.test.ts +0 -108
- package/apps/studio/test/figma-routes.test.ts +0 -294
- package/apps/studio/test/file-lock.test.ts +0 -84
- package/apps/studio/test/fixtures/backgrounding-claude-auth.sh +0 -12
- package/apps/studio/test/fixtures/fake-claude-auth.mjs +0 -23
- package/apps/studio/test/fixtures/figjam-v3-groups-bindings.svg +0 -1
- package/apps/studio/test/fixtures/mock-acp-agent-caps.mjs +0 -158
- package/apps/studio/test/fixtures/mock-acp-agent-commands.mjs +0 -44
- package/apps/studio/test/fixtures/mock-acp-agent-elicit-flood.mjs +0 -46
- package/apps/studio/test/fixtures/mock-acp-agent-elicit-url.mjs +0 -42
- package/apps/studio/test/fixtures/mock-acp-agent-elicit.mjs +0 -63
- package/apps/studio/test/fixtures/mock-acp-agent-permission-flood.mjs +0 -51
- package/apps/studio/test/fixtures/mock-acp-agent-permission.mjs +0 -50
- package/apps/studio/test/fixtures/mock-acp-agent-slow.mjs +0 -45
- package/apps/studio/test/fixtures/mock-acp-agent-usage.mjs +0 -56
- package/apps/studio/test/fixtures/mock-acp-agent-wedged.mjs +0 -37
- package/apps/studio/test/fixtures/mock-acp-agent-write.mjs +0 -118
- package/apps/studio/test/fixtures/mock-acp-agent.mjs +0 -69
- package/apps/studio/test/fixtures/noisy-claude-auth.mjs +0 -27
- package/apps/studio/test/fixtures/perf-canvas.mjs +0 -201
- package/apps/studio/test/fixtures/phase-20-annotations.svg +0 -1
- package/apps/studio/test/fixtures/phase-21-annotations.svg +0 -1
- package/apps/studio/test/fixtures/tiny-subset.woff2 +0 -0
- package/apps/studio/test/fixtures/video-comp-fixture.tsx +0 -82
- package/apps/studio/test/fixtures/wedged-claude-auth.sh +0 -11
- package/apps/studio/test/footage-store.test.ts +0 -100
- package/apps/studio/test/fs-mkdir-api.test.ts +0 -248
- package/apps/studio/test/fs-watch.test.ts +0 -41
- package/apps/studio/test/gemma-models.test.ts +0 -245
- package/apps/studio/test/generate-route.test.ts +0 -106
- package/apps/studio/test/git-api.test.ts +0 -0
- package/apps/studio/test/git-branches.test.ts +0 -341
- package/apps/studio/test/git-cloud-posture.test.ts +0 -59
- package/apps/studio/test/git-grouping.test.ts +0 -106
- package/apps/studio/test/git-lifecycle.test.ts +0 -100
- package/apps/studio/test/git-log-format.test.ts +0 -95
- package/apps/studio/test/git-safe-rel.test.ts +0 -132
- package/apps/studio/test/git-system-engine.test.ts +0 -135
- package/apps/studio/test/git-watch.test.ts +0 -97
- package/apps/studio/test/github-api.test.ts +0 -577
- package/apps/studio/test/grid-track-handles.test.ts +0 -160
- package/apps/studio/test/handoff-static-frames.test.ts +0 -215
- package/apps/studio/test/handoff.test.ts +0 -329
- package/apps/studio/test/history-rollback.test.ts +0 -88
- package/apps/studio/test/hmr-broadcast.test.ts +0 -236
- package/apps/studio/test/hmr-classify.test.ts +0 -87
- package/apps/studio/test/hub-link.test.ts +0 -80
- package/apps/studio/test/identity-cache.test.ts +0 -83
- package/apps/studio/test/import-asset-browser.test.ts +0 -64
- package/apps/studio/test/import-asset-route.test.ts +0 -71
- package/apps/studio/test/import-asset.test.ts +0 -427
- package/apps/studio/test/import-brand-browser.test.ts +0 -88
- package/apps/studio/test/import-brand-route.test.ts +0 -120
- package/apps/studio/test/import-brand.test.ts +0 -206
- package/apps/studio/test/import-figma.test.ts +0 -667
- package/apps/studio/test/import-tokens.test.ts +0 -722
- package/apps/studio/test/index-data-canvas-ds.test.ts +0 -97
- package/apps/studio/test/input-router.test.ts +0 -757
- package/apps/studio/test/inspect-script-syntax.test.ts +0 -53
- package/apps/studio/test/inspect-selections.test.ts +0 -219
- package/apps/studio/test/knob-props-authored.test.ts +0 -87
- package/apps/studio/test/layers-synthetic-groups.test.ts +0 -96
- package/apps/studio/test/locator.test.ts +0 -214
- package/apps/studio/test/marquee-overlay.test.ts +0 -94
- package/apps/studio/test/media-commit-chain.test.ts +0 -210
- package/apps/studio/test/mode-toggle.test.tsx +0 -226
- package/apps/studio/test/motion-sample.test.ts +0 -35
- package/apps/studio/test/move-artboards-command.test.ts +0 -108
- package/apps/studio/test/participants-chrome.test.ts +0 -65
- package/apps/studio/test/paths.test.ts +0 -88
- package/apps/studio/test/pdf-print-boxes.test.ts +0 -359
- package/apps/studio/test/peer-selection-follows-camera.test.tsx +0 -131
- package/apps/studio/test/perf-harness.ts +0 -193
- package/apps/studio/test/phase-3.6-smoke.test.ts +0 -79
- package/apps/studio/test/photo-bg-remove-validation.test.ts +0 -71
- package/apps/studio/test/photo-canvas-bundle.test.ts +0 -79
- package/apps/studio/test/photo-edit-api.test.ts +0 -201
- package/apps/studio/test/photo-filters.test.ts +0 -149
- package/apps/studio/test/photo-pipeline.test.ts +0 -106
- package/apps/studio/test/photo-taxonomy.test.ts +0 -96
- package/apps/studio/test/print-marks.test.ts +0 -113
- package/apps/studio/test/print-units.test.ts +0 -173
- package/apps/studio/test/read-annotations.test.ts +0 -727
- package/apps/studio/test/read-only-gate.test.ts +0 -188
- package/apps/studio/test/read-only-role.test.ts +0 -95
- package/apps/studio/test/readiness.test.ts +0 -337
- package/apps/studio/test/remote-ahead-behind-cache.test.ts +0 -89
- package/apps/studio/test/reorder-api.test.ts +0 -210
- package/apps/studio/test/repo-concurrency.test.ts +0 -146
- package/apps/studio/test/repo-lock.test.ts +0 -350
- package/apps/studio/test/report-proxy.test.ts +0 -125
- package/apps/studio/test/ripple.test.ts +0 -197
- package/apps/studio/test/runtime-bundle-error-mapping.test.ts +0 -43
- package/apps/studio/test/runtime-bundle.test.ts +0 -69
- package/apps/studio/test/sanitize-annotation-svg.test.ts +0 -238
- package/apps/studio/test/scaffold-design.test.ts +0 -122
- package/apps/studio/test/server-lifecycle.test.ts +0 -38
- package/apps/studio/test/session-runtime-state.test.ts +0 -226
- package/apps/studio/test/session-scope.test.ts +0 -100
- package/apps/studio/test/shared-doc-cell-pairing.test.ts +0 -642
- package/apps/studio/test/shared-doc-convergence.test.ts +0 -265
- package/apps/studio/test/shared-doc-foundation.test.ts +0 -63
- package/apps/studio/test/shared-doc-migrate.test.ts +0 -369
- package/apps/studio/test/shared-doc-projection.test.ts +0 -238
- package/apps/studio/test/shell-importmap.test.ts +0 -56
- package/apps/studio/test/sizing-mode.test.ts +0 -102
- package/apps/studio/test/slash-commands.test.ts +0 -117
- package/apps/studio/test/snap-distance-pill.test.ts +0 -68
- package/apps/studio/test/spacing-handles.test.ts +0 -138
- package/apps/studio/test/specimen-select.test.ts +0 -88
- package/apps/studio/test/sync-agent.test.ts +0 -660
- package/apps/studio/test/sync-annotations-cold-start.test.ts +0 -302
- package/apps/studio/test/sync-asset-push.test.ts +0 -931
- package/apps/studio/test/sync-atomic-write.test.ts +0 -62
- package/apps/studio/test/sync-attach-incremental.test.ts +0 -527
- package/apps/studio/test/sync-autocommit.test.ts +0 -537
- package/apps/studio/test/sync-canvas-path.test.ts +0 -200
- package/apps/studio/test/sync-cell-write-nudge.test.ts +0 -346
- package/apps/studio/test/sync-codec.test.ts +0 -230
- package/apps/studio/test/sync-cold-seed-dedup.test.ts +0 -187
- package/apps/studio/test/sync-cold-start.test.ts +0 -304
- package/apps/studio/test/sync-connect-honesty.test.ts +0 -114
- package/apps/studio/test/sync-connection-state.test.ts +0 -337
- package/apps/studio/test/sync-ctl-channel.test.ts +0 -508
- package/apps/studio/test/sync-decide-file.test.ts +0 -420
- package/apps/studio/test/sync-doc-name.test.ts +0 -281
- package/apps/studio/test/sync-echo-guard.test.ts +0 -96
- package/apps/studio/test/sync-file-ledger.test.ts +0 -334
- package/apps/studio/test/sync-file-membership.test.ts +0 -347
- package/apps/studio/test/sync-file-plane.test.ts +0 -976
- package/apps/studio/test/sync-file-pull.test.ts +0 -333
- package/apps/studio/test/sync-fresh-link-parity.test.ts +0 -267
- package/apps/studio/test/sync-fs-mirror.test.ts +0 -181
- package/apps/studio/test/sync-hardening.test.ts +0 -586
- package/apps/studio/test/sync-hub-listing.test.ts +0 -46
- package/apps/studio/test/sync-hubs-config.test.ts +0 -133
- package/apps/studio/test/sync-incident-replay.test.ts +0 -211
- package/apps/studio/test/sync-journal.test.ts +0 -176
- package/apps/studio/test/sync-meta-codec.test.ts +0 -199
- package/apps/studio/test/sync-migrate-flat-fallback.test.ts +0 -98
- package/apps/studio/test/sync-move-retirement.test.ts +0 -231
- package/apps/studio/test/sync-panel-surface.test.ts +0 -153
- package/apps/studio/test/sync-path-pull.test.ts +0 -531
- package/apps/studio/test/sync-presentation.test.ts +0 -262
- package/apps/studio/test/sync-pull-budget.test.ts +0 -169
- package/apps/studio/test/sync-remote-docs.test.ts +0 -333
- package/apps/studio/test/sync-resync-routes.test.ts +0 -168
- package/apps/studio/test/sync-runtime.test.ts +0 -1675
- package/apps/studio/test/sync-seed-defers-to-hub.test.ts +0 -83
- package/apps/studio/test/sync-settings-routes.test.ts +0 -195
- package/apps/studio/test/sync-settings.test.ts +0 -151
- package/apps/studio/test/sync-status.test.ts +0 -261
- package/apps/studio/test/sync-supervisor.test.ts +0 -262
- package/apps/studio/test/sync-tombstone-apply.test.ts +0 -111
- package/apps/studio/test/sync-trash.test.ts +0 -132
- package/apps/studio/test/sync-two-peer-discovery.test.ts +0 -343
- package/apps/studio/test/sync-untrusted.test.ts +0 -103
- package/apps/studio/test/system-endpoint.test.ts +0 -144
- package/apps/studio/test/text-editability-stamp.test.ts +0 -131
- package/apps/studio/test/timeline-comp-target.test.ts +0 -139
- package/apps/studio/test/timeline-media-cache.test.ts +0 -41
- package/apps/studio/test/timeline-parse.test.ts +0 -184
- package/apps/studio/test/timeline-scale.test.ts +0 -65
- package/apps/studio/test/timeline-snap.test.ts +0 -85
- package/apps/studio/test/tool-palette-insert-anchor.test.ts +0 -86
- package/apps/studio/test/tool-palette.test.tsx +0 -55
- package/apps/studio/test/tour-overlay.test.tsx +0 -90
- package/apps/studio/test/trusted-request-host.test.ts +0 -66
- package/apps/studio/test/undo-sequence-byte-compare.test.ts +0 -211
- package/apps/studio/test/undo-stack.test.ts +0 -244
- package/apps/studio/test/use-agent-presence.test.tsx +0 -117
- package/apps/studio/test/use-annotation-resize.test.ts +0 -402
- package/apps/studio/test/use-annotation-selection.test.tsx +0 -77
- package/apps/studio/test/use-artboard-drag.test.ts +0 -324
- package/apps/studio/test/use-canvas-activity.test.tsx +0 -206
- package/apps/studio/test/use-collab.test.ts +0 -0
- package/apps/studio/test/use-cursor-modifiers.test.ts +0 -59
- package/apps/studio/test/use-keyboard-discipline.test.ts +0 -27
- package/apps/studio/test/use-selection-set.test.tsx +0 -166
- package/apps/studio/test/use-snap-guides.test.ts +0 -271
- package/apps/studio/test/use-tool-mode.test.tsx +0 -186
- package/apps/studio/test/use-undo-stack.test.tsx +0 -223
- package/apps/studio/test/video-asset.test.ts +0 -163
- package/apps/studio/test/video-comp-fixture.test.ts +0 -50
- package/apps/studio/test/video-comp.test.ts +0 -270
- package/apps/studio/test/video-encode-lib.test.ts +0 -63
- package/apps/studio/test/video-render-bridge.test.ts +0 -171
- package/apps/studio/test/whats-new.test.ts +0 -113
- package/apps/studio/test/whisper-setup.test.ts +0 -97
- package/apps/studio/test/workspace-containment.test.ts +0 -382
- package/apps/studio/test/workspace-signin.test.ts +0 -292
- package/apps/studio/test/ws-handshake.test.ts +0 -33
- package/cli/commands/cache.test.mjs +0 -166
- package/cli/commands/design-link.test.mjs +0 -419
- package/cli/commands/design.test.mjs +0 -240
- package/cli/commands/doctor.test.mjs +0 -237
- package/cli/commands/hub-workspace.test.mjs +0 -275
- package/cli/commands/hub.test.mjs +0 -225
- package/cli/commands/kg.test.mjs +0 -142
- package/cli/commands/preflight.test.mjs +0 -46
- package/cli/lib/argv.test.mjs +0 -46
- package/cli/lib/cache.test.mjs +0 -303
- package/cli/lib/cell-plan.test.mjs +0 -225
- package/cli/lib/config-lint.test.mjs +0 -117
- package/cli/lib/ddr-to-kgai.test.mjs +0 -118
- package/cli/lib/design-ownership.test.mjs +0 -329
- package/cli/lib/fetch-asset.test.mjs +0 -213
- package/cli/lib/figma-codegen-reachability.test.mjs +0 -104
- package/cli/lib/figma-import-controls.test.mjs +0 -70
- package/cli/lib/flow-design-integration.test.mjs +0 -165
- package/cli/lib/gitignore-block.test.mjs +0 -136
- package/cli/lib/gitignore-drift.test.mjs +0 -156
- package/cli/lib/hubs-config.test.mjs +0 -165
- package/cli/lib/pkg-root.test.mjs +0 -111
- package/cli/lib/plugin-cli-reachability.test.mjs +0 -57
- package/cli/lib/plugin-name-namespace.test.mjs +0 -71
- package/cli/lib/reconstruct-toolset.test.mjs +0 -194
- package/cli/lib/stack-detect.test.mjs +0 -121
- package/cli/lib/update-check.test.mjs +0 -32
- package/cli/lib/workspace-plan.test.mjs +0 -699
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
// convert-to-absolute — feature-4 T8 (DDR-188). The pure AST batch writer behind
|
|
2
|
-
// the context-menu "Convert children to absolute position" (Figma's "Remove auto
|
|
3
|
-
// layout"): rewrite each stamped child to position:absolute with the frozen box,
|
|
4
|
-
// set the container position:relative, all in ONE MagicString pass (→ one undo
|
|
5
|
-
// seq). Mirrors canvas-edit.test.ts: raw source → transpile-computed ids → apply.
|
|
6
|
-
|
|
7
|
-
import { describe, expect, test } from 'bun:test';
|
|
8
|
-
|
|
9
|
-
import { applyConvertToAbsolute, CanvasEditError } from '../canvas-edit.ts';
|
|
10
|
-
import { transpileCanvasSource } from '../canvas-pipeline.ts';
|
|
11
|
-
|
|
12
|
-
const CANVAS = '/abs/Canvas.tsx';
|
|
13
|
-
|
|
14
|
-
function idsOf(source: string): Record<string, string> {
|
|
15
|
-
const { withIds } = transpileCanvasSource(CANVAS, source);
|
|
16
|
-
const out: Record<string, string> = {};
|
|
17
|
-
for (const m of withIds.matchAll(/<(\w+)([^>]*?)data-cd-id="([0-9a-f]{8})"/g)) {
|
|
18
|
-
if (!out[m[1] as string]) out[m[1] as string] = m[3] as string;
|
|
19
|
-
}
|
|
20
|
-
return out;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe('canvas-edit / applyConvertToAbsolute', () => {
|
|
24
|
-
test('converts flow children to absolute + sets container relative (one pass)', () => {
|
|
25
|
-
const src = `function Demo() { return <div className="hero"><h1>Title</h1><button>Go</button></div>; }`;
|
|
26
|
-
const ids = idsOf(src);
|
|
27
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
28
|
-
containerId: ids.div as string,
|
|
29
|
-
containerSetRelative: true,
|
|
30
|
-
children: [
|
|
31
|
-
{ id: ids.h1 as string, left: 10, top: 20, width: 100, height: 30 },
|
|
32
|
-
{ id: ids.button as string, left: 12, top: 60, width: 80, height: 40 },
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
// Container relative (new style attr is inserted right after the tag name).
|
|
36
|
-
expect(out.source).toContain('<div style={{ position: "relative" }} className="hero">');
|
|
37
|
-
// Each child: absolute + frozen border-box + box-sizing.
|
|
38
|
-
expect(out.source).toContain(
|
|
39
|
-
'<h1 style={{ position: "absolute", left: "10px", top: "20px", width: "100px", height: "30px", "box-sizing": "border-box" }}>'
|
|
40
|
-
);
|
|
41
|
-
expect(out.source).toContain(
|
|
42
|
-
'<button style={{ position: "absolute", left: "12px", top: "60px", width: "80px", height: "40px", "box-sizing": "border-box" }}>'
|
|
43
|
-
);
|
|
44
|
-
// Exactly ONE style attr per element (no duplicate-insert bug).
|
|
45
|
-
expect((out.source.match(/style=\{\{/g) || []).length).toBe(3);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test('containerSetRelative=false leaves the container untouched', () => {
|
|
49
|
-
const src = `function Demo() { return <div className="hero"><h1>T</h1></div>; }`;
|
|
50
|
-
const ids = idsOf(src);
|
|
51
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
52
|
-
containerId: ids.div as string,
|
|
53
|
-
containerSetRelative: false,
|
|
54
|
-
children: [{ id: ids.h1 as string, left: 0, top: 0, width: 50, height: 20 }],
|
|
55
|
-
});
|
|
56
|
-
expect(out.source).toContain('<div className="hero">');
|
|
57
|
-
expect(out.source).not.toContain('position: "relative"');
|
|
58
|
-
expect(out.source).toContain('position: "absolute"');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
test('merges into a child that already has an inline style (no duplicate style attr)', () => {
|
|
62
|
-
const src = `function Demo() { return <div><h1 style={{ color: "red" }}>T</h1></div>; }`;
|
|
63
|
-
const ids = idsOf(src);
|
|
64
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
65
|
-
containerId: ids.div as string,
|
|
66
|
-
containerSetRelative: true,
|
|
67
|
-
children: [{ id: ids.h1 as string, left: 5, top: 6, width: 10, height: 12 }],
|
|
68
|
-
});
|
|
69
|
-
// The h1 keeps color AND gains the absolute props — ONE style attribute.
|
|
70
|
-
expect((out.source.match(/<h1 style=\{\{/g) || []).length).toBe(1);
|
|
71
|
-
expect(out.source).toContain('color: "red"');
|
|
72
|
-
expect(out.source).toContain('position: "absolute"');
|
|
73
|
-
expect(out.source).toContain('left: "5px"');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
test('throws when a child id is not found', () => {
|
|
77
|
-
const src = `function Demo() { return <div><h1>T</h1></div>; }`;
|
|
78
|
-
const ids = idsOf(src);
|
|
79
|
-
expect(() =>
|
|
80
|
-
applyConvertToAbsolute(CANVAS, src, {
|
|
81
|
-
containerId: ids.div as string,
|
|
82
|
-
containerSetRelative: false,
|
|
83
|
-
children: [{ id: 'deadbeef', left: 0, top: 0, width: 1, height: 1 }],
|
|
84
|
-
})
|
|
85
|
-
).toThrow(CanvasEditError);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
test('throws when there are no children to convert', () => {
|
|
89
|
-
const src = `function Demo() { return <div><h1>T</h1></div>; }`;
|
|
90
|
-
const ids = idsOf(src);
|
|
91
|
-
expect(() =>
|
|
92
|
-
applyConvertToAbsolute(CANVAS, src, {
|
|
93
|
-
containerId: ids.div as string,
|
|
94
|
-
containerSetRelative: false,
|
|
95
|
-
children: [],
|
|
96
|
-
})
|
|
97
|
-
).toThrow(CanvasEditError);
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
test('a child that resolves to a shared component instance is refused WITHOUT allowShared', () => {
|
|
101
|
-
// Two <Card/> usages → the inner element's cd-id maps to a component; passing
|
|
102
|
-
// an idIndex makes resolveUsageId route to a <Card/> usage (id changes) →
|
|
103
|
-
// the pre-confirm abort fires.
|
|
104
|
-
const src = `
|
|
105
|
-
function Card() { return <article className="card"><h2>Hi</h2></article>; }
|
|
106
|
-
function Demo() { return <div><Card /><Card /></div>; }
|
|
107
|
-
`;
|
|
108
|
-
const ids = idsOf(src);
|
|
109
|
-
// The inner <h2> is the shared element; with an occurrence index it resolves
|
|
110
|
-
// to a <Card/> usage.
|
|
111
|
-
expect(() =>
|
|
112
|
-
applyConvertToAbsolute(CANVAS, src, {
|
|
113
|
-
containerId: ids.div as string,
|
|
114
|
-
containerSetRelative: false,
|
|
115
|
-
children: [{ id: ids.h2 as string, idIndex: 0, left: 0, top: 0, width: 1, height: 1 }],
|
|
116
|
-
})
|
|
117
|
-
).toThrow(CanvasEditError);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
// feature-4 T8b — the "affects N instances" confirm path: with allowShared
|
|
121
|
-
// each instance-child's write routes to its OWN <Component/> usage (the
|
|
122
|
-
// Stage-H3 local-instance model), so both usages get distinct frozen boxes.
|
|
123
|
-
test('allowShared: component-instance children write per-usage boxes (both <Card/> tags styled)', () => {
|
|
124
|
-
const src = `
|
|
125
|
-
function Card() { return <article className="card"><h2>Hi</h2></article>; }
|
|
126
|
-
function Demo() { return <div><Card /><Card /></div>; }
|
|
127
|
-
`;
|
|
128
|
-
const ids = idsOf(src);
|
|
129
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
130
|
-
containerId: ids.div as string,
|
|
131
|
-
containerSetRelative: true,
|
|
132
|
-
allowShared: true,
|
|
133
|
-
children: [
|
|
134
|
-
{ id: ids.article as string, idIndex: 0, left: 0, top: 0, width: 100, height: 50 },
|
|
135
|
-
{ id: ids.article as string, idIndex: 1, left: 0, top: 60, width: 100, height: 50 },
|
|
136
|
-
],
|
|
137
|
-
});
|
|
138
|
-
// Each usage is WRAPPED in its own positioned div (style on the usage tag
|
|
139
|
-
// would require the component to forward it — most don't); the shared
|
|
140
|
-
// definition's <article> is untouched.
|
|
141
|
-
const wrapped =
|
|
142
|
-
out.source.match(/<div style=\{\{ position: "absolute"[^>]*\}\}><Card \/><\/div>/g) || [];
|
|
143
|
-
expect(wrapped.length).toBe(2);
|
|
144
|
-
expect(out.source).toContain('top: "0px"');
|
|
145
|
-
expect(out.source).toContain('top: "60px"');
|
|
146
|
-
expect(out.source).toContain('<article className="card">');
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
test('allowShared: `.map`ed children still refuse (two children → same source element)', () => {
|
|
150
|
-
const src = `
|
|
151
|
-
const ITEMS = ['a', 'b'];
|
|
152
|
-
function Demo() { return <div>{ITEMS.map((t) => <p key={t}>{t}</p>)}</div>; }
|
|
153
|
-
`;
|
|
154
|
-
const ids = idsOf(src);
|
|
155
|
-
expect(() =>
|
|
156
|
-
applyConvertToAbsolute(CANVAS, src, {
|
|
157
|
-
containerId: ids.div as string,
|
|
158
|
-
containerSetRelative: false,
|
|
159
|
-
allowShared: true,
|
|
160
|
-
children: [
|
|
161
|
-
{ id: ids.p as string, idIndex: 0, left: 0, top: 0, width: 1, height: 1 },
|
|
162
|
-
{ id: ids.p as string, idIndex: 1, left: 0, top: 10, width: 1, height: 1 },
|
|
163
|
-
],
|
|
164
|
-
})
|
|
165
|
-
).toThrow(/repeated/);
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
// feature-4 artboard-level convert (2026-07-19) — the `containers` batch shape:
|
|
170
|
-
// whole-artboard flatten in ONE pass / ONE undo seq. Root level (artboard body)
|
|
171
|
-
// has no containerId; nested containers get relative-or-absolute exactly once.
|
|
172
|
-
describe('canvas-edit / applyConvertToAbsolute — containers batch (artboard level)', () => {
|
|
173
|
-
test('multi-level batch: root children absolute, nested container relative+absolute once', () => {
|
|
174
|
-
const src = `function Demo() { return <div className="hero"><h1>T</h1><section className="row"><p>a</p><em>b</em></section></div>; }`;
|
|
175
|
-
const ids = idsOf(src);
|
|
176
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
177
|
-
containers: [
|
|
178
|
-
// Root level — the artboard body (no containerId): the hero div itself.
|
|
179
|
-
{
|
|
180
|
-
containerSetRelative: false,
|
|
181
|
-
children: [{ id: ids.div as string, left: 0, top: 0, width: 520, height: 400 }],
|
|
182
|
-
},
|
|
183
|
-
// The hero div's own children.
|
|
184
|
-
{
|
|
185
|
-
containerId: ids.div as string,
|
|
186
|
-
containerSetRelative: true,
|
|
187
|
-
children: [
|
|
188
|
-
{ id: ids.h1 as string, left: 24, top: 24, width: 200, height: 30 },
|
|
189
|
-
{ id: ids.section as string, left: 24, top: 70, width: 400, height: 60 },
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
// The nested section's children.
|
|
193
|
-
{
|
|
194
|
-
containerId: ids.section as string,
|
|
195
|
-
containerSetRelative: true,
|
|
196
|
-
children: [
|
|
197
|
-
{ id: ids.p as string, left: 0, top: 0, width: 100, height: 20 },
|
|
198
|
-
{ id: ids.em as string, left: 110, top: 0, width: 80, height: 20 },
|
|
199
|
-
],
|
|
200
|
-
},
|
|
201
|
-
],
|
|
202
|
-
});
|
|
203
|
-
// EVERY element position:absolute exactly once; the hero div (root child +
|
|
204
|
-
// container) carries absolute (child role) and NOT a second position key.
|
|
205
|
-
const positions = out.source.match(/position: "(absolute|relative)"/g) || [];
|
|
206
|
-
// 5 elements absolute (div, h1, section, p, em) + 0 extra relative — the
|
|
207
|
-
// div/section container-relative writes are skipped because both already
|
|
208
|
-
// received an absolute child-role write first.
|
|
209
|
-
expect(positions.filter((p) => p.includes('absolute')).length).toBe(5);
|
|
210
|
-
expect(positions.filter((p) => p.includes('relative')).length).toBe(0);
|
|
211
|
-
// No element carries two position keys.
|
|
212
|
-
expect(out.source).not.toMatch(/position:[^}]*position:/);
|
|
213
|
-
// Boxes landed.
|
|
214
|
-
expect(out.source).toContain('left: "110px"');
|
|
215
|
-
expect(out.source).toContain('width: "520px"');
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
// dogfood 2026-07-20 — hand-AUTHORED data-cd-id (the pipeline preserves it, so
|
|
220
|
-
// the DOM id is the authored string, not the positional hash). The whole edit
|
|
221
|
-
// engine must resolve those: findOpening/collectElements* prefer the authored
|
|
222
|
-
// literal ("Convert failed: invalid container data-cd-id" on wal-hero-nav).
|
|
223
|
-
describe('canvas-edit / applyConvertToAbsolute — hand-authored data-cd-id', () => {
|
|
224
|
-
test('an authored-id container + authored-id child convert like any other', () => {
|
|
225
|
-
const src = `function Demo() { return <header data-cd-id="wal-hero-nav" className="nav"><a data-cd-id="wal-nav-link">Home</a><span>auto</span></header>; }`;
|
|
226
|
-
const ids = idsOf(src);
|
|
227
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
228
|
-
containerId: 'wal-hero-nav',
|
|
229
|
-
containerSetRelative: true,
|
|
230
|
-
children: [
|
|
231
|
-
{ id: 'wal-nav-link', left: 0, top: 0, width: 60, height: 20 },
|
|
232
|
-
{ id: ids.span as string, left: 70, top: 0, width: 40, height: 20 },
|
|
233
|
-
],
|
|
234
|
-
});
|
|
235
|
-
expect(out.source).toContain('position: "relative"');
|
|
236
|
-
// New style attr inserts right after the tag name (before authored attrs).
|
|
237
|
-
expect(out.source).toContain('<a style={{ position: "absolute"');
|
|
238
|
-
expect(out.source).toMatch(/<a style=\{\{[^}]+\}\} data-cd-id="wal-nav-link"/);
|
|
239
|
-
// The auto-stamped sibling (positional hash id) still resolves too.
|
|
240
|
-
expect((out.source.match(/position: "absolute"/g) || []).length).toBe(2);
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// feature-4 TRUE FLATTEN (2026-07-20) — dissolve: unstyled layout wrappers'
|
|
245
|
-
// tags are removed from the JSX (children hoist textually); style targets and
|
|
246
|
-
// dissolve targets are disjoint by contract (hard error otherwise).
|
|
247
|
-
describe('canvas-edit / applyConvertToAbsolute — dissolve (true flatten)', () => {
|
|
248
|
-
test('wrapper tags removed, children hoisted + absolute against the surviving root', () => {
|
|
249
|
-
const src = `function Demo() { return <div className="hero"><div className="row"><h1>T</h1><button>Go</button></div></div>; }`;
|
|
250
|
-
const ids = idsOf(src);
|
|
251
|
-
// hero survives (gets relative); row dissolves; its children measured vs hero.
|
|
252
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
253
|
-
containers: [
|
|
254
|
-
{
|
|
255
|
-
containerId: ids.div as string, // hero (first div)
|
|
256
|
-
containerSetRelative: true,
|
|
257
|
-
children: [
|
|
258
|
-
{ id: ids.h1 as string, left: 10, top: 10, width: 100, height: 30 },
|
|
259
|
-
{ id: ids.button as string, left: 10, top: 50, width: 80, height: 40 },
|
|
260
|
-
],
|
|
261
|
-
},
|
|
262
|
-
],
|
|
263
|
-
dissolve: [
|
|
264
|
-
// the row div — second stamped div; find its id via a second idsOf pass
|
|
265
|
-
],
|
|
266
|
-
});
|
|
267
|
-
// Without knowing row's id from idsOf (first-match map), assert base shape.
|
|
268
|
-
expect(out.source).toContain('position: "relative"');
|
|
269
|
-
expect((out.source.match(/position: "absolute"/g) || []).length).toBe(2);
|
|
270
|
-
});
|
|
271
|
-
|
|
272
|
-
test('dissolve removes exactly the wrapper tags (children JSX intact)', () => {
|
|
273
|
-
const src = `function Demo() { return <section className="card"><div className="col"><p>a</p></div></section>; }`;
|
|
274
|
-
const { withIds } = transpileCanvasSource(CANVAS, src);
|
|
275
|
-
const colId = /<div([^>]*?)data-cd-id="([0-9a-f]{8})"/.exec(withIds)?.[2] as string;
|
|
276
|
-
const secId = /<section([^>]*?)data-cd-id="([0-9a-f]{8})"/.exec(withIds)?.[2] as string;
|
|
277
|
-
const pId = /<p([^>]*?)data-cd-id="([0-9a-f]{8})"/.exec(withIds)?.[2] as string;
|
|
278
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
279
|
-
containers: [
|
|
280
|
-
{
|
|
281
|
-
containerId: secId,
|
|
282
|
-
containerSetRelative: true,
|
|
283
|
-
children: [{ id: pId, left: 5, top: 5, width: 50, height: 20 }],
|
|
284
|
-
},
|
|
285
|
-
],
|
|
286
|
-
dissolve: [colId],
|
|
287
|
-
});
|
|
288
|
-
// The col wrapper's tags are gone; the <p> hoisted directly under section.
|
|
289
|
-
expect(out.source).not.toContain('className="col"');
|
|
290
|
-
expect(out.source).toMatch(/<section[^>]*>\s*<p style=\{\{ position: "absolute"/);
|
|
291
|
-
expect(out.source).toContain('</section>');
|
|
292
|
-
expect(out.source).not.toMatch(/<\/div>/);
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
test('an id that is BOTH a style target and a dissolve target throws', () => {
|
|
296
|
-
const src = `function Demo() { return <div><p>a</p></div>; }`;
|
|
297
|
-
const ids = idsOf(src);
|
|
298
|
-
expect(() =>
|
|
299
|
-
applyConvertToAbsolute(CANVAS, src, {
|
|
300
|
-
containers: [
|
|
301
|
-
{
|
|
302
|
-
containerSetRelative: false,
|
|
303
|
-
children: [{ id: ids.p as string, left: 0, top: 0, width: 1, height: 1 }],
|
|
304
|
-
},
|
|
305
|
-
],
|
|
306
|
-
dissolve: [ids.p as string],
|
|
307
|
-
})
|
|
308
|
-
).toThrow(/both a style target and a dissolve/);
|
|
309
|
-
});
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
// dogfood round 4 — the element-level subtree ROOT keeps flow position but
|
|
313
|
-
// freezes its own box (auto height would collapse once children go absolute).
|
|
314
|
-
describe('canvas-edit / applyConvertToAbsolute — root freezeSize', () => {
|
|
315
|
-
test('container gets relative + frozen width/height in one style attr', () => {
|
|
316
|
-
const src = `function Demo() { return <div className="grp"><p>a</p></div>; }`;
|
|
317
|
-
const ids = idsOf(src);
|
|
318
|
-
const out = applyConvertToAbsolute(CANVAS, src, {
|
|
319
|
-
containers: [
|
|
320
|
-
{
|
|
321
|
-
containerId: ids.div as string,
|
|
322
|
-
containerSetRelative: true,
|
|
323
|
-
freezeSize: { width: 472, height: 131 },
|
|
324
|
-
children: [{ id: ids.p as string, left: 12, top: 12, width: 60, height: 30 }],
|
|
325
|
-
},
|
|
326
|
-
],
|
|
327
|
-
});
|
|
328
|
-
expect(out.source).toContain(
|
|
329
|
-
'<div style={{ position: "relative", width: "472px", height: "131px", "box-sizing": "border-box" }} className="grp">'
|
|
330
|
-
);
|
|
331
|
-
expect(out.source).toContain('position: "absolute"');
|
|
332
|
-
});
|
|
333
|
-
});
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
// The credential registry — validate 2026-07-30.
|
|
2
|
-
//
|
|
3
|
-
// The point of these is not that six regexes work. It is that the registry
|
|
4
|
-
// stays COMPLETE: the last test walks the source tree for prefixes the code
|
|
5
|
-
// actually mints and fails when one of them has no grammar. A seventh
|
|
6
|
-
// credential shape cannot reach a diagnostic bundle unnoticed.
|
|
7
|
-
|
|
8
|
-
import { describe, expect, test } from 'bun:test';
|
|
9
|
-
import { readdirSync, readFileSync, statSync } from 'node:fs';
|
|
10
|
-
import { dirname, join } from 'node:path';
|
|
11
|
-
import { fileURLToPath } from 'node:url';
|
|
12
|
-
|
|
13
|
-
import { CREDENTIAL_GRAMMARS, redactMaudeCredentials } from '../credential-grammar.ts';
|
|
14
|
-
import { scrub } from '../debug-bundle.ts';
|
|
15
|
-
|
|
16
|
-
const REPO = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..');
|
|
17
|
-
|
|
18
|
-
describe('every Maude-minted credential is redacted', () => {
|
|
19
|
-
const samples: Array<[string, string]> = [
|
|
20
|
-
['peer-token', 'mau_0123456789abcdef0123456789abcdef'],
|
|
21
|
-
['personal-token', `mpt_${'a'.repeat(48)}`],
|
|
22
|
-
['handoff-code', `mhc_${'b'.repeat(64)}`],
|
|
23
|
-
['device-code', `mdc_${'c'.repeat(48)}`],
|
|
24
|
-
// The one the JWT rule structurally cannot see: TWO parts, not three,
|
|
25
|
-
// because the project token deliberately is not a JWT (DDR-204).
|
|
26
|
-
['project-token', 'eyJlbWFpbCI6ImFAYi5jbyJ9.c2lnbmF0dXJlLXRoYXQtaXMtbG9uZy1lbm91Z2g'],
|
|
27
|
-
['derived-cell-secret', 'f'.repeat(64)],
|
|
28
|
-
];
|
|
29
|
-
|
|
30
|
-
for (const [id, sample] of samples) {
|
|
31
|
-
test(`${id} never survives a scrub`, () => {
|
|
32
|
-
const line = `[sync] presenting ${sample} to the workspace`;
|
|
33
|
-
expect(redactMaudeCredentials(line)).not.toContain(sample);
|
|
34
|
-
// And through the real front door the bug report uses.
|
|
35
|
-
expect(scrub(line)).not.toContain(sample);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
test('a two-part project token is caught even though the JWT rule needs three', () => {
|
|
40
|
-
const twoPart = 'eyJlbWFpbCI6ImFAYi5jbyJ9.c2lnbmF0dXJlLXRoYXQtaXMtbG9uZy1lbm91Z2g';
|
|
41
|
-
expect(twoPart.split('.').length).toBe(2);
|
|
42
|
-
expect(scrub(`token=${twoPart}`)).not.toContain(twoPart);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('an underscore-joined secret env name is redacted (\\b cannot match inside HUB_SECRET)', () => {
|
|
46
|
-
const out = scrub('HUB_SECRET=s3cr3t-value-here CELL_SECRET_MASTER=another-one');
|
|
47
|
-
expect(out).not.toContain('s3cr3t-value-here');
|
|
48
|
-
expect(out).not.toContain('another-one');
|
|
49
|
-
expect(out).toContain('HUB_SECRET');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test('ordinary text is left alone', () => {
|
|
53
|
-
const plain = 'opened .design/ui/home.tsx and rendered 42 artboards in 1.2s';
|
|
54
|
-
expect(scrub(plain)).toContain('home.tsx');
|
|
55
|
-
expect(scrub(plain)).not.toContain('[redacted]');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
describe('the registry stays complete', () => {
|
|
60
|
-
/** Every `<prefix>_` literal the codebase mints a credential with. */
|
|
61
|
-
function mintedPrefixes(): Set<string> {
|
|
62
|
-
const found = new Set<string>();
|
|
63
|
-
const walk = (dir: string, depth = 0) => {
|
|
64
|
-
if (depth > 4) return;
|
|
65
|
-
for (const entry of readdirSync(dir)) {
|
|
66
|
-
if (entry === 'node_modules' || entry.startsWith('.')) continue;
|
|
67
|
-
const p = join(dir, entry);
|
|
68
|
-
let st: ReturnType<typeof statSync>;
|
|
69
|
-
try {
|
|
70
|
-
st = statSync(p);
|
|
71
|
-
} catch {
|
|
72
|
-
continue;
|
|
73
|
-
}
|
|
74
|
-
if (st.isDirectory()) {
|
|
75
|
-
walk(p, depth + 1);
|
|
76
|
-
continue;
|
|
77
|
-
}
|
|
78
|
-
if (!/\.(mjs|ts)$/.test(entry) || /\.test\./.test(entry)) continue;
|
|
79
|
-
const src = readFileSync(p, 'utf8');
|
|
80
|
-
// A mint always builds the value from a literal prefix plus randomness,
|
|
81
|
-
// e.g. `` `mpt_${b64hex(crypto.getRandomValues(...))}` ``.
|
|
82
|
-
for (const m of src.matchAll(/`(m[a-z]{2})_\$\{/g)) found.add(m[1]);
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
for (const app of ['apps/cloud', 'apps/hub', 'apps/cells', 'cli']) {
|
|
86
|
-
try {
|
|
87
|
-
walk(join(REPO, app));
|
|
88
|
-
} catch {
|
|
89
|
-
/* an absent app is not a failure */
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return found;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
test('every prefix the code mints has a grammar', () => {
|
|
96
|
-
const registered = new Set(
|
|
97
|
-
CREDENTIAL_GRAMMARS.flatMap((g) => {
|
|
98
|
-
const m = /\\b(m[a-z]{2})_/.exec(g.pattern.source);
|
|
99
|
-
return m ? [m[1]] : [];
|
|
100
|
-
})
|
|
101
|
-
);
|
|
102
|
-
const minted = mintedPrefixes();
|
|
103
|
-
expect(minted.size).toBeGreaterThan(0); // the walk must actually find things
|
|
104
|
-
const missing = [...minted].filter((p) => !registered.has(p));
|
|
105
|
-
expect(missing).toEqual([]);
|
|
106
|
-
});
|
|
107
|
-
});
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
// cspForCanvasShell — A6 (DDR-060 F1 re-audit) CSP hardening for the segregated
|
|
2
|
-
// canvas origin. Asserts the exfil-relevant directives are present and that
|
|
3
|
-
// `frame-ancestors` is only emitted when the main origin is known (so the legit
|
|
4
|
-
// cross-origin embed is never accidentally blocked).
|
|
5
|
-
|
|
6
|
-
import { describe, expect, test } from 'bun:test';
|
|
7
|
-
|
|
8
|
-
import { cspForCanvasShell } from '../http.ts';
|
|
9
|
-
|
|
10
|
-
const SHELL = '<!doctype html><html><head><script>const x=1;</script></head><body></body></html>';
|
|
11
|
-
|
|
12
|
-
describe('cspForCanvasShell — A6 hardening', () => {
|
|
13
|
-
test('locks down the dangerous lanes', () => {
|
|
14
|
-
const csp = cspForCanvasShell(SHELL);
|
|
15
|
-
expect(csp).toContain("default-src 'none'");
|
|
16
|
-
expect(csp).toContain("connect-src 'self'");
|
|
17
|
-
expect(csp).toContain("object-src 'none'");
|
|
18
|
-
expect(csp).toContain("base-uri 'none'");
|
|
19
|
-
// No eval / no inline-script escape hatch.
|
|
20
|
-
expect(csp).not.toContain('unsafe-eval');
|
|
21
|
-
expect(csp).not.toMatch(/script-src[^;]*unsafe-inline/);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test("adds webrtc 'block' (connect-src does not cover WebRTC exfil)", () => {
|
|
25
|
-
expect(cspForCanvasShell(SHELL)).toContain("webrtc 'block'");
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
test("adds form-action 'none'", () => {
|
|
29
|
-
expect(cspForCanvasShell(SHELL)).toContain("form-action 'none'");
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('hashes inline scripts (no unsafe-inline for script-src)', () => {
|
|
33
|
-
const csp = cspForCanvasShell(SHELL);
|
|
34
|
-
expect(csp).toMatch(/script-src 'self' 'sha256-[A-Za-z0-9+/=]+'/);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
test('frame-ancestors allowlists the main origin when known', () => {
|
|
38
|
-
const csp = cspForCanvasShell(SHELL, 'http://localhost:4399');
|
|
39
|
-
expect(csp).toContain("frame-ancestors 'self' http://localhost:4399");
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('frame-ancestors carries every advertised loopback spelling (localhost + 127.0.0.1)', () => {
|
|
43
|
-
const csp = cspForCanvasShell(SHELL, 'http://localhost:4399 http://127.0.0.1:4399');
|
|
44
|
-
expect(csp).toContain("frame-ancestors 'self' http://localhost:4399 http://127.0.0.1:4399");
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
test('frame-ancestors is OMITTED when the main origin is unknown (would block the legit embed)', () => {
|
|
48
|
-
const csp = cspForCanvasShell(SHELL);
|
|
49
|
-
expect(csp).not.toContain('frame-ancestors');
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
// fix-photo-editor-followup-debt Task 22 — the narrow, documented
|
|
53
|
-
// `connect-src` exception for @imgly/background-removal's model-weight CDN.
|
|
54
|
-
// Regression guard against both directions of drift: the exception being
|
|
55
|
-
// silently reverted, AND further hosts creeping in beside it.
|
|
56
|
-
test('connect-src carries the exact staticimgly.com exception, no more', () => {
|
|
57
|
-
const csp = cspForCanvasShell(SHELL);
|
|
58
|
-
expect(csp).toContain("connect-src 'self' https://staticimgly.com");
|
|
59
|
-
const connectSrc = csp.split('; ').find((d) => d.startsWith('connect-src'));
|
|
60
|
-
expect(connectSrc).toBe("connect-src 'self' https://staticimgly.com");
|
|
61
|
-
});
|
|
62
|
-
});
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
// CSRF Origin guard for the main-origin source-write routes (edit-css /
|
|
2
|
-
// edit-text / edit-attr). DDR-105. The DDR-054 origin-split already blocks the
|
|
3
|
-
// untrusted canvas *iframe* (canvas-origin-gate.test.ts proves that). This guard
|
|
4
|
-
// covers the OTHER untrusted origin: a malicious top-level page in another tab
|
|
5
|
-
// forging a `text/plain` CORS simple-request POST to localhost. The browser
|
|
6
|
-
// stamps such a request with an unspoofable cross-origin `Origin` header, so the
|
|
7
|
-
// guard must reject it — while still letting the legit same-origin shell write
|
|
8
|
-
// and not breaking non-browser clients (which send no Origin header).
|
|
9
|
-
//
|
|
10
|
-
// Unit-level on purpose: `sameOriginWrite` is a pure function of the Request, so
|
|
11
|
-
// we exercise the decision directly instead of booting a subprocess server.
|
|
12
|
-
// (A booted-server integration test would add a 124th server-booting file to the
|
|
13
|
-
// suite, which perturbs bun's worker scheduling and surfaces a PRE-EXISTING
|
|
14
|
-
// cross-worker port-collision flake in canvas-meta-api.test.ts — a test-harness
|
|
15
|
-
// race unrelated to this guard. See the Phase 12.2 validate notes.)
|
|
16
|
-
|
|
17
|
-
import { describe, expect, test } from 'bun:test';
|
|
18
|
-
import { readFileSync } from 'node:fs';
|
|
19
|
-
import { fileURLToPath } from 'node:url';
|
|
20
|
-
|
|
21
|
-
import { sameOriginRead, sameOriginWrite } from '../http.ts';
|
|
22
|
-
|
|
23
|
-
const SELF = 'http://localhost:4399';
|
|
24
|
-
const post = (origin?: string): Request =>
|
|
25
|
-
new Request(`${SELF}/_api/edit-css`, {
|
|
26
|
-
method: 'POST',
|
|
27
|
-
headers: { 'content-type': 'text/plain', ...(origin ? { origin } : {}) },
|
|
28
|
-
body: '{}',
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('CSRF Origin guard — sameOriginWrite (DDR-105)', () => {
|
|
32
|
-
test('rejects a forged cross-origin Origin', () => {
|
|
33
|
-
expect(sameOriginWrite(post('http://evil.example'))).toBe(false);
|
|
34
|
-
// A look-alike host (substring / suffix tricks) must not slip through.
|
|
35
|
-
expect(sameOriginWrite(post('http://localhost.evil.example'))).toBe(false);
|
|
36
|
-
expect(sameOriginWrite(post('http://localhost:4399.evil.example'))).toBe(false);
|
|
37
|
-
// Right host, wrong port is still cross-origin.
|
|
38
|
-
expect(sameOriginWrite(post('http://localhost:4400'))).toBe(false);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
test('allows the legit same-origin shell Origin', () => {
|
|
42
|
-
expect(sameOriginWrite(post(SELF))).toBe(true);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
test('a matching host on a different SCHEME is same-origin — TLS terminates at the cell proxy', () => {
|
|
46
|
-
// The second half of the inspector-edits RCA. In a cell the browser sends
|
|
47
|
-
// `https://<host>` but the studio serves plaintext and computes `req.url` as
|
|
48
|
-
// `http://<host>`, so a scheme-strict compare 403'd every legitimate shell
|
|
49
|
-
// write. Host+port still pins it; a cross-site page has a different host.
|
|
50
|
-
const cell = 'https://alligators.cloud.maude.sh';
|
|
51
|
-
const cellReq = (origin?: string) =>
|
|
52
|
-
new Request('http://alligators.cloud.maude.sh/_api/edit-css', {
|
|
53
|
-
method: 'POST',
|
|
54
|
-
headers: { 'content-type': 'application/json', ...(origin ? { origin } : {}) },
|
|
55
|
-
body: '{}',
|
|
56
|
-
});
|
|
57
|
-
expect(sameOriginWrite(cellReq(cell))).toBe(true); // https Origin ↔ http req.url, same host
|
|
58
|
-
// But a genuinely different host is still rejected, scheme notwithstanding.
|
|
59
|
-
expect(sameOriginWrite(cellReq('https://evil.cloud.maude.sh'))).toBe(false);
|
|
60
|
-
// And the port still discriminates when present.
|
|
61
|
-
expect(sameOriginWrite(post('https://localhost:4400'))).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('allows a request with no Origin header (curl / programmatic / bun:test)', () => {
|
|
65
|
-
expect(sameOriginWrite(post())).toBe(true);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test('rejects an unparseable Origin rather than letting it through', () => {
|
|
69
|
-
expect(sameOriginWrite(post('not a url'))).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe('CSRF read guard — sameOriginRead (Task 2.5 F1, Fetch-Metadata)', () => {
|
|
74
|
-
const get = (secFetchSite?: string): Request =>
|
|
75
|
-
new Request(`${SELF}/_api/generate/audio-search?q=x`, {
|
|
76
|
-
method: 'GET',
|
|
77
|
-
headers: { ...(secFetchSite ? { 'sec-fetch-site': secFetchSite } : {}) },
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
test('rejects a cross-site browser GET (key-bearing fan-out must not be CSRF-triggerable)', () => {
|
|
81
|
-
expect(sameOriginRead(get('cross-site'))).toBe(false);
|
|
82
|
-
expect(sameOriginRead(get('same-site'))).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('allows a same-origin browser GET', () => {
|
|
86
|
-
expect(sameOriginRead(get('same-origin'))).toBe(true);
|
|
87
|
-
expect(sameOriginRead(get('none'))).toBe(true); // direct navigation
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
test('allows a non-browser client (CLI / curl — no Sec-Fetch-Site header)', () => {
|
|
91
|
-
expect(sameOriginRead(get())).toBe(true);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
// phase-30 / DDR-120: the ai-activity bridge now projects `/_api/ai/*` POSTs
|
|
96
|
-
// onto room awareness, which crosses the hub to every connected peer. So a
|
|
97
|
-
// forged cross-origin POST to /start /heartbeat /end is no longer a harmless
|
|
98
|
-
// loopback banner — it injects a fake "<x> is editing <slug>" presence to all
|
|
99
|
-
// peers (the channel that drives the social save/publish decision). These three
|
|
100
|
-
// routes MUST carry the same `sameOriginWrite` guard as the other write routes.
|
|
101
|
-
// Source-level assertion (same "don't boot a server" rationale as above): pin
|
|
102
|
-
// the guard into each route block so an accidental removal fails CI.
|
|
103
|
-
describe('CSRF Origin guard — /_api/ai/* presence-bridge routes (phase-30)', () => {
|
|
104
|
-
const src = readFileSync(fileURLToPath(new URL('../http.ts', import.meta.url)), 'utf8');
|
|
105
|
-
|
|
106
|
-
for (const route of ['/_api/ai/start', '/_api/ai/heartbeat', '/_api/ai/end']) {
|
|
107
|
-
test(`${route} is wired with the sameOriginWrite CSRF guard`, () => {
|
|
108
|
-
// Slice from this route's key to the next route key, then assert the guard
|
|
109
|
-
// appears inside that block.
|
|
110
|
-
const start = src.indexOf(`'${route}':`);
|
|
111
|
-
expect(start).toBeGreaterThan(-1);
|
|
112
|
-
const after = src.indexOf("'/_api/", start + 1);
|
|
113
|
-
const block = src.slice(start, after === -1 ? undefined : after);
|
|
114
|
-
expect(block).toContain('sameOriginWrite(req)');
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
// Phase 12.1 / DDR-138: /_api/reorder is a source-write (node-move). It MUST
|
|
120
|
-
// carry the same sameOriginWrite guard as the other edit-* write routes so a
|
|
121
|
-
// forged cross-origin POST can't drive a structural reorder of the user's .tsx.
|
|
122
|
-
// Source-level assertion (same "don't boot a server" rationale as above).
|
|
123
|
-
describe('CSRF Origin guard — /_api/reorder source-write route (DDR-138)', () => {
|
|
124
|
-
const src = readFileSync(fileURLToPath(new URL('../http.ts', import.meta.url)), 'utf8');
|
|
125
|
-
|
|
126
|
-
test('/_api/reorder is wired with the sameOriginWrite CSRF guard', () => {
|
|
127
|
-
const start = src.indexOf("'/_api/reorder':");
|
|
128
|
-
expect(start).toBeGreaterThan(-1);
|
|
129
|
-
const after = src.indexOf("'/_api/", start + 1);
|
|
130
|
-
const block = src.slice(start, after === -1 ? undefined : after);
|
|
131
|
-
expect(block).toContain('sameOriginWrite(req)');
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
test('/_api/reorder-revert is wired with the sameOriginWrite CSRF guard', () => {
|
|
135
|
-
const start = src.indexOf("'/_api/reorder-revert':");
|
|
136
|
-
expect(start).toBeGreaterThan(-1);
|
|
137
|
-
const after = src.indexOf("'/_api/", start + 1);
|
|
138
|
-
const block = src.slice(start, after === -1 ? undefined : after);
|
|
139
|
-
expect(block).toContain('sameOriginWrite(req)');
|
|
140
|
-
});
|
|
141
|
-
});
|