import type { IdentityDatabase } from './db'; export type ServiceType = 'local' | 'business' | 'cloud' | 'compute'; export interface ServiceTokenRecord { id: string; serviceType: ServiceType; serviceId: string; scopes: string[]; createdAt: Date; expiresAt: Date | null; } export interface CreateServiceTokenOptions { serviceType: ServiceType; serviceId: string; scopes: string[]; expiresAt?: Date | null; } export interface ServiceTokenRepositoryPort { createToken(options: CreateServiceTokenOptions): Promise<{ id: string; token: string; }>; registerToken(token: string, options: CreateServiceTokenOptions): Promise; verifyToken(token: string): Promise; findByService(serviceType: ServiceType, serviceId: string): Promise; deleteToken(id: string): Promise; listTokens(): Promise; } export declare class ServiceTokenRepository implements ServiceTokenRepositoryPort { private readonly db; private readonly logger; private readonly schema; private readonly ready; constructor(db: IdentityDatabase); /** * Create a new service token. Returns the plaintext token (only available at creation time). */ createToken(options: CreateServiceTokenOptions): Promise<{ id: string; token: string; }>; /** * Register a token from a known plaintext value (e.g. XPOD_BUSINESS_TOKEN env var). * Upserts by serviceType + serviceId to avoid duplicates. */ registerToken(token: string, options: CreateServiceTokenOptions): Promise; /** * Verify a plaintext token and return the matching record if valid. */ verifyToken(token: string): Promise; /** * Find a token record by service type and service ID. */ findByService(serviceType: ServiceType, serviceId: string): Promise; /** * Delete a service token by ID. */ deleteToken(id: string): Promise; /** * List all service tokens (without hashes). */ listTokens(): Promise; private hashToken; private toRecord; }