TypeScript client reference
VerdictClient connects your TypeScript or JavaScript application to a Verdict
instance to check authorization decisions, query policy rules, mutate facts,
and manage active policies.
This reference covers the public root exports of @marcporciuncula/verdict-client.
Generated protobuf transport definitions under ./proto are internal to the
package and outside this reference.
import { VerdictClient, identity } from "@marcporciuncula/verdict-client";
const client = new VerdictClient({ instanceUrl: "https://your-instance.example.com", apiKey: "your-instance-key",});
const allowed = await client.authorize( identity("User", "alice"), "read", identity("Document", "handbook"),);Configure VerdictClient with the URL and bearer credential issued for your
instance. Your active .vd policy determines which (actor, action, resource)
checks resolve to true.
Core operations
Section titled “Core operations”VerdictClientdocuments the client constructor, read and mutation methods (authorize,query,insertFact,deleteFact,batchFacts,listFacts,setPolicy,getPolicy), observedrevision, routingsessionId, andsession().VerdictClientOptionsdocuments connection settings, consistency defaults, wire format ("proto"or"json"), HTTP 503 backoff, and mutation timeout bounds.FactInput,PatternInput, andListFilterInputdefine the tuple and object shapes used to supply facts, evaluate or delete patterns, and filter stored facts.IntegerMode,ResultTerm, andIntegerRepresentationErrordefine how 64-bit integers are decoded in responses.- Client sessions, consistency, and retries
explains observed revisions, read consistency modes (
session,eventual,authoritative), request scoping withclient.session(), and automatic mutation retries and timeouts.
Queries, fact filters, and wildcards
Section titled “Queries, fact filters, and wildcards”VerdictClient provides two ways to inspect state:
queryevaluates your policy rules and returns derived rows for each unbound position in aPatternInput.listFactsinspects only stored facts matching an optionalListFilterInputand does not evaluate derived rules.
In patterns passed to query, deleteFact, and listFacts, pass a concrete
term to match an exact value, null for an anonymous wildcard matching any
term, or a { wildcard: { type?, name? } } object to restrict the match by type
or bind repeated variable names to equal values.
Handling 64-bit integers
Section titled “Handling 64-bit integers”Verdict represents integers as signed 64-bit values (int64):
- Inputs: JavaScript
numberarguments must be safe integers (Number.isSafeInteger). Pass abigintwhen supplying values across the full signed 64-bit integer range. - Outputs: By default (
integerMode: "number"), decoded integers inResultTermare returned asnumber, and any response integer outside the safe integer range throwsIntegerRepresentationError. ConfigureintegerModeas"bigint"(always returnbigint) or"adaptive"(returnnumberwhen safe andbigintotherwise) when query or fact results can exceedNumber.MAX_SAFE_INTEGER.
Related guides
Section titled “Related guides”Each generated reference page links directly to the TypeScript source comments that define the contract.
For end-to-end backend integration patterns, see
Integrate with your app,
Managing Facts, and
Enforcing Decisions & Querying. For
.vd policy syntax and modeling, see
Policy Fundamentals and
Designing Policies.