codeTreza SDK

npm versionarrow-up-right License: MITarrow-up-right TypeScriptarrow-up-right

TypeScript SDK for interacting with TREZA's privacy-preserving KYC system and secure enclave management platform.

Features

Enclave Platform Features

  • Secure Enclave Deployment - Deploy and manage AWS Nitro Enclaves with cryptographic attestation

  • Lifecycle Management - Full control over enclave state (deploy, pause, resume, terminate)

  • Attestation & Verification - Hardware-backed cryptographic proof of enclave integrity

  • Comprehensive Logging - Access logs from ECS, Step Functions, Lambda, and applications

  • Provider Management - Support for multiple cloud providers and regions

  • Task Scheduling - Schedule and manage automated tasks within enclaves

  • GitHub Integration - Connect enclaves directly to GitHub repositories

  • Docker Support - Search and deploy Docker Hub images

  • API Key Management - Fine-grained access control with permissions

Secure Key Management

  • Enclave Signing - Transaction signing inside hardware-isolated Nitro Enclaves (recommended)

  • Pluggable Signers - Swap between enclave, local, or browser wallet signing with one line

  • No Key Exposure - Private keys never leave the TEE in production

  • Attestation Verification - Cryptographic proof of enclave integrity before signing

x402 Payments

  • Enclave as Payment Wallet - Use TEE-held keys to sign x402 payment headers

  • Automatic Payments - Wrap fetch or axios to handle 402 responses transparently

  • Bazaar Discovery - Find x402-payable services programmatically

  • AI Agent Commerce - Agents can autonomously pay for APIs using enclave-managed funds

KYC Features

  • Zero-Knowledge KYC - Verify identity without exposing personal data

  • Blockchain Integration - Direct integration with KYCVerifier smart contracts

  • Convenience Methods - Simple APIs for common KYC checks (age, country, document validity)

  • Dual Verification - API-based (fast) OR blockchain-based (trustless)

  • Multi-Chain Support - Ethereum, Sepolia, and compatible networks

AI Agent Support

  • MCP Server - @treza/mcp for Claude, Cursor, and any MCP-compatible agent

  • OpenAPI 3.1 Spec - Machine-readable API schema for agent frameworks (LangChain, CrewAI, etc.)

  • Agent Manifest - Auto-discoverable capabilities at /.well-known/ai-plugin.json

Developer Experience

  • TypeScript Support - Full type safety and IntelliSense

  • Easy Integration - Works with any TypeScript/JavaScript project

  • Code Generation - Auto-generate integration snippets in multiple languages

  • No Authentication Required - Open API protected by rate limiting (KYC endpoints)

  • Secure by Design - No personal data storage, cryptographic proofs only

AI Agent Integration

Treza enclaves are designed to work with AI agents out of the box. Three integration paths are available:

The @treza/mcp package exposes all Treza operations as MCP tools. Add it to any MCP-compatible client:

This gives agents access to 16 tools (enclave management, attestation verification, task scheduling, API key management) and 4 browsable resources.

OpenAPI Spec (For Agent Frameworks)

The full API is documented as an OpenAPI 3.1 spec, compatible with any agent framework that can ingest tool schemas:

Agent Manifest (For Discovery)

A machine-readable manifest describing Treza's capabilities:

x402 Payment Integration

Use a Treza Enclave as an x402arrow-up-right payment wallet. Private keys sign payment headers inside the TEE — they never leave the hardware boundary. This enables AI agents and programmatic clients to automatically pay for x402-gated APIs using enclave-managed funds.

Install Dependencies

Automatic Payments with Fetch

Using the x402 Client Directly

Custom viem Account

For advanced use cases, create a viem-compatible account directly:

Discover Payable Services

Quick Start

Installation

Environment Setup

Create a .env file:

See .env.example for all available configuration options.

In production, private keys are managed inside Treza Nitro Enclaves and never leave the hardware-isolated TEE. The SDK provides pluggable signers so you can swap between enclave signing, local keys, or browser wallets with one line of code.

Local Development (Demo Only)

For local development and testing, you can use LocalSigner with a raw private key. Do not use this in production.

Read-Only Usage (No Signing)

Many KYC operations don't require signing at all:

Basic Usage - Enclave Platform

See Quick Reference for more examples and complete API documentation.

Core Features

KYC Features

Convenience Methods

The SDK provides simple methods for common KYC checks:

Dual Verification

Choose between API-based (fast) or blockchain-based (trustless) verification:

Blockchain Operations

Direct interaction with KYCVerifier smart contracts:

Architecture

KYC Platform

Enclave Platform

Key Management & Signing

The Treza SDK provides a pluggable signing architecture. Instead of storing private keys in .env files, you choose a SignerProvider that matches your environment:

Signer
Environment
How It Works

EnclaveSigner

Production (recommended)

Keys are generated and stored inside a Treza Nitro Enclave. Signing requests go through the Platform API to the TEE. Keys never leave the enclave.

LocalSigner

Development/Testing

Wraps a raw private key string. Emits a warning if used in production.

BrowserWalletSigner

Client-side dApps

Delegates to MetaMask or any injected Web3 wallet. Prompts the user to sign.

Signing Flow (EnclaveSigner)

Using EnclaveSigner

Custom Signers

You can implement the SignerProvider interface to integrate any key management system (AWS KMS, HashiCorp Vault, hardware wallets, etc.):

API Reference

TrezaClient

Main client for enclave platform management.

Constructor

