Add on-chain TEE registry discovery with TLS certificate pinning#6
Merged
adambalogh merged 2 commits intomainfrom May 5, 2026
Merged
Add on-chain TEE registry discovery with TLS certificate pinning#6adambalogh merged 2 commits intomainfrom
adambalogh merged 2 commits intomainfrom
Conversation
Brings the TS SDK in line with the Python SDK: the LLM endpoint is now discovered by querying the on-chain TEERegistry contract instead of a hardcoded URL, and the TEE's TLS certificate is pinned to the value stored at registration time (no TOFU). - src/abi/teeRegistry.ts: minimal read-only ABI for getActiveTEEs. - src/teeRegistry.ts: TEERegistry class wrapping the contract via viem (getActiveTEEsByType, getLLMTEE). - src/teeConnection.ts: StaticTEEConnection (hardcoded URL, TLS verification disabled) and RegistryTEEConnection (registry-resolved, pinned TLS cert via undici Agent, lazy connect, 5-min health check with automatic failover). - src/llm.ts: refactored to drive requests through a TEEConnection, injecting the pinned dispatcher into the x402-paid fetch and retrying once on connection failure with a fresh TEE. - src/client.ts: registry is now the default; passing llmServerUrl switches to a static connection. - types.ts/defaults.ts/index.ts: new ClientConfig fields (rpcUrl, teeRegistryAddress), registry defaults, and re-exports. - package.json: declare viem and undici as direct deps; bump to 2.1.0.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces on-chain TEE registry integration to dynamically discover active LLM proxy endpoints with TLS certificate pinning, replacing hardcoded server URLs. The client now resolves TEE endpoints from the registry by default, with optional fallback to static URLs for development/self-hosted scenarios.
Key Changes
New TEE Registry Integration (
teeRegistry.ts):TEERegistryclass queries the on-chain TEE Registry contract to fetch active TEE endpoints and their DER-encoded TLS certificatesgetActiveTEEsByType()to retrieve all active TEEs of a given type andgetLLMTEE()to select a random active LLM proxyUint8Arrayformat for TLS pinningNew TEE Connection Abstraction (
teeConnection.ts):TEEConnectioninterface provides a common contract for static and registry-backed TEE connectionsStaticTEEConnectionfor hardcoded endpoints (dev/self-hosted) with disabled TLS verificationRegistryTEEConnectionfor registry-backed discovery with:buildPinnedAgent()(creates undici Agent with pinned CA certificate)close()method for dispatchers and timersUpdated LLM Client (
llm.ts):serverUrlandstreamingServerUrlconfig withconnection: TEEConnectionrequestWithRetry()handles TEE resolution and single-retry-on-failure logicsendOnce()builds a paid fetch with the TEE's pinned dispatcher injected into every requestclose()method to tear down resourcesUpdated Client Factory (
client.ts):RegistryTEEConnectionby default (queries registry via RPC)StaticTEEConnectionwhenllmServerUrlis providedrpcUrlandteeRegistryAddressoverridesclose()method for cleanupConfiguration Updates (
types.ts,defaults.ts):llmStreamingServerUrlconfig (both chat and streaming use the same endpoint)llmServerUrldocumentation to clarify it disables registry lookuprpcUrlandteeRegistryAddressconfig optionsPublic API Exports (
index.ts):TEERegistry,TEEEndpoint,TEE_TYPE_*constantsTEEConnection,ActiveTEE,RegistryTEEConnection,StaticTEEConnection,buildPinnedAgentNotable Implementation Details
unref()) and all resources are properly cleaned up onclose()https://claude.ai/code/session_01Nvpzd6GMuRCcgfuFZgotUk