API reference · Browser and Node

# @toip-tools/trust-core

63 public exports.

Module import:

```ts
import { type BodyCodec, type BodyContext, BodyError } from "@toip-tools/trust-core";
```

## Functions

- [`canonicalJson`](https://toip.tools/toolkit/trust-core/api/canonicalJson/)

  JSON Canonicalization Scheme (RFC 8785) — the byte form eddsa-jcs-2022 and

- [`checkStatus`](https://toip.tools/toolkit/trust-core/api/checkStatus/)

- [`decodeBody`](https://toip.tools/toolkit/trust-core/api/decodeBody/)

  Reads a body of any known format, choosing by its first byte.

- [`encodeBody`](https://toip.tools/toolkit/trust-core/api/encodeBody/)

  The body for \`doc\`: \`codec\`'s form when it has one that carries \`doc\` exactly, otherwise JSON.

- [`fromB64u`](https://toip.tools/toolkit/trust-core/api/fromB64u/)

- [`fromUtf8`](https://toip.tools/toolkit/trust-core/api/fromUtf8/)

- [`identityFromSeed`](https://toip.tools/toolkit/trust-core/api/identityFromSeed/)

  Builds an Ed25519 did:key identity and derives its X25519 encryption keys.

- [`isRevokedIn`](https://toip.tools/toolkit/trust-core/api/isRevokedIn/)

- [`issueCredential`](https://toip.tools/toolkit/trust-core/api/issueCredential/)

  Creates and signs a VC-shaped credential with a fresh UUID and the issuer's DID.

- [`memoryReplayStore`](https://toip.tools/toolkit/trust-core/api/memoryReplayStore/)

  A store in memory: survives a new guard, not a new process.

- [`openItem`](https://toip.tools/toolkit/trust-core/api/openItem/)

  Opens the item as \`me\`.

- [`ourSpec`](https://toip.tools/toolkit/trust-core/api/ourSpec/)

  A spec in our own namespace.

- [`resealText`](https://toip.tools/toolkit/trust-core/api/resealText/)

  New text under the item's existing key, for the same readers.

- [`resolveDidKey`](https://toip.tools/toolkit/trust-core/api/resolveDidKey/)

  Resolves an Ed25519 did:key locally and derives its X25519 public key without network access.

- [`sealItem`](https://toip.tools/toolkit/trust-core/api/sealItem/)

- [`seedFrom`](https://toip.tools/toolkit/trust-core/api/seedFrom/)

  Derives a reproducible seed by hashing a label with SHA-256.

- [`signDocument`](https://toip.tools/toolkit/trust-core/api/signDocument/)

  Signs a JSON object with an eddsa-jcs-2022 Data Integrity proof.

- [`toB64u`](https://toip.tools/toolkit/trust-core/api/toB64u/)

  base64url without padding, using only APIs present in browsers and Node.

- [`utf8`](https://toip.tools/toolkit/trust-core/api/utf8/)

- [`verifyCredential`](https://toip.tools/toolkit/trust-core/api/verifyCredential/)

  Checks a credential's proof and validity window.

- [`verifyDocument`](https://toip.tools/toolkit/trust-core/api/verifyDocument/)

  Verifies a document's Data Integrity proof, allowing five minutes of clock skew.

## Classes

- [`BodyError`](https://toip.tools/toolkit/trust-core/api/BodyError/)

  Why a body could not be read, in the TSP binding's failure terms.

- [`Bus`](https://toip.tools/toolkit/trust-core/api/Bus/)

  An in-memory network that delivers bytes by receiver VID, and lets the UI tap every message.

- [`CoarseClock`](https://toip.tools/toolkit/trust-core/api/CoarseClock/)

  A clock that rounds every reading down to \`granularityMs\` (default one hour), so documents and

- [`DemoClock`](https://toip.tools/toolkit/trust-core/api/DemoClock/)

  A manually advanced clock, so tests are deterministic.

- [`Endpoint`](https://toip.tools/toolkit/trust-core/api/Endpoint/)

  Sends and receives Trust Task documents as real TSP Direct messages.

- [`KnowledgeLog`](https://toip.tools/toolkit/trust-core/api/KnowledgeLog/)

- [`PersistentReplayGuard`](https://toip.tools/toolkit/trust-core/api/PersistentReplayGuard/)

- [`Policies`](https://toip.tools/toolkit/trust-core/api/Policies/)

  Rego policies compiled to one WebAssembly bundle with \`opa build -t wasm\`, evaluated locally.

- [`Refusal`](https://toip.tools/toolkit/trust-core/api/Refusal/)

  A handler returns this to refuse a request.

- [`RelayTransport`](https://toip.tools/toolkit/trust-core/api/RelayTransport/)

- [`StatusList`](https://toip.tools/toolkit/trust-core/api/StatusList/)

- [`SystemClock`](https://toip.tools/toolkit/trust-core/api/SystemClock/)

- [`TaskError`](https://toip.tools/toolkit/trust-core/api/TaskError/)

## Interfaces

- [`BodyCodec`](https://toip.tools/toolkit/trust-core/api/BodyCodec/)

- [`BodyContext`](https://toip.tools/toolkit/trust-core/api/BodyContext/)

- [`Clock`](https://toip.tools/toolkit/trust-core/api/Clock/)

  Where every component gets the time.

- [`Credential`](https://toip.tools/toolkit/trust-core/api/Credential/)

- [`CredentialBody`](https://toip.tools/toolkit/trust-core/api/CredentialBody/)

- [`Fact`](https://toip.tools/toolkit/trust-core/api/Fact/)

  What one agent has learned about another, and how.

- [`Identity`](https://toip.tools/toolkit/trust-core/api/Identity/)

  One agent's keys.

- [`OutboxItem`](https://toip.tools/toolkit/trust-core/api/OutboxItem/)

- [`OutboxStore`](https://toip.tools/toolkit/trust-core/api/OutboxStore/)

  Where the outbox survives a restart.

- [`ReplayRecord`](https://toip.tools/toolkit/trust-core/api/ReplayRecord/)

- [`ReplayStore`](https://toip.tools/toolkit/trust-core/api/ReplayStore/)

  Where the record lives.

- [`SealedText`](https://toip.tools/toolkit/trust-core/api/SealedText/)

- [`StatusListDoc`](https://toip.tools/toolkit/trust-core/api/StatusListDoc/)

  A signed revocation list: one bit per credential index.

- [`Traffic`](https://toip.tools/toolkit/trust-core/api/Traffic/)

  One message this endpoint sent or received, for an inspector.

- [`Transport`](https://toip.tools/toolkit/trust-core/api/Transport/)

- [`WireRecord`](https://toip.tools/toolkit/trust-core/api/WireRecord/)

  One message on the simulated network, as an observer sees it, plus what its recipient opened.

## Types

- [`CredentialCheck`](https://toip.tools/toolkit/trust-core/api/CredentialCheck/)

- [`Delivery`](https://toip.tools/toolkit/trust-core/api/Delivery/)

  Delivery of sealed TSP bytes between VIDs.

- [`Handler`](https://toip.tools/toolkit/trust-core/api/Handler/)

- [`RelayStatus`](https://toip.tools/toolkit/trust-core/api/RelayStatus/)

## Constants

- [`ctt1`](https://toip.tools/toolkit/trust-core/api/ctt1/)

  CTT1, format 0x01 (mesh design §8.1).

- [`CTT1_FORMAT`](https://toip.tools/toolkit/trust-core/api/CTT1_FORMAT/)

- [`CTT1_KEYS`](https://toip.tools/toolkit/trust-core/api/CTT1_KEYS/)

  Object keys written as their index.

- [`CTT1_PREFIXES`](https://toip.tools/toolkit/trust-core/api/CTT1_PREFIXES/)

  String prefixes written as \`\[index, rest\]\`.

- [`CTT1_STRINGS`](https://toip.tools/toolkit/trust-core/api/CTT1_STRINGS/)

  Whole strings written as their index.

- [`JSON_FORMAT`](https://toip.tools/toolkit/trust-core/api/JSON_FORMAT/)

- [`jsonBody`](https://toip.tools/toolkit/trust-core/api/jsonBody/)

  The binding's standard JSON body, byte for byte what \`packTrustTask\` seals.

- [`MAX_WIRE_BYTES`](https://toip.tools/toolkit/trust-core/api/MAX_WIRE_BYTES/)

  The relay's per-message limit.

- [`OUR_SPEC_BASE`](https://toip.tools/toolkit/trust-core/api/OUR_SPEC_BASE/)

Signatures and source documentation are generated from [`packages/trust-core/src/index.ts`](https://github.com/yourbuddyconner/toip-tools/blob/main/packages/trust-core/src/index.ts).

---

This is the Markdown version of https://toip.tools/toolkit/trust-core/api/. An index of the documentation for AI assistants is at https://toip.tools/llms.txt.