Config Options:

  • baseUrl: Base API URL (default: https://app.trezalabs.com)

  • timeout: Request timeout in milliseconds (default: 30000)

Enclave Methods

Core Operations:

  • getEnclaves(walletAddress) - Get all enclaves

  • getEnclave(enclaveId) - Get specific enclave

  • createEnclave(request) - Create new enclave

  • updateEnclave(request) - Update enclave

  • deleteEnclave(enclaveId, walletAddress) - Delete enclave

Lifecycle Management:

  • pauseEnclave(enclaveId, walletAddress) - Pause enclave

  • resumeEnclave(enclaveId, walletAddress) - Resume enclave

  • terminateEnclave(enclaveId, walletAddress) - Terminate enclave

  • performEnclaveAction(request) - Generic lifecycle action

Logging:

  • getEnclaveLogs(enclaveId, logType?, limit?) - Get logs

    • Log types: 'all', 'ecs', 'stepfunctions', 'lambda', 'application', 'errors'

Attestation & Verification:

  • getAttestation(enclaveId) - Get attestation document with PCR measurements

  • getVerificationStatus(enclaveId) - Quick verification status

  • verifyAttestation(enclaveId, request?) - Comprehensive verification with compliance checks

  • generateIntegrationSnippet(enclaveId, language?) - Generate code snippets

    • Languages: 'javascript', 'python', 'curl', 'java'

Provider Methods

  • getProviders() - Get all available providers

  • getProvider(providerId) - Get specific provider

Task Methods

  • getTasks(walletAddress) - Get all tasks

  • createTask(request) - Create scheduled task

  • updateTask(request) - Update task

  • deleteTask(taskId, walletAddress) - Delete task

API Key Methods

  • getApiKeys(walletAddress) - Get all API keys

  • createApiKey(request) - Create API key with permissions

  • updateApiKey(request) - Update API key

  • deleteApiKey(apiKeyId, walletAddress) - Delete API key

GitHub Methods

  • getGitHubAuthUrl(state?) - Get OAuth authorization URL

  • exchangeGitHubCode(request) - Exchange OAuth code for token

  • getGitHubRepositories(accessToken) - Get user repositories

  • getRepositoryBranches(request) - Get repository branches

Docker Methods

  • searchDockerImages(query) - Search Docker Hub

  • getDockerTags(repository) - Get available tags for image


TrezaKYCClient

Client for KYC verification operations.

Constructor

Config Options:

  • apiUrl: API endpoint URL (required)

  • apiKey: API key for authenticated requests (optional)

  • blockchain: Blockchain configuration (optional)

    • rpcUrl: Ethereum RPC URL

    • contractAddress: KYCVerifier contract address

    • signerProvider: A SignerProvider for secure key management (recommended)

    • privateKey: (deprecated) Raw private key for write operations — use signerProvider instead

Methods

Convenience Methods:

  • isAdult(proofId, useBlockchain?) - Check if user is 18+

  • getCountry(proofId, useBlockchain?) - Get user's nationality

  • hasValidDocument(proofId, useBlockchain?) - Check document validity

  • getDocumentType(proofId, useBlockchain?) - Get document type

  • getClaims(proofId, useBlockchain?) - Get all public claims

  • meetsRequirements(proofId, requirements, useBlockchain?) - Verify requirements

Core Methods:

  • submitProof(params) - Submit proof to API

  • verifyProof(proofId) - Verify proof via API

  • getProof(proofId) - Get proof details

Blockchain Methods:

  • hasValidKYC(userAddress) - Check if user has valid KYC on-chain

  • getProofFromChain(proofId) - Get proof from blockchain

  • getUserProofId(userAddress) - Get user's latest proof ID

  • submitProofOnChain(params) - Submit proof to blockchain

  • verifyProofOnChain(params) - Verify proof on blockchain

Examples

Age-Gated Content

Country Restrictions

KYC-Gated Platform

Enclave Platform

The TREZA SDK provides comprehensive management of secure AWS Nitro Enclaves with cryptographic attestation for privacy-preserving computation.

Getting Started with Enclaves

Enclave Management

Create and Deploy an Enclave

List and Get Enclaves

Update an Enclave

Enclave Lifecycle Management

Control enclave state with pause, resume, and terminate operations:

Attestation & Cryptographic Verification

TREZA enclaves provide hardware-backed cryptographic proof of integrity:

Integration Code Generation

Generate ready-to-use code snippets for third-party integration:

Comprehensive Logging

Access logs from all enclave components:

Task Scheduling

Schedule automated tasks within enclaves:

GitHub Integration

Connect enclaves to GitHub repositories for automated deployments:

Docker Integration

Search and use Docker Hub images:

API Key Management

Create and manage API keys with fine-grained permissions:

Documentation

KYC Documentation

  • Quick Reference - Common use cases and examples

  • Environment Configuration - Complete configuration guide

  • Setup Guide - Interactive setup script

  • KYC Examples - Working code examples

Enclave Platform Documentation

  • Basic Usage Example - Complete SDK walkthrough

  • Compliance Integration - Enterprise compliance examples

  • Production Readiness - Production deployment guide

Development

Setup

Build

Run Examples

KYC Examples

Enclave Platform Examples

Support

License

MIT License - see LICENSE file for details.

Packages

Package
Description
npm

@treza/sdk

Core SDK for enclaves, KYC, and signing

@treza/react

React components and hooks

@treza/mcp

MCP server for AI agents


Last updated