@fungi.computer/oyster 0.38.1 → 0.39.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.
@@ -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.