@fungi.computer/computer 0.14.2 → 0.14.4
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/dist/port-access.d.ts +6 -1
- package/dist/port-access.js +22 -2
- package/dist/team-candidate-builder.mjs +45 -15
- package/package.json +3 -3
package/dist/port-access.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ export type PortAccessPrincipal = Readonly<{
|
|
|
9
9
|
}>;
|
|
10
10
|
/** Visibility belongs to an existing exposed port, never a second catalog. */
|
|
11
11
|
export type PortVisibility = "private" | "unlisted" | "public";
|
|
12
|
+
/** A host's registrable site, or null when it has none (IPs, single labels). */
|
|
13
|
+
export type PortSite = (url: URL) => string | null;
|
|
12
14
|
/** Refusal at the host's issuance or configuration boundary. */
|
|
13
15
|
export declare class PortAccessError extends Error {
|
|
14
16
|
readonly reason: "unexposed" | "public_disabled" | "not_unlisted" | "capacity";
|
|
@@ -35,5 +37,8 @@ export declare class ComputerPortAccess {
|
|
|
35
37
|
private exchange;
|
|
36
38
|
private admits;
|
|
37
39
|
/** Mount on one target host. Forwarding remains responsible for live exposure. */
|
|
38
|
-
gate(portInput: number,
|
|
40
|
+
gate(portInput: number, policy: Readonly<{
|
|
41
|
+
entryUrl: string;
|
|
42
|
+
site: PortSite;
|
|
43
|
+
}>, forward: (request: Request) => Response | Promise<Response>): Hono;
|
|
39
44
|
}
|
package/dist/port-access.js
CHANGED
|
@@ -46,6 +46,23 @@ async function hash(value) {
|
|
|
46
46
|
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(value));
|
|
47
47
|
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
48
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Sibling hosts on one site share Lax cookies, so a present Origin or Referer
|
|
51
|
+
* must be this exact origin or another site. A value the URL parser refuses,
|
|
52
|
+
* including the opaque `null` Origin, is refused too. Absent headers pass.
|
|
53
|
+
*/
|
|
54
|
+
function fromSibling(request, target, site) {
|
|
55
|
+
const siteOf = (url) => site(url) ?? url.hostname;
|
|
56
|
+
return ["origin", "referer"].some((name) => {
|
|
57
|
+
const value = request.headers.get(name);
|
|
58
|
+
if (value === null)
|
|
59
|
+
return false;
|
|
60
|
+
if (!URL.canParse(value))
|
|
61
|
+
return true;
|
|
62
|
+
const source = new URL(value);
|
|
63
|
+
return source.origin !== target.origin && siteOf(source) === siteOf(target);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
49
66
|
/** One Computer's port credentials; the host owns membership and routing. */
|
|
50
67
|
export class ComputerPortAccess {
|
|
51
68
|
storage;
|
|
@@ -165,8 +182,9 @@ export class ComputerPortAccess {
|
|
|
165
182
|
.toArray().length === 1);
|
|
166
183
|
}
|
|
167
184
|
/** Mount on one target host. Forwarding remains responsible for live exposure. */
|
|
168
|
-
gate(portInput,
|
|
185
|
+
gate(portInput, policy, forward) {
|
|
169
186
|
const port = computerPortSchema.parse(portInput);
|
|
187
|
+
const { entryUrl, site } = policy;
|
|
170
188
|
const app = new Hono();
|
|
171
189
|
app.all("*", async (c) => {
|
|
172
190
|
c.header("Cache-Control", "no-store");
|
|
@@ -179,9 +197,11 @@ export class ComputerPortAccess {
|
|
|
179
197
|
: c.body(null, 401);
|
|
180
198
|
// Sibling preview hosts are same-site but must never use each other's
|
|
181
199
|
// cookies. WebSockets bypass CORS, so require their exact origin too.
|
|
200
|
+
const target = new URL(c.req.url);
|
|
182
201
|
const upgrade = c.req.raw.headers.has("upgrade");
|
|
183
202
|
if (c.req.header("sec-fetch-site") === "same-site" ||
|
|
184
|
-
(
|
|
203
|
+
fromSibling(c.req.raw, target, site) ||
|
|
204
|
+
(upgrade && c.req.header("origin") !== target.origin))
|
|
185
205
|
return denied();
|
|
186
206
|
const visibility = this.visibility(port);
|
|
187
207
|
if (visibility === undefined ||
|
|
@@ -14455,6 +14455,15 @@ function withConstructorDefault2(defaultValue) {
|
|
|
14455
14455
|
function toIssueEffect(self) {
|
|
14456
14456
|
return catchCause2(self, (cause) => failCauseSync2(() => map3(cause, (error2) => error2.issue)));
|
|
14457
14457
|
}
|
|
14458
|
+
function withDecodingDefaultKey(defaultValue, options) {
|
|
14459
|
+
const encode4 = options?.encodingStrategy === "omit" ? omit() : passthrough();
|
|
14460
|
+
return (self) => {
|
|
14461
|
+
return optionalKey2(toEncoded2(self)).pipe(decodeTo2(self, {
|
|
14462
|
+
decode: withDefault(toIssueEffect(defaultValue)),
|
|
14463
|
+
encode: encode4
|
|
14464
|
+
}));
|
|
14465
|
+
};
|
|
14466
|
+
}
|
|
14458
14467
|
function withDecodingDefault(defaultValue, options) {
|
|
14459
14468
|
const encode4 = options?.encodingStrategy === "omit" ? omit() : passthrough();
|
|
14460
14469
|
return (self) => {
|
|
@@ -20751,20 +20760,35 @@ var appGillWatchSchema = Union2([
|
|
|
20751
20760
|
Struct({ storage: meaningful }),
|
|
20752
20761
|
Struct({ binding: meaningful })
|
|
20753
20762
|
]);
|
|
20754
|
-
var
|
|
20755
|
-
|
|
20756
|
-
|
|
20757
|
-
|
|
20763
|
+
var identity3 = meaningful.pipe(check(makeFilter2((id) => !id.includes(":"), {
|
|
20764
|
+
message: "Gill IDs are App-local"
|
|
20765
|
+
})));
|
|
20766
|
+
var desktop = Struct({
|
|
20767
|
+
sizes: ArraySchema(Literals(["S", "M", "L"])).check(isMinLength(1), isMaxLength(3), makeFilter2(isUnique, {
|
|
20768
|
+
message: "Desktop Gill sizes must be unique"
|
|
20769
|
+
}))
|
|
20770
|
+
});
|
|
20771
|
+
var rowGill = (view) => Struct({
|
|
20772
|
+
id: identity3,
|
|
20773
|
+
view,
|
|
20758
20774
|
title: meaningful,
|
|
20759
20775
|
source: meaningful,
|
|
20760
20776
|
params: optional2(appGillParamsSchema),
|
|
20761
20777
|
watch: optional2(appGillWatchSchema),
|
|
20762
|
-
desktop: optional2(
|
|
20763
|
-
sizes: ArraySchema(Literals(["S", "M", "L"])).check(isMinLength(1), isMaxLength(3), makeFilter2(isUnique, {
|
|
20764
|
-
message: "Desktop Gill sizes must be unique"
|
|
20765
|
-
}))
|
|
20766
|
-
}))
|
|
20778
|
+
desktop: optional2(desktop)
|
|
20767
20779
|
});
|
|
20780
|
+
var appDeclaredRowGillSchema = rowGill(Literal2("rows"));
|
|
20781
|
+
var appDeclaredSurfaceGillSchema = Struct({
|
|
20782
|
+
id: identity3,
|
|
20783
|
+
title: meaningful,
|
|
20784
|
+
view: Literal2("surface"),
|
|
20785
|
+
desktop
|
|
20786
|
+
});
|
|
20787
|
+
var appDeclaredGillSchema = Union2([appDeclaredRowGillSchema, appDeclaredSurfaceGillSchema]);
|
|
20788
|
+
var appStoredGillSchema = Union2([
|
|
20789
|
+
rowGill(Literal2("rows").pipe(withDecodingDefaultKey(succeed5("rows")))),
|
|
20790
|
+
appDeclaredSurfaceGillSchema
|
|
20791
|
+
]);
|
|
20768
20792
|
|
|
20769
20793
|
// ../gills/dist/gill.js
|
|
20770
20794
|
var gillParamsSchema = Record(appGillParamKeySchema, String4.check(isMaxLength(256))).check(makeFilter2((params) => Object.keys(params).length <= 4, {
|
|
@@ -20912,7 +20936,7 @@ var appCallSchema = declareConstructor()([appCallFields], ([fields]) => (input,
|
|
|
20912
20936
|
toCodecJson: () => new Link(appCallFields.ast, passthrough2())
|
|
20913
20937
|
});
|
|
20914
20938
|
var appCallsSchema = ArraySchema(appCallSchema).check(isMinLength(1), isMaxLength(16), makeFilter2((calls) => isUnique2(calls.map((call) => call.appId)), unique2));
|
|
20915
|
-
var
|
|
20939
|
+
var declarationSchemaFor = (gill) => Struct({
|
|
20916
20940
|
api: optionalKey2(appApiSchema),
|
|
20917
20941
|
displayName: optional2(String4.pipe(check(isMinLength(1)), check(isMaxLength(64)))),
|
|
20918
20942
|
capabilities: ArraySchema(appCapabilityIdSchema).pipe(check(makeFilter2(isUnique2, unique2))),
|
|
@@ -20926,16 +20950,22 @@ var appDeclarationSchema = Struct({
|
|
|
20926
20950
|
commands: optional2(ArraySchema(appDeclaredCommandSchema).pipe(check(isMaxLength(64)), check(makeFilter2(commandsAreUnique, {
|
|
20927
20951
|
message: "Declared command IDs and slash aliases must be unique"
|
|
20928
20952
|
})))),
|
|
20929
|
-
gills: optional2(ArraySchema(
|
|
20953
|
+
gills: optional2(ArraySchema(gill).pipe(check(isMaxLength(16)), check(makeFilter2(gillsAreUnique, {
|
|
20930
20954
|
message: "Declared Gill IDs must be unique"
|
|
20931
20955
|
})))),
|
|
20932
20956
|
backend: optional2(Struct({
|
|
20933
20957
|
bindings: appBackendBindingsSchema,
|
|
20934
20958
|
sync: optionalKey2(Struct({ method: appApiMethodNameSchema }))
|
|
20935
20959
|
}))
|
|
20936
|
-
}).pipe(check(makeFilter2((declaration3) => declaration3.calls === void 0 || declaration3.capabilities.includes("apps.call"), { message: "App calls require apps.call" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.name !== "BACKGROUND") ?? true, {
|
|
20960
|
+
}).pipe(check(makeFilter2((declaration3) => declaration3.calls === void 0 || declaration3.capabilities.includes("apps.call"), { message: "App calls require apps.call" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.name !== "BACKGROUND") ?? true, {
|
|
20961
|
+
message: "BACKGROUND is host-minted and cannot be declared by an App"
|
|
20962
|
+
})), check(makeFilter2((declaration3) => backgroundSyncAllowed(declaration3.api, declaration3.backend?.sync), {
|
|
20937
20963
|
message: "Background continuation must be a declared write covering all write requirements"
|
|
20938
|
-
})), check(makeFilter2((declaration3) => !(declaration3.receives?.includes("git.push") ?? false) || declaration3.capabilities.includes("git.repository"), { message: "Git push reception requires git.repository" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.operations.every((name) => appBackendBindingOperation(binding.name, name)?.requires.every((capability) => declaration3.capabilities.includes(capability)) === true)) ?? true, { message: "Backend bindings require declared App capabilities" })), check(makeFilter2((declaration3) => !declaration3.backend?.bindings.some((binding) => binding.name === "APP_STORAGE") || (declaration3.storage?.length ?? 0) > 0, { message: "App storage bindings require declared keys" })), check(makeFilter2((declaration3) => Object.values(declaration3.api?.methods ?? {}).every((method2) => method2.requires.every((capability) => declaration3.capabilities.includes(capability))), {
|
|
20964
|
+
})), check(makeFilter2((declaration3) => !(declaration3.receives?.includes("git.push") ?? false) || declaration3.capabilities.includes("git.repository"), { message: "Git push reception requires git.repository" })), check(makeFilter2((declaration3) => declaration3.backend?.bindings.every((binding) => binding.operations.every((name) => appBackendBindingOperation(binding.name, name)?.requires.every((capability) => declaration3.capabilities.includes(capability)) === true)) ?? true, { message: "Backend bindings require declared App capabilities" })), check(makeFilter2((declaration3) => !declaration3.backend?.bindings.some((binding) => binding.name === "APP_STORAGE") || (declaration3.storage?.length ?? 0) > 0, { message: "App storage bindings require declared keys" })), check(makeFilter2((declaration3) => Object.values(declaration3.api?.methods ?? {}).every((method2) => method2.requires.every((capability) => declaration3.capabilities.includes(capability))), {
|
|
20965
|
+
message: "App API requires capabilities outside the App declaration"
|
|
20966
|
+
})));
|
|
20967
|
+
var appDeclarationSchema = declarationSchemaFor(appDeclaredGillSchema);
|
|
20968
|
+
var storedAppDeclarationSchema = declarationSchemaFor(appStoredGillSchema);
|
|
20939
20969
|
|
|
20940
20970
|
// ../../node_modules/.pnpm/nanoid@5.1.16/node_modules/nanoid/index.js
|
|
20941
20971
|
import { webcrypto as crypto2 } from "node:crypto";
|
|
@@ -21322,7 +21352,7 @@ var verifiedAppDescriptionSchema = Struct({
|
|
|
21322
21352
|
profile: verifiedBackendProfileSchema
|
|
21323
21353
|
})),
|
|
21324
21354
|
// Metadata verified before declarations existed requested nothing.
|
|
21325
|
-
declaration:
|
|
21355
|
+
declaration: storedAppDeclarationSchema.pipe(withDecodingDefaultType(succeed5(emptyAppDeclaration)))
|
|
21326
21356
|
});
|
|
21327
21357
|
var verifiedArtifactReadSchema = Struct({
|
|
21328
21358
|
kind: Literal2("verified"),
|
|
@@ -21542,7 +21572,7 @@ var appBackendBuildSchema = Struct({
|
|
|
21542
21572
|
mediaType: Literal2("application/vnd.fungi.app-backend+json")
|
|
21543
21573
|
});
|
|
21544
21574
|
var declaration = {
|
|
21545
|
-
declaration: optionalKey2(
|
|
21575
|
+
declaration: optionalKey2(storedAppDeclarationSchema)
|
|
21546
21576
|
};
|
|
21547
21577
|
var appBuildSchema = Union2([
|
|
21548
21578
|
Struct({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fungi.computer/computer",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"author": "Levi <levi@technomancy.dev>",
|
|
5
5
|
"description": "Cloudflare Computer host for one durable Fungi Computer",
|
|
6
6
|
"type": "module",
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"@fungi.computer/capnweb": "0.12.0-fungi.0",
|
|
65
65
|
"@fungi.computer/cloudflare-computer": "0.2.1-fungi.2",
|
|
66
66
|
"@fungi.computer/cordyceps": "0.4.3",
|
|
67
|
-
"@fungi.computer/knapsack": "0.4.
|
|
67
|
+
"@fungi.computer/knapsack": "0.4.17",
|
|
68
68
|
"@fungi.computer/seam": "0.2.6",
|
|
69
69
|
"@fungi.computer/watchdog": "0.1.4",
|
|
70
|
-
"@fungi.computer/computer-contract": "0.5.
|
|
70
|
+
"@fungi.computer/computer-contract": "0.5.4",
|
|
71
71
|
"effect": "4.0.2",
|
|
72
72
|
"just-bash": "3.4.2",
|
|
73
73
|
"zod": "4.4.3",
|