@fungi.computer/oyster 0.38.0 → 0.39.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.
@@ -1,3 +1,7 @@
1
+ /** Second boundary before an admitted request enters customer backend code.
2
+ * Hub normally builds this shape itself; callers of the App runtime must not
3
+ * be able to pass their own headers through the facet.
4
+ */
1
5
  export declare function appFacetRequest(request: Request): Request;
2
6
  /** Only content metadata crosses back from a guest; origin policy is host-owned. */
3
7
  export declare function appFacetResponse(response: Response): Response;
@@ -2,18 +2,11 @@
2
2
  * Hub normally builds this shape itself; callers of the App runtime must not
3
3
  * be able to pass their own headers through the facet.
4
4
  */
5
- import { appBackendActorHeader, appBackendComputerHeader, } from "@fungi.computer/agar/backend";
6
5
  export function appFacetRequest(request) {
7
6
  const headers = new Headers();
8
- for (const name of [
9
- "Content-Type",
10
- appBackendActorHeader,
11
- appBackendComputerHeader,
12
- ]) {
13
- const value = request.headers.get(name);
14
- if (value !== null)
15
- headers.set(name, value);
16
- }
7
+ const contentType = request.headers.get("Content-Type");
8
+ if (contentType !== null)
9
+ headers.set("Content-Type", contentType);
17
10
  const init = {
18
11
  method: request.method,
19
12
  headers,
@@ -178,8 +178,13 @@ export type SessionDoor = Readonly<{
178
178
  sourceRequestId?: string;
179
179
  }>;
180
180
  }>)) => Promise<void>;
181
- /** Only a matching, contract-closed request clears a visitor reservation. */
182
- errorKind: (error: Error, requestId: string) => "closed_request" | null;
181
+ /**
182
+ * `closed_request`: only a matching, contract-closed request clears a
183
+ * visitor reservation. `intake_refused`: the Session refused the text at
184
+ * its door (it holds a key, or it could not be checked for one), so
185
+ * nothing was admitted or stored.
186
+ */
187
+ errorKind: (error: Error, requestId: string) => "closed_request" | "intake_refused" | null;
183
188
  }>;
184
189
  export declare function createChannelConversations(options: Readonly<{
185
190
  sql: ConversationSql;
@@ -453,9 +453,16 @@ export function createChannelConversations(options) {
453
453
  return { kind: "accepted", sessionId, commandId, delivery };
454
454
  }
455
455
  catch (error) {
456
- if (event.party.kind !== "visitor" ||
457
- !(error instanceof Error) ||
458
- options.door.errorKind(error, requestId) !== "closed_request")
456
+ const kind = error instanceof Error
457
+ ? options.door.errorKind(error, requestId)
458
+ : null;
459
+ if (kind === "intake_refused") {
460
+ // The Session admitted nothing; the reservation must not keep text
461
+ // that holds, or may hold, a key.
462
+ sql.exec("DELETE FROM hub_channel_intake WHERE binding_id=? AND event_id=? AND session_id=? AND state='pending'", binding.bindingId, event.eventId, sessionId);
463
+ throw error;
464
+ }
465
+ if (event.party.kind !== "visitor" || kind !== "closed_request")
459
466
  throw error;
460
467
  // The owner's durable withdrawal fence is authoritative. This reservation
461
468
  // never became a line or command; do not present it as pending intake.
@@ -50,7 +50,7 @@ var __disposeResources = (this && this.__disposeResources) || (function (Suppres
50
50
  var e = new Error(message);
51
51
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
52
52
  });
53
- import { appBackendComputerHeader, appMethodReplySchema, } from "@fungi.computer/agar/backend";
53
+ import { appMethodReplySchema } from "@fungi.computer/agar/backend";
54
54
  import { nativeGitFrameMethods } from "@fungi.computer/agar/git-rpc";
55
55
  import { rpcHandleSchema, rpcMethod } from "@fungi.computer/agar/rpc";
56
56
  import { facetInvocationModule, facetFrameBindingModule, } from "./facet-invocation.js";
@@ -440,7 +440,6 @@ export function createCloudflareAppTestCopies(ctx, loader, ports, limits) {
440
440
  /** Run ordinary backend HTTP with bounded bodies and no live bindings. */
441
441
  fetch: (authority, copyId, request) => execute(authority, copyId, async (stub) => {
442
442
  const safe = appFacetRequest(request);
443
- safe.headers.delete(appBackendComputerHeader);
444
443
  const reply = facetHttpReplySchema.parse(await stub.http({
445
444
  url: safe.url,
446
445
  method: safe.method,