import { credentialResource, gatewayAccessKeyResource, type GatewayAccessKeyRow } from '@undefineds.co/models'; import type { AuthContext } from '../../auth/AuthContext'; import { type PodBaseUrlResolver } from '../pod/PodBaseUrlResolver'; import { type GatewayKeyLocatorCodec } from './GatewayKeyLocatorCodec'; import { type GatewayAccessKeyRecord, type GatewayAccessKeyRepository, type GatewayAccessKeyRepositoryContext } from './GatewayApiKeyAuthenticator'; import type { GatewayDeployment } from './GatewayApiKey'; /** Schema resources this repository reads and writes in the owner's Pod. */ type PodSchemaResource = typeof gatewayAccessKeyResource | typeof credentialResource; type GatewayAccessKeyDb = { init?: (...resources: unknown[]) => Promise; insert(resource: PodSchemaResource): { values(value: unknown): { execute(): Promise; }; }; select(): { from(resource: PodSchemaResource): { where(condition: unknown): { execute(): Promise; }; }; }; findById(resource: PodSchemaResource, id: string): Promise; findByIri(resource: PodSchemaResource, iri: string): Promise; updateById(resource: PodSchemaResource, id: string, patch: unknown): Promise; updateByIri?(resource: PodSchemaResource, iri: string, patch: unknown): Promise; deleteById?(resource: PodSchemaResource, id: string): Promise; }; type GatewayAccessKeyResource = typeof gatewayAccessKeyResource; export interface PodGatewayAccessKeyRepositoryOptions { locatorCodec: GatewayKeyLocatorCodec; internalPodAccess?: InternalPodAccessTokenProvider; podBaseUrlResolver?: PodBaseUrlResolver; dbFactory?: (input: { owner: string; auth?: AuthContext; fetch: typeof fetch; podUrl: string; resource?: GatewayAccessKeyResource; listResource?: GatewayAccessKeyResource; credentialListResource?: typeof credentialResource; }) => Promise; } export interface InternalPodAccessTokenProvider { getTrustedFetch(owner: string, auth?: AuthContext, context?: { reason?: string; podBaseUrl?: string; }): Promise; } export declare class PodGatewayAccessKeyRepository implements GatewayAccessKeyRepository { private readonly dbFactory; private readonly locatorCodec; private readonly internalPodAccess?; private readonly podBaseUrlResolver?; private readonly usesDefaultDbFactory; constructor(options: PodGatewayAccessKeyRepositoryOptions); createKeyId(owner: string, deployment: GatewayDeployment): string; create(record: GatewayAccessKeyRecord, context?: GatewayAccessKeyRepositoryContext): Promise; findById(id: string, context?: GatewayAccessKeyRepositoryContext): Promise; listByOwner(owner: string, context?: GatewayAccessKeyRepositoryContext): Promise; setEnabled(id: string, enabled: boolean, changedAt: Date, context?: GatewayAccessKeyRepositoryContext): Promise; revoke(id: string, revokedAt: Date, context?: GatewayAccessKeyRepositoryContext): Promise; delete(id: string, context?: GatewayAccessKeyRepositoryContext): Promise; revealPlaintext(id: string, context?: GatewayAccessKeyRepositoryContext): Promise; touchLastUsed(id: string, lastUsedAt: Date, context?: GatewayAccessKeyRepositoryContext): Promise; private dbForOwner; private resolveTrustedFetch; private wrapPodFetch; } /** Derived provider id of the built-in Xpod gateway provider; no provider row is persisted. */ export declare function clientCredentialProviderId(): string; export {};