UNPKG

@kya-os/mcp-i

Version:

The TypeScript MCP framework with identity features built-in

130 lines (129 loc) 3.53 kB
/** * Identity Management System for XMCP-I Runtime * * Handles identity loading, generation, and validation for both development * and production environments according to requirements 4.1-4.4. */ /** * Agent identity structure */ export interface AgentIdentity { did: string; kid: string; privateKey: string; publicKey: string; createdAt: string; lastRotated?: string; } /** * Development identity file structure (.mcpi/identity.json) */ export interface DevIdentityFile { version: string; did: string; kid: string; privateKey: string; publicKey: string; createdAt: string; lastRotated?: string; } /** * Production environment variables */ export interface ProdEnvironment { AGENT_PRIVATE_KEY: string; AGENT_KEY_ID: string; AGENT_DID: string; KYA_VOUCHED_API_KEY: string; } /** * Runtime Identity Manager Configuration * * Configuration for the IdentityManager class in the MCP-I runtime. * Controls how identity is loaded and managed at runtime. */ export interface RuntimeIdentityManagerConfig { environment: "development" | "production"; devIdentityPath?: string; privacyMode?: boolean; debug?: boolean; } /** * Error codes for identity management */ export declare const IDENTITY_ERRORS: { readonly ENOIDENTITY: "XMCP_I_ENOIDENTITY"; readonly ECONFIG: "XMCP_I_ECONFIG"; }; /** * Identity management class */ export declare class IdentityManager { private config; private cachedIdentity?; constructor(config?: RuntimeIdentityManagerConfig); /** * Load or generate agent identity * Requirements: 4.1, 4.2, 4.3, 4.4 */ ensureIdentity(): Promise<AgentIdentity>; /** * Load development identity from .mcpi/identity.json or generate new one * Requirement: 4.1 */ private loadOrGenerateDevIdentity; /** * Generate new development identity * Requirements: 4.1, 4.4 */ private generateDevIdentity; /** * Generate multibase-encoded key identifier (z-prefix base58btc) */ private generateMultibaseKid; /** * Simple base58 encoding (matching well-known.ts implementation) */ private encodeBase58; /** * Save development identity to .mcpi/identity.json */ private saveDevIdentity; /** * Load production identity from environment variables * Requirements: 4.2, 4.3 */ private loadProdIdentity; /** * Validate identity configuration */ validateIdentity(identity: AgentIdentity): Promise<boolean>; /** * Clear cached identity (useful for testing) */ clearCache(): void; /** * Get current configuration */ getConfig(): RuntimeIdentityManagerConfig; } /** * Default identity manager instance */ export declare const defaultIdentityManager: IdentityManager; /** * Extract agent ID from DID * @deprecated Use extractAgentId from @kya-os/mcp-i-core/utils/did-helpers instead * This re-export is maintained for backward compatibility */ export { extractAgentId } from '@kya-os/mcp-i-core/utils/did-helpers'; /** * Extract agent slug from DID * @deprecated Use extractAgentSlug from @kya-os/mcp-i-core/utils/did-helpers instead * This re-export is maintained for backward compatibility */ export { extractAgentSlug } from '@kya-os/mcp-i-core/utils/did-helpers'; /** * Convenience function to ensure identity */ export declare function ensureIdentity(config?: RuntimeIdentityManagerConfig): Promise<AgentIdentity>;