This document provides a comprehensive reference for all classes, interfaces, and methods in the ETDI SDK.
The primary client for interacting with ETDI-enabled tools.
constructor(config: ETDIClientConfig)Creates a new ETDIClient instance with the specified configuration.
Parameters:
config: ETDIClientConfig- Configuration for the client
async discoverTools(): Promise<ToolDefinition[]>Discovers available tools from connected servers.
Returns:
Promise<ToolDefinition[]>- Array of discovered tools
async verifyTool(tool: ToolDefinition): Promise<boolean>Verifies a tool's signature.
Parameters:
tool: ToolDefinition- Tool definition to verify
Returns:
Promise<boolean>- True if the tool signature is valid
Throws:
SignatureError- If signature verification fails
async approveTool(tool: ToolDefinition): Promise<void>Approves a tool for usage and stores the approval record.
Parameters:
tool: ToolDefinition- Tool definition to approve
Throws:
SignatureError- If signature verification fails before approvalPermissionError- If permission validation fails
async isToolApproved(toolId: string): Promise<boolean>Checks if a tool has been approved.
Parameters:
toolId: string- ID of the tool to check
Returns:
Promise<boolean>- True if the tool has been approved
async invokeTool(toolId: string, params: any): Promise<any>Invokes a tool with parameters.
Parameters:
toolId: string- ID of the tool to invokeparams: any- Parameters for the tool
Returns:
Promise<any>- Result from the tool invocation
Throws:
ETDIError- If tool invocation fails
async checkVersionChange(toolId: string): Promise<boolean>Checks if a tool's version has changed since approval.
Parameters:
toolId: string- ID of the tool to check
Returns:
Promise<boolean>- True if the version has changed
async requestReapproval(toolId: string): Promise<void>Requests re-approval for a tool.
Parameters:
toolId: string- ID of the tool to request re-approval for
Throws:
ETDIError- If re-approval request fails
async checkPermission(toolId: string, permission: string): Promise<boolean>Checks if a tool has a specific permission.
Parameters:
toolId: string- ID of the tool to checkpermission: string- Permission to check
Returns:
Promise<boolean>- True if the tool has the permission
on(event: string, listener: Function): thisRegisters an event listener.
Parameters:
event: string- Event namelistener: Function- Callback function
Returns:
this- The client instance for chaining
off(event: string, listener: Function): thisRemoves an event listener.
Parameters:
event: string- Event namelistener: Function- Callback function to remove
Returns:
this- The client instance for chaining
Used by tool developers to create and register tools.
constructor(config: ToolProviderConfig)Creates a new ToolProvider instance.
Parameters:
config: ToolProviderConfig- Configuration for the provider
async registerTool(definition: ToolDefinition): Promise<SignedToolDefinition>Registers a new tool and signs its definition.
Parameters:
definition: ToolDefinition- Tool definition to register
Returns:
Promise<SignedToolDefinition>- Signed tool definition
Throws:
ETDIError- If registration fails
async updateTool(toolId: string, definition: ToolDefinition): Promise<SignedToolDefinition>Updates an existing tool.
Parameters:
toolId: string- ID of the tool to updatedefinition: ToolDefinition- New tool definition
Returns:
Promise<SignedToolDefinition>- Updated signed tool definition
Throws:
ETDIError- If update fails
async getTools(): Promise<SignedToolDefinition[]>Gets a list of all registered tools.
Returns:
Promise<SignedToolDefinition[]>- Array of signed tool definitions
async removeTool(toolId: string): Promise<boolean>Removes a tool.
Parameters:
toolId: string- ID of the tool to remove
Returns:
Promise<boolean>- True if the tool was removed
Handles OAuth-related operations.
constructor(config: OAuthConfig)Creates a new OAuthManager instance.
Parameters:
config: OAuthConfig- OAuth configuration
async initialize(): Promise<void>Initializes the manager.
Throws:
ETDIError- If initialization fails
async getToken(): Promise<string>Gets an OAuth token.
Returns:
Promise<string>- JWT token
Throws:
ETDIError- If token acquisition fails
async validateToken(token: string): Promise<boolean>Validates an OAuth token.
Parameters:
token: string- Token to validate
Returns:
Promise<boolean>- True if the token is valid
async refreshToken(token: string): Promise<string>Refreshes an OAuth token.
Parameters:
token: string- Token to refresh
Returns:
Promise<string>- New JWT token
Throws:
ETDIError- If token refresh fails
async hasScopes(scopes: string[]): Promise<boolean>Checks if the current token has the specified scopes.
Parameters:
scopes: string[]- Scopes to check
Returns:
Promise<boolean>- True if the token has all specified scopes
async requestScopes(scopes: string[]): Promise<string>Requests additional scopes.
Parameters:
scopes: string[]- Scopes to request
Returns:
Promise<string>- New JWT token with requested scopes
Throws:
ETDIError- If scope request fails
Represents a tool definition.
interface ToolDefinition {
id: string;
name: string;
version: string;
description: string;
provider: {
id: string;
name: string;
};
schema: JSONSchema;
permissions: Permission[];
}Properties:
id: string- Unique identifier for the toolname: string- Human-readable nameversion: string- Semantic version (MAJOR.MINOR.PATCH)description: string- Human-readable descriptionprovider: { id: string; name: string; }- Provider informationschema: JSONSchema- JSON Schema defining input/outputpermissions: Permission[]- Required permissions
Represents a signed tool definition.
interface SignedToolDefinition extends ToolDefinition {
signature: string;
signatureAlgorithm: string;
oauth?: {
token: string;
idp: string;
};
}Properties:
- All properties from
ToolDefinition signature: string- Base64-encoded signature of the definitionsignatureAlgorithm: string- Signature algorithm usedoauth?: { token: string; idp: string; }- Optional OAuth token information
Represents a permission required by a tool.
interface Permission {
name: string;
description: string;
scope: string;
required: boolean;
}Properties:
name: string- Permission namedescription: string- Human-readable descriptionscope: string- OAuth scope equivalentrequired: boolean- Whether the permission is required
Represents a stored approval record.
interface ToolApprovalRecord {
toolId: string;
providerPublicKeyId: string;
approvedVersion: string;
definitionHash: string;
approvalDate: Date;
permissions: Permission[];
expiryDate?: Date;
}Properties:
toolId: string- Tool identifierproviderPublicKeyId: string- Identifier for the provider's public key usedapprovedVersion: string- Version that was approveddefinitionHash: string- Hash of the complete definitionapprovalDate: Date- When the approval was grantedpermissions: Permission[]- Permissions that were approvedexpiryDate?: Date- Optional expiration of approval
Configuration for ETDIClient.
interface ETDIClientConfig {
securityLevel: 'basic' | 'enhanced' | 'strict';
oauthConfig?: OAuthConfig;
keyConfig?: KeyConfig;
storageConfig?: StorageConfig;
options?: ClientOptions;
}Properties:
securityLevel: 'basic' | 'enhanced' | 'strict'- Security level to useoauthConfig?: OAuthConfig- OAuth configuration (required for enhanced and strict)keyConfig?: KeyConfig- Key configuration (required for basic)storageConfig?: StorageConfig- Storage configurationoptions?: ClientOptions- Additional options
Configuration for OAuth.
interface OAuthConfig {
provider: string | CustomOAuthProvider;
clientId?: string;
clientSecret?: string;
domain?: string;
audience?: string;
scopes?: string[];
tenantId?: string;
}Properties:
provider: string | CustomOAuthProvider- OAuth provider ('auth0', 'okta', 'azure', 'custom') or custom provider instanceclientId?: string- Client IDclientSecret?: string- Client secretdomain?: string- Provider domainaudience?: string- API audiencescopes?: string[]- Default scopestenantId?: string- Tenant ID (for Azure AD)
Configuration for cryptographic keys.
interface KeyConfig {
keyStorage: string | CustomKeyStorage;
trustedProviders?: TrustedProvider[];
}Properties:
keyStorage: string | CustomKeyStorage- Key storage type or custom storage instancetrustedProviders?: TrustedProvider[]- List of trusted providers
Configuration for storage.
interface StorageConfig {
provider: string | CustomStorageProvider;
options?: StorageOptions;
}Properties:
provider: string | CustomStorageProvider- Storage provider type or custom provider instanceoptions?: StorageOptions- Storage options
Base error class for ETDI.
class ETDIError extends Error {
code: string;
cause?: Error;
}Properties:
code: string- Error codecause?: Error- Optional original error
Error for signature verification failures.
class SignatureError extends ETDIError {
// Inherits properties from ETDIError
}Error for version mismatch issues.
class VersionError extends ETDIError {
oldVersion: string;
newVersion: string;
}Properties:
- All properties from
ETDIError oldVersion: string- Previously approved versionnewVersion: string- New version
Error for permission validation failures.
class PermissionError extends ETDIError {
requiredPermissions: Permission[];
approvedPermissions: Permission[];
}Properties:
- All properties from
ETDIError requiredPermissions: Permission[]- Required permissionsapprovedPermissions: Permission[]- Approved permissions
Events emitted by ETDIClient.
| Event Name | Payload | Description |
|---|---|---|
toolVerified |
ToolDefinition |
Emitted when a tool is verified |
toolApproved |
ToolDefinition |
Emitted when a tool is approved |
versionChanged |
{ tool: ToolDefinition, oldVersion: string, newVersion: string } |
Emitted when a tool version changes |
permissionChanged |
{ tool: ToolDefinition, changes: PermissionChange[] } |
Emitted when tool permissions change |
tokenRefreshed |
{ token: string } |
Emitted when an OAuth token is refreshed |
tokenExpired |
{ token: string } |
Emitted when an OAuth token expires |
error |
ETDIError |
Emitted on errors |
enum SecurityLevel {
BASIC = 'basic',
ENHANCED = 'enhanced',
STRICT = 'strict'
}enum VerificationStatus {
VERIFIED = 'VERIFIED',
UNVERIFIED = 'UNVERIFIED',
SIGNATURE_INVALID = 'SIGNATURE_INVALID',
PROVIDER_UNKNOWN = 'PROVIDER_UNKNOWN'
}enum ErrorCode {
SIGNATURE_INVALID = 'SIGNATURE_INVALID',
PROVIDER_NOT_FOUND = 'PROVIDER_NOT_FOUND',
VERSION_MISMATCH = 'VERSION_MISMATCH',
PERMISSION_DENIED = 'PERMISSION_DENIED',
TOKEN_EXPIRED = 'TOKEN_EXPIRED',
TOKEN_INVALID = 'TOKEN_INVALID',
SCOPE_MISSING = 'SCOPE_MISSING',
NETWORK_ERROR = 'NETWORK_ERROR',
STORAGE_ERROR = 'STORAGE_ERROR',
INTERNAL_ERROR = 'INTERNAL_ERROR'
}