import type { Request } from 'express';
import type Database from 'better-sqlite3';
import type { RequestContext, RequestContextAuthType } from '../middleware/auth';
export declare const ENTERPRISE_API_KEY_PREFIX = "spak_";
export interface EnterpriseApiKeyRecord {
    id: string;
    tenantId: string;
    workspaceId?: string;
    ownerUserId?: string;
    name: string;
    scopes: string[];
    createdAt: number;
    expiresAt?: number;
    revokedAt?: number;
    lastUsedAt?: number;
}
export interface CreateEnterpriseApiKeyInput {
    name?: string;
    tenantId?: string;
    workspaceId?: string | null;
    ownerUserId?: string | null;
    scopes?: unknown;
    expiresAt?: unknown;
}
export interface CreatedEnterpriseApiKey {
    apiKey: EnterpriseApiKeyRecord;
    token: string;
}
export interface RequestApiKeyIdentity {
    userId: string;
    email: string;
    subscription: string;
    authType: RequestContextAuthType;
    tenantId: string;
    workspaceId?: string;
    roles: string[];
    scopes: string[];
}
export declare function extractEnterpriseApiKeyToken(req: Request): string | undefined;
export declare function requestHasEnterpriseApiKeyCredential(req: Request): boolean;
export declare class EnterpriseApiKeyService {
    private readonly db;
    private static instance;
    constructor(db?: Database.Database);
    static getInstance(): EnterpriseApiKeyService;
    static resetForTests(): void;
    static setInstanceForTests(service: EnterpriseApiKeyService): void;
    createApiKey(context: RequestContext, input?: CreateEnterpriseApiKeyInput): CreatedEnterpriseApiKey;
    listApiKeys(context: RequestContext): EnterpriseApiKeyRecord[];
    revokeApiKey(context: RequestContext, idInput: string): EnterpriseApiKeyRecord | null;
    resolveRequestIdentityFromRequest(req: Request): RequestApiKeyIdentity | null;
    private getRow;
    private getRowForContext;
    private existingUserId;
}
//# sourceMappingURL=enterpriseApiKeyService.d.ts.map