@openvtc/trust-tasks
v0.2.1
Published
Generated TypeScript bindings for the Trust Tasks framework registry.
Downloads
98
Readme
@openvtc/trust-tasks
Generated TypeScript bindings for the Trust Tasks framework registry.
Every spec under dtgwg-trust-tasks-tf/specs/
that defines a payload.schema.json is compiled — via
scripts/build-ts-bindings.mjs (json-schema-to-typescript) — to a
TypeScript module under
src/<slug>/<version>/payload.ts,
giving you a typed Payload and (where the spec defines one)
Response interface for each Trust Task. The package's root
index.ts re-exports every module under a stable name keyed by the
spec slug.
The Rust counterpart is trust-tasks-rs;
both crates are regenerated together so the Rust and TypeScript wire
shapes stay byte-identical.
Install
npm install @openvtc/trust-tasksUsage
import { AclGrant_v0_1, DidManagementDidRegister_v0_1 } from "@openvtc/trust-tasks";
// Compose a request payload, type-checked against the spec's
// payload.schema.json.
const grant: AclGrant_v0_1.Payload = {
subject: "did:key:z6MkAlice",
role: "admin",
after: { /* … */ },
};
// Each module exports the Response sub-schema too when the spec
// defines one — the framework's #response fragment convention.
const reply: AclGrant_v0_1.Response = {
entry: { /* … */ },
};
// did-management example.
const register: DidManagementDidRegister_v0_1.Payload = {
path: "alice",
method: "webvh",
didData: "{\"versionId\":\"1-…\",…}",
};For the full list of generated modules, see src/index.ts
or the website index.
Module layout
Each spec lands at a stable path:
src/
├── acl/grant/0.1/payload.ts // AclGrant_v0_1
├── auth/authenticate/0.1/payload.ts // AuthAuthenticate_v0_1
├── did-management/did/register/0.1/
│ └── payload.ts // DidManagementDidRegister_v0_1
├── vault/proxy-login/0.1/payload.ts // VaultProxyLogin_v0_1
└── …Slug / separators in the URI map to directory boundaries; the
exported name is generated by Pascal-casing the slug segments and
appending _v<MAJOR>_<MINOR>. Multiple versions of the same spec
land in sibling directories (0.1/, 1.0/, …) and export
distinct names — there is no "latest" alias by design.
Validating payloads at runtime
This package ships TypeScript types only — it does not bundle a
JSON-Schema validator. If you need runtime validation, fetch the
payload.schema.json from
https://trusttasks.org/spec/<slug>/<version> and feed it to
ajv or any other Draft 2020-12
validator.
Versioning
The package version (MAJOR.MINOR.PATCH) tracks the framework
spec's SPEC.md revision MAJOR.MINOR
with the patch component bumped per published binding revision. A
bump in any individual spec's MAJOR.MINOR ships as a new exported
module name (e.g. AclGrant_v1_0 alongside AclGrant_v0_1); the
package version itself only bumps when the binding-generation or
re-exported surface changes.
The Rust crate trust-tasks-rs follows the same release cadence.
License
Apache-2.0. See LICENSE.md at the repo root.
Contributing
This package is generated, not authored by hand. To change the
exported surface, add or modify a spec under specs/ in the
dtgwg-trust-tasks-tf
repo and run npm run build-ts-bindings from the repo root. The
generator updates this package's src/ tree atomically. See
CONTRIBUTING-SPECS.md
for the spec authoring guide.
