driggsby 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/assets/Inter-LICENSE.txt +92 -0
- package/assets/Inter.woff2 +0 -0
- package/dist/dev/app-policy.js +78 -0
- package/dist/dev/dashboard-font.js +14 -0
- package/dist/dev/dev-command.js +3 -0
- package/dist/dev/dev-servers.js +47 -22
- package/dist/dev/host-page.js +7 -2
- package/dist/init/template-styles.js +23 -4
- package/dist/init/templates.js +1 -0
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -123,4 +123,6 @@ signed in with an earlier version of the CLI, run
|
|
|
123
123
|
|
|
124
124
|
## License
|
|
125
125
|
|
|
126
|
-
Apache-2.0
|
|
126
|
+
Apache-2.0. The bundled Inter font (`assets/Inter.woff2`), which
|
|
127
|
+
`driggsby dev` serves to the app it previews, is under the SIL Open Font
|
|
128
|
+
License 1.1; see `assets/Inter-LICENSE.txt`.
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font creation
|
|
14
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
15
|
+
open framework in which fonts may be shared and improved in partnership
|
|
16
|
+
with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply
|
|
25
|
+
to any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software components as
|
|
36
|
+
distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
39
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
40
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
41
|
+
new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION AND CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
49
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
50
|
+
Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components,
|
|
53
|
+
in Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
64
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
65
|
+
presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created
|
|
77
|
+
using the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
Binary file
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// The security headers on every app-origin response, the service worker
|
|
2
|
+
// the app origin hands out, and the policy the host page requires of its
|
|
3
|
+
// frame: a copy of what Driggsby's serving host and console do for a
|
|
4
|
+
// deployed app, so the preview refuses what a deployed app is refused and a
|
|
5
|
+
// page that works here works once deployed. The Driggsby service is
|
|
6
|
+
// canonical: change it there first, then mirror it here.
|
|
7
|
+
//
|
|
8
|
+
// The content security policy keeps the page's loads on its own origin
|
|
9
|
+
// (another site's script, font, image, or fetch is refused), refuses frames,
|
|
10
|
+
// objects, forms, and eval, and sandboxes the page as the serving host does.
|
|
11
|
+
// frame-ancestors names the host page, the only page that may frame the
|
|
12
|
+
// app. A file that can run script (a page, an SVG, JavaScript) also carries
|
|
13
|
+
// Connection-Allowlist, which has Chrome refuse any connection the page
|
|
14
|
+
// starts to anywhere else, WebRTC included. Any other file gets neither the
|
|
15
|
+
// list nor script: its sandbox grants nothing, so it opens in an origin of
|
|
16
|
+
// its own, as it does deployed. Never widen the list to other files; the
|
|
17
|
+
// serving host sends it only where script can run.
|
|
18
|
+
const SCRIPT_MEDIA_TYPES = new Set([
|
|
19
|
+
"text/html",
|
|
20
|
+
"image/svg+xml",
|
|
21
|
+
"text/javascript",
|
|
22
|
+
"application/javascript",
|
|
23
|
+
]);
|
|
24
|
+
const POLICY_DIRECTIVES = [
|
|
25
|
+
"default-src 'self'",
|
|
26
|
+
"script-src 'self' 'unsafe-inline'",
|
|
27
|
+
"style-src 'self' 'unsafe-inline'",
|
|
28
|
+
"img-src 'self' data: blob:",
|
|
29
|
+
"font-src 'self' data:",
|
|
30
|
+
"connect-src 'self'",
|
|
31
|
+
"frame-src 'none'",
|
|
32
|
+
"object-src 'none'",
|
|
33
|
+
"form-action 'none'",
|
|
34
|
+
"base-uri 'none'",
|
|
35
|
+
];
|
|
36
|
+
// What the host page requires of every document its frame shows (the
|
|
37
|
+
// iframe's csp attribute), as the console does: it binds even a document
|
|
38
|
+
// that doesn't come from this server.
|
|
39
|
+
export const FRAME_POLICY = POLICY_DIRECTIVES.join("; ");
|
|
40
|
+
// The only service worker either preview origin hands out, verbatim from
|
|
41
|
+
// the serving host. An app's own worker could answer the frame's
|
|
42
|
+
// navigations with documents it builds, carrying none of these headers, and
|
|
43
|
+
// on these fixed ports it would outlive the preview and answer the next
|
|
44
|
+
// app's too; a worker some other local server once left on the host port
|
|
45
|
+
// would answer the host page, which runs tools. This one listens for
|
|
46
|
+
// nothing.
|
|
47
|
+
export const INERT_SERVICE_WORKER = `// This origin's only service worker. It listens for nothing, so it answers
|
|
48
|
+
// no request: every page and file comes from the network with the host's
|
|
49
|
+
// own headers. It behaves like any default worker: it waits until no page
|
|
50
|
+
// is using the worker before it, then takes over.
|
|
51
|
+
`;
|
|
52
|
+
// hostOrigin is empty until the host server has bound (a startup race
|
|
53
|
+
// measured in milliseconds); until then nothing may frame the app.
|
|
54
|
+
export function appResponseHeaders(hostOrigin, contentType) {
|
|
55
|
+
const mediaType = (contentType.split(";")[0] ?? "").trim().toLowerCase();
|
|
56
|
+
const runsScript = SCRIPT_MEDIA_TYPES.has(mediaType);
|
|
57
|
+
const directives = [
|
|
58
|
+
runsScript ? "sandbox allow-scripts allow-same-origin" : "sandbox",
|
|
59
|
+
...POLICY_DIRECTIVES,
|
|
60
|
+
`frame-ancestors ${hostOrigin === "" ? "'none'" : hostOrigin}`,
|
|
61
|
+
];
|
|
62
|
+
const headers = {
|
|
63
|
+
"Content-Security-Policy": directives.join("; "),
|
|
64
|
+
// The served content types are final; the browser never guesses.
|
|
65
|
+
"X-Content-Type-Options": "nosniff",
|
|
66
|
+
"Referrer-Policy": "no-referrer",
|
|
67
|
+
"Cross-Origin-Resource-Policy": "same-origin",
|
|
68
|
+
"Cross-Origin-Opener-Policy": "same-origin",
|
|
69
|
+
"Permissions-Policy": "camera=(), microphone=(), geolocation=(), payment=()",
|
|
70
|
+
};
|
|
71
|
+
if (hostOrigin !== "") {
|
|
72
|
+
headers["Allow-CSP-From"] = hostOrigin;
|
|
73
|
+
}
|
|
74
|
+
if (runsScript) {
|
|
75
|
+
headers["Connection-Allowlist"] = "(response-origin)";
|
|
76
|
+
}
|
|
77
|
+
return headers;
|
|
78
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Inter, the face Driggsby apps set their text in. Driggsby serves it on
|
|
2
|
+
// every deployed app's own origin at DASHBOARD_FONT_PATH, and the scaffold
|
|
3
|
+
// loads it from there; dev serves the same bytes at the same path, from
|
|
4
|
+
// this package (assets/Inter.woff2, under the SIL Open Font License 1.1 in
|
|
5
|
+
// assets/Inter-LICENSE.txt). So the preview draws the letters the deployed
|
|
6
|
+
// page draws, and nothing reaches the internet for them.
|
|
7
|
+
import { readFile } from "node:fs/promises";
|
|
8
|
+
export const DASHBOARD_FONT_PATH = "/-/inter.woff2";
|
|
9
|
+
export const DASHBOARD_FONT_TYPE = "font/woff2";
|
|
10
|
+
// src/dev/ and dist/dev/ both sit two levels under the package root.
|
|
11
|
+
const FONT_FILE = new URL("../../assets/Inter.woff2", import.meta.url);
|
|
12
|
+
export async function loadDashboardFont() {
|
|
13
|
+
return await readFile(FONT_FILE);
|
|
14
|
+
}
|
package/dist/dev/dev-command.js
CHANGED
|
@@ -13,6 +13,7 @@ import { defaultCredentialEnvironment, } from "../credentials/store.js";
|
|
|
13
13
|
import { requireDeploySession } from "../deploy/api-session.js";
|
|
14
14
|
import { tryOpenUrl } from "../login/open-url.js";
|
|
15
15
|
import { wrapProse } from "../terminal-text.js";
|
|
16
|
+
import { loadDashboardFont } from "./dashboard-font.js";
|
|
16
17
|
import { DEV_IDLE_MINUTES, DEV_START_COMMAND, DEV_STOP_COMMAND } from "./dev-commands.js";
|
|
17
18
|
import { startDevServers } from "./dev-servers.js";
|
|
18
19
|
import { pruneDevStatesForPorts, readDevStates, removeDevState, writeDevState } from "./dev-state.js";
|
|
@@ -63,6 +64,7 @@ export async function runDev(options = {}, environment = defaultCredentialEnviro
|
|
|
63
64
|
const session = await requireDeploySession(environment);
|
|
64
65
|
await refuseSecondPreview(environment.homeDirectory, projectDirectory);
|
|
65
66
|
const sdkBundle = await loadSdkBundle();
|
|
67
|
+
const dashboardFont = await loadDashboardFont();
|
|
66
68
|
// Retries like the production host, so the preview loads the way the
|
|
67
69
|
// deployed app would.
|
|
68
70
|
const broker = new McpBroker({ baseUrl: session.baseUrl, token: session.token, retries: true });
|
|
@@ -83,6 +85,7 @@ export async function runDev(options = {}, environment = defaultCredentialEnviro
|
|
|
83
85
|
background: config.background,
|
|
84
86
|
serveDirectory: config.serveDirectory,
|
|
85
87
|
sdkBundle,
|
|
88
|
+
dashboardFont,
|
|
86
89
|
runToolCall: async (tool, argumentsObject) => {
|
|
87
90
|
const started = Date.now();
|
|
88
91
|
const calledIn = documentGeneration;
|
package/dist/dev/dev-servers.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// The two local servers behind `driggsby dev`, mirroring production's
|
|
2
2
|
// topology: the host origin (the page a person opens; serves the host page
|
|
3
3
|
// and the CLI's tool-call endpoint) and the app origin (the app's own
|
|
4
|
-
// files, plus the Driggsby SDK at /-/driggsby-sdk.js
|
|
5
|
-
// only. The app token never appears
|
|
6
|
-
// the CLI process.
|
|
4
|
+
// files, plus the Driggsby SDK at /-/driggsby-sdk.js and the dashboard font
|
|
5
|
+
// at /-/inter.woff2). Both bind loopback only. The app token never appears
|
|
6
|
+
// here — the broker callback holds it in the CLI process.
|
|
7
7
|
import { createServer } from "node:http";
|
|
8
|
+
import { appResponseHeaders, INERT_SERVICE_WORKER } from "./app-policy.js";
|
|
9
|
+
import { DASHBOARD_FONT_PATH, DASHBOARD_FONT_TYPE } from "./dashboard-font.js";
|
|
8
10
|
import { DEV_IDENTITY_PATH } from "./dev-state.js";
|
|
9
11
|
import { hostPageHtml, HOST_PAGE_JS } from "./host-page.js";
|
|
10
12
|
import { serveStaticFile } from "./static-files.js";
|
|
@@ -15,13 +17,16 @@ import { APP_TOOL_ALLOWLIST } from "./tool-allowlist.js";
|
|
|
15
17
|
export const GENERIC_TOOL_TROUBLE = "We couldn't run that just now. Try again in a moment.";
|
|
16
18
|
export const TOOL_NOT_ALLOWED_MESSAGE = "That tool isn't available to Driggsby apps. Apps can use read-only tools like get_overview and list_accounts.";
|
|
17
19
|
const MAX_TOOL_CALL_BODY_BYTES = 65_536;
|
|
20
|
+
const PLAIN_TEXT = "text/plain; charset=utf-8";
|
|
21
|
+
const JAVASCRIPT = "text/javascript; charset=utf-8";
|
|
18
22
|
export async function startDevServers(options) {
|
|
19
23
|
// Both origins bind and advertise 127.0.0.1: advertising "localhost"
|
|
20
24
|
// while binding only the IPv4 loopback breaks on machines whose browser
|
|
21
25
|
// resolves localhost to ::1 first.
|
|
22
26
|
let appPortForGuard = 0;
|
|
23
|
-
// Filled in once the host server binds; app responses
|
|
24
|
-
// frame-ancestors
|
|
27
|
+
// Filled in once the host server binds; app responses name it in their
|
|
28
|
+
// frame-ancestors and Allow-CSP-From, so only the real host page can
|
|
29
|
+
// frame the app.
|
|
25
30
|
let hostOriginForFraming = "";
|
|
26
31
|
const appServer = createServer((request, response) => {
|
|
27
32
|
void handleAppRequest(options, appPortForGuard, hostOriginForFraming, request, response);
|
|
@@ -67,42 +72,53 @@ export async function startDevServers(options) {
|
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
// ---------------------------------------------------------------------------
|
|
70
|
-
// The app origin: the SDK
|
|
75
|
+
// The app origin: the SDK and font paths, then the project's own files.
|
|
71
76
|
// ---------------------------------------------------------------------------
|
|
72
77
|
async function handleAppRequest(options, appPort, hostOrigin, request, response) {
|
|
73
|
-
//
|
|
74
|
-
//
|
|
75
|
-
//
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
const appHeaders = {
|
|
79
|
-
"Content-Security-Policy": `frame-ancestors ${hostOrigin === "" ? "'none'" : hostOrigin};`,
|
|
80
|
-
"X-Content-Type-Options": "nosniff",
|
|
81
|
-
};
|
|
78
|
+
// Every response carries the deployed app's headers (app-policy.ts). Their
|
|
79
|
+
// frame-ancestors lets only the real host page frame the app: without it,
|
|
80
|
+
// any other loopback-served page could embed the app origin, pin itself
|
|
81
|
+
// as the app's host, and feed it fabricated numbers.
|
|
82
|
+
const plainTextHeaders = appResponseHeaders(hostOrigin, PLAIN_TEXT);
|
|
82
83
|
// Same rebinding guard as the host origin: a page on another site that
|
|
83
84
|
// tricked DNS into pointing here carries its own Host, and fails.
|
|
84
85
|
if (!hostHeaderIsLocal(request.headers.host, appPort)) {
|
|
85
|
-
sendText(response, 403,
|
|
86
|
+
sendText(response, 403, PLAIN_TEXT, "Forbidden.", plainTextHeaders);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// Every service worker script request, whatever path it names, gets the
|
|
90
|
+
// inert worker (app-policy.ts), as deployed. Browsers mark each one.
|
|
91
|
+
if (isServiceWorkerScriptRequest(request)) {
|
|
92
|
+
sendText(response, 200, JAVASCRIPT, INERT_SERVICE_WORKER, appResponseHeaders(hostOrigin, JAVASCRIPT));
|
|
86
93
|
return;
|
|
87
94
|
}
|
|
88
95
|
const path = requestPath(request);
|
|
89
96
|
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
90
|
-
sendText(response, 405,
|
|
97
|
+
sendText(response, 405, PLAIN_TEXT, "Method not allowed.", plainTextHeaders);
|
|
91
98
|
return;
|
|
92
99
|
}
|
|
93
100
|
if (path === "/-/driggsby-sdk.js") {
|
|
94
|
-
sendText(response, 200,
|
|
101
|
+
sendText(response, 200, JAVASCRIPT, options.sdkBundle, appResponseHeaders(hostOrigin, JAVASCRIPT));
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (path === DASHBOARD_FONT_PATH) {
|
|
105
|
+
response.writeHead(200, {
|
|
106
|
+
"Content-Type": DASHBOARD_FONT_TYPE,
|
|
107
|
+
"Cache-Control": "no-store",
|
|
108
|
+
...appResponseHeaders(hostOrigin, DASHBOARD_FONT_TYPE),
|
|
109
|
+
});
|
|
110
|
+
response.end(options.dashboardFont);
|
|
95
111
|
return;
|
|
96
112
|
}
|
|
97
113
|
const file = await serveStaticFile(options.serveDirectory, path);
|
|
98
114
|
if (file === null) {
|
|
99
|
-
sendText(response, 404,
|
|
115
|
+
sendText(response, 404, PLAIN_TEXT, "Not found.", plainTextHeaders);
|
|
100
116
|
return;
|
|
101
117
|
}
|
|
102
118
|
response.writeHead(file.status, {
|
|
103
119
|
"Content-Type": file.contentType,
|
|
104
120
|
"Cache-Control": "no-store",
|
|
105
|
-
...
|
|
121
|
+
...appResponseHeaders(hostOrigin, file.contentType),
|
|
106
122
|
});
|
|
107
123
|
response.end(file.body);
|
|
108
124
|
}
|
|
@@ -117,6 +133,12 @@ async function handleHostRequest(options, hostPort, appOrigin, sseClients, reque
|
|
|
117
133
|
sendJson(response, 403, { ok: false, error: { message: "Forbidden." } });
|
|
118
134
|
return;
|
|
119
135
|
}
|
|
136
|
+
// The host page registers no worker, so a worker script request here is
|
|
137
|
+
// a foreign one; the inert worker replaces it (app-policy.ts).
|
|
138
|
+
if (isServiceWorkerScriptRequest(request)) {
|
|
139
|
+
sendText(response, 200, JAVASCRIPT, INERT_SERVICE_WORKER);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
120
142
|
const path = requestPath(request);
|
|
121
143
|
if (request.method === "GET" && path === DEV_IDENTITY_PATH) {
|
|
122
144
|
// Lets `dev --stop` (and `dev`) confirm that a record in ~/.driggsby
|
|
@@ -129,7 +151,7 @@ async function handleHostRequest(options, hostPort, appOrigin, sseClients, reque
|
|
|
129
151
|
return;
|
|
130
152
|
}
|
|
131
153
|
if (request.method === "GET" && path === "/host.js") {
|
|
132
|
-
sendText(response, 200,
|
|
154
|
+
sendText(response, 200, JAVASCRIPT, HOST_PAGE_JS);
|
|
133
155
|
return;
|
|
134
156
|
}
|
|
135
157
|
if (request.method === "GET" && path === "/events") {
|
|
@@ -150,7 +172,7 @@ async function handleHostRequest(options, hostPort, appOrigin, sseClients, reque
|
|
|
150
172
|
await handleToolCall(options, hostPort, request, response);
|
|
151
173
|
return;
|
|
152
174
|
}
|
|
153
|
-
sendText(response, 404,
|
|
175
|
+
sendText(response, 404, PLAIN_TEXT, "Not found.");
|
|
154
176
|
return;
|
|
155
177
|
}
|
|
156
178
|
async function handleToolCall(options, hostPort, request, response) {
|
|
@@ -209,6 +231,9 @@ function requestPath(request) {
|
|
|
209
231
|
const queryStart = url.indexOf("?");
|
|
210
232
|
return queryStart === -1 ? url : url.slice(0, queryStart);
|
|
211
233
|
}
|
|
234
|
+
function isServiceWorkerScriptRequest(request) {
|
|
235
|
+
return request.headers["service-worker"] === "script" || request.headers["sec-fetch-dest"] === "serviceworker";
|
|
236
|
+
}
|
|
212
237
|
function hostHeaderIsLocal(host, port) {
|
|
213
238
|
return host === `localhost:${String(port)}` || host === `127.0.0.1:${String(port)}`;
|
|
214
239
|
}
|
package/dist/dev/host-page.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
// inside Driggsby. The page carries no token and no data; every tool call
|
|
6
6
|
// goes to the CLI's own /tool-calls endpoint, which holds the token and
|
|
7
7
|
// enforces the allowlist and bounds.
|
|
8
|
+
import { FRAME_POLICY } from "./app-policy.js";
|
|
8
9
|
// The page's script is served as its own file so the page can carry a
|
|
9
10
|
// Content-Security-Policy with no inline scripts.
|
|
10
11
|
//
|
|
@@ -14,7 +15,11 @@
|
|
|
14
15
|
// `appOrigin` is built by startDevServers from a literal plus a bound port
|
|
15
16
|
// number, and `background` has passed readProjectConfig's strict hex-color
|
|
16
17
|
// rule (or is null). Anything looser than those sources must not be
|
|
17
|
-
// passed here.
|
|
18
|
+
// passed here. FRAME_POLICY is a constant with no double quote in it.
|
|
19
|
+
//
|
|
20
|
+
// The frame gets the console's sandbox and, as its csp attribute, the
|
|
21
|
+
// deployed policy (app-policy.ts), which Chrome then requires of every
|
|
22
|
+
// document the frame shows, even one this server didn't send.
|
|
18
23
|
export function hostPageHtml(slug, appOrigin, background) {
|
|
19
24
|
return `<!doctype html>
|
|
20
25
|
<html lang="en" data-app-origin="${appOrigin}">
|
|
@@ -84,7 +89,7 @@ export function hostPageHtml(slug, appOrigin, background) {
|
|
|
84
89
|
<span class="slug">${slug}</span>
|
|
85
90
|
<span class="mode">driggsby dev — your live data</span>
|
|
86
91
|
</header>
|
|
87
|
-
<iframe id="app" src="${appOrigin}/" sandbox="allow-scripts allow-same-origin
|
|
92
|
+
<iframe id="app" src="${appOrigin}/" sandbox="allow-scripts allow-same-origin" csp="${FRAME_POLICY}"></iframe>
|
|
88
93
|
<script type="module" src="/host.js"></script>
|
|
89
94
|
</body>
|
|
90
95
|
</html>
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
// console's stylesheet, so each gray is written as the console paints it
|
|
6
6
|
// on its black page (the console's cards and fills are translucent over
|
|
7
7
|
// that ground) and each hue verbatim. The :root block is the same one
|
|
8
|
-
// Driggsby's own example dashboard carries
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// Driggsby's own example dashboard carries, --font-sans leading with
|
|
9
|
+
// Inter, the face Driggsby serves every app (dev/dashboard-font.ts).
|
|
10
|
+
// --bg-app must stay equal to driggsby.json's "background"
|
|
11
|
+
// (init-command.test.ts pins the two together): Driggsby paints that color
|
|
12
|
+
// while the app loads.
|
|
11
13
|
export const STYLES_CSS = `/* Driggsby's console palette, so this page reads as part of the app it
|
|
12
14
|
opens inside. Change these together if you re-theme; keep --bg-app equal
|
|
13
15
|
to the "background" in driggsby.json. The status tones are the
|
|
@@ -28,10 +30,27 @@ export const STYLES_CSS = `/* Driggsby's console palette, so this page reads as
|
|
|
28
30
|
--text-error: oklch(0.8 0.13 25);
|
|
29
31
|
--radius-card: 8px;
|
|
30
32
|
--radius-bar: 4px;
|
|
31
|
-
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
|
33
|
+
--font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
|
|
32
34
|
--ease: cubic-bezier(0.2, 0, 0, 1);
|
|
33
35
|
}
|
|
34
36
|
|
|
37
|
+
/* Inter, which Driggsby serves at /-/inter.woff2 on this app's own origin
|
|
38
|
+
(driggsby dev serves the same file there), so nothing loads from another
|
|
39
|
+
site. Keep the page's text set in it: the Dashboards page shows a
|
|
40
|
+
picture of this page, taken on a server with none of your fonts, and
|
|
41
|
+
only a font the page loads itself looks the same there. Fonts from other
|
|
42
|
+
sites are refused. To switch faces, put the font file in this folder,
|
|
43
|
+
point an @font-face at it, name it first in --font-sans, and change the
|
|
44
|
+
preload in index.html to match. Text waits for the font (font-display:
|
|
45
|
+
block, preloaded) rather than flash another face first. */
|
|
46
|
+
@font-face {
|
|
47
|
+
font-family: "Inter";
|
|
48
|
+
src: url("/-/inter.woff2") format("woff2");
|
|
49
|
+
font-weight: 100 900;
|
|
50
|
+
font-style: normal;
|
|
51
|
+
font-display: block;
|
|
52
|
+
}
|
|
53
|
+
|
|
35
54
|
* {
|
|
36
55
|
box-sizing: border-box;
|
|
37
56
|
}
|
package/dist/init/templates.js
CHANGED
|
@@ -15,6 +15,7 @@ export function indexHtml(slug) {
|
|
|
15
15
|
<meta charset="utf-8">
|
|
16
16
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
17
17
|
<title>${slug}</title>
|
|
18
|
+
<link rel="preload" href="/-/inter.woff2" as="font" type="font/woff2" crossorigin>
|
|
18
19
|
<link rel="stylesheet" href="styles.css">
|
|
19
20
|
</head>
|
|
20
21
|
<body>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "driggsby",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Set up and build on Driggsby, the MCP server for personal finance.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
5
|
+
"license": "Apache-2.0 AND OFL-1.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/driggsby/driggsby.git"
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
"driggsby": "bin/driggsby.js"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
|
+
"assets/Inter.woff2",
|
|
17
|
+
"assets/Inter-LICENSE.txt",
|
|
16
18
|
"bin",
|
|
17
19
|
"dist",
|
|
18
20
|
"LICENSE",
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"node": ">=18"
|
|
29
31
|
},
|
|
30
32
|
"dependencies": {
|
|
31
|
-
"@driggsby/deploy": "0.7.
|
|
32
|
-
"@driggsby/sdk": "0.7.
|
|
33
|
+
"@driggsby/deploy": "0.7.2",
|
|
34
|
+
"@driggsby/sdk": "0.7.2"
|
|
33
35
|
}
|
|
34
36
|
}
|