import type { S3Client } from "@aws-sdk/client-s3"; import type { AwsClient } from "aws4fetch"; import type { Adapter } from "../index.js"; export interface RustfsAdapterOptions { /** RustFS bucket name. The adapter scopes all operations to it. */ bucket: string; /** * RustFS server URL, e.g. `http://localhost:9000` (the S3 API port; the * console lives on 9001). Include the scheme — `http://` for local dev, * `https://` in production. */ endpoint: string; /** * Static credentials. Falls back to `RUSTFS_ACCESS_KEY_ID`, then to the * `RUSTFS_ACCESS_KEY` variable the RustFS server itself reads (so a * docker-compose `.env` serves both sides); required if neither is set. */ accessKeyId?: string; /** * Static credentials. Falls back to `RUSTFS_SECRET_ACCESS_KEY`, then to * the `RUSTFS_SECRET_KEY` variable the RustFS server itself reads; * required if neither is set. */ secretAccessKey?: string; /** * SigV4 region used for signing. Defaults to `us-east-1`, which is also * the server's default (`RUSTFS_REGION`). Set it to match the server if * you changed that variable — RustFS rejects signatures for a different * region. */ region?: string; /** * Use path-style addressing (`//`) rather than virtual-hosted * style. Defaults to `true` — RustFS serves path style out of the box and * only accepts virtual-hosted requests once `RUSTFS_SERVER_DOMAINS` and a * wildcard DNS record are configured. */ forcePathStyle?: boolean; /** * Origin used to build URLs from `url()`. When set, `url(key)` returns * `${publicBaseUrl}/${key}` — appropriate for a public bucket policy or * a reverse proxy in front of RustFS. When unset, `url()` falls back to * a presigned GetObject (default expiry: 1 hour). An explicit * `url(key, { expiresIn })` or `responseContentDisposition` still presigns. */ publicBaseUrl?: string; /** * Default expiry, in seconds, for the presigned URLs returned by * `url()` when the call passes no `expiresIn`. Defaults to 3600 (1 hour). */ defaultUrlExpiresIn?: number; /** * Which HTTP engine backs the adapter. * * Defaults to `"aws-sdk"`, except on Cloudflare Workers (detected via * `navigator.userAgent === "Cloudflare-Workers"`, or the workerd-only * `WebSocketPair` global when `navigator` is disabled), where it defaults * to `"fetch"` — the aws-sdk engine's XML parsing needs `DOMParser`, which * workerd doesn't provide. A Worker that polyfills `DOMParser` keeps the * `"aws-sdk"` default. Note the `"fetch"` engine's narrower surface below * before relying on the default in a Worker. * * - `"aws-sdk"`: `@aws-sdk/client-s3` — the full surface, including * multipart/resumable uploads, byte-level upload progress, and batched * `deleteMany`. Requires the `@aws-sdk/*` optional peer dependencies. * Loaded lazily on first use, so `raw` is `undefined` until a method * has run. * - `"fetch"`: SigV4-signed `fetch` via `aws4fetch` (~2.5 KB) — no * `@aws-sdk/*` install needed, ideal for Workers and other edge * runtimes. Covers upload, download (+ ranges), head, exists, delete, * list (+ delimiter), server-side copy, presigned `url()`, and * `signedUploadUrl()`. Trade-offs: `ReadableStream` bodies are buffered * before the single PUT, `multipart`/`control` uploads throw, bulk * deletes fan out per-key instead of batching, `signedUploadUrl` rejects * `maxSize`, keys with `.`/`..` segments are rejected, and `raw` is an * aws4fetch `AwsClient`. * * Both engines keep RustFS's defaults — path-style addressing, the * `us-east-1` signing region, `RustFS error` labels — which is what * reaching for the generic `s3Fetch()` instead would drop. */ client?: "aws-sdk" | "fetch"; /** * Override the `fetch` implementation used by the `"fetch"` client — for * tests, or runtimes that hand out a bound/instrumented fetch. Defaults to * `globalThis.fetch`. Ignored by the `"aws-sdk"` client. */ fetch?: (request: Request) => Promise; } export type RustfsAdapter = Adapter; export declare const rustfs: (opts: RustfsAdapterOptions) => RustfsAdapter; //# sourceMappingURL=index.d.ts.map