@cosmicdrift/kumiko-renderer-web 0.158.2 → 0.159.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cosmicdrift/kumiko-renderer-web",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.159.1",
|
|
4
4
|
"description": "Web-platform bindings for @cosmicdrift/kumiko-renderer. HTML default-primitives, browser history-based navigation, EventSource-backed live events, and a one-call createKumikoApp that mounts the whole stack via react-dom.",
|
|
5
5
|
"license": "BUSL-1.1",
|
|
6
6
|
"author": "Marc Frost <marc@cosmicdriftgamestudio.com>",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"./styles.css": "./src/styles.css"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@cosmicdrift/kumiko-dispatcher-live": "0.
|
|
20
|
-
"@cosmicdrift/kumiko-headless": "0.
|
|
21
|
-
"@cosmicdrift/kumiko-renderer": "0.
|
|
19
|
+
"@cosmicdrift/kumiko-dispatcher-live": "0.159.1",
|
|
20
|
+
"@cosmicdrift/kumiko-headless": "0.159.1",
|
|
21
|
+
"@cosmicdrift/kumiko-renderer": "0.159.1",
|
|
22
22
|
"@radix-ui/react-dialog": "^1.1.15",
|
|
23
23
|
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
24
24
|
"@radix-ui/react-label": "^2.1.8",
|
|
@@ -499,6 +499,31 @@ describe("KumikoScreen", () => {
|
|
|
499
499
|
expect(bannerText).not.toBe("errors.access.denied");
|
|
500
500
|
});
|
|
501
501
|
|
|
502
|
+
test("entityList: query-Error zeigt übersetzten Text statt rohem i18nKey (issue #1193)", async () => {
|
|
503
|
+
const dispatcher = makeDispatcher({
|
|
504
|
+
query: (async () => ({
|
|
505
|
+
isSuccess: false,
|
|
506
|
+
error: {
|
|
507
|
+
code: "access_denied",
|
|
508
|
+
httpStatus: 403,
|
|
509
|
+
i18nKey: "errors.access.denied",
|
|
510
|
+
message: "",
|
|
511
|
+
},
|
|
512
|
+
})) as unknown as Dispatcher["query"],
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
render(
|
|
516
|
+
<DispatcherProvider dispatcher={dispatcher}>
|
|
517
|
+
<KumikoScreen schema={schema} qn="tasks:screen:task-list" />
|
|
518
|
+
</DispatcherProvider>,
|
|
519
|
+
);
|
|
520
|
+
|
|
521
|
+
await waitFor(() => expect(screen.queryByTestId("kumiko-screen-error")).toBeTruthy());
|
|
522
|
+
const bannerText = screen.getByTestId("kumiko-screen-error").textContent;
|
|
523
|
+
expect(bannerText).toBe(kumikoDefaultTranslations["en"]?.["errors.access.denied"] ?? "");
|
|
524
|
+
expect(bannerText).not.toBe("errors.access.denied");
|
|
525
|
+
});
|
|
526
|
+
|
|
502
527
|
// RowActions-Mapping (Tier 2.7a Resolution-Layer): pinst dass
|
|
503
528
|
// EntityListBody die Schema-Form (handler-QN, label-i18nKey, payload-
|
|
504
529
|
// builder, visible-Function, confirmLabel) zu DataTableRowAction
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Pins the XSS-escaping behavior for tenant-/pattern-authored content
|
|
3
|
+
// (kumiko-framework#1321). renderer-web has no dangerouslySetInnerHTML
|
|
4
|
+
// and no field-renderer path that wires tenant data into href/src — this
|
|
5
|
+
// test guards JSX auto-escaping against future regressions (e.g. if
|
|
6
|
+
// someone adds rich-text/markdown support via dangerouslySetInnerHTML),
|
|
7
|
+
// and pins the Link primitive's scheme guard (kumiko-framework#1365)
|
|
8
|
+
// against javascript:/data: hrefs as defense-in-depth.
|
|
9
|
+
|
|
10
|
+
import { describe, expect, test } from "bun:test";
|
|
11
|
+
import { defaultPrimitives } from "../primitives";
|
|
12
|
+
import { StatCard } from "../widgets/stat";
|
|
13
|
+
import { render, screen } from "./test-utils";
|
|
14
|
+
|
|
15
|
+
const PAYLOAD = '<script>window.__xss = true;</script><img src=x onerror="window.__xss = true">';
|
|
16
|
+
const UNSAFE_HREFS = [
|
|
17
|
+
"javascript:window.__xss = true",
|
|
18
|
+
"data:text/html,<script>window.__xss=true</script>",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
describe("XSS-safety (tenant-authored content)", () => {
|
|
22
|
+
test("Text-Primitive rendert Payload als Text, nicht als HTML", () => {
|
|
23
|
+
render(<defaultPrimitives.Text testId="txt">{PAYLOAD}</defaultPrimitives.Text>);
|
|
24
|
+
const node = screen.getByTestId("txt");
|
|
25
|
+
expect(node.textContent).toBe(PAYLOAD);
|
|
26
|
+
expect(node.querySelector("script")).toBeNull();
|
|
27
|
+
expect(node.querySelector("img")).toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("StatCard-Widget rendert label/value/sub als Text, nicht als HTML", () => {
|
|
31
|
+
render(<StatCard testId="stat" label={PAYLOAD} value={PAYLOAD} sub={PAYLOAD} />);
|
|
32
|
+
const node = screen.getByTestId("stat");
|
|
33
|
+
expect(node.querySelector("script")).toBeNull();
|
|
34
|
+
expect(node.querySelector("img")).toBeNull();
|
|
35
|
+
expect(node.textContent).toContain(PAYLOAD);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test.each(UNSAFE_HREFS)("Link-Primitive neutralisiert unsicheren href-Scheme: %s", (href) => {
|
|
39
|
+
render(
|
|
40
|
+
<defaultPrimitives.Link testId="link" href={href}>
|
|
41
|
+
text
|
|
42
|
+
</defaultPrimitives.Link>,
|
|
43
|
+
);
|
|
44
|
+
const node = screen.getByTestId("link");
|
|
45
|
+
expect(node.getAttribute("href")).toBe("#");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("Link-Primitive lässt sichere hrefs (https/mailto/relativ) unverändert", () => {
|
|
49
|
+
for (const href of ["https://example.com", "mailto:a@example.com", "/relative/path"]) {
|
|
50
|
+
render(
|
|
51
|
+
<defaultPrimitives.Link testId={`link-${href}`} href={href}>
|
|
52
|
+
text
|
|
53
|
+
</defaultPrimitives.Link>,
|
|
54
|
+
);
|
|
55
|
+
expect(screen.getByTestId(`link-${href}`).getAttribute("href")).toBe(href);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -63,4 +63,15 @@ describe("firstOpenScreenQn", () => {
|
|
|
63
63
|
];
|
|
64
64
|
expect(firstOpenScreenQn(features)).toBeUndefined();
|
|
65
65
|
});
|
|
66
|
+
|
|
67
|
+
test("resolves a bare screen id in nav to the qualified screen name", () => {
|
|
68
|
+
const features: readonly FeatureSchema[] = [
|
|
69
|
+
feature({
|
|
70
|
+
featureName: "shop",
|
|
71
|
+
screens: [customScreen({ id: "catalog" })],
|
|
72
|
+
navs: [{ id: "catalog", label: "shop:nav.catalog", screen: "catalog" }],
|
|
73
|
+
}),
|
|
74
|
+
];
|
|
75
|
+
expect(firstOpenScreenQn(features)).toBe("shop:screen:catalog");
|
|
76
|
+
});
|
|
66
77
|
});
|
package/src/primitives/index.tsx
CHANGED
|
@@ -1661,6 +1661,15 @@ function DefaultText({ variant = "body", children, testId }: TextProps): ReactNo
|
|
|
1661
1661
|
|
|
1662
1662
|
// ---- Link (anchor mit Button-/Muted-Optik) ----
|
|
1663
1663
|
|
|
1664
|
+
// http(s)/mailto or scheme-less (relative/anchor) allowed; javascript:, data:,
|
|
1665
|
+
// vbscript:, etc. rejected. Mirrors renderer-mail-html's renderSafeMarkdown
|
|
1666
|
+
// href guard — no sanitizer dependency needed for a four-line regex check.
|
|
1667
|
+
function isSafeHref(href: string): boolean {
|
|
1668
|
+
const trimmed = href.trim().toLowerCase();
|
|
1669
|
+
if (!/^[a-z][a-z0-9+.-]*:/.test(trimmed)) return true;
|
|
1670
|
+
return /^(?:https?|mailto):/.test(trimmed);
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1664
1673
|
// `button` nutzt die Primary-Buttonfläche auf einem semantischen <a> —
|
|
1665
1674
|
// der Standard für „weiter zu"-Navigationen nach Success-States (ehem.
|
|
1666
1675
|
// authButtonClass), `muted` der dezente Sekundär-Link (ehem.
|
|
@@ -1681,7 +1690,7 @@ function DefaultLink({
|
|
|
1681
1690
|
: "text-primary underline-offset-4 hover:underline";
|
|
1682
1691
|
return (
|
|
1683
1692
|
<a
|
|
1684
|
-
href={href}
|
|
1693
|
+
href={isSafeHref(href) ? href : "#"}
|
|
1685
1694
|
target={target}
|
|
1686
1695
|
rel={target === "_blank" ? "noreferrer" : undefined}
|
|
1687
1696
|
data-testid={testId}
|
|
File without changes
|