SeparationCheck
PREVIEW
The key-separation check EsseyAgent runs before every signature.
Signatures below are copied from the source; descriptions are the source's own doc comments.
From separation.ts#
Exported by index.ts.
SeparationCode#
TypeScript
export type SeparationCode =
"KEYS_NOT_SEPARATE" | "OWNER_CAP_PUBLIC" | "OWNER_CAP_UNVERIFIABLE" | "AGENT_CAP_MISMATCH";OwnerCapRecord#
TypeScript
export type OwnerCapRecord = { treasuryId: string; ownerCapId: string; owner: string };ForeignCap#
TypeScript
export type ForeignCap = {
code: "FOREIGN_AGENT_CAP";
treasuryId: string;
agentCapId: string;
message: string;
};Separation#
TypeScript
export type Separation =
| { ok: true; agent: string; treasuries: OwnerCapRecord[]; warnings: ForeignCap[] }
| { ok: false; code: SeparationCode; treasuryId: string | null; message: string };CapRef#
TypeScript
export type CapRef = { treasuryId: string; agentCapId: string };SeparationChain#
TypeScript
export type SeparationChain = { client: Reads; events: EventReader; touches: TouchReader | null };SeparationCheck#
Rule 2 of the bring-your-own-agent scope: the agent's key must not own the OwnerCap of a treasury of its account (required). Anyone can mint this address an AgentCap on a treasury of their own and freeze its OwnerCap, so caps outside the account are warnings, never refusals. Each treasury has exactly one OwnerCap (treasury.move share), created in the transaction that emitted its TreasuryCreated event; that id never changes, so it is cached, and its owner is re-read on every run.
TypeScript
export class SeparationCheckconstructor
TypeScript
constructor(
readonly chain: SeparationChain,
readonly pkg: string,
readonly agent: string,
) {
this.client = chain.client;
}
private type(name: string)SeparationCheck.run
TypeScript
async run(required: CapRef[]): Promise<Separation>SeparationCheck.ownerCapOf
TypeScript
async ownerCapOf(treasuryId: string): Promise<string | null>