class · Browser and Node
MandateEngine
@toip-tools/mandatesView sourceimport { MandateEngine } from "@toip-tools/mandates";
Constructor
This class has no public constructor. Use its public factory methods below to create an instance.
Properties
policyHashrequired · readonlystring
Methods
evaluate
Runs the policy on facts. Deterministic: the same input gives the same output.
evaluate(input: PolicyInput): PolicyOutput;
Parameters
inputrequiredPolicyInput
Returns
narrowing
The narrowing step for one parent and child, on facts. Empty means the child narrows.
narrowing(parent: LinkFacts, child: LinkFacts): Reason[];
Parameters
Returns
Reason[]narrows
Whether child narrows parent (§7.2, §7.3). Empty means it does. Signatures and links aren't checked here.
narrows(parent: Mandate, child: Mandate): Promise<Reason[]>;
Parameters
Returns
Promise<Reason[]>checkChain
Checks a chain without an action: steps 1 to 9. Status lists are checked only with a resolver. A delegate uses it on a mandate it receives.
checkChain(i: {
chain: Mandate[];
presenter: string;
clock: Clock;
status?: StatusResolver;
requirements?: Requirements;
}): Promise<Reason[]>;
Parameters
irequired{ chain: Mandate[]; presenter: string; clock: Clock; status?: StatusResolver; requirements?: Requirements; }
Returns
Promise<Reason[]>decide
Decides an action against a chain (§8.2).
decide(i: DecideInput): Promise<Decision>;
Parameters
irequiredDecideInput
Returns
Promise<Decision>verifyPresentation
What a counterparty runs on a presentation (§8.7). sender is the TSP sender; me is this verifier's DID.
The presentation's spend statement is the budget state, and its status lists are hints: the newest valid list wins.
verifyPresentation(p: Presentation, o: {
sender: string;
me: string;
status: StatusResolver;
requirements?: Requirements;
clock: Clock;
}): Promise<Decision>;
Parameters
prequiredPresentationorequired{ sender: string; me: string; status: StatusResolver; requirements?: Requirements; clock: Clock; }
Returns
Promise<Decision>static load
Loads the policy. Without wasm, the bundled policy/policy.wasm (read from disk in Node, fetched in a browser).
load(wasm?: BufferSource): Promise<MandateEngine>;
Parameters
wasmoptionalBufferSource | undefined
Returns
Promise<MandateEngine>