anon-identity
Version:
Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure
74 lines • 2.56 kB
TypeScript
import { AgentMessage, AgentMessageType, MessageEnvelope, MessageValidationResult } from './types';
export declare class MessageProtocol {
private static readonly VERSION;
private static readonly MESSAGE_TTL;
/**
* Creates a new message with proper formatting and metadata
*/
static createMessage<T extends AgentMessage>(type: AgentMessageType, from: string, to: string, payload: any, options?: {
replyTo?: string;
expiresAt?: Date;
metadata?: Record<string, any>;
}): T;
/**
* Signs a message with the sender's private key
*/
static signMessage(message: AgentMessage, senderKeyPair: {
publicKey: Uint8Array;
privateKey: Uint8Array;
}): Promise<AgentMessage>;
/**
* Verifies a message signature
*/
static verifyMessage(message: AgentMessage): Promise<boolean>;
/**
* Validates message structure and content
*/
static validateMessage(message: AgentMessage): MessageValidationResult;
/**
* Creates a message envelope for transport
*/
static createEnvelope(message: AgentMessage, options?: {
routingPath?: string[];
ttl?: number;
encryption?: {
algorithm: string;
recipientKey: string;
};
}): MessageEnvelope;
/**
* Extracts message from envelope and validates
*/
static processEnvelope(envelope: MessageEnvelope, agentKeyPair?: {
publicKey: Uint8Array;
privateKey: Uint8Array;
}): Promise<{
message: AgentMessage;
errors?: string[];
}>;
/**
* Creates standard response messages
*/
static createResponse(originalMessage: AgentMessage, responseType: AgentMessageType, payload: any, from: string): AgentMessage;
/**
* Creates error response
*/
static createErrorResponse(originalMessage: AgentMessage, error: string, from: string): AgentMessage;
/**
* Creates acknowledgment response
*/
static createAckResponse(originalMessage: AgentMessage, from: string, status?: 'received' | 'processing' | 'completed'): AgentMessage;
private static generateMessageId;
private static canonicalizeMessage;
private static isValidDID;
private static validateMessagePayload;
/**
* Serializes a message for transport
*/
static serialize(message: AgentMessage): string;
/**
* Deserializes a message from transport
*/
static deserialize(data: string): AgentMessage;
}
//# sourceMappingURL=message-protocol.d.ts.map