@ibanzajoe/uploader 1.6.0 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,7 +26,7 @@ function App() {
26
26
  <>
27
27
  <button onClick={() => setOpen(true)}>Upload</button>
28
28
  <PickerOverlay
29
- apikey="pk_your_api_key"
29
+ apikey="pk_your_publishable_key"
30
30
  apiUrl="https://your-api.example.com"
31
31
  open={open}
32
32
  onClose={() => setOpen(false)}
@@ -47,7 +47,7 @@ React dependency.
47
47
  import { UploaderClient } from '@ibanzajoe/uploader/core'
48
48
 
49
49
  const client = new UploaderClient({
50
- apikey: 'pk_your_api_key', // required — your public key
50
+ apikey: 'pk_your_publishable_key', // required — publishable, safe in client code
51
51
  apiUrl: 'https://your-api.example.com',
52
52
  })
53
53
 
@@ -117,7 +117,7 @@ Full-screen modal picker with drag-and-drop, progress, and error UI.
117
117
 
118
118
  | Prop | Type | Description |
119
119
  |---|---|---|
120
- | `apikey` | `string` | API key (`pk_…`). **Required.** |
120
+ | `apikey` | `string` | Publishable key (`pk_…`) — identifies your account, not a credential. **Required.** |
121
121
  | `apiUrl` | `string` | Base URL of the API server |
122
122
  | `open` | `boolean` | Whether the modal is open. **Required.** |
123
123
  | `onClose` | `() => void` | Called when the modal should close (ESC, backdrop, cancel) |
@@ -136,6 +136,7 @@ function xhrPut(url, body, opts) {
136
136
  });
137
137
  }
