UNPKG

@venly/wallet-mcp

Version:

Production-ready MCP server enabling AI agents to perform Web3 wallet operations through Venly's blockchain infrastructure. Supports 14+ networks including Ethereum, Polygon, Arbitrum, and stablecoin operations.

60 lines 3 kB
/** * Credential Validator * * Validates user-provided Venly credentials with fail-fast error handling */ import { VenlyApiError } from '../venly/VenlyClient.js'; export class CredentialValidator { /** * Validate user-provided Venly credentials * Throws VenlyApiError with clear messages for invalid credentials */ static validateCredentials(credentials) { // Check for missing client ID if (!credentials.clientId || credentials.clientId.trim() === '') { throw new VenlyApiError('MISSING_CLIENT_ID', 'Venly Client ID is required. Please provide your Venly Client ID.', 400, true); } // Check for missing client secret if (!credentials.clientSecret || credentials.clientSecret.trim() === '') { throw new VenlyApiError('MISSING_CLIENT_SECRET', 'Venly Client Secret is required. Please provide your Venly Client Secret.', 400, true); } // Validate client ID format (basic validation) if (credentials.clientId.length < 10) { throw new VenlyApiError('INVALID_CLIENT_ID', 'Venly Client ID appears to be invalid. Please check your Client ID from the Venly Developer Portal.', 400, true); } // Validate client secret format (basic validation) if (credentials.clientSecret.length < 20) { throw new VenlyApiError('INVALID_CLIENT_SECRET', 'Venly Client Secret appears to be invalid. Please check your Client Secret from the Venly Developer Portal.', 400, true); } // Check for common mistakes if (credentials.clientId.includes(' ') || credentials.clientSecret.includes(' ')) { throw new VenlyApiError('INVALID_CREDENTIALS_FORMAT', 'Venly credentials should not contain spaces. Please check your credentials.', 400, true); } // Check for placeholder values const placeholders = ['your-client-id', 'client-id', 'your-client-secret', 'client-secret', 'test', 'example']; const lowerClientId = credentials.clientId.toLowerCase(); const lowerClientSecret = credentials.clientSecret.toLowerCase(); if (placeholders.some(placeholder => lowerClientId.includes(placeholder) || lowerClientSecret.includes(placeholder))) { throw new VenlyApiError('PLACEHOLDER_CREDENTIALS', 'Please replace placeholder values with your actual Venly credentials from the Developer Portal.', 400, true); } } /** * Sanitize credentials for logging (never log actual secrets) */ static sanitizeForLogging(credentials) { return { clientId: credentials.clientId.substring(0, 8) + '...', clientSecret: '***REDACTED***' }; } /** * Extract credentials from MCP tool arguments */ static extractCredentials(args) { return { clientId: args['venly_client_id'], clientSecret: args['venly_client_secret'] }; } } //# sourceMappingURL=CredentialValidator.js.map