UNPKG

anon-identity

Version:

Decentralized identity framework with DIDs, Verifiable Credentials, and privacy-preserving selective disclosure

135 lines 4.89 kB
import { AgentMessage, AgentMessageType, DelegationRequestMessage, DelegationGrantMessage, DelegationDenyMessage, StatusQueryMessage, StatusResponseMessage } from './types'; import { DelegationCredential } from '../types'; /** * Factory class for creating common message types */ export declare class MessageFactory { /** * Creates a delegation request message */ static createDelegationRequest(from: string, to: string, requestedScopes: string[], options?: { serviceDID?: string; duration?: number; purpose?: string; constraints?: Record<string, any>; replyTo?: string; }): DelegationRequestMessage; /** * Creates a delegation grant message */ static createDelegationGrant(from: string, to: string, credential: DelegationCredential, grantedScopes: string[], expiresAt: Date, options?: { limitations?: string[]; replyTo?: string; }): DelegationGrantMessage; /** * Creates a delegation deny message */ static createDelegationDeny(from: string, to: string, reason: string, options?: { violations?: string[]; suggestedScopes?: string[]; retryAfter?: Date; replyTo?: string; }): DelegationDenyMessage; /** * Creates a status query message */ static createStatusQuery(from: string, to: string, options?: { includeChain?: boolean; includeScopes?: boolean; includeMetrics?: boolean; replyTo?: string; }): StatusQueryMessage; /** * Creates a status response message */ static createStatusResponse(from: string, to: string, status: 'active' | 'suspended' | 'revoked', delegationDepth: number, remainingDepth: number, options?: { scopes?: string[]; metrics?: { subAgentsCreated: number; delegationsGranted: number; delegationsDenied: number; lastActivity: Date; }; replyTo?: string; }): StatusResponseMessage; /** * Creates a ping message */ static createPing(from: string, to: string, options?: { timestamp?: Date; metadata?: Record<string, any>; replyTo?: string; }): AgentMessage; /** * Creates a pong message (response to ping) */ static createPong(from: string, to: string, originalPingId: string, options?: { agentStatus?: string; responseTime?: number; metadata?: Record<string, any>; }): AgentMessage; /** * Creates an error message */ static createError(from: string, to: string, error: string, originalMessageId?: string, options?: { errorCode?: string; details?: Record<string, any>; replyTo?: string; }): AgentMessage; /** * Creates an acknowledgment message */ static createAck(from: string, to: string, originalMessageId: string, status?: 'received' | 'processing' | 'completed', options?: { details?: Record<string, any>; metadata?: Record<string, any>; }): AgentMessage; /** * Creates a revocation notification message */ static createRevocationNotification(from: string, to: string, revokedAgentDID: string, reason: string, options?: { effectiveDate?: Date; cascading?: boolean; metadata?: Record<string, any>; }): AgentMessage; /** * Creates an expiration notification message */ static createExpirationNotification(from: string, to: string, agentDID: string, expirationDate: Date, options?: { gracePeriod?: number; autoRenew?: boolean; metadata?: Record<string, any>; }): AgentMessage; /** * Creates a policy change notification message */ static createPolicyChangeNotification(from: string, to: string, policyId: string, changeType: 'created' | 'updated' | 'deleted' | 'enabled' | 'disabled', options?: { effectiveDate?: Date; affectedAgents?: string[]; description?: string; metadata?: Record<string, any>; }): AgentMessage; /** * Creates a batch of messages with common properties */ static createBatch(from: string, recipients: string[], messageType: AgentMessageType, payload: any, options?: { batchId?: string; metadata?: Record<string, any>; }): AgentMessage[]; /** * Utility to check if a message is of a specific type with type safety */ static isMessageType<T extends AgentMessage>(message: AgentMessage, type: AgentMessageType): message is T; /** * Extracts common message metadata */ static extractMessageInfo(message: AgentMessage): { id: string; type: AgentMessageType; from: string; to: string; timestamp: Date; isExpired: boolean; age: number; }; } //# sourceMappingURL=message-factory.d.ts.map