UNPKG

atp-sdk

Version:

Official TypeScript SDK for Agent Trust Protocolâ„¢ - Build secure, verifiable, and trustworthy applications with decentralized identity, verifiable credentials, payment protocols (AP2/ACP), and robust access control

77 lines • 2.2 kB
/** * Protocol Adapter Interface * * Defines the contract that all protocol adapters must implement * to integrate with ATP's security and monitoring framework. */ /** * Abstract Base Adapter - Provides common functionality */ export class BaseProtocolAdapter { constructor() { this.ready = false; } async initialize(config) { this.config = config; this.ready = true; } async secure(message) { if (!this.config) { throw new Error('Adapter not initialized'); } // Default implementation - can be overridden by specific adapters return { ...message, signature: '', // To be implemented with actual crypto trustLevel: 0, timestamp: message.timestamp || new Date().toISOString() }; } async verify(message) { if (!this.config) { throw new Error('Adapter not initialized'); } // Default implementation - can be overridden by specific adapters return { verified: true, trustScore: message.trustLevel, verifiedAt: new Date().toISOString(), details: { signatureValid: true, senderVerified: true, trustLevel: 'BASIC' } }; } async audit(event) { if (!this.config) { throw new Error('Adapter not initialized'); } return { id: event.id, timestamp: event.timestamp, source: event.source.agentDid, action: event.type, resource: event.protocol, protocol: event.protocol, operation: event.type, agentDid: event.source.agentDid, result: 'success', hash: '', // To be implemented with actual crypto details: event.data }; } async cleanup() { this.ready = false; } isReady() { return this.ready; } getConfig() { if (!this.config) { throw new Error('Adapter not initialized'); } return this.config; } } //# sourceMappingURL=adapter.js.map