import { C as ContentAddressedBlobStore } from './content-addressed-blob-store-CRUU_iCe.js'; import { BlobRefMetadata, BlobRef, KoraError } from '@korajs/core'; export { B as BlobGcOptions, a as BlobGcResult, D as DEFAULT_BLOB_GC_GRACE_MS, S as ServerBlobCallbacks, c as collectBlobGarbage, t as toServerBlobCallbacks } from './blob-gc-DQBbw3AM.js'; type BlobStoreEnvironment = Readonly>; /** * Opens the blob store the host configured, so application code never names a provider. * * - `KORA_BLOB_STORE_URL=s3://`, with `KORA_BLOB_STORE_ACCESS_KEY_ID`, * `KORA_BLOB_STORE_SECRET_ACCESS_KEY`, and optionally `KORA_BLOB_STORE_REGION` and * `KORA_BLOB_STORE_ENDPOINT` for S3-compatible services such as R2 and MinIO. * - `KORA_BLOB_STORE_URL=https://.blob.core.windows.net/`, using the workload's * managed identity (`AZURE_CLIENT_ID` picks one). * - `KORA_BLOB_DIR=/path` for a directory. * * Returns null when none is configured. A store it can't use is refused here, at startup, rather * than at the first upload. * * @example * ```typescript * const blobs = openBlobStoreFromEnv(process.env) * createProductionServer({ store, syncOptions: blobs ? toServerBlobCallbacks(blobs) : {} }) * ``` */ declare function openBlobStoreFromEnv(env: BlobStoreEnvironment): (ContentAddressedBlobStore & { readonly location?: string; }) | null; declare class ObjectStoreError extends KoraError { readonly status: number | null; constructor(message: string, status: number | null); } interface ObjectProperties { readonly etag: string; readonly bytes: number; readonly writtenAt: number; } /** * The few operations a cloud object store must offer. Everything that decides whether data is safe * lives in {@link ObjectBlobStore}, so a new provider is only this translation. */ interface ObjectStorageBackend { /** Where the bytes live, for logs. Must not contain a credential. */ readonly location: string; /** Writes atomically unless the key exists, and must never replace existing bytes. */ putIfAbsent(key: string, bytes: Uint8Array): Promise<'created' | 'exists'>; /** Makes an existing object count as just written. */ touch(key: string): Promise; head(key: string): Promise; get(key: string): Promise; /** With `ifEtag`, deletes only that exact version. False when the condition failed. */ delete(key: string, ifEtag?: string): Promise; list(): Promise; } /** * A durable {@link ContentAddressedBlobStore} on any object store. * * Objects use the `/` layout of the filesystem store, so a store moves between * providers by copying paths. Reads verify the bytes hash to the requested key. Beyond the base * contract it reports write times and total bytes, which a server needs to bound the store and * collect unreferenced content safely. */ declare class ObjectBlobStore implements ContentAddressedBlobStore { private readonly backend; readonly durable = true; readonly location: string; private totalCache; private capacityQueue; constructor(backend: ObjectStorageBackend); put(bytes: Uint8Array, metadata?: BlobRefMetadata): Promise; /** * {@link put}, unless the content is new and would take the store past `maxTotalBytes`. Serialized * within this process. Separate processes can overshoot by what they upload at the same moment. */ putWithinCapacity(bytes: Uint8Array, maxTotalBytes: number): Promise<'stored' | 'refreshed' | 'full'>; get(hash: string): Promise; has(hash: string): Promise; delete(hash: string): Promise; /** When the bytes behind `hash` were last written or uploaded again, in ms, or null when absent. */ lastWrittenAt(hash: string): Promise; /** Deletes only if not written since `cutoffMs`. A re-upload racing the delete wins. */ deleteIfWrittenBefore(hash: string, cutoffMs: number): Promise; size(): Promise; list(): Promise; totalBytes(): Promise; private write; private properties; private adjustTotal; } interface RetryOptions { readonly fetch?: typeof globalThis.fetch; readonly maxAttempts?: number; readonly sleep?: (ms: number) => Promise; } interface AzureBlobBackendOptions extends RetryOptions { /** `https://.blob.core.windows.net/` */ readonly containerUrl: string; readonly getToken: () => Promise; } interface ManagedIdentityEnvironment { readonly IDENTITY_ENDPOINT?: string | undefined; readonly IDENTITY_HEADER?: string | undefined; } /** * Tokens from the managed identity of the Azure workload this process runs in, so the application * holds no storage key. `clientId` picks one identity when several are attached. */ declare function managedIdentityTokenProvider(env: ManagedIdentityEnvironment, clientId: string | undefined, fetchImpl?: typeof globalThis.fetch): () => Promise; declare function createAzureBlobBackend(options: AzureBlobBackendOptions): ObjectStorageBackend; interface S3BlobBackendOptions extends RetryOptions { readonly bucket: string; readonly accessKeyId: string; readonly secretAccessKey: string; readonly region?: string; /** For S3-compatible services such as R2 and MinIO. Defaults to AWS for the region. */ readonly endpoint?: string; readonly now?: () => Date; } /** S3 and the services that speak its API. Needs conditional writes and deletes, which AWS has offered since 2024. */ declare function createS3BlobBackend(options: S3BlobBackendOptions): ObjectStorageBackend; export { type AzureBlobBackendOptions, type BlobStoreEnvironment, ContentAddressedBlobStore, ObjectBlobStore, type ObjectProperties, type ObjectStorageBackend, ObjectStoreError, type S3BlobBackendOptions, createAzureBlobBackend, createS3BlobBackend, managedIdentityTokenProvider, openBlobStoreFromEnv };