UNPKG

anon-identity

Version:

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

71 lines 2.79 kB
import { ScopeReductionPolicy } from './types'; export interface ScopeReductionResult { grantedScopes: string[]; deniedScopes: string[]; reason?: string; metadata?: Record<string, any>; } export interface ScopeHierarchy { scope: string; implies: string[]; requiredBy: string[]; } export declare class ScopeReductionStrategies { private static scopeRegistry; /** * Intersection strategy - only grant scopes that both parent has and child requests */ static intersection(parentScopes: string[], requestedScopes: string[]): ScopeReductionResult; /** * Subset strategy - grant all requested scopes only if they form a subset of parent scopes */ static subset(parentScopes: string[], requestedScopes: string[]): ScopeReductionResult; /** * Hierarchical reduction - considers scope dependencies and implications */ static hierarchical(parentScopes: string[], requestedScopes: string[]): ScopeReductionResult; /** * Category-based reduction - allows scopes within certain categories */ static categoryBased(parentScopes: string[], requestedScopes: string[], allowedCategories: string[]): ScopeReductionResult; /** * Risk-based reduction - filters scopes based on risk level */ static riskBased(parentScopes: string[], requestedScopes: string[], maxRiskLevel: 'low' | 'medium' | 'high'): ScopeReductionResult; /** * Time-based reduction - grants different scopes based on time/duration */ static timeBased(parentScopes: string[], requestedScopes: string[], duration: number): ScopeReductionResult; /** * Composite strategy - combines multiple strategies */ static composite(parentScopes: string[], requestedScopes: string[], strategies: Array<{ type: 'intersection' | 'subset' | 'hierarchical' | 'category' | 'risk' | 'time'; params?: any; weight?: number; }>): ScopeReductionResult; /** * Creates a custom reducer that applies a specific policy */ static createCustomReducer(policy: ScopeReductionPolicy): (parentScopes: string[], requestedScopes: string[]) => string[]; private static buildScopeHierarchy; private static findRequiredBy; private static canGrantScope; /** * Analyzes the impact of scope reduction */ static analyzeReduction(original: string[], reduced: string[]): { removed: string[]; retained: string[]; reductionPercentage: number; categoryImpact: Record<string, { removed: number; retained: number; }>; riskImpact: Record<string, { removed: number; retained: number; }>; }; } //# sourceMappingURL=scope-reduction-strategies.d.ts.map