import * as blob from "@vercel/blob"; import type { Adapter } from "../index.js"; export interface VercelBlobAdapterOptions { /** * Long-lived read-write token. Defaults to `process.env.BLOB_READ_WRITE_TOKEN`. * * Takes priority over OIDC even when both are present (mirrors the * upstream `@vercel/blob` resolution order). For code running on * Vercel, prefer leaving this unset and using OIDC instead. */ token?: string; /** * Vercel OIDC token. Defaults to `process.env.VERCEL_OIDC_TOKEN`, which * Vercel populates automatically on every deployment when a Blob store * is connected to the project. * * OIDC tokens are short-lived and auto-rotated, so they remove the risk * that a long-lived `BLOB_READ_WRITE_TOKEN` leaks from your codebase * or environment. To activate OIDC, **both** `oidcToken` and `storeId` * must be available (option or env) and `token` must be unset — that * matches the upstream SDK's resolution order. * * Pass `oidcToken` explicitly when your framework doesn't load * `.env.local` into `process.env` automatically (Vite, etc.) — the * adapter would otherwise silently fall back to the read-write token. */ oidcToken?: string; /** * Blob store id, used with OIDC. Defaults to `process.env.BLOB_STORE_ID`. * Accepted in either `store_` or `` form (mirrors the SDK). * * Independently powers the `url()` fast path: when a `storeId` is known * (from option, env, or derived from a `vercel_blob_rw__…` * token), public URLs are synthesized without a round trip if * `addRandomSuffix: false`. */ storeId?: string; /** * Whether blobs uploaded by this adapter are public or private. * * - `"public"` (default): blobs are uploaded with `access: "public"` and * reachable via their CDN URL without authentication. `url()` returns a * permanent public URL. * - `"private"`: blobs are uploaded with `access: "private"`. They cannot * be fetched by URL — `download()` and the lazy bodies returned from * `head()` / `list()` instead route through `blob.get(key, { access: * "private" })`, which uses whichever credentials the adapter resolved * (read-write token or OIDC). `url()` throws because there is no * permanent public URL for private blobs. * * The setting is fixed at construction so a single `Files` instance is * unambiguously one or the other. If you need both, instantiate two * adapters. */ access?: "public" | "private"; /** * Add a random suffix to uploaded keys (Vercel default). * * When `false`, the resulting pathname matches the key 1:1, which keeps * the API consistent with S3/R2 where callers expect to control the key. * Defaults to `false`. */ addRandomSuffix?: boolean; /** * Allow overwriting existing keys on upload. Defaults to `true` so that the * "predictable keys" behavior (`addRandomSuffix: false`) actually works — * Vercel rejects same-pathname uploads otherwise. * * **Trade-off:** with the defaults, an `upload(key, ...)` call silently * clobbers any existing object at `key`. If keys are derived from * untrusted input or your callers expect "create-only" semantics, set * `allowOverwrite: false` and handle the resulting Conflict. */ allowOverwrite?: boolean; /** * Timeout in milliseconds for public-URL fetches issued by `download()`, * and by lazy bodies returned from `head()`/`list()`. A hung CDN response * would otherwise leak a fetch that never resolves. * * Defaults to 300_000 (5 minutes). Pass `0` to disable the timeout (not * recommended in server contexts — a stuck request will pin a connection * until the runtime tears it down). */ downloadTimeoutMs?: number; } export type VercelBlobClient = typeof blob; export type VercelBlobAdapter = Adapter; export declare const vercelBlob: (config?: VercelBlobAdapterOptions) => VercelBlobAdapter; //# sourceMappingURL=index.d.ts.map