/** * Delegation Graph Manager * * Tracks parent-child relationships between delegation credentials. * Critical for cascading revocation per Delegation-Revocation.md. * * SOLID Principles: * - Single Responsibility: Only manages delegation relationships * - Open/Closed: Extensible via storage provider interface * - Liskov Substitution: Any storage provider can be used * - Interface Segregation: Minimal graph operations interface * - Dependency Inversion: Depends on storage abstraction * * Related Spec: MCP-I ยง4.4, Delegation Chains * Python Reference: Delegation-Revocation.md:45-67 */ /** * Delegation node in the graph */ export interface DelegationNode { /** Delegation credential ID */ id: string; /** Parent delegation ID (null for root) */ parentId: string | null; /** Child delegation IDs */ children: string[]; /** Issuer DID */ issuerDid: string; /** Subject DID */ subjectDid: string; /** Credential status reference (for revocation) */ credentialStatusId?: string; } /** * Storage provider interface for delegation graphs * * Platform-specific implementations (CloudflareKV, DynamoDB, etc.) */ export interface DelegationGraphStorageProvider { /** * Get a delegation node by ID */ getNode(delegationId: string): Promise; /** * Save a delegation node */ setNode(node: DelegationNode): Promise; /** * Get all children of a delegation */ getChildren(delegationId: string): Promise; /** * Get the full chain from root to this delegation */ getChain(delegationId: string): Promise; /** * Get all descendants (children, grandchildren, etc.) */ getDescendants(delegationId: string): Promise; /** * Delete a node (used for cleanup) */ deleteNode(delegationId: string): Promise; } /** * Delegation Graph Manager * * Manages the tree/graph structure of delegations. * Per Delegation-Revocation.md: * - Track parent-child relationships * - Support chain validation * - Enable cascading revocation */ export declare class DelegationGraphManager { private storage; constructor(storage: DelegationGraphStorageProvider); /** * Register a new delegation in the graph * * @param delegation - The delegation to register * @returns The created node */ registerDelegation(params: { id: string; parentId: string | null; issuerDid: string; subjectDid: string; credentialStatusId?: string; }): Promise; /** * Add a child to a parent node * * @param parentId - Parent delegation ID * @param childId - Child delegation ID */ private addChildToParent; /** * Get a delegation node * * @param delegationId - The delegation ID * @returns The node, or null if not found */ getNode(delegationId: string): Promise; /** * Get all direct children of a delegation * * @param delegationId - The parent delegation ID * @returns Array of child nodes */ getChildren(delegationId: string): Promise; /** * Get all descendants (children, grandchildren, etc.) * * Used for cascading revocation. * Per Delegation-Revocation.md:56-67 * * @param delegationId - The parent delegation ID * @returns Array of all descendant nodes */ getDescendants(delegationId: string): Promise; /** * Get the full delegation chain from root to this node * * Used for chain validation. * * @param delegationId - The delegation ID * @returns Array of nodes from root to this node */ getChain(delegationId: string): Promise; /** * Check if delegation A is an ancestor of delegation B * * @param ancestorId - Potential ancestor ID * @param descendantId - Potential descendant ID * @returns true if ancestorId is an ancestor of descendantId */ isAncestor(ancestorId: string, descendantId: string): Promise; /** * Get the depth of a delegation in the tree * * @param delegationId - The delegation ID * @returns Depth (0 for root, 1 for immediate child, etc.) */ getDepth(delegationId: string): Promise; /** * Validate that a delegation chain is properly formed * * Checks that: * - Each child's issuer is the parent's subject * - No cycles exist * - Chain is continuous * * @param delegationId - The delegation ID to validate * @returns Validation result */ validateChain(delegationId: string): Promise<{ valid: boolean; reason?: string; }>; /** * Remove a delegation from the graph * * Note: This doesn't cascade - use CascadingRevocationManager for that. * * @param delegationId - The delegation ID to remove */ removeDelegation(delegationId: string): Promise; } /** * Create a delegation graph manager * * Convenience factory function. * * @param storage - Storage provider * @returns DelegationGraphManager instance */ export declare function createDelegationGraph(storage: DelegationGraphStorageProvider): DelegationGraphManager; //# sourceMappingURL=delegation-graph.d.ts.map