@app-vitals/agent-admin 1.118.0 → 1.120.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@app-vitals/agent-admin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.120.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/app-vitals/agent.git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@anthropic-ai/sdk": "0.137.0",
|
|
47
|
-
"@app-vitals/agent-lib": "1.
|
|
47
|
+
"@app-vitals/agent-lib": "1.120.0",
|
|
48
48
|
"@hono/zod-openapi": "^1.0.0",
|
|
49
49
|
"@prisma/adapter-pg": "^7.10.0",
|
|
50
50
|
"@prisma/client": "^7.10.0",
|
|
@@ -24,6 +24,17 @@ export function runWithToolbarAudience<T>(
|
|
|
24
24
|
return storage.run({ audience }, fn);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
const logoStorage = new AsyncLocalStorage<string>();
|
|
28
|
+
|
|
29
|
+
/** Wrap a request so the toolbar renders the given logo beside the wordmark. */
|
|
30
|
+
export function runWithHeaderLogo<T>(logoUrl: string, fn: () => T): T {
|
|
31
|
+
return logoStorage.run(logoUrl, fn);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function currentHeaderLogoUrl(): string | undefined {
|
|
35
|
+
return logoStorage.getStore();
|
|
36
|
+
}
|
|
37
|
+
|
|
27
38
|
export function currentToolbarViewer(): ToolbarViewer | undefined {
|
|
28
39
|
return storage.getStore();
|
|
29
40
|
}
|
package/src/admin-ui-layout.ts
CHANGED
|
@@ -53,6 +53,7 @@ export function renderAdminPage(opts: RenderAdminPageOptions): string {
|
|
|
53
53
|
<meta charset="utf-8" />
|
|
54
54
|
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
|
|
55
55
|
<title>${escapeHtml(opts.title)}</title>
|
|
56
|
+
<link rel="icon" type="image/png" href="/admin/icons/favicon-32.png" />
|
|
56
57
|
<meta name="color-scheme" content="light dark" />
|
|
57
58
|
${themeBootScript()}
|
|
58
59
|
${tzCookieScript()}
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { describe, expect, test } from "bun:test";
|
|
10
|
+
import { runWithHeaderLogo } from "./admin-ui-account-nav.ts";
|
|
10
11
|
import { renderAdminPage } from "./admin-ui-layout.ts";
|
|
12
|
+
import { renderAdminToolbar } from "./admin-ui-styles.ts";
|
|
11
13
|
|
|
12
14
|
describe("renderAdminPage", () => {
|
|
13
15
|
test("renders a full HTML document with DOCTYPE, head, and body", () => {
|
|
@@ -154,3 +156,42 @@ describe("renderAdminPage — theme", () => {
|
|
|
154
156
|
expect(html).toContain(':root[data-theme="dark"]');
|
|
155
157
|
});
|
|
156
158
|
});
|
|
159
|
+
|
|
160
|
+
describe("renderAdminPage favicon", () => {
|
|
161
|
+
test("always emits the favicon link in <head>", () => {
|
|
162
|
+
const html = renderAdminPage({ title: "Page", body: "<div></div>" });
|
|
163
|
+
const head = html.slice(0, html.indexOf("</head>"));
|
|
164
|
+
expect(head).toContain(
|
|
165
|
+
'<link rel="icon" type="image/png" href="/admin/icons/favicon-32.png" />',
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
describe("header logo", () => {
|
|
171
|
+
test("renders no logo when unset", () => {
|
|
172
|
+
const html = renderAdminToolbar("Dan");
|
|
173
|
+
expect(html).not.toContain("vos-logo");
|
|
174
|
+
expect(html).toContain('class="vos-wordmark">Shipwright</a>');
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
test("renders an escaped logo for a same-origin path", () => {
|
|
178
|
+
const html = renderAdminToolbar("Dan");
|
|
179
|
+
expect(html).not.toContain("<img");
|
|
180
|
+
const out = runWithHeaderLogo('/admin/icons/a"b.png', () =>
|
|
181
|
+
renderAdminToolbar("Dan"),
|
|
182
|
+
);
|
|
183
|
+
expect(out).toContain('src="/admin/icons/a"b.png"');
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("ignores external, protocol-relative and scheme URLs", () => {
|
|
187
|
+
for (const bad of [
|
|
188
|
+
"https://evil.example/x.png",
|
|
189
|
+
"//evil.example/x.png",
|
|
190
|
+
"javascript:alert(1)",
|
|
191
|
+
"/\\evil.example",
|
|
192
|
+
]) {
|
|
193
|
+
const out = runWithHeaderLogo(bad, () => renderAdminToolbar("Dan"));
|
|
194
|
+
expect(out).not.toContain("<img");
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
});
|
package/src/admin-ui-styles.ts
CHANGED
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
renderShipwrightToolbar,
|
|
4
4
|
baseStyles as toolbarBaseStyles,
|
|
5
5
|
} from "@app-vitals/agent-lib/web/toolbar.ts";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
currentHeaderLogoUrl,
|
|
8
|
+
currentToolbarViewer,
|
|
9
|
+
} from "./admin-ui-account-nav.ts";
|
|
7
10
|
|
|
8
11
|
export { escapeHtml };
|
|
9
12
|
|
|
@@ -691,5 +694,6 @@ export function renderAdminToolbar(userName: string, activePath = ""): string {
|
|
|
691
694
|
logoutAction: "/admin/logout",
|
|
692
695
|
metricsUrl: process.env.METRICS_DASHBOARD_URL ?? "/dashboard",
|
|
693
696
|
audience: viewer?.audience ?? "member",
|
|
697
|
+
logoUrl: currentHeaderLogoUrl(),
|
|
694
698
|
});
|
|
695
699
|
}
|
package/src/admin-ui.ts
CHANGED
|
@@ -47,7 +47,10 @@ import {
|
|
|
47
47
|
type SettingsNavContribution,
|
|
48
48
|
} from "./admin-extension.ts";
|
|
49
49
|
import { registerAccountRoutes } from "./admin-ui-account.ts";
|
|
50
|
-
import {
|
|
50
|
+
import {
|
|
51
|
+
runWithHeaderLogo,
|
|
52
|
+
runWithToolbarAudience,
|
|
53
|
+
} from "./admin-ui-account-nav.ts";
|
|
51
54
|
import { renderZeroQuotaNotice } from "./admin-ui-account-pages.ts";
|
|
52
55
|
import { registerAdminAccountsRoutes } from "./admin-ui-accounts.ts";
|
|
53
56
|
import { registerAdminGithubEnterpriseRoutes } from "./admin-ui-github-enterprise.ts";
|
|
@@ -626,6 +629,12 @@ export interface AdminUIDeps {
|
|
|
626
629
|
* one-time/on-demand scripts/build-pwa-icons.ts).
|
|
627
630
|
*/
|
|
628
631
|
pwaAssetsDir?: string;
|
|
632
|
+
/**
|
|
633
|
+
* Optional same-origin path (e.g. "/admin/icons/icon-192.png") of a logo
|
|
634
|
+
* rendered beside the toolbar wordmark. Unset = no logo; non-same-origin
|
|
635
|
+
* values are ignored at render time.
|
|
636
|
+
*/
|
|
637
|
+
headerLogoUrl?: string;
|
|
629
638
|
/**
|
|
630
639
|
* App version string interpolated into the service worker's cache name
|
|
631
640
|
* (see admin/src/pwa.ts's buildServiceWorkerBody) so a version bump busts
|
|
@@ -1142,6 +1151,11 @@ export function createAdminUIApp(deps: AdminUIDeps): Hono<AdminUIEnv> {
|
|
|
1142
1151
|
}
|
|
1143
1152
|
const tzOf = (c: Context<AdminUIEnv>): string => c.var.timezone ?? timezone;
|
|
1144
1153
|
|
|
1154
|
+
if (deps.headerLogoUrl) {
|
|
1155
|
+
const logoUrl = deps.headerLogoUrl;
|
|
1156
|
+
app.use("/admin/*", (_c, next) => runWithHeaderLogo(logoUrl, () => next()));
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1145
1159
|
// GHE-1.4: per-request toolbar audience; TOOLBAR_NAV_ITEMS decides visibility.
|
|
1146
1160
|
if (
|
|
1147
1161
|
githubEnterpriseApi ||
|
|
@@ -15,6 +15,7 @@ import { readFileSync } from "node:fs";
|
|
|
15
15
|
import { join } from "node:path";
|
|
16
16
|
import {
|
|
17
17
|
CHILD_ALLOWED_SECRET_ENV_VARS,
|
|
18
|
+
MAPPED_ENV_VARS,
|
|
18
19
|
RUNTIME_ONLY_ENV_VARS,
|
|
19
20
|
} from "@app-vitals/agent-lib/child-env";
|
|
20
21
|
import {
|
|
@@ -53,6 +54,7 @@ const NON_SECRET_SYSTEM_ENV_VARS: readonly string[] = [
|
|
|
53
54
|
const classified = new Set<string>([
|
|
54
55
|
...RUNTIME_ONLY_ENV_VARS,
|
|
55
56
|
...CHILD_ALLOWED_SECRET_ENV_VARS,
|
|
57
|
+
...MAPPED_ENV_VARS,
|
|
56
58
|
...NON_SECRET_SYSTEM_ENV_VARS,
|
|
57
59
|
]);
|
|
58
60
|
|
|
@@ -142,6 +144,7 @@ describe("system-provisioned agent env classification", () => {
|
|
|
142
144
|
const secretish = new Set<string>([
|
|
143
145
|
...RUNTIME_ONLY_ENV_VARS,
|
|
144
146
|
...CHILD_ALLOWED_SECRET_ENV_VARS,
|
|
147
|
+
...MAPPED_ENV_VARS,
|
|
145
148
|
]);
|
|
146
149
|
for (const name of NON_SECRET_SYSTEM_ENV_VARS)
|
|
147
150
|
expect(secretish.has(name)).toBe(false);
|