@truthlock/sdk
v1.0.2
Published
Official Truthlock JavaScript/TypeScript SDK
Downloads
291
Maintainers
Readme
@truthlock/sdk
Official JavaScript/TypeScript SDK for the Truthlocks cryptographic trust infrastructure.
Installation
npm install @truthlock/sdk
# or
yarn add @truthlock/sdk
# or
pnpm add @truthlock/sdkQuick Start
import { TruthlockClient, Algorithm, Verdict } from "@truthlock/sdk";
const client = new TruthlockClient({
baseUrl: "https://api.truthlocks.com",
auth: { type: "tenant", tenantId: "your-tenant-id" },
});
// Create an issuer
const issuer = await client.issuers.create({
name: "My Org",
legal_name: "My Organization Inc.",
display_name: "My Org",
});
await client.issuers.trust(issuer.id);
// Register a signing key
await client.keys.register(issuer.id, {
kid: "key-1",
alg: Algorithm.Ed25519,
public_key_b64url: "your-public-key",
});
// Mint an attestation
const attestation = await client.attestations.mint({
issuer_id: issuer.id,
kid: "key-1",
alg: Algorithm.Ed25519,
payload_b64url: Buffer.from("Hello World").toString("base64url"),
});
// Verify
const result = await client.verify.verifyOnline({
attestation_id: attestation.attestation_id,
payload_b64url: Buffer.from("Hello World").toString("base64url"),
});
if (result.verdict === Verdict.Valid) {
console.log("Document verified successfully");
}Features
- Full TypeScript support with complete type definitions
- Automatic idempotency key generation
- Built-in retry handling
- ESM and CommonJS support
- Zero runtime dependencies
Requirements
- Node.js >= 18.0.0
- TypeScript >= 4.7.0 (optional)
Documentation
Full documentation: docs.truthlocks.com/sdk/js
License
MIT
