Skip to main content

TypeScript Reference

The JavaScript and TypeScript implementation is @alx-protocol/sdk, published on npm. The package exposes deterministic Block creation and validation alongside canonicalization, Graph verification, attribution tracing, signing, replay checks, and Merkle helpers, with TypeScript types included.

Implementation​

ResourceLocation
Package@alx-protocol/sdk
Registrynpm
Installnpm install @alx-protocol/sdk
RequirementsNode.js 20, 21, or 22; ESM. Every entry point except /middleware is free of Node.js built-in imports.

Exports​

The root export covers canonicalization, Block creation and validation, parent normalization, Graph verification, attribution tracing, signed Blocks, replay windows, hash utilities, and error codes. Task-specific subpaths (/block, /lineage, /trace, /canonicalization, /signatures, /replay, /hash-utils) re-export subsets of the root for narrower imports. The Ed25519, P-256, and EIP-712 signers and verifiers are exported from the root and from /ed25519, /p256, and /eip712. Merkle helpers and the middleware are exported only from /merkle and /middleware.

Serialize protocol JSON the one canonical way, and read the domains and version the hashes bind.

  • Serialization: canonicalizeProtocolJson, parseStrictJson, parseStrictJsonBytes
  • Constants: CANONICALIZATION_ALGORITHM, ALX_PROTOCOL_VERSION, BLOCK_HASH_DOMAIN, CONTENT_HASH_DOMAIN, ATTESTATION_HASH_DOMAIN, MAX_PARENTS, HASH_PATTERN.

When to Use TypeScript​

Choose this package for Node.js, serverless, and JavaScript-based agent workflows, and for browsers through an ESM bundler (every entry point except /middleware). Run the shared conformance material after changing canonicalization, hashing, lineage, signing, or Merkle behavior in an integration that wraps the package.