@1agh/maude 0.58.1 → 0.58.3
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/apps/studio/.ai/cache/_stats.json +1 -1
- package/apps/studio/acp/bridge.ts +165 -15
- package/apps/studio/annotations-bindings.ts +83 -4
- package/apps/studio/api.ts +6 -1
- package/apps/studio/bin/_fetch-asset.mjs +169 -5
- package/apps/studio/bin/_import-asset.mjs +72 -0
- package/apps/studio/bin/_import-figma.mjs +1121 -0
- package/apps/studio/bin/_video-playwright.mjs +86 -3
- package/apps/studio/bin/import-figma.sh +38 -0
- package/apps/studio/bin/read-annotations.mjs +11 -1
- package/apps/studio/bun.lock +16 -22
- package/apps/studio/canvas-edit.ts +29 -5
- package/apps/studio/client/app.jsx +129 -23
- package/apps/studio/client/export-center.jsx +42 -4
- package/apps/studio/client/panels/ChatPanel.jsx +25 -2
- package/apps/studio/client/panels/CloudBar.jsx +92 -1
- package/apps/studio/client/panels/FigmaImportPanel.jsx +264 -0
- package/apps/studio/client/panels/GitPanel.jsx +26 -6
- package/apps/studio/client/panels/SettingsPanel.jsx +181 -0
- package/apps/studio/client/panels/SetupChecklist.jsx +26 -2
- package/apps/studio/client/panels/TimelinePanel.jsx +2 -2
- package/apps/studio/client/panels/timeline-parse.js +3 -3
- package/apps/studio/client/styles/3-shell-maude.css +7 -0
- package/apps/studio/client/styles/4-components.css +134 -0
- package/apps/studio/client/styles/6-acp-chat.css +12 -0
- package/apps/studio/clip-ops.ts +93 -17
- package/apps/studio/cloud/endpoints.ts +78 -10
- package/apps/studio/cloud/renew.ts +183 -0
- package/apps/studio/context.ts +2 -1
- package/apps/studio/dist/client.bundle.js +1491 -1491
- package/apps/studio/dist/runtime/@remotion_media.js +56 -136
- package/apps/studio/dist/runtime/@remotion_player.js +18 -18
- package/apps/studio/dist/runtime/@remotion_transitions.js +9 -9
- package/apps/studio/dist/runtime/@remotion_transitions_clock-wipe.js +1 -1
- package/apps/studio/dist/runtime/remotion.js +12 -12
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/exporters/_browser-bundles.ts +20 -6
- package/apps/studio/exporters/_runtime.ts +19 -0
- package/apps/studio/exporters/degraded.ts +92 -0
- package/apps/studio/exporters/index.ts +5 -0
- package/apps/studio/exporters/jobs.ts +19 -0
- package/apps/studio/exporters/unsupported-media.ts +170 -0
- package/apps/studio/exporters/video-encode-lib.ts +27 -1
- package/apps/studio/exporters/video-render-lib.ts +6 -0
- package/apps/studio/exporters/video.ts +62 -1
- package/apps/studio/figma/assets.test.ts +372 -0
- package/apps/studio/figma/assets.ts +398 -0
- package/apps/studio/figma/client.test.ts +395 -0
- package/apps/studio/figma/client.ts +513 -0
- package/apps/studio/figma/comments-to-strokes.test.ts +194 -0
- package/apps/studio/figma/comments-to-strokes.ts +173 -0
- package/apps/studio/figma/endpoints.ts +200 -0
- package/apps/studio/figma/sanitize.test.ts +256 -0
- package/apps/studio/figma/sanitize.ts +315 -0
- package/apps/studio/figma/style-map.ts +352 -0
- package/apps/studio/figma/to-artboard.test.ts +808 -0
- package/apps/studio/figma/to-artboard.ts +701 -0
- package/apps/studio/figma/to-render.test.ts +180 -0
- package/apps/studio/figma/to-render.ts +306 -0
- package/apps/studio/figma/to-strokes-roundtrip.test.ts +152 -0
- package/apps/studio/figma/to-strokes.test.ts +705 -0
- package/apps/studio/figma/to-strokes.ts +749 -0
- package/apps/studio/figma/to-tokens.test.ts +321 -0
- package/apps/studio/figma/to-tokens.ts +305 -0
- package/apps/studio/figma/types.ts +539 -0
- package/apps/studio/figma/url.test.ts +167 -0
- package/apps/studio/figma/url.ts +160 -0
- package/apps/studio/http.ts +129 -0
- package/apps/studio/sync/asset-push.ts +124 -0
- package/apps/studio/sync/canvas-path.ts +329 -0
- package/apps/studio/sync/codec.ts +42 -0
- package/apps/studio/sync/connection-state.ts +11 -0
- package/apps/studio/sync/hub-link.ts +63 -7
- package/apps/studio/sync/hubs-config.ts +31 -3
- package/apps/studio/sync/index.ts +755 -32
- package/apps/studio/sync/migrate-flat-fallback.ts +121 -0
- package/apps/studio/sync/presentation.ts +45 -1
- package/apps/studio/sync/projection.ts +11 -1
- package/apps/studio/sync/remote-docs.ts +122 -15
- package/apps/studio/sync/supervisor.ts +5 -1
- package/apps/studio/sync/workspace-signin.ts +7 -3
- package/apps/studio/test/acp-bridge-lifetime.test.ts +106 -0
- package/apps/studio/test/annotations-bindings.test.ts +150 -12
- package/apps/studio/test/canvas-create-api.test.ts +4 -1
- package/apps/studio/test/canvas-origin-gate.test.ts +13 -0
- package/apps/studio/test/capture-determinism-shape.test.ts +135 -0
- package/apps/studio/test/clip-addressing.test.ts +6 -1
- package/apps/studio/test/clip-ops.test.ts +5 -1
- package/apps/studio/test/cloud-endpoints.test.ts +96 -0
- package/apps/studio/test/cloud-renew.test.ts +205 -0
- package/apps/studio/test/cloud-shell-surfaces.test.ts +11 -2
- package/apps/studio/test/comment-relay-origin-gate.test.ts +117 -0
- package/apps/studio/test/comments-fs-rebroadcast.test.ts +155 -0
- package/apps/studio/test/exporters/degraded-propagation.test.ts +123 -0
- package/apps/studio/test/exporters/unsupported-media.test.ts +123 -0
- package/apps/studio/test/fetch-asset-gate.test.ts +189 -0
- package/apps/studio/test/figma-provenance.test.ts +108 -0
- package/apps/studio/test/figma-routes.test.ts +294 -0
- package/apps/studio/test/fixtures/mock-acp-agent-wedged.mjs +37 -0
- package/apps/studio/test/git-cloud-posture.test.ts +50 -0
- package/apps/studio/test/hub-link.test.ts +11 -0
- package/apps/studio/test/import-figma.test.ts +479 -0
- package/apps/studio/test/sync-asset-push.test.ts +124 -0
- package/apps/studio/test/sync-canvas-path.test.ts +200 -0
- package/apps/studio/test/sync-connection-state.test.ts +13 -0
- package/apps/studio/test/sync-hubs-config.test.ts +5 -0
- package/apps/studio/test/sync-migrate-flat-fallback.test.ts +98 -0
- package/apps/studio/test/sync-path-pull.test.ts +465 -0
- package/apps/studio/test/sync-presentation.test.ts +77 -0
- package/apps/studio/test/sync-remote-docs.test.ts +55 -3
- package/apps/studio/test/sync-runtime.test.ts +434 -1
- package/apps/studio/test/video-comp.test.ts +23 -1
- package/apps/studio/test/workspace-containment.test.ts +1 -0
- package/apps/studio/video-comp.tsx +70 -6
- package/apps/studio/whats-new.json +36 -0
- package/apps/studio/workspace-mode.ts +4 -0
- package/cli/commands/design.mjs +8 -0
- package/package.json +8 -8
- package/plugins/flow/.claude-plugin/config.schema.json +3 -3
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// RCA issue-mp4-audio-export-html5audio-silent-degrade — the pre-flight scanner.
|
|
2
|
+
//
|
|
3
|
+
// The cases here are the ones the RCA's Testing Requirements name, and the
|
|
4
|
+
// barrel case is the one that matters most: the reproducer does NOT import
|
|
5
|
+
// `Audio` from 'remotion' in the canvas file. It imports it from `_broadcast`,
|
|
6
|
+
// which re-exports it. A scanner that reads only the canvas sees a clean local
|
|
7
|
+
// import and waves the export through — which is exactly how this shipped.
|
|
8
|
+
|
|
9
|
+
import { describe, expect, test } from 'bun:test';
|
|
10
|
+
import { mkdtempSync, writeFileSync } from 'node:fs';
|
|
11
|
+
import { tmpdir } from 'node:os';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
|
|
14
|
+
import { audioRefusalMessage, scanUnsupportedMedia } from '../../exporters/unsupported-media.ts';
|
|
15
|
+
|
|
16
|
+
function sandbox(files: Record<string, string>): string {
|
|
17
|
+
const dir = mkdtempSync(join(tmpdir(), 'maude-unsupported-'));
|
|
18
|
+
for (const [name, body] of Object.entries(files)) {
|
|
19
|
+
writeFileSync(join(dir, name), body);
|
|
20
|
+
}
|
|
21
|
+
return dir;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
describe('scanUnsupportedMedia', () => {
|
|
25
|
+
test('flags a direct <Audio> import from remotion', () => {
|
|
26
|
+
const dir = sandbox({
|
|
27
|
+
'c.tsx': `import { AbsoluteFill, Audio } from 'remotion';
|
|
28
|
+
export const C = () => <AbsoluteFill><Audio src="x.mp3" /></AbsoluteFill>;`,
|
|
29
|
+
});
|
|
30
|
+
const found = scanUnsupportedMedia(join(dir, 'c.tsx'));
|
|
31
|
+
expect(found).toHaveLength(1);
|
|
32
|
+
expect(found[0].element).toBe('Audio');
|
|
33
|
+
expect(found[0].viaBarrel).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('flags it in a multi-binding import alongside supported names', () => {
|
|
37
|
+
const dir = sandbox({
|
|
38
|
+
'c.tsx': `import { AbsoluteFill, OffthreadVideo, Audio } from 'remotion';
|
|
39
|
+
export const C = () => <><Audio src="a" /><OffthreadVideo src="v" /></>;`,
|
|
40
|
+
});
|
|
41
|
+
const els = scanUnsupportedMedia(join(dir, 'c.tsx')).map((f) => f.element);
|
|
42
|
+
expect(els).toContain('Audio');
|
|
43
|
+
expect(els).toContain('OffthreadVideo');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test('sees through a re-export barrel one hop away — the actual shape of the bug', () => {
|
|
47
|
+
const dir = sandbox({
|
|
48
|
+
'_broadcast.tsx': `export { Audio } from 'remotion';
|
|
49
|
+
export const Brand = () => null;`,
|
|
50
|
+
'c.tsx': `import { Audio, Brand } from './_broadcast';
|
|
51
|
+
export const C = () => <><Brand /><Audio src="sax.mp3" /></>;`,
|
|
52
|
+
});
|
|
53
|
+
const found = scanUnsupportedMedia(join(dir, 'c.tsx'));
|
|
54
|
+
expect(found).toHaveLength(1);
|
|
55
|
+
expect(found[0].element).toBe('Audio');
|
|
56
|
+
expect(found[0].viaBarrel).toBe(true);
|
|
57
|
+
expect(found[0].sourceFile).toContain('_broadcast');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('does NOT flag the supported @remotion/media import', () => {
|
|
61
|
+
const dir = sandbox({
|
|
62
|
+
'c.tsx': `import { Audio, Video } from '@remotion/media';
|
|
63
|
+
export const C = () => <><Audio src="a" /><Video src="v" /></>;`,
|
|
64
|
+
});
|
|
65
|
+
expect(scanUnsupportedMedia(join(dir, 'c.tsx'))).toHaveLength(0);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('does not flag a sibling package whose name merely starts with remotion', () => {
|
|
69
|
+
const dir = sandbox({
|
|
70
|
+
'c.tsx': `import { TransitionSeries } from '@remotion/transitions';
|
|
71
|
+
import { Audio } from '@remotion/media';
|
|
72
|
+
export const C = () => <Audio src="a" />;`,
|
|
73
|
+
});
|
|
74
|
+
expect(scanUnsupportedMedia(join(dir, 'c.tsx'))).toHaveLength(0);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test('ignores an unused import — not worth refusing an export over', () => {
|
|
78
|
+
const dir = sandbox({
|
|
79
|
+
'c.tsx': `import { AbsoluteFill, Audio } from 'remotion';
|
|
80
|
+
export const C = () => <AbsoluteFill>silent</AbsoluteFill>;`,
|
|
81
|
+
});
|
|
82
|
+
expect(scanUnsupportedMedia(join(dir, 'c.tsx'))).toHaveLength(0);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('catches an aliased import mounted under its alias', () => {
|
|
86
|
+
const dir = sandbox({
|
|
87
|
+
'c.tsx': `import { Audio as Sound } from 'remotion';
|
|
88
|
+
export const C = () => <Sound src="a" />;`,
|
|
89
|
+
});
|
|
90
|
+
const found = scanUnsupportedMedia(join(dir, 'c.tsx'));
|
|
91
|
+
expect(found).toHaveLength(1);
|
|
92
|
+
// Reported as the element it IS, but matched on the name it renders under.
|
|
93
|
+
expect(found[0].element).toBe('Audio');
|
|
94
|
+
expect(found[0].localName).toBe('Sound');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('an aliased-but-unused import is still not worth refusing over', () => {
|
|
98
|
+
const dir = sandbox({
|
|
99
|
+
'c.tsx': `import { Audio as Sound } from 'remotion';
|
|
100
|
+
export const C = () => <div>silent</div>;`,
|
|
101
|
+
});
|
|
102
|
+
expect(scanUnsupportedMedia(join(dir, 'c.tsx'))).toHaveLength(0);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
test('an unreadable canvas is not this check’s business to report', () => {
|
|
106
|
+
expect(scanUnsupportedMedia('/definitely/not/here.tsx')).toEqual([]);
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
describe('audioRefusalMessage', () => {
|
|
111
|
+
test('states the cause, the cost, and the one-word fix', () => {
|
|
112
|
+
const msg = audioRefusalMessage(
|
|
113
|
+
{ element: 'Audio', sourceFile: '/x/_broadcast.tsx', viaBarrel: true, localName: 'Audio' },
|
|
114
|
+
'ui/social/Krpole.tsx'
|
|
115
|
+
);
|
|
116
|
+
expect(msg).toContain('Html5Audio');
|
|
117
|
+
expect(msg).toContain('@remotion/media');
|
|
118
|
+
expect(msg).toContain('_broadcast.tsx');
|
|
119
|
+
// The escape hatch must be discoverable from the refusal itself, or a user
|
|
120
|
+
// who genuinely wants a muted export is stuck.
|
|
121
|
+
expect(msg).toContain('allowUnsupportedMedia');
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
// `_fetch-asset.mjs` — the gate's pure decision functions, plus the three
|
|
2
|
+
// DDR-216 additions. Standing tests, not optional hardening: DDR-216's
|
|
3
|
+
// Consequences names each of these by hand because this is a SHARED,
|
|
4
|
+
// security-reviewed helper whose OTHER caller (the DDR-147 moodboard lane) has
|
|
5
|
+
// no host allowlist at all.
|
|
6
|
+
|
|
7
|
+
import { describe, expect, test } from 'bun:test';
|
|
8
|
+
|
|
9
|
+
import { mkdtempSync, rmSync } from 'node:fs';
|
|
10
|
+
import { tmpdir } from 'node:os';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
FetchAssetError,
|
|
15
|
+
fetchAsset,
|
|
16
|
+
parseHttpsTarget,
|
|
17
|
+
sniffImageExt,
|
|
18
|
+
sniffStagedKind,
|
|
19
|
+
} from '../bin/_fetch-asset.mjs';
|
|
20
|
+
|
|
21
|
+
const FIGMA_HOSTS = ['figma.com', 'figma-alpha-api.s3.us-west-2.amazonaws.com'];
|
|
22
|
+
|
|
23
|
+
const png = () => Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0, 0, 0, 0]);
|
|
24
|
+
const svg = (s = '<svg xmlns="http://www.w3.org/2000/svg"><rect/></svg>') => Buffer.from(s, 'utf8');
|
|
25
|
+
|
|
26
|
+
describe('the host allowlist is exact-or-dotted-suffix, never endsWith', () => {
|
|
27
|
+
test.each([
|
|
28
|
+
['the apex', 'https://figma.com/x'],
|
|
29
|
+
['a real subdomain', 'https://www.figma.com/x'],
|
|
30
|
+
['a deep subdomain', 'https://a.b.figma.com/x'],
|
|
31
|
+
['the render bucket, exactly', 'https://figma-alpha-api.s3.us-west-2.amazonaws.com/x'],
|
|
32
|
+
])('admits %s', (_label, url) => {
|
|
33
|
+
expect(() => parseHttpsTarget(url, { allowHosts: FIGMA_HOSTS })).not.toThrow();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test.each([
|
|
37
|
+
// The classic suffix bug: a bare endsWith('figma.com') admits this.
|
|
38
|
+
['a suffix look-alike', 'https://evil-figma.com/x'],
|
|
39
|
+
['figma.com as a prefix of another domain', 'https://figma.com.evil.tld/x'],
|
|
40
|
+
['an unrelated host', 'https://evil.tld/x'],
|
|
41
|
+
// A bare endsWith('.amazonaws.com') would admit EVERY S3 bucket on earth.
|
|
42
|
+
['a different S3 bucket', 'https://attacker-bucket.s3.us-west-2.amazonaws.com/x'],
|
|
43
|
+
['the bare bucket parent', 'https://s3.us-west-2.amazonaws.com/x'],
|
|
44
|
+
])('refuses %s', (_label, url) => {
|
|
45
|
+
expect(() => parseHttpsTarget(url, { allowHosts: FIGMA_HOSTS })).toThrow(FetchAssetError);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("an absent allowlist keeps today's unrestricted behaviour", () => {
|
|
49
|
+
// The moodboard/research lane passes no allowlist and must be untouched.
|
|
50
|
+
expect(() => parseHttpsTarget('https://upload.wikimedia.org/x.png')).not.toThrow();
|
|
51
|
+
expect(parseHttpsTarget('https://anything.example/x').host).toBe('anything.example');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('a refusal names the host as a charset-validated token, never raw (D10)', () => {
|
|
55
|
+
try {
|
|
56
|
+
parseHttpsTarget('https://evil.tld/x', { allowHosts: FIGMA_HOSTS });
|
|
57
|
+
throw new Error('expected a rejection');
|
|
58
|
+
} catch (err) {
|
|
59
|
+
expect((err as Error).message).toMatch(/^host not in this lane's allowlist: [a-z0-9.-]+$/);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('port pinning is opt-in, and is new logic', () => {
|
|
65
|
+
test('the default still accepts any valid port (unchanged behaviour)', () => {
|
|
66
|
+
expect(parseHttpsTarget('https://example.test:8443/x').port).toBe(8443);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test('the pinned lane refuses a non-443 port', () => {
|
|
70
|
+
expect(() => parseHttpsTarget('https://figma.com:8443/x', { pinPort443: true })).toThrow(
|
|
71
|
+
FetchAssetError
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test('the pinned lane accepts 443, explicit or implicit', () => {
|
|
76
|
+
expect(parseHttpsTarget('https://figma.com/x', { pinPort443: true }).port).toBe(443);
|
|
77
|
+
expect(parseHttpsTarget('https://figma.com:443/x', { pinPort443: true }).port).toBe(443);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe('the allowlist NARROWS the gate — it never replaces the rest of it', () => {
|
|
82
|
+
test.each([
|
|
83
|
+
['non-https', 'http://figma.com/x'],
|
|
84
|
+
['embedded credentials', 'https://user:pw@figma.com/x'],
|
|
85
|
+
['a file URL', 'file:///etc/passwd'],
|
|
86
|
+
])('%s is still refused even on an allowlisted host', (_label, url) => {
|
|
87
|
+
expect(() => parseHttpsTarget(url, { allowHosts: FIGMA_HOSTS })).toThrow(FetchAssetError);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('sniffImageExt is NOT widened — the moodboard lane depends on it', () => {
|
|
92
|
+
test.each([
|
|
93
|
+
['an SVG', svg()],
|
|
94
|
+
['an XML-prologue SVG', svg('<?xml version="1.0"?><svg></svg>')],
|
|
95
|
+
['an SVG comment prologue', svg('<!-- c --><svg></svg>')],
|
|
96
|
+
['HTML', Buffer.from('<!doctype html><html></html>', 'utf8')],
|
|
97
|
+
['a script', Buffer.from('alert(1)', 'utf8')],
|
|
98
|
+
])('still returns null for %s', (_label, bytes) => {
|
|
99
|
+
// DDR-216 D11 step 6: this is THE test that makes the tempting two-line
|
|
100
|
+
// "just add svg to the sniff" fix fail CI. If it ever goes green for SVG,
|
|
101
|
+
// arbitrary remote vectors can land in the versioned, peer-synced assets/
|
|
102
|
+
// tree of a lane this feature never touches.
|
|
103
|
+
expect(sniffImageExt(bytes)).toBeNull();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('still accepts a real raster', () => {
|
|
107
|
+
expect(sniffImageExt(png())).toBe('png');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
describe('sniffStagedKind — the --raw-out accept set', () => {
|
|
112
|
+
test('accepts everything sniffImageExt accepts', () => {
|
|
113
|
+
expect(sniffStagedKind(png())).toBe('png');
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
test('additionally accepts SVG, which is the whole point of the mode', () => {
|
|
117
|
+
expect(sniffStagedKind(svg())).toBe('svg');
|
|
118
|
+
expect(sniffStagedKind(svg('<?xml version="1.0"?><svg></svg>'))).toBe('svg');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('still REFUSES the things a bypass would let through', () => {
|
|
122
|
+
// `--raw-out` must never mean "skip the type gate" — that would turn the one
|
|
123
|
+
// reviewable downloader into an unsniffed one for the next caller.
|
|
124
|
+
expect(sniffStagedKind(Buffer.from('<!doctype html><html></html>', 'utf8'))).toBeNull();
|
|
125
|
+
expect(sniffStagedKind(Buffer.from('alert(1)', 'utf8'))).toBeNull();
|
|
126
|
+
expect(sniffStagedKind(Buffer.from('PKzipbytes', 'utf8'))).toBeNull();
|
|
127
|
+
expect(sniffStagedKind(Buffer.from('', 'utf8'))).toBeNull();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('only the HEAD is probed — a late `<svg` does not rescue a blob', () => {
|
|
131
|
+
const late = Buffer.concat([Buffer.alloc(512, 0x41), svg()]);
|
|
132
|
+
expect(sniffStagedKind(late)).toBeNull();
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
describe('--raw-out containment survives an OS-symlinked temp root', () => {
|
|
137
|
+
test('a legitimate staging path under os.tmpdir() is ACCEPTED', async () => {
|
|
138
|
+
// The bug this pins: `realpathSync` on the root but not the target compares
|
|
139
|
+
// `/private/var/…` against `/var/…` on macOS (both `/var` and `/tmp` are
|
|
140
|
+
// OS-level symlinks) and rejects every legitimate path. It shipped, and the
|
|
141
|
+
// first real import skipped all 29 of its assets with a generic
|
|
142
|
+
// "download or sanitize failed". Same trap DDR-172 Decision 1 documents.
|
|
143
|
+
const dir = mkdtempSync(join(tmpdir(), 'raw-out-probe-'));
|
|
144
|
+
try {
|
|
145
|
+
const out = join(dir, 'staged.png');
|
|
146
|
+
// Reaches the network gate rather than the containment check: any throw
|
|
147
|
+
// must NOT be the containment one.
|
|
148
|
+
let err: unknown;
|
|
149
|
+
try {
|
|
150
|
+
await fetchAsset({
|
|
151
|
+
url: 'https://figma.com/definitely-not-real.png',
|
|
152
|
+
root: dir,
|
|
153
|
+
rawOut: out,
|
|
154
|
+
rawRoot: dir,
|
|
155
|
+
allowHosts: FIGMA_HOSTS,
|
|
156
|
+
maxTime: 1,
|
|
157
|
+
});
|
|
158
|
+
} catch (e) {
|
|
159
|
+
err = e;
|
|
160
|
+
}
|
|
161
|
+
expect((err as Error | undefined)?.message ?? '').not.toContain('--raw-out must resolve');
|
|
162
|
+
} finally {
|
|
163
|
+
rmSync(dir, { recursive: true, force: true });
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test('a path OUTSIDE the declared root is still refused', async () => {
|
|
168
|
+
const dir = mkdtempSync(join(tmpdir(), 'raw-out-probe-'));
|
|
169
|
+
try {
|
|
170
|
+
await expect(
|
|
171
|
+
fetchAsset({
|
|
172
|
+
url: 'https://figma.com/x.png',
|
|
173
|
+
root: dir,
|
|
174
|
+
rawOut: join(dir, '..', 'escaped.png'),
|
|
175
|
+
rawRoot: dir,
|
|
176
|
+
allowHosts: FIGMA_HOSTS,
|
|
177
|
+
})
|
|
178
|
+
).rejects.toThrow(/--raw-out must resolve inside/);
|
|
179
|
+
} finally {
|
|
180
|
+
rmSync(dir, { recursive: true, force: true });
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
test('--raw-out without --raw-root is refused outright', async () => {
|
|
185
|
+
await expect(
|
|
186
|
+
fetchAsset({ url: 'https://figma.com/x.png', root: '/tmp', rawOut: '/tmp/x.png' })
|
|
187
|
+
).rejects.toThrow(/requires --raw-root/);
|
|
188
|
+
});
|
|
189
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Provenance for an imported canvas (DDR-216 D7 / T9).
|
|
2
|
+
//
|
|
3
|
+
// The plan flags this exact prop-threading as having silently no-opped once
|
|
4
|
+
// before: a badge shipped prop-threaded-but-never-stored, so `.meta.json` said
|
|
5
|
+
// one thing and the tree showed nothing. So this asserts the SERVER half
|
|
6
|
+
// end-to-end against a live `/_index-data` — that `kind` actually survives
|
|
7
|
+
// `loadCanvasMeta` → `NOTABLE_KINDS` → the wire — rather than unit-testing a
|
|
8
|
+
// constant that a missing wire would leave green.
|
|
9
|
+
|
|
10
|
+
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
|
|
11
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
import type { Subprocess } from 'bun';
|
|
14
|
+
|
|
15
|
+
import { bootServer, killProc, makeSandbox, nextPort } from './_helpers.ts';
|
|
16
|
+
|
|
17
|
+
let proc: Subprocess;
|
|
18
|
+
let base: string;
|
|
19
|
+
let designRoot: string;
|
|
20
|
+
|
|
21
|
+
const CANVAS = `import { DCArtboard, DesignCanvas } from '@maude/canvas-lib';
|
|
22
|
+
export default function Canvas() {
|
|
23
|
+
return (
|
|
24
|
+
<DesignCanvas>
|
|
25
|
+
<DCArtboard id="node-2-23" label="Imported" width={400} height={300} kind="digital" />
|
|
26
|
+
</DesignCanvas>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
beforeAll(async () => {
|
|
32
|
+
const sandbox = makeSandbox();
|
|
33
|
+
designRoot = sandbox.designRoot;
|
|
34
|
+
mkdirSync(join(designRoot, 'ui'), { recursive: true });
|
|
35
|
+
|
|
36
|
+
// An imported canvas: `kind` + a source block carrying IDENTIFIERS ONLY.
|
|
37
|
+
writeFileSync(join(designRoot, 'ui', 'imported.tsx'), CANVAS);
|
|
38
|
+
writeFileSync(
|
|
39
|
+
join(designRoot, 'ui', 'imported.meta.json'),
|
|
40
|
+
JSON.stringify({
|
|
41
|
+
kind: 'imported-figma',
|
|
42
|
+
source: {
|
|
43
|
+
fileKey: 'dGNzRC2kmrmGnOxaBa0RI7',
|
|
44
|
+
nodeId: '2:23',
|
|
45
|
+
importedAt: '2026-08-09T00:00:00.000Z',
|
|
46
|
+
},
|
|
47
|
+
layout: { artboards: [{ id: 'node-2-23', x: 0, y: 0 }] },
|
|
48
|
+
})
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// A hand-authored canvas alongside it — the badge must NOT appear on this one.
|
|
52
|
+
writeFileSync(join(designRoot, 'ui', 'handmade.tsx'), CANVAS);
|
|
53
|
+
writeFileSync(join(designRoot, 'ui', 'handmade.meta.json'), JSON.stringify({ layout: {} }));
|
|
54
|
+
|
|
55
|
+
const port = nextPort();
|
|
56
|
+
base = `http://localhost:${port}`;
|
|
57
|
+
proc = await bootServer(sandbox.root, port);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
afterAll(async () => {
|
|
61
|
+
await killProc(proc);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
async function indexData(): Promise<Record<string, unknown>> {
|
|
65
|
+
const res = await fetch(`${base}/_index-data`);
|
|
66
|
+
expect(res.status).toBe(200);
|
|
67
|
+
return (await res.json()) as Record<string, unknown>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
describe('the imported-figma kind reaches the tree', () => {
|
|
71
|
+
test('canvasKinds carries it for the imported canvas', async () => {
|
|
72
|
+
const data = await indexData();
|
|
73
|
+
const kinds = data.canvasKinds as Record<string, string>;
|
|
74
|
+
const entry = Object.entries(kinds).find(([p]) => p.endsWith('imported.tsx'));
|
|
75
|
+
expect(entry).toBeDefined();
|
|
76
|
+
expect(entry?.[1]).toBe('imported-figma');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('a hand-authored canvas gets NO kind — the badge means something', async () => {
|
|
80
|
+
const data = await indexData();
|
|
81
|
+
const kinds = data.canvasKinds as Record<string, string>;
|
|
82
|
+
expect(Object.keys(kinds).some((p) => p.endsWith('handmade.tsx'))).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('provenance carries identifiers only (D7)', () => {
|
|
87
|
+
test('no Figma NAME or node text is anywhere on the wire', async () => {
|
|
88
|
+
// `.meta.json` and `config.json` are versioned, peer-synced (DDR-054) AND
|
|
89
|
+
// read into multiple agents' context. DDR-172 Decision 8 traced exactly
|
|
90
|
+
// this class and ELIMINATED the free-text sink rather than bounding it;
|
|
91
|
+
// D7 applies the same elimination here.
|
|
92
|
+
const raw = JSON.stringify(await indexData());
|
|
93
|
+
expect(raw).not.toContain('Karta');
|
|
94
|
+
expect(raw).not.toContain('žluť');
|
|
95
|
+
expect(raw).not.toContain('<script');
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('the recorded source fields are charset-constrained shapes', async () => {
|
|
99
|
+
const meta = JSON.parse(
|
|
100
|
+
await Bun.file(join(designRoot, 'ui', 'imported.meta.json')).text()
|
|
101
|
+
) as { source: { fileKey: string; nodeId: string; importedAt: string } };
|
|
102
|
+
expect(meta.source.fileKey).toMatch(/^[A-Za-z0-9]{10,64}$/);
|
|
103
|
+
expect(meta.source.nodeId).toMatch(/^[0-9]+:[0-9]+$/);
|
|
104
|
+
expect(Number.isNaN(Date.parse(meta.source.importedAt))).toBe(false);
|
|
105
|
+
// Exactly three fields — no room for a name, a title or a description.
|
|
106
|
+
expect(Object.keys(meta.source).sort()).toEqual(['fileKey', 'importedAt', 'nodeId']);
|
|
107
|
+
});
|
|
108
|
+
});
|