Skip to content

TypeScript Helper

The standalone TypeScript reference implementation lives at grigb/um-typescript. It is optional — you can implement the specification in any language — but it provides a complete TypeScript path for create, validate, sign, verify, and resolve operations.

Terminal window
npm install @universalmanifest/typescript
import {
assertValidManifest,
getManifestId,
} from '@universalmanifest/typescript'
const raw = JSON.parse(jsonString)
// Structural validation -- throws if the manifest is malformed
assertValidManifest(raw)
// After assertion, `raw` is typed as UniversalManifestV01
console.log('UMID:', getManifestId(raw))
console.log('Subject:', raw.subject)

v0.2 manifests require an Ed25519 signature. The helper validates the structure and verifies the signature in one call:

import { verify } from '@universalmanifest/typescript'
const signed = JSON.parse(signedJsonString)
const result = verify(signed)
if (!result.ok) {
throw new Error(result.error)
}

Signature verification uses the inline publicKeySpkiB64 field. External key resolution via keyRef (DID documents, HTTPS endpoints) is out of scope for this helper.

TypeDescription
UniversalManifestV01Full v0.1 manifest document
UniversalManifestV02Full v0.2 manifest document (requires signature)
UmEntityV01A typed entity embedded inside a shard
UmShardV01A named data section within a manifest
UmSignatureV01Signature for v0.1
UmSignatureV02Ed25519 + JCS signature for v0.2
JsonLdContextJSON-LD @context value
JsonLdTypeJSON-LD @type value
FunctionDescription
create(input)Create a v0.1 manifest or unsigned v0.2 draft
assertValidManifest(value, options?)Structural validation for v0.1/v0.2 manifests
sign(unsignedV02, options)Sign a v0.2 manifest with Ed25519 + JCS
verify(value, options?)Verify v0.2 signature (and optional freshness)
resolve(input, options?)Resolve from inline object, registry, callback, or resolver URL
getManifestId(manifest)Extract the @id (UMID) from a manifest

The reference implementation includes unit tests and conformance verification:

Terminal window
git clone https://github.com/grigb/um-typescript.git
cd um-typescript
npm install
npm test
npm run conformance

The full source is available in the standalone repository at grigb/um-typescript.