138
138
  var UploaderClient = class {
139
+ /** The publishable key (`pk_…`) — a project identifier, not a credential. */
139
140
  apikey;
140
141
  apiUrl;
141
142
  security;
@@ -150,7 +151,7 @@ var UploaderClient = class {
150
151
  #capsPromise = null;
151
152
  constructor(options) {
152
153
  this.apikey = options.apikey;
153
- this.apiUrl = (options.apiUrl ?? "https://api.uploaderhq.io").replace(/\/$/, "");
154
+ this.apiUrl = (options.apiUrl ?? "https://api.postila.app").replace(/\/$/, "");
154
155
  this.security = options.security;
155
156
  this.#directUploadOption = options.directUpload;
156
157
  this.#deliveryProtection = options.deliveryProtection;
@@ -167,7 +168,7 @@ var UploaderClient = class {
167
168
  const w = body.usageWarning;
168
169
  if (typeof w !== "object" || w === null) return;
169
170
  const warning = w;
170
- if (warning.type !== "bandwidth") return;
171
+ if (typeof warning.type !== "string" || typeof warning.message !== "string") return;
171
172
  if (this.#onUsageWarning) this.#onUsageWarning(warning);
172
173
  else console.warn(`[uploader] ${warning.message}`);
173
174
  }
@@ -262,15 +263,18 @@ var UploaderClient = class {
262
263
  // ─── Auth headers ──────────────────────────────────────────────────────────
263
264
  /**
264
265
  * Build the auth headers shared by all requests.
265
- * Attaches the API key and, when present, the signed policy pair.
266
+ * Attaches the API key and, when present, the signed policy pair. A per-call
267
+ * `security` overrides the client-level one (the file-management methods
268
+ * need policies with different `call` grants than uploads).
266
269
  */
267
- #authHeaders() {
270
+ #authHeaders(security) {
268
271
  const headers = {
269
272
  "X-Uploader-Key": this.apikey
270
273
  };
271
- if (this.security) {
272
- headers["X-Uploader-Policy"] = this.security.policy;
273
- headers["X-Uploader-Signature"] = this.security.signature;
274
+ const pair = security ?? this.security;
275
+ if (pair) {
276
+ headers["X-Uploader-Policy"] = pair.policy;
277
+ headers["X-Uploader-Signature"] = pair.signature;
274
278
  }
275
279
  return headers;
276
280
  }
@@ -390,6 +394,72 @@ var UploaderClient = class {
390
394
  }
391
395
  return this.#uploadMultipart(file, plan.parts, opts);
392
396
  }
397
+ /**
398
+ * List the account's files (paginated, 50 per page).
399
+ *
400
+ * Accounts with required signed policies must supply a policy whose `call`
401
+ * includes `'list'` — a handle-bound `'read'` policy from a delivery URL is
402
+ * deliberately not enough to enumerate the account.
403
+ *
404
+ * @throws {UploaderError} with code NETWORK_ERROR | SERVER_ERROR |
405
+ * CLIENT_ERROR | INVALID_RESPONSE
406
+ */
407
+ async listFiles(query = {}, opts = {}) {
408
+ const params = new URLSearchParams();
409
+ for (const [k, v] of Object.entries(query)) {
410
+ if (v !== void 0) params.set(k, String(v));
411
+ }
412
+ const qs = params.toString();
413
+ const res = await fetchWithRetry(
414
+ `${this.apiUrl}/api/files${qs ? `?${qs}` : ""}`,
415
+ { headers: this.#authHeaders(opts.security) },
416
+ opts.signal
417
+ );
418
+ const body = await res.json().catch(() => null);
419
+ if (!body || !Array.isArray(body.files)) {
420
+ throw new UploaderError("INVALID_RESPONSE", "Unexpected response shape from file list API");
421
+ }
422
+ return body;
423
+ }
424
+ /**
425
+ * Fetch one file's record by its public handle.
426
+ *
427
+ * Accounts with required signed policies must supply a policy whose `call`
428
+ * includes `'read'` (handle-bound policies must match this handle).
429
+ *
430
+ * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle
431
+ * does not exist (or belongs to another account).
432
+ */
433
+ async getFile(handle, opts = {}) {
434
+ const res = await fetchWithRetry(
435
+ `${this.apiUrl}/api/files/${encodeURIComponent(handle)}`,
436
+ { headers: this.#authHeaders(opts.security) },
437
+ opts.signal
438
+ );
439
+ const body = await res.json().catch(() => null);
440
+ if (!body || typeof body.handle !== "string") {
441
+ throw new UploaderError("INVALID_RESPONSE", "Unexpected response shape from file API");
442
+ }
443
+ return body;
444
+ }
445
+ /**
446
+ * Delete a file by its public handle.
447
+ *
448
+ * The file stops being served immediately (soft-delete + edge cache purge);
449
+ * the stored bytes and derivatives are removed by a background cleanup.
450
+ * Accounts with required signed policies must supply a policy whose `call`
451
+ * includes `'remove'` (handle-bound policies must match this handle).
452
+ *
453
+ * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle
454
+ * does not exist (or belongs to another account).
455
+ */
456
+ async deleteFile(handle, opts = {}) {
457
+ await fetchWithRetry(
458
+ `${this.apiUrl}/api/files/${encodeURIComponent(handle)}`,
459
+ { method: "DELETE", headers: this.#authHeaders(opts.security) },
460
+ opts.signal
461
+ );
462
+ }
393
463
  /**
394
464
  * Upload multiple files with concurrency limiting.
395
465
  *
@@ -431,4 +501,4 @@ export {
431
501
  planChunks,
432
502
  UploaderClient
433
503
  };
434
- //# sourceMappingURL=chunk-7LTEX76J.js.map
504
+ //# sourceMappingURL=chunk-Y2U6IGZ2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/errors.ts","../src/core/chunk.ts","../src/core/client.ts"],"sourcesContent":["/**\n * Typed errors for UploaderClient.\n *\n * UploaderError is thrown by upload / uploadAll on any non-retried failure.\n * The caller can narrow on `err.code` for structured handling.\n */\n\nexport type UploaderErrorCode =\n | 'ABORTED' // AbortSignal fired\n | 'NETWORK_ERROR' // fetch() threw (no response)\n | 'SERVER_ERROR' // 5xx after all retries exhausted\n | 'CLIENT_ERROR' // 4xx (not retried)\n | 'INVALID_RESPONSE' // response body did not match expected shape\n\nexport class UploaderError extends Error {\n readonly code: UploaderErrorCode\n /** HTTP status code when available (undefined for ABORTED / NETWORK_ERROR). */\n readonly statusCode?: number\n\n constructor(code: UploaderErrorCode, message: string, statusCode?: number) {\n super(message)\n this.name = 'UploaderError'\n this.code = code\n this.statusCode = statusCode\n }\n}\n","/**\n * Chunk planner for multipart uploads.\n *\n * Decides single-shot vs multipart by comparing the file size against\n * MULTIPART_THRESHOLD. For multipart files, slices the Blob into parts of\n * `chunkSize` bytes.\n */\n\n/** Files ≤ this size use single-shot POST /api/store. */\nexport const MULTIPART_THRESHOLD = 5 * 1024 * 1024 // 5 MB\n\n/** Default part size for multipart uploads. */\nexport const DEFAULT_CHUNK_SIZE = 5 * 1024 * 1024 // 5 MB\n\nexport type ChunkPlan =\n | { mode: 'single' }\n | { mode: 'multipart'; parts: Blob[]; partSize: number }\n\n/**\n * Build a chunk plan for a file.\n *\n * @param file The File or Blob to upload.\n * @param chunkSize Desired part size in bytes (default DEFAULT_CHUNK_SIZE).\n * @returns A plan describing whether to use single-shot or multipart.\n */\nexport function planChunks(file: File | Blob, chunkSize = DEFAULT_CHUNK_SIZE): ChunkPlan {\n if (file.size <= MULTIPART_THRESHOLD) {\n return { mode: 'single' }\n }\n\n const parts: Blob[] = []\n let offset = 0\n while (offset < file.size) {\n parts.push(file.slice(offset, offset + chunkSize))\n offset += chunkSize\n }\n return { mode: 'multipart', parts, partSize: chunkSize }\n}\n","/**\n * UploaderClient — headless upload client.\n *\n * Chooses single-shot (POST /api/store, multipart/form-data) vs multipart\n * (start/part/complete) based on file size relative to MULTIPART_THRESHOLD\n * (5 MB). Parts are retried individually with exponential backoff. Progress\n * is emitted as a 0–100 integer. AbortSignal cancels in-flight work.\n */\n\nimport type {\n FileResult,\n UploadStartResponse,\n UploadPartResponse,\n UploaderClientOptions,\n UploadAllOptions,\n UploadOptions,\n UsageWarning,\n SecurityPair,\n StoredFileRecord,\n ListFilesQuery,\n ListFilesResult,\n FileManageOptions,\n} from './types.js'\nimport { UploaderError } from './errors.js'\nimport { planChunks } from './chunk.js'\n\n// ─── Constants ────────────────────────────────────────────────────────────────\n\nconst MAX_RETRIES = 3\nconst RETRY_BASE_MS = 200\n\n/**\n * Single presigned PUT ceiling (mirrors the server's Phase-A limit). Files above\n * this fall back to the proxied multipart flow.\n */\nconst MAX_DIRECT_PUT_BYTES = 5 * 1024 * 1024 * 1024 // 5 GB\n\n/**\n * Skip the advisory client checksum above this size — SubtleCrypto has no\n * streaming API, so hashing would load the whole file into memory a second time.\n * The checksum is advisory only (the server can't verify it anyway).\n */\nconst SHA256_MAX_BYTES = 64 * 1024 * 1024 // 64 MB\n\n// ─── Internal helpers ─────────────────────────────────────────────────────────\n\n/** Sleep for `ms` milliseconds, resolving early if signal fires. */\nfunction sleep(ms: number, signal?: AbortSignal): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (signal?.aborted) {\n reject(new UploaderError('ABORTED', 'Upload aborted'))\n return\n }\n const timer = setTimeout(resolve, ms)\n signal?.addEventListener('abort', () => {\n clearTimeout(timer)\n reject(new UploaderError('ABORTED', 'Upload aborted'))\n }, { once: true })\n })\n}\n\n/** Throw UploaderError(ABORTED) if signal has already fired. */\nfunction checkAbort(signal?: AbortSignal): void {\n if (signal?.aborted) {\n throw new UploaderError('ABORTED', 'Upload aborted')\n }\n}\n\n/**\n * Fetch with retry on network errors and 5xx responses.\n * 4xx responses are not retried — they surface immediately as CLIENT_ERROR.\n */\nasync function fetchWithRetry(\n url: string,\n init: RequestInit,\n signal?: AbortSignal,\n maxRetries = MAX_RETRIES,\n): Promise<Response> {\n let lastErr: unknown\n for (let attempt = 0; attempt < maxRetries; attempt++) {\n checkAbort(signal)\n try {\n const res = await fetch(url, { ...init, signal })\n if (res.status >= 400 && res.status < 500) {\n // Client error — do not retry\n const body = await res.text().catch(() => '')\n throw new UploaderError(\n 'CLIENT_ERROR',\n `HTTP ${res.status}: ${body}`,\n res.status,\n )\n }\n if (res.status >= 500) {\n // Server error — retry with backoff\n lastErr = new UploaderError(\n 'SERVER_ERROR',\n `HTTP ${res.status}`,\n res.status,\n )\n if (attempt < maxRetries - 1) {\n await sleep(RETRY_BASE_MS * 2 ** attempt, signal)\n }\n continue\n }\n return res\n } catch (err) {\n if (err instanceof UploaderError) {\n if (err.code === 'CLIENT_ERROR' || err.code === 'ABORTED') throw err\n lastErr = err\n } else {\n // fetch() threw (network failure, CORS, etc.)\n lastErr = new UploaderError(\n 'NETWORK_ERROR',\n err instanceof Error ? err.message : String(err),\n )\n }\n if (attempt < maxRetries - 1) {\n await sleep(RETRY_BASE_MS * 2 ** attempt, signal)\n }\n }\n }\n throw lastErr\n}\n\n/**\n * Best-effort SHA-256 (hex) of a Blob for the advisory checksum sent at confirm.\n * Returns undefined when SubtleCrypto is unavailable (insecure context / older\n * runtime) or the file is large — never throws. The server treats this as a hint\n * only, so skipping it is safe.\n */\nasync function sha256Hex(blob: Blob): Promise<string | undefined> {\n try {\n const c = (globalThis as { crypto?: Crypto }).crypto\n if (!c?.subtle || blob.size > SHA256_MAX_BYTES) return undefined\n const digest = await c.subtle.digest('SHA-256', await blob.arrayBuffer())\n return Array.from(new Uint8Array(digest))\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('')\n } catch {\n return undefined\n }\n}\n\n/**\n * PUT a body straight to a presigned bucket URL via XMLHttpRequest.\n *\n * XHR (not fetch) so real upload progress is reported (fetch cannot). The\n * Content-Type header MUST equal the value the server signed, or S3/R2 reject\n * the signature. Bytes go browser → bucket; our server never sees them.\n */\nfunction xhrPut(\n url: string,\n body: Blob,\n opts: { contentType: string; onProgress?: (percent: number) => void; signal?: AbortSignal },\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n if (opts.signal?.aborted) {\n reject(new UploaderError('ABORTED', 'Upload aborted'))\n return\n }\n const xhr = new XMLHttpRequest()\n xhr.open('PUT', url)\n xhr.setRequestHeader('Content-Type', opts.contentType)\n\n if (opts.onProgress) {\n xhr.upload.onprogress = (e: ProgressEvent) => {\n if (e.lengthComputable) {\n // Reserve the last 5% for the confirm round-trip.\n opts.onProgress!(Math.round((e.loaded / e.total) * 95))\n }\n }\n }\n xhr.onload = () => {\n if (xhr.status >= 200 && xhr.status < 300) {\n resolve()\n } else {\n const code = xhr.status >= 400 && xhr.status < 500 ? 'CLIENT_ERROR' : 'SERVER_ERROR'\n reject(new UploaderError(code, `Bucket PUT failed: HTTP ${xhr.status}`, xhr.status))\n }\n }\n xhr.onerror = () => reject(new UploaderError('NETWORK_ERROR', 'Bucket PUT network error'))\n xhr.onabort = () => reject(new UploaderError('ABORTED', 'Upload aborted'))\n\n if (opts.signal) {\n opts.signal.addEventListener('abort', () => xhr.abort(), { once: true })\n }\n xhr.send(body)\n })\n}\n\n/**\n * Shape returned by POST /api/uploads/presign.\n *\n * Deliberately no `storageKey`: the server stopped returning it (docs/22\n * §5.3a) because it addresses the object on the raw CDN domain, bypassing\n * delivery protection. Nothing here ever read it — the upload PUTs to\n * `putUrl` and confirms by `handle`.\n */\ntype PresignResponse = { handle: string; putUrl: string; contentType: string }\n\n// ─── UploaderClient ────────────────────────────────────────────────────────────\n\nexport class UploaderClient {\n /** The publishable key (`pk_…`) — a project identifier, not a credential. */\n readonly apikey: string\n readonly apiUrl: string\n readonly security: UploaderClientOptions['security']\n readonly #directUploadOption?: boolean\n /** Client-level default per-file delivery protection (docs/13). */\n readonly #deliveryProtection?: UploaderClientOptions['deliveryProtection']\n /** Client-level default per-file allowed origins (docs/13). */\n readonly #allowedOrigins?: string[]\n /** Optional consumer hook for non-disruptive usage warnings (soft bandwidth cap). */\n readonly #onUsageWarning?: UploaderClientOptions['onUsageWarning']\n\n /** Memoized capability probe — one request per client, shared across uploads. */\n #capsPromise: Promise<{ directUpload: boolean }> | null = null\n\n constructor(options: UploaderClientOptions) {\n this.apikey = options.apikey\n this.apiUrl = (options.apiUrl ?? 'https://api.postila.app').replace(/\\/$/, '')\n this.security = options.security\n this.#directUploadOption = options.directUpload\n this.#deliveryProtection = options.deliveryProtection\n this.#allowedOrigins = options.allowedOrigins\n this.#onUsageWarning = options.onUsageWarning\n }\n\n /**\n * Surface a non-disruptive usage warning carried on an upload response. Routes\n * to the consumer's `onUsageWarning` hook if provided, else `console.warn`.\n * Tolerates arbitrary JSON: only a well-formed `{ usageWarning }` triggers it.\n */\n #emitUsageWarning(body: unknown): void {\n if (typeof body !== 'object' || body === null) return\n const w = (body as { usageWarning?: unknown }).usageWarning\n if (typeof w !== 'object' || w === null) return\n const warning = w as UsageWarning\n // Any known dimension (storage/bandwidth/transform/uploads) — C2 generalized\n // this from bandwidth-only. A future dimension still parses as a string type.\n if (typeof warning.type !== 'string' || typeof warning.message !== 'string') return\n if (this.#onUsageWarning) this.#onUsageWarning(warning)\n else console.warn(`[uploader] ${warning.message}`)\n }\n\n /**\n * Resolve the effective per-file protection for one upload: a per-upload value\n * overrides the client-level default (docs/13). Returns an object carrying ONLY\n * the keys that are set, so callers spread it into the request body and unset\n * fields are omitted entirely — an old server ignores them and the file inherits\n * the account mode (`null`).\n */\n #resolveProtection(opts: UploadOptions): {\n deliveryProtection?: UploaderClientOptions['deliveryProtection']\n allowedOrigins?: string[]\n } {\n const out: { deliveryProtection?: UploaderClientOptions['deliveryProtection']; allowedOrigins?: string[] } = {}\n const mode = opts.deliveryProtection ?? this.#deliveryProtection\n if (mode !== undefined) out.deliveryProtection = mode\n const origins = opts.allowedOrigins ?? this.#allowedOrigins\n if (origins !== undefined) out.allowedOrigins = origins\n return out\n }\n\n // ─── Capability negotiation ─────────────────────────────────────────────────\n\n /**\n * Probe GET /api/capabilities once per client and cache the result. Fails OPEN\n * to the proxied flow ({ directUpload: false }) on any error/timeout, so a\n * flaky probe never blocks uploads and old servers (404) are handled.\n */\n #getCapabilities(): Promise<{ directUpload: boolean }> {\n // Explicit opt-out — never probe, never use direct upload.\n if (this.#directUploadOption === false) {\n return Promise.resolve({ directUpload: false })\n }\n if (!this.#capsPromise) {\n this.#capsPromise = fetch(`${this.apiUrl}/api/capabilities`, {\n headers: this.#authHeaders(),\n })\n .then(async (res) => {\n if (!res.ok) return { directUpload: false }\n const body = (await res.json().catch(() => ({}))) as Record<string, unknown>\n return { directUpload: body['directUpload'] === true }\n })\n .catch(() => ({ directUpload: false }))\n }\n return this.#capsPromise\n }\n\n // ─── Direct-to-bucket upload ────────────────────────────────────────────────\n\n /**\n * Presign → PUT-to-bucket → confirm. Bytes go browser → bucket directly; our\n * server only signs and records. Used when the account has the directUpload\n * capability and the file fits a single PUT.\n */\n async #uploadDirect(file: File | Blob, opts: UploadOptions): Promise<FileResult> {\n const { onProgress, filename, signal } = opts\n const name = filename ?? (file instanceof File ? file.name : 'upload')\n // Must match the Content-Type we send on the PUT (the server signs it).\n const contentType = file instanceof File && file.type ? file.type : 'application/octet-stream'\n\n onProgress?.(0)\n checkAbort(signal)\n\n const protection = this.#resolveProtection(opts)\n const presign = async (): Promise<PresignResponse> => {\n const res = await fetchWithRetry(\n `${this.apiUrl}/api/uploads/presign`,\n {\n method: 'POST',\n headers: { ...this.#authHeaders(), 'Content-Type': 'application/json' },\n body: JSON.stringify({ filename: name, contentType, size: file.size, ...protection }),\n },\n signal,\n )\n return (await res.json()) as PresignResponse\n }\n\n let signed = await presign()\n\n // Advisory checksum (best-effort; unverifiable server-side).\n const checksum = await sha256Hex(file)\n\n // PUT straight to the bucket. A 403 means the short-lived signature lapsed\n // (or a stale key) — re-presign once and retry before giving up.\n try {\n await xhrPut(signed.putUrl, file, { contentType: signed.contentType, onProgress, signal })\n } catch (err) {\n if (err instanceof UploaderError && err.statusCode === 403) {\n signed = await presign()\n await xhrPut(signed.putUrl, file, { contentType: signed.contentType, onProgress, signal })\n } else {\n throw err\n }\n }\n\n // Confirm — server verifies the object exists, records usage, enqueues.\n checkAbort(signal)\n const confirmRes = await fetchWithRetry(\n `${this.apiUrl}/api/uploads/confirm`,\n {\n method: 'POST',\n headers: { ...this.#authHeaders(), 'Content-Type': 'application/json' },\n body: JSON.stringify({ handle: signed.handle, checksum }),\n },\n signal,\n )\n const body = (await confirmRes.json()) as unknown\n onProgress?.(100)\n // Non-disruptive soft-cap heads-up (bandwidth). Emitted before returning so a\n // consumer sees it even if they ignore the return value; never throws.\n this.#emitUsageWarning(body)\n return this.#parseFileResult(body)\n }\n\n // ─── Auth headers ──────────────────────────────────────────────────────────\n\n /**\n * Build the auth headers shared by all requests.\n * Attaches the API key and, when present, the signed policy pair. A per-call\n * `security` overrides the client-level one (the file-management methods\n * need policies with different `call` grants than uploads).\n */\n #authHeaders(security?: SecurityPair): Record<string, string> {\n const headers: Record<string, string> = {\n 'X-Uploader-Key': this.apikey,\n }\n const pair = security ?? this.security\n if (pair) {\n headers['X-Uploader-Policy'] = pair.policy\n headers['X-Uploader-Signature'] = pair.signature\n }\n return headers\n }\n\n // ─── Single-shot upload ────────────────────────────────────────────────────\n\n /**\n * POST /api/store — multipart/form-data for files ≤ MULTIPART_THRESHOLD.\n */\n async #uploadSingleShot(\n file: File | Blob,\n opts: UploadOptions,\n ): Promise<FileResult> {\n const { onProgress, filename, signal } = opts\n\n onProgress?.(0)\n checkAbort(signal)\n\n const form = new FormData()\n form.append('file', file, filename ?? (file instanceof File ? file.name : 'upload'))\n if (filename) form.append('filename', filename)\n // Per-file delivery protection (docs/13) — sent as form fields; allowedOrigins\n // is JSON-encoded to match the server's parse. Omitted when unset (inherit).\n const protection = this.#resolveProtection(opts)\n if (protection.deliveryProtection) form.append('deliveryProtection', protection.deliveryProtection)\n if (protection.allowedOrigins) form.append('allowedOrigins', JSON.stringify(protection.allowedOrigins))\n\n const res = await fetchWithRetry(\n `${this.apiUrl}/api/store`,\n {\n method: 'POST',\n headers: this.#authHeaders(),\n body: form,\n },\n signal,\n )\n\n const body = await res.json() as unknown\n onProgress?.(100)\n return this.#parseFileResult(body)\n }\n\n // ─── Multipart upload ──────────────────────────────────────────────────────\n\n /**\n * start → parts (parallel with progress) → complete for files > MULTIPART_THRESHOLD.\n */\n async #uploadMultipart(\n file: File | Blob,\n parts: Blob[],\n opts: UploadOptions,\n ): Promise<FileResult> {\n const { onProgress, filename, signal } = opts\n const name = filename ?? (file instanceof File ? file.name : 'upload')\n const mime = file instanceof File ? file.type : 'application/octet-stream'\n\n onProgress?.(0)\n checkAbort(signal)\n\n // 1. Start\n const protection = this.#resolveProtection(opts)\n const startRes = await fetchWithRetry(\n `${this.apiUrl}/api/upload/start`,\n {\n method: 'POST',\n headers: { ...this.#authHeaders(), 'Content-Type': 'application/json' },\n body: JSON.stringify({ filename: name, mimetype: mime, size: file.size, ...protection }),\n },\n signal,\n )\n const { uploadId } = await startRes.json() as UploadStartResponse\n\n // 2. Upload parts sequentially (retried individually)\n const etags: { partNumber: number; etag: string }[] = []\n let uploadedBytes = 0\n\n for (let i = 0; i < parts.length; i++) {\n checkAbort(signal)\n const partBlob = parts[i]!\n const partNumber = i + 1\n\n const partForm = new FormData()\n partForm.append('uploadId', uploadId)\n partForm.append('partNumber', String(partNumber))\n partForm.append('part', partBlob)\n\n const partRes = await fetchWithRetry(\n `${this.apiUrl}/api/upload/part`,\n {\n method: 'POST',\n headers: this.#authHeaders(),\n body: partForm,\n },\n signal,\n )\n const { etag } = await partRes.json() as UploadPartResponse\n\n etags.push({ partNumber, etag })\n uploadedBytes += partBlob.size\n onProgress?.(Math.round((uploadedBytes / file.size) * 95)) // reserve 5% for complete\n }\n\n // 3. Complete\n checkAbort(signal)\n const completeRes = await fetchWithRetry(\n `${this.apiUrl}/api/upload/complete`,\n {\n method: 'POST',\n headers: { ...this.#authHeaders(), 'Content-Type': 'application/json' },\n body: JSON.stringify({ uploadId, parts: etags }),\n },\n signal,\n )\n const body = await completeRes.json() as unknown\n onProgress?.(100)\n return this.#parseFileResult(body)\n }\n\n // ─── Response parser ───────────────────────────────────────────────────────\n\n #parseFileResult(body: unknown): FileResult {\n if (\n typeof body !== 'object' ||\n body === null ||\n typeof (body as Record<string, unknown>)['handle'] !== 'string' ||\n typeof (body as Record<string, unknown>)['url'] !== 'string'\n ) {\n throw new UploaderError('INVALID_RESPONSE', 'Unexpected response shape from upload API')\n }\n return body as FileResult\n }\n\n // ─── Public API ───────────────────────────────────────────────────────────\n\n /**\n * Upload a single file.\n *\n * Automatically selects single-shot vs multipart upload based on file size.\n * Emits progress via `opts.onProgress` (0–100). Respects `opts.signal` for\n * cancellation. Retries network errors and 5xx responses up to 3 times with\n * exponential backoff; 4xx errors are surfaced immediately.\n *\n * @throws {UploaderError} with code ABORTED | NETWORK_ERROR | SERVER_ERROR |\n * CLIENT_ERROR | INVALID_RESPONSE\n */\n async upload(\n file: File | Blob,\n opts: UploadOptions = {},\n ): Promise<FileResult> {\n // Prefer direct-to-bucket when the account supports it and the file fits a\n // single PUT. The probe fails open, so an old server or a disabled account\n // transparently uses the proxied flow below.\n const caps = await this.#getCapabilities()\n if (caps.directUpload && file.size <= MAX_DIRECT_PUT_BYTES) {\n return this.#uploadDirect(file, opts)\n }\n\n const plan = planChunks(file, opts.chunkSize)\n if (plan.mode === 'single') {\n return this.#uploadSingleShot(file, opts)\n }\n return this.#uploadMultipart(file, plan.parts, opts)\n }\n\n /**\n * List the account's files (paginated, 50 per page).\n *\n * Accounts with required signed policies must supply a policy whose `call`\n * includes `'list'` — a handle-bound `'read'` policy from a delivery URL is\n * deliberately not enough to enumerate the account.\n *\n * @throws {UploaderError} with code NETWORK_ERROR | SERVER_ERROR |\n * CLIENT_ERROR | INVALID_RESPONSE\n */\n async listFiles(query: ListFilesQuery = {}, opts: FileManageOptions = {}): Promise<ListFilesResult> {\n const params = new URLSearchParams()\n for (const [k, v] of Object.entries(query)) {\n if (v !== undefined) params.set(k, String(v))\n }\n const qs = params.toString()\n const res = await fetchWithRetry(\n `${this.apiUrl}/api/files${qs ? `?${qs}` : ''}`,\n { headers: this.#authHeaders(opts.security) },\n opts.signal,\n )\n const body = (await res.json().catch(() => null)) as ListFilesResult | null\n if (!body || !Array.isArray(body.files)) {\n throw new UploaderError('INVALID_RESPONSE', 'Unexpected response shape from file list API')\n }\n return body\n }\n\n /**\n * Fetch one file's record by its public handle.\n *\n * Accounts with required signed policies must supply a policy whose `call`\n * includes `'read'` (handle-bound policies must match this handle).\n *\n * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle\n * does not exist (or belongs to another account).\n */\n async getFile(handle: string, opts: FileManageOptions = {}): Promise<StoredFileRecord> {\n const res = await fetchWithRetry(\n `${this.apiUrl}/api/files/${encodeURIComponent(handle)}`,\n { headers: this.#authHeaders(opts.security) },\n opts.signal,\n )\n const body = (await res.json().catch(() => null)) as StoredFileRecord | null\n if (!body || typeof body.handle !== 'string') {\n throw new UploaderError('INVALID_RESPONSE', 'Unexpected response shape from file API')\n }\n return body\n }\n\n /**\n * Delete a file by its public handle.\n *\n * The file stops being served immediately (soft-delete + edge cache purge);\n * the stored bytes and derivatives are removed by a background cleanup.\n * Accounts with required signed policies must supply a policy whose `call`\n * includes `'remove'` (handle-bound policies must match this handle).\n *\n * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle\n * does not exist (or belongs to another account).\n */\n async deleteFile(handle: string, opts: FileManageOptions = {}): Promise<void> {\n await fetchWithRetry(\n `${this.apiUrl}/api/files/${encodeURIComponent(handle)}`,\n { method: 'DELETE', headers: this.#authHeaders(opts.security) },\n opts.signal,\n )\n }\n\n /**\n * Upload multiple files with concurrency limiting.\n *\n * Resolves once all uploads settle (fulfilled or rejected). The returned\n * array preserves input order. `opts.concurrency` caps simultaneous\n * in-flight uploads (default 3). Each file shares the same opts\n * (including onProgress — the callback fires per-file, not aggregate).\n *\n * @returns Array of PromiseSettledResult in input order.\n */\n async uploadAll(\n files: Array<File | Blob>,\n opts: UploadAllOptions = {},\n ): Promise<PromiseSettledResult<FileResult>[]> {\n const concurrency = opts.concurrency ?? 3\n const results: PromiseSettledResult<FileResult>[] = new Array(files.length)\n\n let index = 0\n\n async function worker(client: UploaderClient): Promise<void> {\n while (index < files.length) {\n const i = index++\n const file = files[i]!\n try {\n results[i] = { status: 'fulfilled', value: await client.upload(file, opts) }\n } catch (err) {\n results[i] = { status: 'rejected', reason: err }\n }\n }\n }\n\n const workers = Array.from({ length: Math.min(concurrency, files.length) }, () =>\n worker(this),\n )\n await Promise.all(workers)\n return results\n }\n}\n"],"mappings":";AAcO,IAAM,gBAAN,cAA4B,MAAM;AAAA,EAC9B;AAAA;AAAA,EAEA;AAAA,EAET,YAAY,MAAyB,SAAiB,YAAqB;AACzE,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AACZ,SAAK,aAAa;AAAA,EACpB;AACF;;;AChBO,IAAM,sBAAsB,IAAI,OAAO;AAGvC,IAAM,qBAAqB,IAAI,OAAO;AAatC,SAAS,WAAW,MAAmB,YAAY,oBAA+B;AACvF,MAAI,KAAK,QAAQ,qBAAqB;AACpC,WAAO,EAAE,MAAM,SAAS;AAAA,EAC1B;AAEA,QAAM,QAAgB,CAAC;AACvB,MAAI,SAAS;AACb,SAAO,SAAS,KAAK,MAAM;AACzB,UAAM,KAAK,KAAK,MAAM,QAAQ,SAAS,SAAS,CAAC;AACjD,cAAU;AAAA,EACZ;AACA,SAAO,EAAE,MAAM,aAAa,OAAO,UAAU,UAAU;AACzD;;;ACTA,IAAM,cAAc;AACpB,IAAM,gBAAgB;AAMtB,IAAM,uBAAuB,IAAI,OAAO,OAAO;AAO/C,IAAM,mBAA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AAA,QAC7E,SAAS,KAAK;AACZ,kBAAQ,CAAC,IAAI,EAAE,QAAQ,YAAY,QAAQ,IAAI;AAAA,QACjD;AAAA,MACF;AAAA,IACF;AAEA,UAAM,UAAU,MAAM;AAAA,MAAK,EAAE,QAAQ,KAAK,IAAI,aAAa,MAAM,MAAM,EAAE;AAAA,MAAG,MAC1E,OAAO,IAAI;AAAA,IACb;AACA,UAAM,QAAQ,IAAI,OAAO;AACzB,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -16,6 +16,13 @@ type FileResult = {
16
16
  size: number;
17
17
  status: 'Stored';
18
18
  uploadId?: string;
19
+ /**
20
+ * ISO timestamp after which `url` stops working. Present ONLY for BYO Lite
21
+ * private-bucket presigned URLs (24h TTL); absent means the URL is stable.
22
+ * Store the `handle` and re-fetch (getFile/listFiles) rather than persisting
23
+ * an expiring URL — or set a `public_base_url` for durable links.
24
+ */
25
+ urlExpiresAt?: string;
19
26
  };
20
27
  /** Response from the picker overlay / upload batch. */
21
28
  type PickerResponse = {
@@ -39,14 +46,17 @@ type PolicySpec = {
39
46
  };
40
47
  /**
41
48
  * A non-disruptive usage warning surfaced alongside an upload response (mirrors
42
- * @uploader/shared UsageWarning). Bandwidth limits are SOFT delivery is never
43
- * blocked when exceeded so this is only ever an informational heads-up when the
44
- * account is approaching or over its included monthly bandwidth.
49
+ * @uploader/shared UsageWarning). Fires when the account is approaching (85%) or
50
+ * over an included monthly allowance. `type` names the dimension; for `bandwidth`
51
+ * delivery is soft (never blocked), while storage/transform/uploads pause when
52
+ * exceeded — the `message` states each case.
45
53
  */
46
54
  type UsageWarning = {
47
- type: 'bandwidth';
55
+ type: 'storage' | 'bandwidth' | 'transform' | 'uploads';
48
56
  level: 'approaching' | 'over';
57
+ /** Month-to-date usage: bytes for storage/bandwidth, a count for transform/uploads. */
49
58
  usedBytes: number;
59
+ /** Included allowance, same unit as usedBytes. */
50
60
  limitBytes: number;
51
61
  percent: number;
52
62
  message: string;
@@ -62,9 +72,26 @@ type UsageWarning = {
62
72
  */
63
73
  type DeliveryProtection = 'public' | 'hotlink' | 'signed';
64
74
  type UploaderClientOptions = {
65
- /** Public API key (pk_...). */
75
+ /**
76
+ * Your **publishable key** (`pk_…`) — a project identifier, safe to ship in
77
+ * client code.
78
+ *
79
+ * Deliberately NOT called "authentication": it identifies which account an
80
+ * upload belongs to, and anyone who views your page can read it. If uploads
81
+ * to your account must be authorized, enable required signed policies for
82
+ * the account and mint a policy server-side (`security` below) — that is the
83
+ * credential. Treating the publishable key as a secret is the mistake this
84
+ * name exists to prevent.
85
+ *
86
+ * (The option is spelled `apikey`, lowercase, for backwards compatibility —
87
+ * renaming it would break every existing integration.)
88
+ */
66
89
  apikey: string;
67
- /** Base URL of the upload API. Defaults to the hosted endpoint. */
90
+ /**
91
+ * Base URL of the upload API. Defaults to the hosted endpoint
92
+ * (`https://api.postila.app`). Pass `''` to use same-origin relative URLs
93
+ * (e.g. behind a dev proxy).
94
+ */
68
95
  apiUrl?: string;
69
96
  /** Optional signed security policy. */
70
97
  security?: {
@@ -103,7 +130,11 @@ type UploaderClientOptions = {
103
130
  type UploadOptions = {
104
131
  /** Progress callback, value 0–100. */
105
132
  onProgress?: (percent: number) => void;
106
- /** Storage path prefix. */
133
+ /**
134
+ * @deprecated Ignored — the server assigns storage keys and no upload route
135
+ * reads a path prefix. Kept only for type compatibility; passing it has no
136
+ * effect on where the file is stored.
137
+ */
107
138
  path?: string;
108
139
  /** Override the file's stored name. */
109
140
  filename?: string;
@@ -131,6 +162,74 @@ type UploadAllOptions = UploadOptions & {
131
162
  /** Maximum concurrent uploads. Defaults to 3. */
132
163
  concurrency?: number;
133
164
  };
165
+ /** A signed policy + signature pair, as minted by your backend. */
166
+ type SecurityPair = {
167
+ policy: string;
168
+ signature: string;
169
+ };
170
+ /** Lifecycle status of a stored file. */
171
+ type StoredFileStatus = 'uploading' | 'stored' | 'processing' | 'ready' | 'flagged' | 'quarantined' | 'deleted';
172
+ /**
173
+ * One stored file's record, as returned by the file-management API
174
+ * (GET /api/files). Richer than the upload-time FileResult: carries lifecycle
175
+ * status, timestamps, image dimensions, and tags.
176
+ */
177
+ type StoredFileRecord = {
178
+ id: string;
179
+ handle: string;
180
+ filename: string;
181
+ mimetype: string;
182
+ size: number;
183
+ status: StoredFileStatus;
184
+ url: string;
185
+ /**
186
+ * ISO timestamp after which `url` stops working — present only for BYO Lite
187
+ * private-bucket presigned URLs (24h TTL). Absent = stable URL.
188
+ */
189
+ urlExpiresAt?: string;
190
+ createdAt: string;
191
+ updatedAt: string;
192
+ width?: number | null;
193
+ height?: number | null;
194
+ tags?: string[];
195
+ };
196
+ /** Query filters for listFiles. All optional; pages are fixed-size (50). */
197
+ type ListFilesQuery = {
198
+ /** Full-text search over filename (and extracted text). */
199
+ q?: string;
200
+ /** Mimetype prefix filter, e.g. "image" or "image/png". */
201
+ mimetype?: string;
202
+ status?: StoredFileStatus;
203
+ tag?: string;
204
+ sizeMin?: number;
205
+ sizeMax?: number;
206
+ /** ISO date bounds on creation time. */
207
+ dateFrom?: string;
208
+ dateTo?: string;
209
+ /** Sort key; prefix with '-' for descending, e.g. '-created_at'. */
210
+ sort?: 'created_at' | '-created_at' | 'size' | '-size' | 'filename' | '-filename';
211
+ /** 1-based page number. */
212
+ page?: number;
213
+ };
214
+ /** Paginated result of listFiles. */
215
+ type ListFilesResult = {
216
+ files: StoredFileRecord[];
217
+ total: number;
218
+ page: number;
219
+ pageSize: number;
220
+ };
221
+ /**
222
+ * Per-call options for the file-management methods.
223
+ *
224
+ * `security` overrides the client-level policy for this one call — useful
225
+ * because these operations need different policy `call` grants than uploads:
226
+ * listFiles needs `list`, getFile needs `read`, deleteFile needs `remove`
227
+ * (accounts without required signed policies need none of this).
228
+ */
229
+ type FileManageOptions = {
230
+ security?: SecurityPair;
231
+ signal?: AbortSignal;
232
+ };
134
233
 
135
234
  /**
136
235
  * UploaderClient — headless upload client.
@@ -143,6 +242,7 @@ type UploadAllOptions = UploadOptions & {
143
242
 
144
243
  declare class UploaderClient {
145
244
  #private;
245
+ /** The publishable key (`pk_…`) — a project identifier, not a credential. */
146
246
  readonly apikey: string;
147
247
  readonly apiUrl: string;
148
248
  readonly security: UploaderClientOptions['security'];
@@ -159,6 +259,39 @@ declare class UploaderClient {
159
259
  * CLIENT_ERROR | INVALID_RESPONSE
160
260
  */
161
261
  upload(file: File | Blob, opts?: UploadOptions): Promise<FileResult>;
262
+ /**
263
+ * List the account's files (paginated, 50 per page).
264
+ *
265
+ * Accounts with required signed policies must supply a policy whose `call`
266
+ * includes `'list'` — a handle-bound `'read'` policy from a delivery URL is
267
+ * deliberately not enough to enumerate the account.
268
+ *
269
+ * @throws {UploaderError} with code NETWORK_ERROR | SERVER_ERROR |
270
+ * CLIENT_ERROR | INVALID_RESPONSE
271
+ */
272
+ listFiles(query?: ListFilesQuery, opts?: FileManageOptions): Promise<ListFilesResult>;
273
+ /**
274
+ * Fetch one file's record by its public handle.
275
+ *
276
+ * Accounts with required signed policies must supply a policy whose `call`
277
+ * includes `'read'` (handle-bound policies must match this handle).
278
+ *
279
+ * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle
280
+ * does not exist (or belongs to another account).
281
+ */
282
+ getFile(handle: string, opts?: FileManageOptions): Promise<StoredFileRecord>;
283
+ /**
284
+ * Delete a file by its public handle.
285
+ *
286
+ * The file stops being served immediately (soft-delete + edge cache purge);
287
+ * the stored bytes and derivatives are removed by a background cleanup.
288
+ * Accounts with required signed policies must supply a policy whose `call`
289
+ * includes `'remove'` (handle-bound policies must match this handle).
290
+ *
291
+ * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle
292
+ * does not exist (or belongs to another account).
293
+ */
294
+ deleteFile(handle: string, opts?: FileManageOptions): Promise<void>;
162
295
  /**
163
296
  * Upload multiple files with concurrency limiting.
164
297
  *
@@ -172,4 +305,4 @@ declare class UploaderClient {
172
305
  uploadAll(files: Array<File | Blob>, opts?: UploadAllOptions): Promise<PromiseSettledResult<FileResult>[]>;
173
306
  }
174
307
 
175
- export { type DeliveryProtection as D, type FileResult as F, type PickerResponse as P, type UploadAllOptions as U, type PolicySpec as a, type UploadOptions as b, UploaderClient as c, type UploaderClientOptions as d, type UsageWarning as e };
308
+ export { type DeliveryProtection as D, type FileManageOptions as F, type ListFilesQuery as L, type PickerResponse as P, type SecurityPair as S, type UploadAllOptions as U, type FileResult as a, type ListFilesResult as b, type PolicySpec as c, type StoredFileRecord as d, type StoredFileStatus as e, type UploadOptions as f, UploaderClient as g, type UploaderClientOptions as h, type UsageWarning as i };
@@ -16,6 +16,13 @@ type FileResult = {
16
16
  size: number;
17
17
  status: 'Stored';
18
18
  uploadId?: string;
19
+ /**
20
+ * ISO timestamp after which `url` stops working. Present ONLY for BYO Lite
21
+ * private-bucket presigned URLs (24h TTL); absent means the URL is stable.
22
+ * Store the `handle` and re-fetch (getFile/listFiles) rather than persisting
23
+ * an expiring URL — or set a `public_base_url` for durable links.
24
+ */
25
+ urlExpiresAt?: string;
19
26
  };
20
27
  /** Response from the picker overlay / upload batch. */
21
28
  type PickerResponse = {
@@ -39,14 +46,17 @@ type PolicySpec = {
39
46
  };
40
47
  /**
41
48
  * A non-disruptive usage warning surfaced alongside an upload response (mirrors
42
- * @uploader/shared UsageWarning). Bandwidth limits are SOFT delivery is never
43
- * blocked when exceeded so this is only ever an informational heads-up when the
44
- * account is approaching or over its included monthly bandwidth.
49
+ * @uploader/shared UsageWarning). Fires when the account is approaching (85%) or
50
+ * over an included monthly allowance. `type` names the dimension; for `bandwidth`
51
+ * delivery is soft (never blocked), while storage/transform/uploads pause when
52
+ * exceeded — the `message` states each case.
45
53
  */
46
54
  type UsageWarning = {
47
- type: 'bandwidth';
55
+ type: 'storage' | 'bandwidth' | 'transform' | 'uploads';
48
56
  level: 'approaching' | 'over';
57
+ /** Month-to-date usage: bytes for storage/bandwidth, a count for transform/uploads. */
49
58
  usedBytes: number;
59
+ /** Included allowance, same unit as usedBytes. */
50
60
  limitBytes: number;
51
61
  percent: number;
52
62
  message: string;
@@ -62,9 +72,26 @@ type UsageWarning = {
62
72
  */
63
73
  type DeliveryProtection = 'public' | 'hotlink' | 'signed';
64
74
  type UploaderClientOptions = {
65
- /** Public API key (pk_...). */
75
+ /**
76
+ * Your **publishable key** (`pk_…`) — a project identifier, safe to ship in
77
+ * client code.
78
+ *
79
+ * Deliberately NOT called "authentication": it identifies which account an
80
+ * upload belongs to, and anyone who views your page can read it. If uploads
81
+ * to your account must be authorized, enable required signed policies for
82
+ * the account and mint a policy server-side (`security` below) — that is the
83
+ * credential. Treating the publishable key as a secret is the mistake this
84
+ * name exists to prevent.
85
+ *
86
+ * (The option is spelled `apikey`, lowercase, for backwards compatibility —
87
+ * renaming it would break every existing integration.)
88
+ */
66
89
  apikey: string;
67
- /** Base URL of the upload API. Defaults to the hosted endpoint. */
90
+ /**
91
+ * Base URL of the upload API. Defaults to the hosted endpoint
92
+ * (`https://api.postila.app`). Pass `''` to use same-origin relative URLs
93
+ * (e.g. behind a dev proxy).
94
+ */
68
95
  apiUrl?: string;
69
96
  /** Optional signed security policy. */
70
97
  security?: {
@@ -103,7 +130,11 @@ type UploaderClientOptions = {
103
130
  type UploadOptions = {
104
131
  /** Progress callback, value 0–100. */
105
132
  onProgress?: (percent: number) => void;
106
- /** Storage path prefix. */
133
+ /**
134
+ * @deprecated Ignored — the server assigns storage keys and no upload route
135
+ * reads a path prefix. Kept only for type compatibility; passing it has no
136
+ * effect on where the file is stored.
137
+ */
107
138
  path?: string;
108
139
  /** Override the file's stored name. */
109
140
  filename?: string;
@@ -131,6 +162,74 @@ type UploadAllOptions = UploadOptions & {
131
162
  /** Maximum concurrent uploads. Defaults to 3. */
132
163
  concurrency?: number;
133
164
  };
165
+ /** A signed policy + signature pair, as minted by your backend. */
166
+ type SecurityPair = {
167
+ policy: string;
168
+ signature: string;
169
+ };
170
+ /** Lifecycle status of a stored file. */
171
+ type StoredFileStatus = 'uploading' | 'stored' | 'processing' | 'ready' | 'flagged' | 'quarantined' | 'deleted';
172
+ /**
173
+ * One stored file's record, as returned by the file-management API
174
+ * (GET /api/files). Richer than the upload-time FileResult: carries lifecycle
175
+ * status, timestamps, image dimensions, and tags.
176
+ */
177
+ type StoredFileRecord = {
178
+ id: string;
179
+ handle: string;
180
+ filename: string;
181
+ mimetype: string;
182
+ size: number;
183
+ status: StoredFileStatus;
184
+ url: string;
185
+ /**
186
+ * ISO timestamp after which `url` stops working — present only for BYO Lite
187
+ * private-bucket presigned URLs (24h TTL). Absent = stable URL.
188
+ */
189
+ urlExpiresAt?: string;
190
+ createdAt: string;
191
+ updatedAt: string;
192
+ width?: number | null;
193
+ height?: number | null;
194
+ tags?: string[];
195
+ };
196
+ /** Query filters for listFiles. All optional; pages are fixed-size (50). */
197
+ type ListFilesQuery = {
198
+ /** Full-text search over filename (and extracted text). */
199
+ q?: string;
200
+ /** Mimetype prefix filter, e.g. "image" or "image/png". */
201
+ mimetype?: string;
202
+ status?: StoredFileStatus;
203
+ tag?: string;
204
+ sizeMin?: number;
205
+ sizeMax?: number;
206
+ /** ISO date bounds on creation time. */
207
+ dateFrom?: string;
208
+ dateTo?: string;
209
+ /** Sort key; prefix with '-' for descending, e.g. '-created_at'. */
210
+ sort?: 'created_at' | '-created_at' | 'size' | '-size' | 'filename' | '-filename';
211
+ /** 1-based page number. */
212
+ page?: number;
213
+ };
214
+ /** Paginated result of listFiles. */
215
+ type ListFilesResult = {
216
+ files: StoredFileRecord[];
217
+ total: number;
218
+ page: number;
219
+ pageSize: number;
220
+ };
221
+ /**
222
+ * Per-call options for the file-management methods.
223
+ *
224
+ * `security` overrides the client-level policy for this one call — useful
225
+ * because these operations need different policy `call` grants than uploads:
226
+ * listFiles needs `list`, getFile needs `read`, deleteFile needs `remove`
227
+ * (accounts without required signed policies need none of this).
228
+ */
229
+ type FileManageOptions = {
230
+ security?: SecurityPair;
231
+ signal?: AbortSignal;
232
+ };
134
233
 
135
234
  /**
136
235
  * UploaderClient — headless upload client.
@@ -143,6 +242,7 @@ type UploadAllOptions = UploadOptions & {
143
242
 
144
243
  declare class UploaderClient {
145
244
  #private;
245
+ /** The publishable key (`pk_…`) — a project identifier, not a credential. */
146
246
  readonly apikey: string;
147
247
  readonly apiUrl: string;
148
248
  readonly security: UploaderClientOptions['security'];
@@ -159,6 +259,39 @@ declare class UploaderClient {
159
259
  * CLIENT_ERROR | INVALID_RESPONSE
160
260
  */
161
261
  upload(file: File | Blob, opts?: UploadOptions): Promise<FileResult>;
262
+ /**
263
+ * List the account's files (paginated, 50 per page).
264
+ *
265
+ * Accounts with required signed policies must supply a policy whose `call`
266
+ * includes `'list'` — a handle-bound `'read'` policy from a delivery URL is
267
+ * deliberately not enough to enumerate the account.
268
+ *
269
+ * @throws {UploaderError} with code NETWORK_ERROR | SERVER_ERROR |
270
+ * CLIENT_ERROR | INVALID_RESPONSE
271
+ */
272
+ listFiles(query?: ListFilesQuery, opts?: FileManageOptions): Promise<ListFilesResult>;
273
+ /**
274
+ * Fetch one file's record by its public handle.
275
+ *
276
+ * Accounts with required signed policies must supply a policy whose `call`
277
+ * includes `'read'` (handle-bound policies must match this handle).
278
+ *
279
+ * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle
280
+ * does not exist (or belongs to another account).
281
+ */
282
+ getFile(handle: string, opts?: FileManageOptions): Promise<StoredFileRecord>;
283
+ /**
284
+ * Delete a file by its public handle.
285
+ *
286
+ * The file stops being served immediately (soft-delete + edge cache purge);
287
+ * the stored bytes and derivatives are removed by a background cleanup.
288
+ * Accounts with required signed policies must supply a policy whose `call`
289
+ * includes `'remove'` (handle-bound policies must match this handle).
290
+ *
291
+ * @throws {UploaderError} — CLIENT_ERROR with statusCode 404 when the handle
292
+ * does not exist (or belongs to another account).
293
+ */
294
+ deleteFile(handle: string, opts?: FileManageOptions): Promise<void>;
162
295
  /**
163
296
  * Upload multiple files with concurrency limiting.
164
297
  *
@@ -172,4 +305,4 @@ declare class UploaderClient {
172
305
  uploadAll(files: Array<File | Blob>, opts?: UploadAllOptions): Promise<PromiseSettledResult<FileResult>[]>;
173
306
  }
174
307
 
175
- export { type DeliveryProtection as D, type FileResult as F, type PickerResponse as P, type UploadAllOptions as U, type PolicySpec as a, type UploadOptions as b, UploaderClient as c, type UploaderClientOptions as d, type UsageWarning as e };
308
+ export { type DeliveryProtection as D, type FileManageOptions as F, type ListFilesQuery as L, type PickerResponse as P, type SecurityPair as S, type UploadAllOptions as U, type FileResult as a, type ListFilesResult as b, type PolicySpec as c, type StoredFileRecord as d, type StoredFileStatus as e, type UploadOptions as f, UploaderClient as g, type UploaderClientOptions as h, type UsageWarning as i };