import { Knex } from 'knex'; import { AdminApiKey, AdminAuthProvider, AdminSessionManager, InternalAdmin } from '../types/admin.js'; import { KnexAdminService } from '../services/admin.knex.service.js'; import { AdminApiKeyService } from '../services/admin-api-key.service.js'; import { ConfigStore } from '../types.js'; import { AuthConfig } from '../types.js'; /** * Manager for internal admin functionality */ export declare class InternalAdminManager { private knex; private adminAuthProvider; private adminSessionManager; private configStore; private adminService; private apiKeyService; constructor(knex: Knex, adminAuthProvider: AdminAuthProvider, adminSessionManager: AdminSessionManager, configStore: ConfigStore, adminService: KnexAdminService, apiKeyService: AdminApiKeyService); /** * Create initial super admin if no admins exist */ ensureInitialAdmin(email: string, password: string, createInitialApiKey: boolean, initialApiKeyName?: string, initialApiKeyScopes?: string[]): Promise; /** * Check if admin feature is enabled * @throws AdminFeatureDisabledError if admin feature is disabled */ private checkEnabled; /** * Authenticate an admin with email and password * @param email Admin email * @param password Admin password * @returns Admin and session token */ login(email: string, password: string): Promise<{ admin: InternalAdmin; token: string; }>; /** * Verify an admin's session token * @param token Session token * @returns Admin associated with the token */ validateToken(token: string): Promise<{ admin: InternalAdmin; }>; /** * Logout an admin by destroying their session * @param token Session token */ logout(token: string): Promise; /** * Find an admin by ID * @param adminId Admin ID * @returns Admin or null if not found */ findAdminById(adminId: string): Promise; /** * Find an admin by email * @param email Admin email * @returns Admin or null if not found */ findAdminByEmail(email: string): Promise; /** * Create a new admin * @param adminData Admin data * @param password Admin password * @param creatorId ID of admin creating the new admin * @returns Created admin */ createAdmin(adminData: Partial, password: string, creatorId?: string): Promise; /** * Update an admin * @param adminId Admin ID to update * @param adminData New admin data * @param updaterId ID of admin making the update * @returns Updated admin */ updateAdmin(adminId: string, adminData: Partial, updaterId: string): Promise; /** * Delete an admin * @param adminId Admin ID to delete * @param deleterId ID of admin performing the delete */ deleteAdmin(adminId: string, deleterId: string): Promise; /** * List all admins with pagination * @param page Page number * @param limit Items per page * @returns Paginated list of admins */ listAdmins(page?: number, limit?: number): Promise<{ admins: InternalAdmin[]; total: number; page: number; limit: number; }>; /** * Grant a permission to an admin * @param adminId Admin to grant permission to * @param permission Permission to grant * @param granterId ID of admin granting the permission */ grantPermission(adminId: string, permission: string, granterId: string): Promise; /** * Revoke a permission from an admin * @param adminId Admin to revoke permission from * @param permission Permission to revoke * @param revokerId ID of admin revoking the permission */ revokePermission(adminId: string, permission: string, revokerId: string): Promise; /** * Check if an admin has super admin privileges * @param adminId Admin ID to check * @returns True if the admin is a super admin */ isSuperAdmin(adminId: string): Promise; /** * Update the auth configuration * @param updates Config updates * @param adminId ID of admin making the update * @returns Updated config */ updateAuthConfig(updates: Partial, adminId: string): Promise; /** * Get the current auth configuration * @returns Current auth config */ getAuthConfig(): Promise; /** * Create an admin audit log entry * @param logEntry Log entry data */ private createAuditLog; /** * Get audit logs with pagination * @param adminId Optional admin ID to filter logs by * @param page Page number * @param limit Items per page * @returns Paginated audit logs */ getAuditLogs(adminId?: string, page?: number, limit?: number): Promise<{ logs: any[]; total: number; page: number; limit: number; }>; /** * Create a new API key for an admin * @param adminId The admin ID * @param options API key creation options * @returns The created API key and the full key (only returned once) */ createApiKey(adminId: string, options: { name: string; scopes?: string[]; expires_at?: Date | null; }): Promise<{ apiKey: AdminApiKey; fullKey: string; }>; /** * List all API keys for an admin * @param adminId The admin ID * @returns Array of API keys */ listApiKeys(adminId: string): Promise; /** * Get an API key by ID * @param keyId The API key ID * @param adminId The admin ID (for permission checking) * @returns The API key if found and owned by the admin */ getApiKey(keyId: string, adminId: string): Promise; /** * Update an API key * @param keyId The API key ID * @param adminId The admin ID (for permission checking) * @param updates The updates to apply * @returns The updated API key */ updateApiKey(keyId: string, adminId: string, updates: { name?: string; scopes?: string[]; expires_at?: Date | null; }): Promise; /** * Delete an API key * @param keyId The API key ID * @param adminId The admin ID (for permission checking) * @returns True if the key was deleted */ deleteApiKey(keyId: string, adminId: string): Promise; /** * Validate an API key and get the associated admin * @param apiKey The API key to validate * @returns The admin associated with the API key if valid */ validateApiKey(apiKey: string): Promise<{ admin: InternalAdmin; scopes: string[]; }>; /** * Check if an API key has a specific scope * @param apiKey The API key * @param scope The scope to check * @returns True if the API key has the scope */ hasApiKeyScope(apiKey: AdminApiKey, scope: string): boolean; } //# sourceMappingURL=internal-admin-manager.d.ts.map