/** * Policy Service Implementation * * Policy-based access control and namespace governance for SochDB. */ import { EmbeddedDatabase } from '../embedded'; import { PolicyRule, PolicyEvaluation, NamespacePolicy, NamespaceGrant, NamespacePermission, PolicyRequest, PolicyAuditEntry } from './types'; /** * Policy Service for access control and governance * * @example * ```typescript * import { EmbeddedDatabase, PolicyService } from '@sochdb/sochdb'; * * const db = EmbeddedDatabase.open('./mydb'); * const policy = new PolicyService(db); * * // Create a namespace policy * await policy.createNamespacePolicy({ * namespace: 'tenant_123', * rules: [{ * id: 'read_only', * name: 'Read Only Access', * effect: 'allow', * principals: ['user:*'], * resources: ['collection:*'], * actions: ['read', 'search'] * }], * defaultEffect: 'deny' * }); * * // Evaluate access * const result = await policy.evaluate({ * principal: 'user:alice', * action: 'read', * resource: 'collection:documents' * }); * ``` */ export declare class PolicyService { private db; private prefix; private cache; private auditEnabled; constructor(db: EmbeddedDatabase, options?: { enableAudit?: boolean; }); /** * Create a namespace policy */ createNamespacePolicy(policy: NamespacePolicy): Promise; /** * Get a namespace policy */ getNamespacePolicy(namespace: string): Promise; /** * Update a namespace policy */ updateNamespacePolicy(namespace: string, updates: Partial): Promise; /** * Delete a namespace policy */ deleteNamespacePolicy(namespace: string): Promise; /** * Add a rule to a namespace policy */ addRule(namespace: string, rule: PolicyRule): Promise; /** * Remove a rule from a namespace policy */ removeRule(namespace: string, ruleId: string): Promise; /** * Evaluate a policy request */ evaluate(request: PolicyRequest): Promise; /** * Grant namespace access to a principal */ grantAccess(grant: NamespaceGrant): Promise; /** * Revoke namespace access from a principal */ revokeAccess(namespace: string, principal: string): Promise; /** * Check if principal has permission */ hasPermission(namespace: string, principal: string, permission: NamespacePermission): Promise; /** * List all grants for a namespace */ listGrants(namespace: string): Promise; /** * Get audit log entries */ getAuditLog(options?: { namespace?: string; principal?: string; action?: string; since?: number; limit?: number; }): Promise; /** * Clear policy cache */ clearCache(): void; private policyKey; private grantKey; private extractNamespace; private matchesRule; private matchesPatterns; private matchesPattern; private evaluateCondition; private logAudit; } //# sourceMappingURL=service.d.ts.map