@adonis-agora/media
Version:
Media-library for AdonisJS — owner collections (MIME whitelist, single-file replace, ordering), image conversions (eager/lazy), pluggable content transformers (HLS video via mediabunny, metadata probe, image blur-up placeholder), and column attachments, a
1,357 lines • 186 kB
Markdown
# @adonis-agora/media
## 1.1.1
### Patch Changes
- [#394](https://github.com/DavideCarvalho/adonis-agora-media/pull/394) [`652db90`](https://github.com/DavideCarvalho/adonis-agora-media/commit/652db90ea257b63fd83277ad594d4a9ea6f81442) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `node ace configure @adonis-agora/media --topology=tenant` publishes `config/media.ts` in the one-line tenant form (`defineConfig({ topology: 'tenant' })`), with a note that url, token and partition come from `@adonis-agora/authkit-client` and the explicit `tenant` fields commented out, and skips the store, upload-session and tenancy migrations a tenant never uses. Without the flag, configure is unchanged.
## 1.1.0
### Minor Changes
- [#386](https://github.com/DavideCarvalho/adonis-agora-media/pull/386) [`2ec18af`](https://github.com/DavideCarvalho/adonis-agora-media/commit/2ec18af62c521a301deb52ad09977e786a81fb09) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `topology: 'tenant'` needs no `tenant` block when `@adonis-agora/authkit-client` is booted with its `service` configured: its `authkit.client.tenantOf('urn:agora:media')` supplies `tenant.url`, `tenant.token` and `tenant.partition`. Detected by shape (no dependency on authkit-client; a version without `tenantOf` counts as absent). Each field set in `tenant` wins, one by one, and `tenant: { auto: false }` turns it off. With neither, a web boot fails naming both fixes. `agora:doctor`'s `media.topology` shows where each field came from (`authkit-client (auto)` or `explicit`), and `media.control-plane` checks the filled-in client.
## 1.0.0
### Major Changes
- [#284](https://github.com/DavideCarvalho/adonis-agora-media/pull/284) [`ddf507b`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ddf507bf477c00e89f8ca4ab033f56efd56519ad) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The media console is closed in production until you set `authorize`. Without `authorize` in `config/media_dashboard.ts`, the console is open outside production and in production answers `403` to every page and API request. Either way it logs once at boot: ``[@adonis-agora/media] console has no `authorize` configured: it is open outside production and denies every request in production. Set `authorize` in config/media_dashboard.ts.`` Before, it was open in every environment unless `middleware` or `auth` closed it. `authorize` runs before `middleware`, so a console guarded only by `middleware` needs `authorize` too, for example `authorize: () => true` to keep your middleware as the gate.
`authorize` now takes the access contract shared by every Agora console, in three forms: an inline function `(ctx) => result`, a `ConsoleAuthorizer` class (built through the container, so `@inject()` works), or a lazy import of one (`() => import('#policies/console_access')`, loaded once). A check may also answer `{ redirectTo: '/login' }`: page navigations are redirected there and API calls get `401`. Every result the hook accepted before keeps working, and a check that throws is still a `403`.
API refusals now answer `{ error: 'forbidden' }` (`403`) and `{ error: 'unauthenticated' }` (`401`, plus `redirectTo` when the check asked for a redirect), the same bodies as every other Agora console. Before they were `{ error: 'Forbidden' }` and `{ error: 'Unauthorized' }`.
New `authorizeByToken({ token })` for machine access: `authorize: authorizeByToken({ token: env.get('CONSOLE_TOKEN') })` allows requests with `Authorization: Bearer <token>` and answers `401` otherwise. An empty or missing token throws when the config loads.
The `DashboardAuthorize`, `AuthorizeResult` and `AuthorizeDecision` types are replaced by `ConsoleAuthorize`, `ConsoleAuthorizeResult` and `ConsoleAuthorizer`, exported from `@adonis-agora/media/dashboard` together with `resolveConsoleAuthorize` and `authorizeByToken`.
The console no longer has a login of its own: the `auth` option of `config/media_dashboard.ts` is removed, with no alias. Gone with it: the console's login screen and sign out button, the `GET /me`, `POST /login`, `POST /session` and `POST /logout` API routes, the `media_dashboard_session` cookie and its `secret`/`ttl`/`session`/`login`/`revalidate` hooks, and the exports `resolveConsoleAuth`, `signSessionCookie`, `verifySessionCookie` and the types `ConsoleAuthOptions`, `ResolvedConsoleAuth`, `ConsoleSession`, `ConsoleSessionUser`, `ConsoleSessionUserInfo`, `AuthMode`, `SessionHook`, `LoginHook`, `RevalidateHook`, `MeResponse` and `LoginBody` (from `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard`). Sign-in is your app's own: gate the console in `authorize` and return `{ redirectTo: '/login' }` for a signed-out visitor. When one of the console's API calls answers `401`, the console follows that `redirectTo`, or reloads the page when there is none. `@adonis-agora/media-dashboard`'s client drops `me()`, `login()`, `logout()` and `ConsoleAuthState`, and takes an `onUnauthenticated` option (default `followUnauthenticated`).
`@adonis-agora/media-react` drops the console launcher, which only minted the removed console session: `OpenMediaDashboardButton`, `useOpenMediaDashboard`, `openMediaDashboardMutationOptions`, `openMediaDashboard`, `mintMediaDashboardSession`, `mediaDashboardSessionUrl`, `mediaDashboardUrl`, `ConsoleSessionError` and their types. Link to the console's `basePath` instead.
- [#301](https://github.com/DavideCarvalho/adonis-agora-media/pull/301) [`4fdd451`](https://github.com/DavideCarvalho/adonis-agora-media/commit/4fdd4513f77c5d640bafee365ef7bf22afb557cc) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The console's list routes use the `@adonis-agora/filter` list format.
- `GET /objects`: `?disk=&prefix=` → `?filter[disk]=&filter[prefix]=` (`filter[disk]` required). Paging stays `after` / `first` (default and max 1000). The response is `{ data, meta: { nextCursor, prevCursor, hasNext, hasPrev } }`; `data` holds folders, then files, each tagged `type: 'folder' | 'file'` (was `{ folders, files, nextCursor, prevCursor, hasNext, hasPrev }`). `sort` accepts only `key`.
- `GET /collections`: `?collection=&ownerType=&ownerId=&prefix=` → `?filter[collection]=&filter[ownerType]=&filter[ownerId]=&filter[prefix]=`. Paging stays `after` / `first` (default 50, max 200). The response is `{ data, meta }` (was `{ items, nextCursor, prevCursor, hasNext, hasPrev }`). `sort` accepts only `-createdAt`.
- `GET /uploads`: `?disk=&prefix=` → `?filter[disk]=&filter[prefix]=`; `sort=createdAt|-createdAt` (default newest first). Response `{ data }` (was `{ uploads }`).
- `GET /disks` answers `{ data }` (was `{ disks }`); `GET /collections/summary` answers `{ data }` (was `{ collections }`).
- An unknown filter field, an operator other than equality, a sort outside the route's list, or `before` / `last` is a `400`.
- `DashboardService`: `objects()` and `collections()` return `CursorPageResponse<T>` (`{ data, meta }`); `disks()`, `uploads()` and `collectionsSummary()` return `{ data }`; `uploads()` takes `order: 'asc' | 'desc'`.
- Types: `CursorPage` and `CursorPageInfo` are removed; new `CursorPageResponse<T>`, `CursorPageMeta`, `ListResponse<T>`, `ObjectListItem`, `UploadFilter`. `ObjectListResponse`, `CollectionListResponse`, `DiskListResponse`, `UploadListResponse` and `CollectionsSummaryResponse` change shape as above.
- New `readObjectsQuery`, `readCollectionsQuery` and `readUploadsQuery` in `@adonis-agora/media/dashboard` read these routes' query strings for your own routes.
- `@adonis-agora/media` now depends on `@adonis-agora/filter`.
- [#281](https://github.com/DavideCarvalho/adonis-agora-media/pull/281) [`94f8af1`](https://github.com/DavideCarvalho/adonis-agora-media/commit/94f8af12bb87bf614a8ff0262958dd6120708851) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Release 1.0. Every export, option, subpath and ace command of `@adonis-agora/media` and `@adonis-agora/media-react` from 0.x works unchanged (see "Migrating to 1.0" in the docs). One behaviour is gone: the embedded console no longer reads a `window.__MEDIA_DASHBOARD__` global, only the JSON data block the provider injects.
- Node.js 24 or later is required (`engines.node: ">=24"`, unchanged).
- `@adonis-agora/media` accepts `@adonis-agora/authz`, `@adonis-agora/authkit-client`, `@adonis-agora/authkit-server` and `@adonis-agora/telescope` 1.x, including the 1.0 release candidates (`<lower> <2.0.0 || >=1.0.0-rc.0 <2.0.0`, lower bounds unchanged).
### Minor Changes
- [#304](https://github.com/DavideCarvalho/adonis-agora-media/pull/304) [`a1a5ab4`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a1a5ab4315225caa605e44f37ba034b761d5481b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console shell: the media console is rebuilt on the Agora console kit, the shell every `@adonis-agora` console now shares. Its accent is amber (the access-denied page follows).
- Left sidebar with the brand (the console switcher), nav grouped as LIBRARY (Library, Collections) and TRANSFERS (Uploads, Upload), and a footer with the signed-in user, a theme toggle and sign-out. Below 768px the sidebar becomes a drawer.
- Topbar with the page title, the organization picker, the disk / uploads / actions pills, the live dot and ⌘K search across consoles.
- Each page opens with metric cards (disks and folder contents, record totals, sessions in progress). Library rows keep Preview inline and move copy key / copy / move / rename / delete into a row menu. Lists page with "Load more" on the cursor envelope.
- Light mode. The theme is remembered per console in localStorage.
- Fonts are bundled (Sora, JetBrains Mono); the page no longer loads Google Fonts.
- Every page and region has its own error boundary with a retry button, shaped skeletons and empty states.
Server: the page's data block gains `search`, `viewer` and `signOut`. The new `viewer(ctx)` config option sets the user row; without it the console reads `ctx.auth.user` when the request is already authenticated. The new `signOut` option takes a POST action path, `{ href }` or `false`; without it the console uses the sign-out an account console announces on the `agora.consoles` registry (`account.signOut`). A POST sign-out carries the request's CSRF token.
- [#342](https://github.com/DavideCarvalho/adonis-agora-media/pull/342) [`32c3445`](https://github.com/DavideCarvalho/adonis-agora-media/commit/32c3445e7cd5413d2d2f72c6ec5c64f6a9f28272) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Federated console: `proxyActions` on an `apps` entry sends this console's actions on that app's media (delete, copy, move, folders, delete record, cancel upload) to the app's own console API over HTTP (`POST` on its `origin` + `apiPath`, headers only to that origin, `redirect: 'manual'`), and the app runs them with its own store and disks. A new per-app `actions` overrides the console's own switch for that app. `/apps` now says, per app, `mode: 'federated'` and who runs its actions (`actions: 'app' | 'none'`).
App side: `authorizeAppCaller({ identify, permit })` lets another app's console read object bytes (`media:objects:read`) and run the action routes (`media:objects:write`, listed in `MEDIA_ACTION_ROUTES`), with presets `identifyAgoraCaller()` / `identifySharedSecret()` and `permitTokenCapabilities()` / `permitAll()`. `authorizeAgoraCaller()` takes `actions: true` to open the action routes. `mediaCallerCsrfExceptions()` lets those calls through shield's CSRF check.
Console UI: federated apps carry a "federated" badge in the App picker, a notice at the top of the page says where their data comes from and who runs actions, and the actions of a read-only federated app show disabled with the reason.
- [#336](https://github.com/DavideCarvalho/adonis-agora-media/pull/336) [`53d7ddd`](https://github.com/DavideCarvalho/adonis-agora-media/commit/53d7dddc463993f1509e37d1bdaac872c6d78d36) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Federated console: the media console can also show other apps' media, with an **App** selector (`?app=` in the URL). Each app keeps its own tables, disks and credentials. `config/media_dashboard.ts` gains `apps` (`label`, `store`, `uploadSessions`, `controlPlane: { connection, prefix }`, `origin`, `timeoutMs`) and `appLabel`; records, collections and upload sessions are read from the other app's tables (read-only, never created or altered), and disks, object URLs and the actions are asked of that app over Redis, which answers with `consoleCommands: { connection, prefix, actions }` in its `config/media.ts` (one instance runs each command, claimed with `SET NX`). New `GET <api>/apps`; `authorize` may grant `apps`. An unknown app answers 404, an app that does not answer 503, an app error 502, a command it does not run 501. Uploading from the console stays the console app's own.
- [#340](https://github.com/DavideCarvalho/adonis-agora-media/pull/340) [`9cb2d96`](https://github.com/DavideCarvalho/adonis-agora-media/commit/9cb2d96bfe7e514f5b6b65d96b6f686a44308c5a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Federated console: `proxyObjects` on an `apps` entry serves that app's object bytes from this console (same origin), fetching them from the app with optional `headers` (a service token). Previews, thumbnails and "Open" then work without a session in the other app and under a strict `img-src`. New `authorizeAgoraCaller()` lets another Agora app holding `media:objects:read` read `GET <apiBase>/object/raw`, and `capabilityAllows()` is exported. `object/raw` now serves HTML, SVG, XML and scripts as downloads with a sandboxing CSP and `nosniff`.
- [#289](https://github.com/DavideCarvalho/adonis-agora-media/pull/289) [`d13f522`](https://github.com/DavideCarvalho/adonis-agora-media/commit/d13f5227c318bf84df2bc2bf0896208c1988e6cb) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A "My files" page in the authkit account console (`/account/files`), registered automatically when authkit's `'authkit.accountExtensions'` registry is in the app (authkit-server, or authkit-client with remote pages). Nothing is exposed until `accountConsole.collections` in `config/media.ts` lists a collection; each listed collection gets browse, upload, rename, delete (confirmed, sudo) and download (short-lived signed URLs), each allowed by that collection's own `access` rules and switchable per collection. Owner defaults to authkit's mapped subject (`owner` hook to override); with tenancy on, the page follows the active organization. Uploads use a same-origin script (`<path>/upload.js`) and a ticket-authorized endpoint (`POST <path>/uploads`, default `/media/account`); `publicUrl` serves remote IdPs. New `media.library.page(ownerType, ownerId, { collections, cursor, limit })`, `media.library.rename(id, name)`, and the optional store method `MediaStore.listByOwnerPaged` (both bundled stores implement it). No runtime dependency on authkit.
- [#290](https://github.com/DavideCarvalho/adonis-agora-media/pull/290) [`cd949a0`](https://github.com/DavideCarvalho/adonis-agora-media/commit/cd949a034a7632bba2ba9246a798d611c486409b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `node ace agora:doctor` (and `media:doctor`): one health check for every installed `@adonis-agora` lib, the same command every lib ships (canonical revision 1.1). Media adds `media.disks` (every disk it writes to exists), `media.console-gate` (console `authorize`, an error in production), `media.account-console` (listed collections exist and have rules) and `media.tenancy-schema` (deep: the `tenant_id` column with tenancy on). New subpath `./doctor`; the commands are in the `@adonis-agora/media/commands` barrel `configure` registers.
- [#306](https://github.com/DavideCarvalho/adonis-agora-media/pull/306) [`71900c9`](https://github.com/DavideCarvalho/adonis-agora-media/commit/71900c94effc0bc6dc180f5397bc4b70ad94edb3) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Every media console action is now a `node ace` command: `media:disks:list`, `media:objects:list`, `media:objects:show`, `media:objects:upload`, `media:objects:copy`, `media:objects:move`, `media:objects:rename`, `media:objects:delete`, `media:folders:create`, `media:collections:list`, `media:records:list`, `media:records:show`, `media:records:delete`, `media:uploads:list`, `media:uploads:show` and `media:uploads:abort`. They use the console's settings from `config/media_dashboard.ts` (its disks, its `actions` switch, its object URLs), print `--json` in the console API's `{ data, meta }` shape, take `--tenant=<id>` with tenancy on, ask before a destructive change unless `--force`, and exit with code `1` on failure. See the new CLI page in the docs.
- [`68c904e`](https://github.com/DavideCarvalho/adonis-agora-media/commit/68c904e832c91ab8d17edaedbeb5143349163bbe) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Security fixes (found in an internal security audit). **Breaking**, see each item.
**The federated console's Redis channel is authenticated.** Every request (reads included: listing disks and objects and signing URLs for any key used to run for anyone who could publish on Redis) and every answer is authenticated; a request over a minute old is refused, a replay runs once, a forged answer is ignored.
- **Zero configuration with `@adonis-agora/crypto`**: when crypto runs in both apps, requests are sealed with the crypto key `console-media` in the owning app's crypto partition, with no auth line in either config. The Hub (crypto embedded) creates the key and encrypts as `media:console`; a console that is a crypto tenant seals through its own crypto channel (`crypto:seal:console-*`); the owning app decrypts with its own (`crypto:decrypt:console-*`) and creates the key at boot when it may, or logs the exact command to run. A federated app's new `partition` option (default: its key) names its crypto partition.
- **Zero configuration with authkit's calls between apps**: the console sends its app-call token for the app, which the app verifies (audience-bound); the capabilities authkit granted the console app cap the request. With crypto too, the request is sealed and carries the token.
- Explicit modes stay: `crypto` (any cipher, `owns` for a KMS of your own), `token` + `publicKey` / `verifyTenant` (authkit service-tenant tokens or your own verifier; a control plane's own `verifyTenant` is the fallback), and the shared `secret`. Explicit options win; `crypto: false`, `token: false` and `verifyTenant: false` turn a detection off. New: `node ace media:console-key`.
- **Breaking:** the default crypto key is `console-media` (was `media-console`). An app with `consoleCommands` and no way to authenticate now **fails to boot** (web processes) with the line to add, and so does a console entry that may run actions (`actions: false` only warns). The console always sends the viewer's capabilities (`authorize` may return `capabilities`, narrowed to `media:objects:read`/`write`, also `media:console:read`/`write`/`*`), and the app refuses a request without them. Upgrade the console and its apps together.
- New `agora:doctor` checks: `media.console-commands` (the mode each side resolved, matching what boot does) and the deep `media.console-commands-key` (in crypto mode, a probe encrypted and decrypted).
- **Breaking:** a console's `apps` entries default `actions` to `true` (they used to follow the console's own `actions`); the app's `consoleCommands.actions` still decides, and `actions: false` makes an entry browse-only. A refusal for a missing viewer capability set has the code `capabilities-required`; refusals say who lacks a capability ("the console's token lacks …" / "the viewer lacks …"). `anyAuthorize` keeps the deciding authorizer's `capabilities`, and `authorize` may answer `access: 'read'`. A viewer's `capabilities` / `access: 'read'` now restrict the console's actions on its own app too (`403` "the viewer lacks media:objects:write", action buttons disabled); an `authorize` that says nothing keeps full access.
**A control plane no longer crashes on a crafted query.** `?conversion=` and `?w=` were written into the `ETag` before validation, so a control character or a non-latin-1 character killed the process when the response was written, reachable by tenant tokens and, with proxy delivery, by anonymous visitors of a tenant. They are now validated first (`400`: a conversion name, `w` in 1–8192, `q` in 1–100), the ETag is always header-safe (and distinct per quality), and every `Content-Type` this package sends from a record, a disk or another app is checked. A declared `mimeType` (`x-media-attach`, `x-media-mime-type`) must be a bare `type/subtype`.
**Generating a conversion needs write**: `POST /records/:id/conversions/:conversion` and `GET /records/:id/image?generate=1` on a control plane need `media:write` (read-only tokens get `403`).
**Breaking: the built-in upload routes (`uploads.routes`) never take a key or a free disk from the client.** The client sends a `fileName`; the key is derived on the server (`routes.keyFor`, default `uploads/<uuid>/<fileName>`), the disk is `routes.disk` or one of `routes.disks`, and the multipart parts/complete/abort calls need the `uploadToken` the initiate answered. A client `visibility` is no longer read. New `routes.middleware`: without it the routes do not mount in production (the boot says what to add; `allowUnguarded: true` when a global middleware guards them) and warn elsewhere. The same guard (`middleware`, `allowUnguarded`) now applies to the TUS (`uploads.resumable.routes`) and direct-session (`uploads.direct.routes`) routes: without middleware they do not mount in production either. Upload tokens and the account console's upload tickets are signed with `APP_KEY` (or the new `uploads.secret`); without either the app fails to boot in production when it mounts them (a per-process key, with a warning, only outside production). `@adonis-agora/media-react`'s proxy upload sends `fileName` and uses the key the server answers (`meta.key` is ignored).
**The console access contract is the one every Agora lib shares** (`console_authorize.ts`, identical across the libs). Breaking for code that reads decisions directly: `resolveConsoleAuthorize`/`normalizeConsoleAuthorizeResult` answer a sign-in redirect as `{ allowed: false, status: 302, redirectTo }` (was `401` + `redirectTo`; the console still answers the API with `401 { error: 'unauthenticated', redirectTo }` and redirects pages), a refusal from a throwing check carries its `error`, `anyAuthorize` rethrows it when every check refused, `apps`/`tenants` lists are kept as given (numbers as strings, empty names dropped), and `access` is kept as a field (`viewerConsoleCapabilities(decision)` turns it into media's capabilities). Media's additions (`capabilityAllows`, `capabilitiesAllow`, `MEDIA_OBJECTS_*`, `authorizeAgoraCaller` and the app-caller helpers) moved to `console_apps.ts`; `@adonis-agora/media/dashboard` exports them as before. `authorizeByToken` accepts `apps`, `tenants`, `capabilities` and `access`.
**Console capabilities use the one matcher every Agora lib shares** (`console_capabilities.ts`): `*`, `media:*`, `media:console:*`, `media:console:write` (reads and writes), `media:console:read` (reads), the exact name, or a hierarchical grant like `media:objects:*`. **Breaking (security):** a `*` anywhere else grants nothing (`media:*:write`, `*:objects:write`, `*:console:*` used to widen). This applies to console tokens, viewer capabilities, app callers over HTTP (`permitTokenCapabilities`) and the console's own actions; `capabilityAllows` / `capabilitiesAllow` follow it. The owning app checks a command in a fixed order: capabilities present, the console's token, the viewer, the token's partition, then `consoleCommands.actions`.
**Uniform messages across the Agora libs.** The boot errors (`ConsoleAuthConfigError`), the mode labels (`crypto (auto, key console-media)`, `token checked when sent (…)`, `token (…; sealed to <id>)`, `secret`), the `; actions on|off` boot line and the console-side timeout (`no instance of "<app>" answered within <n>s — …`) follow one template. The boot log no longer prints the app's command public key (only its short id, in token mode; `node ace media:console-key` prints it). The Hub creates each app's `console-media` key at boot (not on the first command), and `media.console-commands-key` checks it from the console too. A garbage or refused message on the channel is logged once per reason and dropped.
**Libs coordinate through their siblings.** With authkit's calls between apps and no crypto, an app in token mode publishes its command public key in authkit's key directory at boot (purpose `console:media`) and the console fetches it from there: no `controlPlane.publicKey` to copy (an explicit one still wins). An app opens its own `console-*` crypto keys with no grant (the `crypto:decrypt:console-*` grant is no longer needed, harmless if present); a key not created yet on a crypto tenant is one info line (the crypto server creates it on the console's first seal). Zero config: together with the Hub's crypto, no lines and no grants; a separate crypto app, only the console's `crypto:seal:console-*`; authkit without crypto, no lines and one authkit grant (the console app gets `media:console:*`, or narrower, on the owning app: the token is mandatory there and caps every command).
A refused command is logged once per reason as `console commands: refused a command (<reason>)` (`not JSON`, `no command id`, `did not open with this app's key`, `bad signature`, `stale`, `replayed`, `token refused`, `capabilities-required`, `mode not accepted here (…)`); the token mode shows its key as `sealed to key <8-char id>`; the doctor uses the boot log's sentences. Media opens no long-lived connection in a console (ace) process.
**Mixed Hubs.** A console with crypto and authkit picks the way to each app lazily (the app's key in authkit's directory → token mode, else crypto), cached and decided again after 5 minutes or a refused command. In crypto mode a failing app-call token never blocks a command (it goes crypto-only, one warning with the grant to add, retried in 5 minutes). The APP_KEY is read from `config/app.ts`, else `config/encryption.ts` (AdonisJS 7), else the environment. An app publishes its key in authkit's directory only when token mode is its only way in; with crypto active it says nothing about it. The crypto key check uses crypto's `hasKey` when available (no decrypt error rows in the crypto audit).
- [#287](https://github.com/DavideCarvalho/adonis-agora-media/pull/287) [`bbca45d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/bbca45d5ef0f0090291cdaf5b0617d6ad198009c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The media console joins the Agora console switcher. It registers itself in the app's `'agora.consoles'` registry (created by whichever console boots first), and its brand becomes a menu to the other Agora consoles the viewer may open, each checked with that console's own `authorize` (300 ms each, in parallel; `ctx.agoraProbe` is `true` while they run). Ctrl/Cmd-K searches every console the viewer may open; media answers record ids, collection names and disk names. New routes: `GET <apiBase>/consoles` and `GET <apiBase>/consoles/search?q=`, behind the console's `authorize`. `registerAgoraConsole` is exported from `@adonis-agora/media/dashboard` for consoles an app mounts itself. The Collections view opens filtered from `#/collections?collection=<name>`. Nothing changes for an app with a single console.
- [#349](https://github.com/DavideCarvalho/adonis-agora-media/pull/349) [`f9345d8`](https://github.com/DavideCarvalho/adonis-agora-media/commit/f9345d83b99aabe7a6007d62d9aedbb0a9bc15a6) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Control plane and tenants: several apps can keep their media on one central app. `config/media.ts` gains `topology: 'standalone' | 'control-plane' | 'tenant'`.
- **Control plane** (`topology: 'control-plane'`, `verifyTenant`, `controlPlane: { prefix, collections, maxBytes, accounts }`): mounts the tenant API under `/_media/v1`. Each request carries an app's service token (`authkitTenantVerifier({ issuer, resource: 'urn:agora:media' })` or `sharedSecretVerifier({ partitions })`); the app and its capabilities (`media:read`, `media:write`) come from the token. Each app's records and files are kept apart (owner type `<app>/<ownerType>`, keys under `<app>/`), and the control plane runs the collections' rules and conversions.
- **Tenant** (`topology: 'tenant'`, `tenant: { url, partition, token, urls, timeoutMs, uploadTimeoutMs, retries }`): `media.library` keeps its API (`attach`, `list`, `find`, `for`, `page`, `rename`, `delete`, `ensureConversion`, `url`, `signedUrl`, `image`, `deliver`) and runs it on the control plane; `media.access` and the delivery route work unchanged. `url` takes `controlPlaneUrl({ issuer, resource: 'urn:agora:media' })`. URLs point at the app's own delivery route by default (`urls: 'app'`), or at the control plane's storage URLs (`urls: 'control-plane'`). A control plane that does not answer fails every call fast with `MediaControlPlaneError` (`503`, `E_MEDIA_CONTROL_PLANE_UNAVAILABLE`); its refusals keep their status and code.
- **Account files** (`controlPlane.accounts`): a person's own files shared by every app (an avatar). Apps read them with their service token; the person writes and removes them with their own access token. In a tenant: `media.accounts.serve()`, `read()`, `records()`, `replace()`, `remove()`.
- **Console**: `apps` entries with `mode: 'control-plane'` list the control plane's tenant apps (their media lives here, actions run here), hinted **control plane** in the App selector.
- `agora:doctor` checks `media.topology` and `media.control-plane` (the tenant reaches the control plane, and its token is accepted for its app with `media:read` and `media:write`). A tenant describes itself to telescope as using the control plane for its media files.
- [#295](https://github.com/DavideCarvalho/adonis-agora-media/pull/295) [`b29ec2c`](https://github.com/DavideCarvalho/adonis-agora-media/commit/b29ec2cc8b8feaa9107267a81fb524ed48b46567) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `stores.lucid({ schema })` and `uploadSessions.lucid({ schema })` put media's tables in a database schema other than the connection's (a Postgres schema, a MySQL database). Every statement names the schema, so it works on any connection without `searchPath`. Auto-create makes the schema when missing, the published migrations take the same `schema`, `createMediaTables` / `dropMediaTables` and `media:tenancy:backfill --schema` accept it, SQLite fails at boot when it is set, and `agora:doctor --deep` checks it (`media.db-schema`, registered only when a schema is set). The auto-created table now also works on MySQL (identifiers are quoted per dialect). Without `schema` nothing changes.
- [#286](https://github.com/DavideCarvalho/adonis-agora-media/pull/286) [`847e057`](https://github.com/DavideCarvalho/adonis-agora-media/commit/847e0578c41b3823526de1c117c50fb32f891850) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The media console now serves its data to coding agents on the app's dev MCP endpoint (`/mcp/agora`) when the app registers `@adonis-agora/agent/mcp_provider`. Ten `media_*` tools, gated by the console's own `authorize`: reads (`media_list_disks`, `media_list_objects`, `media_get_object`, `media_list_uploads`, `media_get_upload`, `media_list_collections`, `media_get_collections_summary`, `media_get_media`) are listed by default and never return a URL; the actions (`media_abort_upload`, `media_delete_objects`) only when the app opts in on the dev endpoint and the console has `actions: true`. No configuration in this package.
New `anyAuthorize(...authorizers)` in `@adonis-agora/media/dashboard`: allows a request when any of the given `authorize` forms does, e.g. a console token for MCP clients or a signed-in admin.
- [#288](https://github.com/DavideCarvalho/adonis-agora-media/pull/288) [`a2d73fd`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a2d73fded8a53f62c60a60d4029a8e2234fafa4a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Organizations as tenants. When tenancy is on in `config/context.ts` (new `tenancy` option in `config/media.ts`: `'inherit'` by default, `false` opts out, plus `kinds`, `nullRows` and `pathPrefix`), new files and upload sessions are stamped with the active tenant and stored under `t/<tenantId>/`, and every app-facing read (`find`, `list`, `url`, `image`, `deliver`, the delivery and stream routes, upload sessions) only sees the active tenant's files; another tenant's file is not found. Public collections and signed delivery URLs stay readable from every tenant. New nullable `tenant_id` column via `node ace media:publish-migration tenancy` (also published by `configure`, and added automatically with `autoCreateSchema`); without it and with tenancy on, queries fail with `E_MEDIA_TENANCY_SCHEMA`. New `node ace media:tenancy:backfill --owner-type=Organization`, `authorizers.sameTenant()`, `tenantId` on `attach`/`attachExisting`, `MediaStore.listTenants`, `tenantIds` on `MediaStore.list`/`collectionTotals`. New `@adonis-agora/media/commands` barrel (`configure` registers it; add it to `adonisrc.ts` `commands` on an existing app). Console: `authorize` may return `{ allowed: true, tenants: '*' | string[] }`; an Organization picker in the header (`?tenant=`, out-of-scope picks see nothing and are logged), an Organization column, and tenant-prefixed disk browsing for confined viewers; `GET <apiBase>/tenants`. Nothing changes while tenancy is off.
- [#350](https://github.com/DavideCarvalho/adonis-agora-media/pull/350) [`a2bc269`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a2bc26946d71668d50d4171b2fe60644ee25042c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `media.accounts` in an app that keeps its own media: `accounts: { url, partition, token }` in `config/media.ts` (same fields as `tenant`, without `urls`) points a standalone app at the control plane that keeps people's account files (an avatar), while `media.library` stays on the app's own disks and store. Refused on a tenant (which uses `tenant`) and on a control plane.
- [#355](https://github.com/DavideCarvalho/adonis-agora-media/pull/355) [`7ee2095`](https://github.com/DavideCarvalho/adonis-agora-media/commit/7ee2095cc9df0897600353812f49c75468790bad) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Upload sessions have `updatedAt` as well as `createdAt`. The built-in session stores set it on create and move it on every update (`createdAt` never moves). The Lucid store's `media_upload_sessions` table gets a nullable `updated_at` column: new tables have it, and an existing one gets it from `node ace media:publish-migration timestamps` (no backfill; the store keeps working without the column). `agora:doctor --deep` warns while it is missing (`media.timestamps-schema`). The console API's `UploadInfo` has `updatedAt` (ISO string, or `null` when unknown), `media:uploads:show` prints it, and the bundled console shows Created and Updated on record and upload-session details, with the full timestamp on hover in the lists.
### Patch Changes
- [#315](https://github.com/DavideCarvalho/adonis-agora-media/pull/315) [`14a9a6d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/14a9a6ddea1540a7b662137f58fa047158ef3f60) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `authkitIdentity()` on the authkit-client side sets `realId` from the identity's actor (the token's `act` claim), falling back to `sub`. Under impersonation through a remote authkit, permission checks are made for the impersonating human, as they already were on the authkit-server side.
- [#281](https://github.com/DavideCarvalho/adonis-agora-media/pull/281) [`94f8af1`](https://github.com/DavideCarvalho/adonis-agora-media/commit/94f8af12bb87bf614a8ff0262958dd6120708851) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console fixes:
- The console now sends shield's CSRF token (`x-xsrf-token`, from the `XSRF-TOKEN` cookie) on every POST, including uploads from the Upload tab, so actions work in apps that use `@adonisjs/shield`. A redirected or non-2xx response now shows as an error instead of a silent success.
- The Uploads tab shows `upload sessions table missing — run the media migration (node ace migration:run)` (HTTP 503) instead of a 500 when the `lucid` upload-session store's tables do not exist.
- `FolderBody` is exported from `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard`.
- [#312](https://github.com/DavideCarvalho/adonis-agora-media/pull/312) [`922a1b0`](https://github.com/DavideCarvalho/adonis-agora-media/commit/922a1b065c2d2188aa6ddc855e74b5d2d0d4aff7) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console sidebar matches the old authkit admin console exactly (Agora console kit): nav rows are 32px with no gap between them, section labels and the brand/switcher header use authkit's spacing, the footer role shows as sent (no forced uppercase), and the theme toggle sits left-aligned with a 13px icon next to a 26px sign-out button.
- [#309](https://github.com/DavideCarvalho/adonis-agora-media/pull/309) [`3950127`](https://github.com/DavideCarvalho/adonis-agora-media/commit/39501275ffbe5e1ce1d8e0e86361ba9b325c438d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Server: the `agora.consoles` registry accepts the `flags` and `cms` icon keys, so those consoles show their own tile instead of `generic`. Console: the console switcher shows the CMS console with its own orange tile and glyph, and the kit gains a 16px `DocumentIcon`; the collapsible nav section toggle has a test pinning its focus ring (Agora console kit round 3).
- [#307](https://github.com/DavideCarvalho/adonis-agora-media/pull/307) [`9b9c638`](https://github.com/DavideCarvalho/adonis-agora-media/commit/9b9c63829e644925f24014c24ee633be175e5e2d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console footer: the signed-in user's role now shows when no `viewer` hook is set. The structural read of `ctx.auth.user` takes `role`, `roles` (strings, `{ name }` or authz `{ role }` rows) and `globalRoles`, plus the global roles of authkit's per-request identity on `ctx.authkit` (read structurally, 250 ms cap). One role is shown: an admin-like one first, else the first.
Console: inline SVG favicon in the console accent, so the browser no longer probes `/favicon.ico` and logs a 404 in the host app.
- [#337](https://github.com/DavideCarvalho/adonis-agora-media/pull/337) [`b6b9f95`](https://github.com/DavideCarvalho/adonis-agora-media/commit/b6b9f95669ec0acb4238187e3f76cec1c7a867ed) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - An app without `@adonisjs/drive` (no `drive.manager` binding) no longer fails every media call with "Cannot resolve binding drive.manager": Drive's service is only loaded when the app registers it, so the store and the console work; a disk outside `disks` then fails with `DriveNotConfiguredError`, which names the cause. The console of an app with no storage of its own (no `config/drive.ts`, no `disk`/`disks` in `config/media.ts`, e.g. one that only hosts the federated console) now says so, with a button for each of the other apps, instead of showing failing pages. `topology` gains `storage`.
- [#339](https://github.com/DavideCarvalho/adonis-agora-media/pull/339) [`2ad4a43`](https://github.com/DavideCarvalho/adonis-agora-media/commit/2ad4a435ec5360038ea89657de60cbd7341273f4) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console ⌘K: arrow keys now visibly move the selection. The highlighted item was styled with a bare `data-selected:` (cmdk marks every item `true` or `false`) and with the dialog's own surface color, so moving looked like nothing happened.
- [#341](https://github.com/DavideCarvalho/adonis-agora-media/pull/341) [`1ceea44`](https://github.com/DavideCarvalho/adonis-agora-media/commit/1ceea4400e9b4fd16a83b5b5437d573216a82a21) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console: the Collections filter's collection field autocompletes from the existing collections and still accepts a typed key. The console kit gains `ComboSelect` / `ComboMultiSelect`.
- [#308](https://github.com/DavideCarvalho/adonis-agora-media/pull/308) [`ac3a139`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ac3a139fa656bc925d3d728e1e6517cebcce0232) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console ⌘K shows its loading state: a spinner in the search box while a request is in flight, skeleton rows until the first answer, earlier hits kept but dimmed during a re-search, "Nothing found" only after an empty answer, and a quiet "didn't answer" line with Retry when the search fails. Synced with the shared console kit (DataTable `rowClassName`/`subRow`, ⌘K console-local `commands`, collapsible nav sections).
- [#294](https://github.com/DavideCarvalho/adonis-agora-media/pull/294) [`46cfbec`](https://github.com/DavideCarvalho/adonis-agora-media/commit/46cfbec707862231789e78aa0e5eb0397c737b06) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `stores.lucid({ connection })`: auto-creating the `media` table (and the tenant column) now runs on the configured connection. It used to run on the default connection, so the table was created in the wrong database and the store's first query failed.
- [#296](https://github.com/DavideCarvalho/adonis-agora-media/pull/296) [`25916df`](https://github.com/DavideCarvalho/adonis-agora-media/commit/25916df1627ddbea46244e89982c759fdd3565ed) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Tenancy on MySQL: the `media_tenant_owner_idx` index (tenant, owner type, owner id, collection) was over InnoDB's 3072-byte key limit under utf8mb4, so the tenancy migration and the auto-added tenant column failed there. On MySQL the index now covers the first 191 characters of each column; Postgres and SQLite are unchanged. Re-running the tenancy migration after a failed MySQL attempt (column added, index missing) now completes it.
- [#345](https://github.com/DavideCarvalho/adonis-agora-media/pull/345) [`bdca58b`](https://github.com/DavideCarvalho/adonis-agora-media/commit/bdca58bc5347b999045b86424230f02d3794b508) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Describe media's infrastructure for telescope's Architecture page: the Drive disks it writes to, `disks.s3()` buckets (`s3`/`r2`/`gcs`/`minio`), the selected Lucid store and upload-session store connections, and the `consoleCommands` Redis connection. No app code needed.
- [#338](https://github.com/DavideCarvalho/adonis-agora-media/pull/338) [`fc58763`](https://github.com/DavideCarvalho/adonis-agora-media/commit/fc5876322c794372f0a46603fa6630ea85a240dd) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The console's object preview shows Parquet files (`application/vnd.apache.parquet`, `application/x-parquet`, or a `.parquet` key) as a table: the schema with column types, the row count, and the first 50 rows. Files up to 25 MB preview inline; larger ones, or ones compressed with a codec other than Snappy, fall back to "Open original". The reader loads only when a Parquet file is opened.
- [#322](https://github.com/DavideCarvalho/adonis-agora-media/pull/322) [`d38b22c`](https://github.com/DavideCarvalho/adonis-agora-media/commit/d38b22caaccb7ff347f879ebefc9705b37ef6a95) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ships the current console: chart tooltips (TanStack Charts) and ⌘K navigation to pages and consoles. The console is bundled into this package, so the dashboard-only release did not reach apps.
- [#348](https://github.com/DavideCarvalho/adonis-agora-media/pull/348) [`80a42aa`](https://github.com/DavideCarvalho/adonis-agora-media/commit/80a42aa5b473da480944009ef60d1012b18052cd) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ship the console with the shared App/Organization picker: the dashboard is bundled into this package at build time, and the picker changesets only bumped the dashboard package, so this release carries it to apps.
- [#335](https://github.com/DavideCarvalho/adonis-agora-media/pull/335) [`fede0d9`](https://github.com/DavideCarvalho/adonis-agora-media/commit/fede0d95a7ceda70d8737026cb6efc3641a4c5e5) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ships the console with its filters in the URL (copy the link to share a filtered view). The console is bundled into this package at build time, so it needs its own release to reach apps.
- [#356](https://github.com/DavideCarvalho/adonis-agora-media/pull/356) [`a905f2d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a905f2d70456f0b6be2bd2a21291d8f3f87f1249) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix: on a table without the new `updated_at` column, starting an upload inside a transaction failed on Postgres ("current transaction is aborted"). The column check ran a query that fails when the column is missing, which aborts the surrounding transaction (Lucid's global test transaction, or a request wrapped in one). It now reads `information_schema` (`PRAGMA table_info` on SQLite) and never fails.
## 1.0.0-rc.33
### Minor Changes
- [`68c904e`](https://github.com/DavideCarvalho/adonis-agora-media/commit/68c904e832c91ab8d17edaedbeb5143349163bbe) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Security fixes (found in an internal security audit). **Breaking**, see each item.
**The federated console's Redis channel is authenticated.** Every request (reads included: listing disks and objects and signing URLs for any key used to run for anyone who could publish on Redis) and every answer is authenticated; a request over a minute old is refused, a replay runs once, a forged answer is ignored.
- **Zero configuration with `@adonis-agora/crypto`**: when crypto runs in both apps, requests are sealed with the crypto key `console-media` in the owning app's crypto partition, with no auth line in either config. The Hub (crypto embedded) creates the key and encrypts as `media:console`; a console that is a crypto tenant seals through its own crypto channel (`crypto:seal:console-*`); the owning app decrypts with its own (`crypto:decrypt:console-*`) and creates the key at boot when it may, or logs the exact command to run. A federated app's new `partition` option (default: its key) names its crypto partition.
- **Zero configuration with authkit's calls between apps**: the console sends its app-call token for the app, which the app verifies (audience-bound); the capabilities authkit granted the console app cap the request. With crypto too, the request is sealed and carries the token.
- Explicit modes stay: `crypto` (any cipher, `owns` for a KMS of your own), `token` + `publicKey` / `verifyTenant` (authkit service-tenant tokens or your own verifier; a control plane's own `verifyTenant` is the fallback), and the shared `secret`. Explicit options win; `crypto: false`, `token: false` and `verifyTenant: false` turn a detection off. New: `node ace media:console-key`.
- **Breaking:** the default crypto key is `console-media` (was `media-console`). An app with `consoleCommands` and no way to authenticate now **fails to boot** (web processes) with the line to add, and so does a console entry that may run actions (`actions: false` only warns). The console always sends the viewer's capabilities (`authorize` may return `capabilities`, narrowed to `media:objects:read`/`write`, also `media:console:read`/`write`/`*`), and the app refuses a request without them. Upgrade the console and its apps together.
- New `agora:doctor` checks: `media.console-commands` (the mode each side resolved, matching what boot does) and the deep `media.console-commands-key` (in crypto mode, a probe encrypted and decrypted).
- **Breaking:** a console's `apps` entries default `actions` to `true` (they used to follow the console's own `actions`); the app's `consoleCommands.actions` still decides, and `actions: false` makes an entry browse-only. A refusal for a missing viewer capability set has the code `capabilities-required`; refusals say who lacks a capability ("the console's token lacks …" / "the viewer lacks …"). `anyAuthorize` keeps the deciding authorizer's `capabilities`, and `authorize` may answer `access: 'read'`. A viewer's `capabilities` / `access: 'read'` now restrict the console's actions on its own app too (`403` "the viewer lacks media:objects:write", action buttons disabled); an `authorize` that says nothing keeps full access.
**A control plane no longer crashes on a crafted query.** `?conversion=` and `?w=` were written into the `ETag` before validation, so a control character or a non-latin-1 character killed the process when the response was written, reachable by tenant tokens and, with proxy delivery, by anonymous visitors of a tenant. They are now validated first (`400`: a conversion name, `w` in 1–8192, `q` in 1–100), the ETag is always header-safe (and distinct per quality), and every `Content-Type` this package sends from a record, a disk or another app is checked. A declared `mimeType` (`x-media-attach`, `x-media-mime-type`) must be a bare `type/subtype`.
**Generating a conversion needs write**: `POST /records/:id/conversions/:conversion` and `GET /records/:id/image?generate=1` on a control plane need `media:write` (read-only tokens get `403`).
**Breaking: the built-in upload routes (`uploads.routes`) never take a key or a free disk from the client.** The client sends a `fileName`; the key is derived on the server (`routes.keyFor`, default `uploads/<uuid>/<fileName>`), the disk is `routes.disk` or one of `routes.disks`, and the multipart parts/complete/abort calls need the `uploadToken` the initiate answered. A client `visibility` is no longer read. New `routes.middleware`: without it the routes do not mount in production (the boot says what to add; `allowUnguarded: true` when a global middleware guards them) and warn elsewhere. The same guard (`middleware`, `allowUnguarded`) now applies to the TUS (`uploads.resumable.routes`) and direct-session (`uploads.direct.routes`) routes: without middleware they do not mount in production either. Upload tokens and the account console's upload tickets are signed with `APP_KEY` (or the new `uploads.secret`); without either the app fails to boot in production when it mounts them (a per-process key, with a warning, only outside production). `@adonis-agora/media-react`'s proxy upload sends `fileName` and uses the key the server answers (`meta.key` is ignored).
**The console access contract is the one every Agora lib shares** (`console_authorize.ts`, identical across the libs). Breaking for code that reads decisions directly: `resolveConsoleAuthorize`/`normalizeConsoleAuthorizeResult` answer a sign-in redirect as `{ allowed: false, status: 302, redirectTo }` (was `401` + `redirectTo`; the console still answers the API with `401 { error: 'unauthenticated', redirectTo }` and redirects pages), a refusal from a throwing check carries its `error`, `anyAuthorize` rethrows it when every check refused, `apps`/`tenants` lists are kept as given (numbers as strings, empty names dropped), and `access` is kept as a field (`viewerConsoleCapabilities(decision)` turns it into media's capabilities). Media's additions (`capabilityAllows`, `capabilitiesAllow`, `MEDIA_OBJECTS_*`, `authorizeAgoraCaller` and the app-caller helpers) moved to `console_apps.ts`; `@adonis-agora/media/dashboard` exports them as before. `authorizeByToken` accepts `apps`, `tenants`, `capabilities` and `access`.
**Console capabilities use the one matcher every Agora lib shares** (`console_capabilities.ts`): `*`, `media:*`, `media:console:*`, `media:console:write` (reads and writes), `media:console:read` (reads), the exact name, or a hierarchical grant like `media:objects:*`. **Breaking (security):** a `*` anywhere else grants nothing (`media:*:write`, `*:objects:write`, `*:console:*` used to widen). This applies to console tokens, viewer capabilities, app callers over HTTP (`permitTokenCapabilities`) and the console's own actions; `capabilityAllows` / `capabilitiesAllow` follow it. The owning app checks a command in a fixed order: capabilities present, the console's token, the viewer, the token's partition, then `consoleCommands.actions`.
**Uniform messages across the Agora libs.** The boot errors (`ConsoleAuthConfigError`), the mode labels (`crypto (auto, key console-media)`, `token checked when sent (…)`, `token (…; sealed to <id>)`, `secret`), the `; actions on|off` boot line and the console-side timeout (`no instance of "<app>" answered within <n>s — …`) follow one template. The boot log no longer prints the app's command public key (only its short id, in token mode; `node ace media:console-key` prints it). The Hub creates each app's `console-media` key at boot (not on the first command), and `media.console-commands-key` checks it from the console too. A garbage or refused message on the channel is logged once per reason and dropped.
**Libs coordinate through their siblings.** With authkit's calls between apps and no crypto, an app in token mode publishes its command public key in authkit's key directory at boot (purpose `console:media`) and the console fetches it from there: no `controlPlane.publicKey` to copy (an explicit one still wins). An app opens its own `console-*` crypto keys with no grant (the `crypto:decrypt:console-*` grant is no longer needed, harmless if present); a key not created yet on a crypto tenant is one info line (the crypto server creates it on the console's first seal). Zero config: together with the Hub's crypto, no lines and no grants; a separate crypto app, only the console's `crypto:seal:console-*`; authkit without crypto, no lines and one authkit grant (the console app gets `media:console:*`, or narrower, on the owning app: the token is mandatory there and caps every command).
A refused command is logged once per reason as `console commands: refused a command (<reason>)` (`not JSON`, `no command id`, `did not open with this app's key`, `bad signature`, `stale`, `replayed`, `token refused`, `capabilities-required`, `mode not accepted here (…)`); the token mode shows its key as `sealed to key <8-char id>`; the doctor uses the boot log's sentences. Media opens no long-lived connection in a console (ace) process.
**Mixed Hubs.** A console with crypto and authkit picks the way to each app lazily (the app's key in authkit's directory → token mode, else crypto), cached and decided again after 5 minutes or a refused command. In crypto mode a failing app-call token never blocks a command (it goes crypto-only, one warning with the grant to add, retried in 5 minutes). The APP_KEY is read from `config/app.ts`, else `config/encryption.ts` (AdonisJS 7), else the environment. An app publishes its key in authkit's directory only when token mode is its only way in; with crypto active it says nothing about it. The crypto key check uses crypto's `hasKey` when available (no decrypt error rows in the crypto audit).
## 1.0.0-rc.32
### Patch Changes
- [#356](https://github.com/DavideCarvalho/adonis-agora-media/pull/356) [`a905f2d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a905f2d70456f0b6be2bd2a21291d8f3f87f1249) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix: on a table without the new `updated_at` column, starting an upload inside a transaction failed on Postgres ("current transaction is aborted"). The column check ran a query that fails when the column is missing, which aborts the surrounding transaction (Lucid's global test transaction, or a request wrapped in one). It now reads `information_schema` (`PRAGMA table_info` on SQLite) and never fails.
## 1.0.0-rc.31
### Minor Changes
- [#355](https://github.com/DavideCarvalho/adonis-agora-media/pull/355) [`7ee2095`](https://github.com/DavideCarvalho/adonis-agora-media/commit/7ee2095cc9df0897600353812f49c75468790bad) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Upload sessions have `updatedAt` as well as `createdAt`. The built-in session stores set it on create and move it on every update (`createdAt` never moves). The Lucid store's `media_upload_sessions` table gets a nullable `updated_at` column: new tables have it, and an existing one gets it from `node ace media:publish-migration timestamps` (no backfill; the store keeps working without the column). `agora:doctor --deep` warns while it is missing (`media.timestamps-schema`). The console API's `UploadInfo` has `updatedAt` (ISO string, or `null` when unknown), `media:uploads:show` prints it, and the bundled console shows Created and Updated on record and upload-session details, with the full timestamp on hover in the lists.
## 1.0.0-rc.30
### Minor Changes
- [#350](https://github.com/DavideCarvalho/adonis-agora-media/pull/350) [`a2bc269`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a2bc26946d71668d50d4171b2fe60644ee25042c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `media.accounts` in an app that keeps its own media: `accounts: { url, partition, token }` in `config/media.ts` (same fields as `tenant`, without `urls`) points a standalone app at the control plane that keeps people's account files (an avatar), while `media.library` stays on the app's own disks and store. Refused on a tenant (which uses `tenant`) and on a control plane.
## 1.0.0-rc.29
### Minor Changes
- [#349](https://github.com/DavideCarvalho/adonis-agora-media/pull/349) [`f9345d8`](https://github.com/DavideCarvalho/adonis-agora-media/commit/f9345d83b99aabe7a6007d62d9aedbb0a9bc15a6) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Control plane and tenants: several apps can keep their media on one central app. `config/media.ts` gains `topology: 'standalone' | 'control-plane' | 'tenant'`.
- **Control plane** (`topology: 'control-plane'`, `verifyTenant`, `controlPlane: { prefix, collections, maxBytes, accounts }`): mounts the tenant API under `/_media/v1`. Each request carries an app's service token (`authkitTenantVerifier({ issuer, resource: 'urn:agora:media' })` or `sharedSecretVerifier({ partitions })`); the app and its capabilities (`media:read`, `media:write`) come from the token. Each app's records and files are kept apart (owner type `<app>/<ownerType>`, keys under `<app>/`), and the control plane runs the collections' rules and conversions.
- **Tenant** (`topology: 'tenant'`, `tenant: { url, partition, token, urls, timeoutMs, uploadTimeoutMs, retries }`): `media.library` keeps its API (`attach`, `list`, `find`, `for`, `page`, `rename`, `delete`, `ensureConversion`, `url`, `signedUrl`, `image`, `deliver`) and runs it on the control plane; `media.access` and the delivery route work unchanged. `url` takes `controlPlaneUrl({ issuer, resource: 'urn:agora:media' })`. URLs point at the app's own delivery route by default (`urls: 'app'`), or at the control plane's storage URLs (`urls: 'control-plane'`). A control plane that does not answer fails every call fast with `MediaControlPlaneError` (`503`, `E_MEDIA_CONTROL_PLANE_UNAVAILABLE`); its refusals keep their status and code.
- **Account files** (`controlPlane.accounts`): a person's own files shared by every app (an avatar). Apps read them with their service token; the person writes and removes them with their own access token. In a tenant: `media.accounts.serve()`, `read()`, `records()`, `replace()`, `remove()`.
- **Console**: `apps` entries with `mode: 'control-plane'` list the control plane's tenant apps (their media lives here, actions run here), hinted **control plane** in the App selector.
- `agora:doctor` checks `media.topology` and `media.control-plane` (the tenant reaches the control plane, and its token is accepted for its app with `media:read` and `media:write`). A tenant describes itself to telescope as using the control plane for its media files.
## 1.0.0-rc.28
### Patch Changes
- [#348](https://github.com/DavideCarvalho/adonis-agora-media/pull/348) [`80a42aa`](https://github.com/DavideCarvalho/adonis-agora-media/commit/80a42aa5b473da480944009ef60d1012b18052cd) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ship the console with the shared App/Organization picker: the dashboard is bundled into this package at build time, and the picker changesets only bumped the dashboard package, so this release carries it to apps.
## 1.0.0-rc.27
### Patch Changes
- [#345](https://github.com/DavideCarvalho/adonis-agora-media/pull/345) [`bdca58b`](https://github.com/DavideCarvalho/adonis-agora-media/commit/bdca58bc5347b999045b86424230f02d3794b508) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Describe media's infrastructure for telescope's Architecture page: the Drive disks it writes to, `disks.s3()` buckets (`s3`/`r2`/`gcs`/`minio`), the selected Lucid store and upload-session store connections, and the `consoleCommands` Redis connection. No app code needed.
## 1.0.0-rc.26
### Minor Changes
- [#342](https://github.com/DavideCarvalho/adonis-agora-media/pull/342) [`32c3445`](https://github.com/DavideCarvalho/adonis-agora-media/commit/32c3445e7cd5413d2d2f72c6ec5c64f6a9f28272) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Federated console: `proxyActions` on an `apps` entry sends this console's actions on that app's media (delete, copy, move, folders, delete record, cancel upload) to the app's own console API over HTTP (`POST` on its `origin` + `apiPath`, headers only to that origin, `redirect: 'manual'`), and the app runs them with its own store and disks. A new per-app `actions` overrides the console's own switch for that app. `/apps` now says, per app, `mode: 'federated'` and who runs its actions (`actions: 'app' | 'none'`).
App side: `authorizeAppCaller({ identify, permit })` lets another app's console read object bytes (`media:objects:read`) and run the action routes (`media:objects:write`, listed in `MEDIA_ACTION_ROUTES`), with presets `identifyAgoraCaller()` / `identifySharedSecret()` and `permitTokenCapabilities()` / `permitAll()`. `authorizeAgoraCaller()` takes `actions: true` to open the action routes. `mediaCallerCsrfExceptions()` lets those calls through shield's CSRF check.
Console UI: federated apps carry a "federated" badge in the App picker, a notice at the top of the page says where their data comes from and who runs actions, and the actions of a read-only federated app show disabled with the reason.
## 1.0.0-rc.25
### Patch Changes
- [#341](https://github.com/DavideCarvalho/adonis-agora-media/pull/341) [`1ceea44`](https://github.com/DavideCarvalho/adonis-agora-media/commit/1ceea4400e9b4fd16a83b5b5437d573216a82a21) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console: the Collections filter's collection field autocompletes from the existing collections and still accepts a typed key. The console kit gains `ComboSelect` / `ComboMultiSelect`.
## 1.0.0-rc.24
### Minor Changes
- [#340](https://github.com/DavideCarvalho/adonis-agora-media/pull/340) [`9cb2d96`](https://github.com/DavideCarvalho/adonis-agora-media/commit/9cb2d96bfe7e514f5b6b65d96b6f686a44308c5a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Federated console: `proxyObjects` on an `apps` entry serves that app's object bytes from this console (same origin), fetching them from the app with optional `headers` (a service token). Previews, thumbnails and "Open" then work without a session in the other app and under a strict `img-src`. New `authorizeAgoraCaller()` lets another Agora app holding `media:objects:read` read `GET <apiBase>/object/raw`, and `capabilityAllows()` is exported. `object/raw` now serves HTML, SVG, XML and scripts as downloads with a sandboxing CSP and `nosniff`.
## 1.0.0-rc.23
### Patch Changes
- [#338](https://github.com/DavideCarvalho/adonis-agora-media/pull/338) [`fc58763`](https://github.com/DavideCarvalho/adonis-agora-media/commit/fc5876322c794372f0a46603fa6630ea85a240dd) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The console's object preview shows Parquet files (`application/vnd.apache.parquet`, `application/x-parquet`, or a `.parquet` key) as a table: the schema with column types, the row count, and the first 50 rows. Files up to 25 MB preview inline; larger ones, or ones compressed with a codec other than Snappy, fall back to "Open original". The reader loads only when a Parquet file is opened.
## 1.0.0-rc.22
### Patch Changes
- [#337](https://github.com/DavideCarvalho/adonis-agora-media/pull/337) [`b6b9f95`](https://github.com/DavideCarvalho/adonis-agora-media/commit/b6b9f95669ec0acb4238187e3f76cec1c7a867ed) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - An app without `@adonisjs/drive` (no `drive.manager` binding) no longer fails every media call with "Cannot resolve binding drive.manager": Drive's service is only loaded when the app registers it, so the store and the console work; a disk outside `disks` then fails with `DriveNotConfiguredError`, which names the cause. The console of an app with no storage of its own (no `config/drive.ts`, no `disk`/`disks` in `config/media.ts`, e.g. one that only hosts the federated console) now says so, with a button for each of the other apps, instead of showing failing pages. `topology` gains `storage`.
## 1.0.0-rc.21
### Patch Changes
- [#339](https://github.com/DavideCarvalho/adonis-agora-media/pull/339) [`2ad4a43`](https://github.com/DavideCarvalho/adonis-agora-media/commit/2ad4a435ec5360038ea89657de60cbd7341273f4) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console ⌘K: arrow keys now visibly move the selection. The highlighted item was styled with a bare `data-selected:` (cmdk marks every item `true` or `false`) and with the dialog's own surface color, so moving looked like nothing happened.
## 1.0.0-rc.20
### Minor Changes
- [#336](https://github.com/DavideCarvalho/adonis-agora-media/pull/336) [`53d7ddd`](https://github.com/DavideCarvalho/adonis-agora-media/commit/53d7dddc463993f1509e37d1bdaac872c6d78d36) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Federated console: the media console can also show other apps' media, with an **App** selector (`?app=` in the URL). Each app keeps its own tables, disks and credentials. `config/media_dashboard.ts` gains `apps` (`label`, `store`, `uploadSessions`, `controlPlane: { connection, prefix }`, `origin`, `timeoutMs`) and `appLabel`; records, collections and upload sessions are read from the other app's tables (read-only, never created or altered), and disks, object URLs and the actions are asked of that app over Redis, which answers with `consoleCommands: { connection, prefix, actions }` in its `config/media.ts` (one instance runs each command, claimed with `SET NX`). New `GET <api>/apps`; `authorize` may grant `apps`. An unknown app answers 404, an app that does not answer 503, an app error 502, a command it does not run 501. Uploading from the console stays the console app's own.
## 1.0.0-rc.19
### Patch Changes
- [#335](https://github.com/DavideCarvalho/adonis-agora-media/pull/335) [`fede0d9`](https://github.com/DavideCarvalho/adonis-agora-media/commit/fede0d95a7ceda70d8737026cb6efc3641a4c5e5) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ships the console with its filters in the URL (copy the link to share a filtered view). The console is bundled into this package at build time, so it needs its own release to reach apps.
## 1.0.0-rc.18
### Patch Changes
- [#322](https://github.com/DavideCarvalho/adonis-agora-media/pull/322) [`d38b22c`](https://github.com/DavideCarvalho/adonis-agora-media/commit/d38b22caaccb7ff347f879ebefc9705b37ef6a95) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ships the current console: chart tooltips (TanStack Charts) and ⌘K navigation to pages and consoles. The console is bundled into this package, so the dashboard-only release did not reach apps.
## 1.0.0-rc.17
### Patch Changes
- [#315](https://github.com/DavideCarvalho/adonis-agora-media/pull/315) [`14a9a6d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/14a9a6ddea1540a7b662137f58fa047158ef3f60) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `authkitIdentity()` on the authkit-client side sets `realId` from the identity's actor (the token's `act` claim), falling back to `sub`. Under impersonation through a remote authkit, permission checks are made for the impersonating human, as they already were on the authkit-server side.
## 1.0.0-rc.16
### Patch Changes
- [#312](https://github.com/DavideCarvalho/adonis-agora-media/pull/312) [`922a1b0`](https://github.com/DavideCarvalho/adonis-agora-media/commit/922a1b065c2d2188aa6ddc855e74b5d2d0d4aff7) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console sidebar matches the old authkit admin console exactly (Agora console kit): nav rows are 32px with no gap between them, section labels and the brand/switcher header use authkit's spacing, the footer role shows as sent (no forced uppercase), and the theme toggle sits left-aligned with a 13px icon next to a 26px sign-out button.
## 1.0.0-rc.15
### Patch Changes
- [#309](https://github.com/DavideCarvalho/adonis-agora-media/pull/309) [`3950127`](https://github.com/DavideCarvalho/adonis-agora-media/commit/39501275ffbe5e1ce1d8e0e86361ba9b325c438d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Server: the `agora.consoles` registry accepts the `flags` and `cms` icon keys, so those consoles show their own tile instead of `generic`. Console: the console switcher shows the CMS console with its own orange tile and glyph, and the kit gains a 16px `DocumentIcon`; the collapsible nav section toggle has a test pinning its focus ring (Agora console kit round 3).
## 1.0.0-rc.14
### Patch Changes
- [#308](https://github.com/DavideCarvalho/adonis-agora-media/pull/308) [`ac3a139`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ac3a139fa656bc925d3d728e1e6517cebcce0232) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console ⌘K shows its loading state: a spinner in the search box while a request is in flight, skeleton rows until the first answer, earlier hits kept but dimmed during a re-search, "Nothing found" only after an empty answer, and a quiet "didn't answer" line with Retry when the search fails. Synced with the shared console kit (DataTable `rowClassName`/`subRow`, ⌘K console-local `commands`, collapsible nav sections).
## 1.0.0-rc.13
### Patch Changes
- [#307](https://github.com/DavideCarvalho/adonis-agora-media/pull/307) [`9b9c638`](https://github.com/DavideCarvalho/adonis-agora-media/commit/9b9c63829e644925f24014c24ee633be175e5e2d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console footer: the signed-in user's role now shows when no `viewer` hook is set. The structural read of `ctx.auth.user` takes `role`, `roles` (strings, `{ name }` or authz `{ role }` rows) and `globalRoles`, plus the global roles of authkit's per-request identity on `ctx.authkit` (read structurally, 250 ms cap). One role is shown: an admin-like one first, else the first.
Console: inline SVG favicon in the console accent, so the browser no longer probes `/favicon.ico` and logs a 404 in the host app.
## 1.0.0-rc.12
### Minor Changes
- [#306](https://github.com/DavideCarvalho/adonis-agora-media/pull/306) [`71900c9`](https://github.com/DavideCarvalho/adonis-agora-media/commit/71900c94effc0bc6dc180f5397bc4b70ad94edb3) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Every media console action is now a `node ace` command: `media:disks:list`, `media:objects:list`, `media:objects:show`, `media:objects:upload`, `media:objects:copy`, `media:objects:move`, `media:objects:rename`, `media:objects:delete`, `media:folders:create`, `media:collections:list`, `media:records:list`, `media:records:show`, `media:records:delete`, `media:uploads:list`, `media:uploads:show` and `media:uploads:abort`. They use the console's settings from `config/media_dashboard.ts` (its disks, its `actions` switch, its object URLs), print `--json` in the console API's `{ data, meta }` shape, take `--tenant=<id>` with tenancy on, ask before a destructive change unless `--force`, and exit with code `1` on failure. See the new CLI page in the docs.
## 1.0.0-rc.11
### Minor Changes
- [#304](https://github.com/DavideCarvalho/adonis-agora-media/pull/304) [`a1a5ab4`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a1a5ab4315225caa605e44f37ba034b761d5481b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console shell: the media console is rebuilt on the Agora console kit, the shell every `@adonis-agora` console now shares. Its accent is amber (the access-denied page follows).
- Left sidebar with the brand (the console switcher), nav grouped as LIBRARY (Library, Collections) and TRANSFERS (Uploads, Upload), and a footer with the signed-in user, a theme toggle and sign-out. Below 768px the sidebar becomes a drawer.
- Topbar with the page title, the organization picker, the disk / uploads / actions pills, the live dot and ⌘K search across consoles.
- Each page opens with metric cards (disks and folder contents, record totals, sessions in progress). Library rows keep Preview inline and move copy key / copy / move / rename / delete into a row menu. Lists page with "Load more" on the cursor envelope.
- Light mode. The theme is remembered per console in localStorage.
- Fonts are bundled (Sora, JetBrains Mono); the page no longer loads Google Fonts.
- Every page and region has its own error boundary with a retry button, shaped skeletons and empty states.
Server: the page's data block gains `search`, `viewer` and `signOut`. The new `viewer(ctx)` config option sets the user row; without it the console reads `ctx.auth.user` when the request is already authenticated. The new `signOut` option takes a POST action path, `{ href }` or `false`; without it the console uses the sign-out an account console announces on the `agora.consoles` registry (`account.signOut`). A POST sign-out carries the request's CSRF token.
## 1.0.0-rc.10
### Major Changes
- [#301](https://github.com/DavideCarvalho/adonis-agora-media/pull/301) [`4fdd451`](https://github.com/DavideCarvalho/adonis-agora-media/commit/4fdd4513f77c5d640bafee365ef7bf22afb557cc) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The console's list routes use the `@adonis-agora/filter` list format.
- `GET /objects`: `?disk=&prefix=` → `?filter[disk]=&filter[prefix]=` (`filter[disk]` required). Paging stays `after` / `first` (default and max 1000). The response is `{ data, meta: { nextCursor, prevCursor, hasNext, hasPrev } }`; `data` holds folders, then files, each tagged `type: 'folder' | 'file'` (was `{ folders, files, nextCursor, prevCursor, hasNext, hasPrev }`). `sort` accepts only `key`.
- `GET /collections`: `?collection=&ownerType=&ownerId=&prefix=` → `?filter[collection]=&filter[ownerType]=&filter[ownerId]=&filter[prefix]=`. Paging stays `after` / `first` (default 50, max 200). The response is `{ data, meta }` (was `{ items, nextCursor, prevCursor, hasNext, hasPrev }`). `sort` accepts only `-createdAt`.
- `GET /uploads`: `?disk=&prefix=` → `?filter[disk]=&filter[prefix]=`; `sort=createdAt|-createdAt` (default newest first). Response `{ data }` (was `{ uploads }`).
- `GET /disks` answers `{ data }` (was `{ disks }`); `GET /collections/summary` answers `{ data }` (was `{ collections }`).
- An unknown filter field, an operator other than equality, a sort outside the route's list, or `before` / `last` is a `400`.
- `DashboardService`: `objects()` and `collections()` return `CursorPageResponse<T>` (`{ data, meta }`); `disks()`, `uploads()` and `collectionsSummary()` return `{ data }`; `uploads()` takes `order: 'asc' | 'desc'`.
- Types: `CursorPage` and `CursorPageInfo` are removed; new `CursorPageResponse<T>`, `CursorPageMeta`, `ListResponse<T>`, `ObjectListItem`, `UploadFilter`. `ObjectListResponse`, `CollectionListResponse`, `DiskListResponse`, `UploadListResponse` and `CollectionsSummaryResponse` change shape as above.
- New `readObjectsQuery`, `readCollectionsQuery` and `readUploadsQuery` in `@adonis-agora/media/dashboard` read these routes' query strings for your own routes.
- `@adonis-agora/media` now depends on `@adonis-agora/filter`.
## 1.0.0-rc.9
### Patch Changes
- [#296](https://github.com/DavideCarvalho/adonis-agora-media/pull/296) [`25916df`](https://github.com/DavideCarvalho/adonis-agora-media/commit/25916df1627ddbea46244e89982c759fdd3565ed) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Tenancy on MySQL: the `media_tenant_owner_idx` index (tenant, owner type, owner id, collection) was over InnoDB's 3072-byte key limit under utf8mb4, so the tenancy migration and the auto-added tenant column failed there. On MySQL the index now covers the first 191 characters of each column; Postgres and SQLite are unchanged. Re-running the tenancy migration after a failed MySQL attempt (column added, index missing) now completes it.
## 1.0.0-rc.8
### Minor Changes
- [#295](https://github.com/DavideCarvalho/adonis-agora-media/pull/295) [`b29ec2c`](https://github.com/DavideCarvalho/adonis-agora-media/commit/b29ec2cc8b8feaa9107267a81fb524ed48b46567) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `stores.lucid({ schema })` and `uploadSessions.lucid({ schema })` put media's tables in a database schema other than the connection's (a Postgres schema, a MySQL database). Every statement names the schema, so it works on any connection without `searchPath`. Auto-create makes the schema when missing, the published migrations take the same `schema`, `createMediaTables` / `dropMediaTables` and `media:tenancy:backfill --schema` accept it, SQLite fails at boot when it is set, and `agora:doctor --deep` checks it (`media.db-schema`, registered only when a schema is set). The auto-created table now also works on MySQL (identifiers are quoted per dialect). Without `schema` nothing changes.
## 1.0.0-rc.7
### Patch Changes
- [#294](https://github.com/DavideCarvalho/adonis-agora-media/pull/294) [`46cfbec`](https://github.com/DavideCarvalho/adonis-agora-media/commit/46cfbec707862231789e78aa0e5eb0397c737b06) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `stores.lucid({ connection })`: auto-creating the `media` table (and the tenant column) now runs on the configured connection. It used to run on the default connection, so the table was created in the wrong database and the store's first query failed.
## 1.0.0-rc.6
### Minor Changes
- [#290](https://github.com/DavideCarvalho/adonis-agora-media/pull/290) [`cd949a0`](https://github.com/DavideCarvalho/adonis-agora-media/commit/cd949a034a7632bba2ba9246a798d611c486409b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `node ace agora:doctor` (and `media:doctor`): one health check for every installed `@adonis-agora` lib, the same command every lib ships (canonical revision 1.1). Media adds `media.disks` (every disk it writes to exists), `media.console-gate` (console `authorize`, an error in production), `media.account-console` (listed collections exist and have rules) and `media.tenancy-schema` (deep: the `tenant_id` column with tenancy on). New subpath `./doctor`; the commands are in the `@adonis-agora/media/commands` barrel `configure` registers.
## 1.0.0-rc.5
### Minor Changes
- [#289](https://github.com/DavideCarvalho/adonis-agora-media/pull/289) [`d13f522`](https://github.com/DavideCarvalho/adonis-agora-media/commit/d13f5227c318bf84df2bc2bf0896208c1988e6cb) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A "My files" page in the authkit account console (`/account/files`), registered automatically when authkit's `'authkit.accountExtensions'` registry is in the app (authkit-server, or authkit-client with remote pages). Nothing is exposed until `accountConsole.collections` in `config/media.ts` lists a collection; each listed collection gets browse, upload, rename, delete (confirmed, sudo) and download (short-lived signed URLs), each allowed by that collection's own `access` rules and switchable per collection. Owner defaults to authkit's mapped subject (`owner` hook to override); with tenancy on, the page follows the active organization. Uploads use a same-origin script (`<path>/upload.js`) and a ticket-authorized endpoint (`POST <path>/uploads`, default `/media/account`); `publicUrl` serves remote IdPs. New `media.library.page(ownerType, ownerId, { collections, cursor, limit })`, `media.library.rename(id, name)`, and the optional store method `MediaStore.listByOwnerPaged` (both bundled stores implement it). No runtime dependency on authkit.
## 1.0.0-rc.4
### Minor Changes
- [#288](https://github.com/DavideCarvalho/adonis-agora-media/pull/288) [`a2d73fd`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a2d73fded8a53f62c60a60d4029a8e2234fafa4a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Organizations as tenants. When tenancy is on in `config/context.ts` (new `tenancy` option in `config/media.ts`: `'inherit'` by default, `false` opts out, plus `kinds`, `nullRows` and `pathPrefix`), new files and upload sessions are stamped with the active tenant and stored under `t/<tenantId>/`, and every app-facing read (`find`, `list`, `url`, `image`, `deliver`, the delivery and stream routes, upload sessions) only sees the active tenant's files; another tenant's file is not found. Public collections and signed delivery URLs stay readable from every tenant. New nullable `tenant_id` column via `node ace media:publish-migration tenancy` (also published by `configure`, and added automatically with `autoCreateSchema`); without it and with tenancy on, queries fail with `E_MEDIA_TENANCY_SCHEMA`. New `node ace media:tenancy:backfill --owner-type=Organization`, `authorizers.sameTenant()`, `tenantId` on `attach`/`attachExisting`, `MediaStore.listTenants`, `tenantIds` on `MediaStore.list`/`collectionTotals`. New `@adonis-agora/media/commands` barrel (`configure` registers it; add it to `adonisrc.ts` `commands` on an existing app). Console: `authorize` may return `{ allowed: true, tenants: '*' | string[] }`; an Organization picker in the header (`?tenant=`, out-of-scope picks see nothing and are logged), an Organization column, and tenant-prefixed disk browsing for confined viewers; `GET <apiBase>/tenants`. Nothing changes while tenancy is off.
## 1.0.0-rc.3
### Minor Changes
- [#287](https://github.com/DavideCarvalho/adonis-agora-media/pull/287) [`bbca45d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/bbca45d5ef0f0090291cdaf5b0617d6ad198009c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The media console joins the Agora console switcher. It registers itself in the app's `'agora.consoles'` registry (created by whichever console boots first), and its brand becomes a menu to the other Agora consoles the viewer may open, each checked with that console's own `authorize` (300 ms each, in parallel; `ctx.agoraProbe` is `true` while they run). Ctrl/Cmd-K searches every console the viewer may open; media answers record ids, collection names and disk names. New routes: `GET <apiBase>/consoles` and `GET <apiBase>/consoles/search?q=`, behind the console's `authorize`. `registerAgoraConsole` is exported from `@adonis-agora/media/dashboard` for consoles an app mounts itself. The Collections view opens filtered from `#/collections?collection=<name>`. Nothing changes for an app with a single console.
## 1.0.0-rc.2
### Minor Changes
- [#286](https://github.com/DavideCarvalho/adonis-agora-media/pull/286) [`847e057`](https://github.com/DavideCarvalho/adonis-agora-media/commit/847e0578c41b3823526de1c117c50fb32f891850) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The media console now serves its data to coding agents on the app's dev MCP endpoint (`/mcp/agora`) when the app registers `@adonis-agora/agent/mcp_provider`. Ten `media_*` tools, gated by the console's own `authorize`: reads (`media_list_disks`, `media_list_objects`, `media_get_object`, `media_list_uploads`, `media_get_upload`, `media_list_collections`, `media_get_collections_summary`, `media_get_media`) are listed by default and never return a URL; the actions (`media_abort_upload`, `media_delete_objects`) only when the app opts in on the dev endpoint and the console has `actions: true`. No configuration in this package.
New `anyAuthorize(...authorizers)` in `@adonis-agora/media/dashboard`: allows a request when any of the given `authorize` forms does, e.g. a console token for MCP clients or a signed-in admin.
## 1.0.0-rc.1
### Major Changes
- [#284](https://github.com/DavideCarvalho/adonis-agora-media/pull/284) [`ddf507b`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ddf507bf477c00e89f8ca4ab033f56efd56519ad) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The media console is closed in production until you set `authorize`. Without `authorize` in `config/media_dashboard.ts`, the console is open outside production and in production answers `403` to every page and API request. Either way it logs once at boot: ``[@adonis-agora/media] console has no `authorize` configured: it is open outside production and denies every request in production. Set `authorize` in config/media_dashboard.ts.`` Before, it was open in every environment unless `middleware` or `auth` closed it. `authorize` runs before `middleware`, so a console guarded only by `middleware` needs `authorize` too, for example `authorize: () => true` to keep your middleware as the gate.
`authorize` now takes the access contract shared by every Agora console, in three forms: an inline function `(ctx) => result`, a `ConsoleAuthorizer` class (built through the container, so `@inject()` works), or a lazy import of one (`() => import('#policies/console_access')`, loaded once). A check may also answer `{ redirectTo: '/login' }`: page navigations are redirected there and API calls get `401`. Every result the hook accepted before keeps working, and a check that throws is still a `403`.
API refusals now answer `{ error: 'forbidden' }` (`403`) and `{ error: 'unauthenticated' }` (`401`, plus `redirectTo` when the check asked for a redirect), the same bodies as every other Agora console. Before they were `{ error: 'Forbidden' }` and `{ error: 'Unauthorized' }`.
New `authorizeByToken({ token })` for machine access: `authorize: authorizeByToken({ token: env.get('CONSOLE_TOKEN') })` allows requests with `Authorization: Bearer <token>` and answers `401` otherwise. An empty or missing token throws when the config loads.
The `DashboardAuthorize`, `AuthorizeResult` and `AuthorizeDecision` types are replaced by `ConsoleAuthorize`, `ConsoleAuthorizeResult` and `ConsoleAuthorizer`, exported from `@adonis-agora/media/dashboard` together with `resolveConsoleAuthorize` and `authorizeByToken`.
The console no longer has a login of its own: the `auth` option of `config/media_dashboard.ts` is removed, with no alias. Gone with it: the console's login screen and sign out button, the `GET /me`, `POST /login`, `POST /session` and `POST /logout` API routes, the `media_dashboard_session` cookie and its `secret`/`ttl`/`session`/`login`/`revalidate` hooks, and the exports `resolveConsoleAuth`, `signSessionCookie`, `verifySessionCookie` and the types `ConsoleAuthOptions`, `ResolvedConsoleAuth`, `ConsoleSession`, `ConsoleSessionUser`, `ConsoleSessionUserInfo`, `AuthMode`, `SessionHook`, `LoginHook`, `RevalidateHook`, `MeResponse` and `LoginBody` (from `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard`). Sign-in is your app's own: gate the console in `authorize` and return `{ redirectTo: '/login' }` for a signed-out visitor. When one of the console's API calls answers `401`, the console follows that `redirectTo`, or reloads the page when there is none. `@adonis-agora/media-dashboard`'s client drops `me()`, `login()`, `logout()` and `ConsoleAuthState`, and takes an `onUnauthenticated` option (default `followUnauthenticated`).
`@adonis-agora/media-react` drops the console launcher, which only minted the removed console session: `OpenMediaDashboardButton`, `useOpenMediaDashboard`, `openMediaDashboardMutationOptions`, `openMediaDashboard`, `mintMediaDashboardSession`, `mediaDashboardSessionUrl`, `mediaDashboardUrl`, `ConsoleSessionError` and their types. Link to the console's `basePath` instead.
## 1.0.0-rc.0
### Major Changes
- [#281](https://github.com/DavideCarvalho/adonis-agora-media/pull/281) [`94f8af1`](https://github.com/DavideCarvalho/adonis-agora-media/commit/94f8af12bb87bf614a8ff0262958dd6120708851) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Release 1.0. Every export, option, subpath and ace command of `@adonis-agora/media` and `@adonis-agora/media-react` from 0.x works unchanged (see "Migrating to 1.0" in the docs). One behaviour is gone: the embedded console no longer reads a `window.__MEDIA_DASHBOARD__` global, only the JSON data block the provider injects.
- Node.js 24 or later is required (`engines.node: ">=24"`, unchanged).
- `@adonis-agora/media` accepts `@adonis-agora/authz`, `@adonis-agora/authkit-client`, `@adonis-agora/authkit-server` and `@adonis-agora/telescope` 1.x, including the 1.0 release candidates (`<lower> <2.0.0 || >=1.0.0-rc.0 <2.0.0`, lower bounds unchanged).
### Patch Changes
- [#281](https://github.com/DavideCarvalho/adonis-agora-media/pull/281) [`94f8af1`](https://github.com/DavideCarvalho/adonis-agora-media/commit/94f8af12bb87bf614a8ff0262958dd6120708851) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console fixes:
- The console now sends shield's CSRF token (`x-xsrf-token`, from the `XSRF-TOKEN` cookie) on every POST, including uploads from the Upload tab, so actions work in apps that use `@adonisjs/shield`. A redirected or non-2xx response now shows as an error instead of a silent success.
- The Uploads tab shows `upload sessions table missing — run the media migration (node ace migration:run)` (HTTP 503) instead of a 500 when the `lucid` upload-session store's tables do not exist.
- `FolderBody` is exported from `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard`.
## 0.30.0
### Minor Changes
- [#270](https://github.com/DavideCarvalho/adonis-agora-media/pull/270) [`64d5c2a`](https://github.com/DavideCarvalho/adonis-agora-media/commit/64d5c2abf610ab693b0198f2fc72f8fb9488de50) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `engines.mediabunny({ ladder })` encodes an adaptive-bitrate ladder without spawning ffmpeg, through the optional peer `@mediabunny/server` (mediabunny's Node decoders/encoders over NodeAV; its native binary needs glibc). Every rung is encoded from one decode of the video, with a keyframe every `targetDuration` seconds, and the audio once to aac as the shared group; both manifests are written over the CMAF playlists. Without `ladder` it is the default remux engine. A missing `@mediabunny/server` throws `TransformerRuntimeMissingError`. The audio is muxed in its own pass because mediabunny 1.65.2's HLS muxer fails an assertion — as an unhandled rejection — when several video variants share an audio group in one output.
`VideoPackagingEngine` gains an optional `storyboard` flag: `transformers.video({ storyboard })` now refuses, at config time, any engine that does not declare it (`engines.ffmpeg()` does). The HLS master of the mediabunny engines lists every video rendition.
- [#270](https://github.com/DavideCarvalho/adonis-agora-media/pull/270) [`64d5c2a`](https://github.com/DavideCarvalho/adonis-agora-media/commit/64d5c2abf610ab693b0198f2fc72f8fb9488de50) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `transformers.video({ storyboard })` writes timeline thumbnails — the preview a player shows over the progress bar while scrubbing — next to the streaming package: JPEG sprite sheets (`storyboard-001.jpg`…, a frame every `interval` seconds, `width` px wide, `columns` × `rows` per sheet; defaults 5 s, 160 px, 10 × 10) and a WebVTT (`storyboard.vtt`, `VIDEO_STORYBOARD`) mapping each interval to its tile with `#xywh=`. The stream route serves the sheets as `image/jpeg`, and the conversion `meta.storyboard` names the WebVTT; under `delivery.signing` a package WebVTT is signed like a manifest — only its cue lines that name package files get the signature, before the `#xywh=` fragment (new: `isWebVtt`, `rewriteWebVtt`, `WEBVTT_MIME_TYPE`). `engines.ffmpeg()` runs the storyboard decode alongside the encode, from the same local source; the default mediabunny engine cannot decode frames in Node, so `storyboard` without an engine is refused at config time. Also exported: `buildStoryboardArgs`, `buildStoryboardVtt`, `storyboardTileHeight`, `VIDEO_STORYBOARD_DEFAULTS`.
## 0.29.0
### Minor Changes
- [#258](https://github.com/DavideCarvalho/adonis-agora-media/pull/258) [`cb90771`](https://github.com/DavideCarvalho/adonis-agora-media/commit/cb90771a3e30c2e08b6342b51978af124d172c95) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **`media.fake()` / `media.restore()`** — fake the media service in app tests, like `drive.fake()` and `mail.fake()`.
`import media from '@adonis-agora/media/services/main'` captures the `MediaManager` once at boot, so `app.container.swap(MediaManager, …)` never reaches code that already imported it, and apps fell back to monkeypatching `media.library.attach = …`, which leaks between suites. The swap now happens inside the manager:
```ts
const fake = media.fake()
await uploadAvatar()
fake.assertCalled('attach', (input) => input.collection === 'avatar')
assert.equal(fake.calls.signedUrl[0]?.[1], 300) // TTL
fake.stub('deliver', async () => ({ kind: 'redirect', url: 'https://cdn.test/x' }))
media.restore()
```
- While faked, `media.library` (and `store`, `storage`, `attachments`, `uploads`, `resumable`, `direct`) run the real library code, with the configured collections and delivery settings, over an `InMemoryMediaStore`, an `InMemoryDisk` for every disk name and a `FakeImageProcessor`.
- The returned `MediaFake` records every `media.library` call with typed arguments (`fake.calls.<method>`), has `assertCalled` / `assertNotCalled`, and `stub(method, fn)` / `unstub(method)` to force a result or an error.
- `media.fake()` again starts a fresh fake; `media.restore()` is a no-op without one.
- New exports from `@adonis-agora/media/testing`: `MediaFake`, `MEDIA_FAKE_METHODS`, `lazyInMemoryDiskResolver`, and the types `MediaFakeOptions`, `MediaFakeMethod`, `MediaFakeCall`, `MediaFakeCalls`, `MediaFakeStub`.
`MediaManager.storage`, `library`, `attachments`, `store` and `uploads` are now getters instead of readonly fields. Reading them is unchanged; nothing could assign them before (they were `readonly`).
## 0.28.2
### Patch Changes
- [#246](https://github.com/DavideCarvalho/adonis-agora-media/pull/246) [`2e21558`](https://github.com/DavideCarvalho/adonis-agora-media/commit/2e215589fab2c7373bd7f34e7f97d807dc587a4f) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `S3Disk.deleteMany` now works on MinIO versions that reject `DeleteObjects` with `MissingContentMD5`: it falls back to single deletes and remembers.
## 0.28.1
### Patch Changes
- [#231](https://github.com/DavideCarvalho/adonis-agora-media/pull/231) [`32f9b32`](https://github.com/DavideCarvalho/adonis-agora-media/commit/32f9b324c9ddba49d80ce34ade1ba0692f33357c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - perf: fewer round-trips on the delivery hot paths.
- Proxied delivery (`deliver()` / `media.access.serve()` in `proxy` mode, `streamFile()` segments, the HLS
delivery route's streamed segments) issues the disk's `getMetaData` and `getStream` together instead
of one after the other — one storage round-trip less before the first byte. A metadata failure still
wins (and the opened stream is destroyed).
- `deliver()` with `?w=` reuses the record the resize already holds instead of fetching it again; the size
is still validated before the lookup.
- `media.access.serve()` (by id), `media.access.image()` and `media.access.stream()` hand the record they
just fetched and authorized to the library instead of letting it look the same id up again.
- Buffered writes (`toBytes`, proxy upload to a disk without `putStream`, console upload) no longer copy
every chunk and then the whole payload once more; HLS/DASH manifests are decoded without a copy.
## 0.28.0
### Minor Changes
- [#230](https://github.com/DavideCarvalho/adonis-agora-media/pull/230) [`1cdd8bc`](https://github.com/DavideCarvalho/adonis-agora-media/commit/1cdd8bc6952490e1e1268269006e0687e22d6693) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Dashboard: the `authorize` hook now follows the dashboard-gate contract shared by every `@adonis-agora` console. It may return `boolean | AuthorizeDecision` (`{ allowed, reason?: 'unauthenticated' | 'forbidden' }`); both types are exported from `@adonis-agora/media/dashboard`. `{ allowed: false }` denies (previously a decision object was truthy and would have been let through), `reason: 'unauthenticated'` answers `401` (`{ error: 'Unauthorized' }` JSON on the API, the "Sign in required" access-denied page on a navigation), and a bare `false`, a missing reason, `'forbidden'` or a throw keep answering `403`. A redirect — or a body — the hook wrote still wins, now on the API as well as on the page.
## 0.27.0
### Minor Changes
- [#228](https://github.com/DavideCarvalho/adonis-agora-media/pull/228) [`98ae7c1`](https://github.com/DavideCarvalho/adonis-agora-media/commit/98ae7c1af1187943eff5215e41196bff36e508f0) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Faster and lighter hot paths, plus an exact console summary:
- Resumable `complete()` on a disk without native multipart streams the parts in order into `putStream` instead of concatenating the whole upload in memory (three copies of it before), so a multi-gigabyte upload no longer runs the process out of memory.
- Attaching to a collection with eager conversions reads the original once for every preset (zero times when the bytes are in hand) and records all of them in one save. `stripMetadata` strips the uploaded bytes before the single write instead of writing, reading back and rewriting them.
- `image()` builds every `srcSet` URL from the record it already fetched: one store read per image instead of one per candidate.
- Concurrent requests for the same missing lazy conversion (or on-demand size) share one generation, and conversion entries generated at once for the same media in the same process no longer overwrite each other.
- The HLS playlist route checks references against a set, the SigV4 presigner reuses the derived signing key per (secret, day, region, service), and `S3Disk` parses its endpoints once: a 1,200-segment playlist renders about 3x faster.
- `transformers.video()` uploads the package six files at a time; when one fails, the rest finish before the partial output is swept.
- The `media` table gains `(created_at, id)` and `(collection, created_at, id)` indexes for the newest-first `list()`. The auto-created schema adds them on boot; the published migration includes them. It no longer creates `media_owner_idx`, whose columns are the leftmost prefix of `media_owner_collection_idx`.
- `MediaStore` gains an optional `collectionTotals()`, implemented by both bundled stores (a `GROUP BY` in Lucid). The console's collection summary uses it and is now exact at any size, where it previously stopped counting at 5,000 records.
## 0.26.2
### Patch Changes
- [#222](https://github.com/DavideCarvalho/adonis-agora-media/pull/222) [`8a9f335`](https://github.com/DavideCarvalho/adonis-agora-media/commit/8a9f33593037af3d145a476b71ef27b1ccc8c3cc) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `engines.ffmpeg()` also removes `#EXT-X-MEDIA-SEQUENCE` from the HLS playlists of a CMAF package. ffmpeg numbers them from 1, like the MPD's `startNumber`, and a player that reads the sequence as elapsed segments (mediabunny) started the video one segment late, reporting a 10s video as 14s. Without the tag, the sequence is 0 for every player.
## 0.26.1
### Patch Changes
- [#221](https://github.com/DavideCarvalho/adonis-agora-media/pull/221) [`bcf2a18`](https://github.com/DavideCarvalho/adonis-agora-media/commit/bcf2a18920569045be2b3b77258dbaa0f2525dca) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `engines.ffmpeg()` removes `#EXT-X-PROGRAM-DATE-TIME` from the HLS playlists of a CMAF package. ffmpeg's DASH muxer writes the wall-clock time of the transcode there. That means nothing for a VOD, and a player that maps the timeline to it reports a duration of decades and seeks wrong.
## 0.26.0
### Minor Changes
- [#220](https://github.com/DavideCarvalho/adonis-agora-media/pull/220) [`f3c135e`](https://github.com/DavideCarvalho/adonis-agora-media/commit/f3c135e4c9bd9a2409c4fa0cb88a871e6ffe8229) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Breaking (beta):** one video transformer replaces `transformers.hls()` and `transformers.dash()`.
- `transformers.video({ formats, segments, engine })`, with default conversion name `'video'`.
- **Default:** CMAF segments described by both an HLS master (`index.m3u8`) and a DASH manifest (`manifest.mpd`). The video is stored once and plays everywhere.
- **`segments: 'ts'`:** HLS over MPEG-TS, for players older than fMP4 HLS. Asking for DASH over TS throws at boot.
- **`formats: ['hls']` or `['dash']`:** writes only that manifest.
- **Pure JS by default.** mediabunny writes the CMAF package in two passes (video and audio in their own playlists, because dash.js does not play muxed segments), and the library builds the MPD from those playlists. No ffmpeg is needed on the host for either format.
- **`engines.ffmpeg({ ladder })` replaces `engines.ffmpegHls` and `engines.ffmpegDash`.** CMAF goes through ffmpeg's DASH muxer, TS through its HLS muxer.
- **Persisted meta:** `meta.hlsEntry`, `meta.dashManifest` and `meta.segments` record what was written, and `media.library.stream()` reads them.
- **`HlsDeliveryHandler`** now defaults to the `'video'` conversion.
- **New exports:** `buildDashManifest`, `parseMasterPlaylist` and `parseMediaPlaylist`, for packages from other HLS-only muxers.
Migration:
- `transformers.hls()` becomes `transformers.video()`, or `transformers.video({ segments: 'ts', formats: ['hls'] })` to keep TS segments.
- `transformers.dash()` becomes `transformers.video()`.
- `engines.ffmpegHls(o)` and `engines.ffmpegDash(o)` become `engines.ffmpeg(o)`.
- `transform(id, 'hls')` and `transform(id, 'dash')` become `transform(id, 'video')`, unless you keep the old name with `name: 'hls'`.
## 0.25.0
### Minor Changes
- [#218](https://github.com/DavideCarvalho/adonis-agora-media/pull/218) [`9cc5f45`](https://github.com/DavideCarvalho/adonis-agora-media/commit/9cc5f455f136025370c4405500977b0de938e48e) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Video streaming, HLS and DASH:
- `transformers.dash()` packages CMAF with the system ffmpeg: a DASH manifest and an HLS master playlist over the same fragmented-MP4 segments (`hls: false` for DASH only). `engines.ffmpegDash({ ladder })` encodes an ABR ladder.
- `media.access.streamRoute()` serves HLS/DASH packages at `/media/:id/stream/:conversion/*`. It authorizes every request with the collection's `access.read`, checks the file against the package, and redirects or streams segments per `delivery.mode`. `serveStream()` is the same for your own controller.
- `media.library.stream(id)` / `media.access.stream(ctx, id)` return the manifest URLs for a player, HLS first. With `delivery.signing` they are signed for the whole package, the route carries the signature onto every manifest reference, and it never expires before the video plus an hour.
- `delivery.streamPath` sets where those URLs point.
- `useMediaStream(ref, stream, { hls, dash })` in `@adonis-agora/media-react` plays HLS/DASH in your own `<video>`, headless. hls.js and dash.js are loaded on demand, iOS falls back to native HLS, and the hook exposes quality levels, `setLevel`, errors and the player instance.
## 0.24.0
### Minor Changes
- [#211](https://github.com/DavideCarvalho/adonis-agora-media/pull/211) [`f84d3fe`](https://github.com/DavideCarvalho/adonis-agora-media/commit/f84d3fe6b5e7797969a0c26f263cf214f1f84bb6) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `media.access.serve(ctx, record | id, options)` is the core of the delivery route, for a controller that finds the record its own way, such as a stable `/profiles/:id/photo` URL or a record looked up by its owner. It authorizes the read (a valid signature counts), honours the query and `Accept`, answers with the right headers, and maps the library's errors to HTTP. A missing record is a 404. `deliveryRoute()` is now built on it.
Fix: in `proxy` delivery, an object whose storage type is generic (`application/octet-stream`, which S3 reports for multipart/TUS-assembled objects) is now served as the record's MIME type, for the original. A PDF uploaded through TUS was reaching browsers and phones as an opaque binary that no viewer would open.
## 0.23.0
### Minor Changes
- [#206](https://github.com/DavideCarvalho/adonis-agora-media/pull/206) [`6276c41`](https://github.com/DavideCarvalho/adonis-agora-media/commit/6276c419bf832606c3cc55cb064dc1e97ce6910f) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Authorization that plugs into the app's auth: `media.access`.
- **Collection rules:** `collections[].access: { read?, write? }`. A rule built with `authorizers` (`owner`, `authenticated`, `roles`, `public`, `any`, `all`) or your own function. An absent rule denies.
- **The current user:** `access.identity` resolves it. The default reads `ctx.auth.user`. `authkitIdentity()` from the new `@adonis-agora/media/authkit` subpath covers both sides of authkit: on the server it takes the acting account plus the real human under impersonation; on the client, the token's sub, global roles and active organization.
- **authz rules:** `authz.can(permission | fn)` and `authz.roles([...])` from the new `@adonis-agora/media/authz` subpath. They check the real human (never an impersonated account), or the app's user object when the identity has one.
- **The delivery route:** `media.access.deliveryRoute(options?)` is a ready handler that every app used to write by hand. It authorizes the read (a valid signed URL counts as authorization), passes `?w`/`?q`/`?conversion`/`Accept`/`?exp`/`?sig` through, redirects or streams with the right headers (private `Cache-Control` by default, `Vary: Accept`, an RFC 6266 `inline` disposition), and answers the library's errors as 400/401/403/404 JSON.
- **In your own code:** `media.access.can()`, `authorize()` (throws the new `MediaAccessDeniedError`, with `status` 401 or 403), `subject()` and `image(ctx, id)`. The last one is `media.library.image()` after a read check.
authkit and authz are optional peers, imported only when used.
## 0.22.1
### Patch Changes
- [#204](https://github.com/DavideCarvalho/adonis-agora-media/pull/204) [`ae852da`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ae852da0803997df19f1fdd0f31f1df188b01624) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `MediaDeliveryHandler` takes `requireSignature`, which overrides `delivery.signing.required` for its route. Before, turning on signing (required by default) made every delivery route refuse unsigned requests, including those that already authorize by session or ownership. A route like that can now opt out with `requireSignature: false`: it keeps serving its own requests and still honours signed ones. `media.library.checkDeliverySignature(request, { required })` takes the same override.
## 0.22.0
### Minor Changes
- [#199](https://github.com/DavideCarvalho/adonis-agora-media/pull/199) [`0bee4fd`](https://github.com/DavideCarvalho/adonis-agora-media/commit/0bee4fd8ffbf3385f2bcf61baf5c50411af96e9b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `next/image` for stored images, and the features of other image libraries (Nuxt Image/IPX, Astro, Unpic, spatie, imgproxy) that were worth having.
**Rendering (`@adonis-agora/media-react`)**
- `<MediaImage>` renders one `<img>`. It loads lazily by default, `priority` marks the LCP image (React 19 also preloads it), and `fill` sizes it to the parent box. A blurred preview is painted behind it until it loads; this works with SSR, survives hydration, and stays in place if the image fails. Three ways to feed it:
- `image={await media.library.image(id)}`: a descriptor built on the server.
- `src="/a.jpg"`: a plain URL, with your own `srcSet`, `blurDataURL` and `placeholderColor`.
- `src={mediaId} loader={mediaImageLoader()}`: a loader, with `next/image`'s algorithm and widths.
- `layout` (`constrained` / `fullWidth` / `fixed`) derives the box style and `sizes`. A lazy image gets `sizes="auto, …"`.
- `focalPoint` becomes `object-position`.
- `<MediaPicture>` does art direction with `<source>`s, each with its own size.
- `placeholderStyle()` paints the preview on other components.
**Server (`@adonis-agora/media`)**
- `media.library.image(id)` returns `src`, a `srcSet` of same-picture presets, the intrinsic size, the placeholder and the focal point. An explicit `conversions` list forms its own art-directed group, and `onDemand` switches to resize URLs.
- On-demand resize through `MediaDeliveryHandler` (`?w=`/`?q=`): each size is resized once and cached as a conversion, never enlarged, and limited to the `delivery.images` whitelist. The format (AVIF/WebP) is negotiated from `Accept`, and the result carries `vary: 'Accept'`.
- Signed delivery URLs (`delivery.signing`, `media.library.deliveryUrl()`): an HMAC over the record, the conversion, the size and the expiry. Expiries are rounded so URLs stay cacheable. Unsigned requests are refused by default. With signing configured, `image()` only hands out signed route URLs.
- Focal points (`media.library.setFocalPoint()`) and preset `position` (`'attention'`/`'entropy'`) for content-aware crops.
- `responsive: true` collections: presets at standard widths (skipping those wider than the original) and the placeholder, from one flag.
- `stripMetadata: true` collections: the original is rewritten without EXIF/GPS/XMP/IPTC, with the orientation baked in and the colour profile kept.
- Generated image conversions record their output size in `meta`. Presets gain `withoutEnlargement`, `onlyDownscale` and `position`. `ImageProcessor` gains optional `dimensions()`/`stripMetadata()` and a `focalPoint` convert option.
- Fixes: animated GIF/WebP keep their frames when converted to WebP. Concurrent conversions of one record no longer drop each other.
- New errors: `ImageSizeNotAllowedError`, `NotAnImageError`, `DeliverySignatureError`.
## 0.21.0
### Minor Changes
- [#193](https://github.com/DavideCarvalho/adonis-agora-media/pull/193) [`ee1a275`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ee1a2753b4b7e2056880e6ed8f91f43fdd676193) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **ffmpeg engines for the HLS and probe transformers.** `engines.ffmpegHls()` and `engines.ffprobe()` plug into the existing `engine` option of `transformers.hls()` / `transformers.probe()` and spawn the system `ffmpeg` / `ffprobe` binaries. There is no npm dependency, and nothing is bundled.
- **Remux by default.** Without a ladder, `ffmpegHls()` does a stream copy, the same contract as the mediabunny engine.
- **`ladder` transcodes.** With `ladder: [{ height, videoBitrate, audioBitrate? }]` it encodes an h264/aac adaptive-bitrate ladder into one master playlist.
- Keyframes are forced on segment boundaries.
- Rungs taller than the source are dropped, so it never upscales.
- Ready-made ladders: `engines.ladders.standard` (360/720/1080p) and `engines.ladders.compact` (360/720p).
- This is the transcoding mediabunny can't do in Node without WebCodecs.
- **Same package shape.** The output is the shape the mediabunny engine writes (`index.m3u8` master, per-rendition playlists, MPEG-TS segments), so HLS delivery and playlist rewriting work unchanged.
- **Errors.**
- A missing binary throws `TransformerRuntimeMissingError`.
- A source with no video stream throws `HlsSourceUnsupportedError`, the same definitive signal the mediabunny engine gives, so callers branch on one error whatever the engine.
- Any other failed run throws the new `FfmpegFailedError` (`E_MEDIA_FFMPEG_FAILED`), carrying `exitCode` and the tail of `stderr`.
- `HlsSourceUnsupportedError` gains an optional `hint` constructor argument.
- **Validation.** The ladder is checked when the engine is built: heights must be positive even integers, and bitrates must parse.
- **ffprobe gaps.** The ffprobe engine reports `format` as ffprobe's `format_name` and does not report `mimeType`.
- **Also exported:** `ffmpegHlsEngine`, `ffprobeEngine`, `buildHlsArgs` and `effectiveLadder`, plus the `FfmpegRendition` / `FfmpegHlsEngineOptions` / `FfmpegBinaryOptions` types.
## 0.20.0
### Minor Changes
- [#190](https://github.com/DavideCarvalho/adonis-agora-media/pull/190) [`e7c4368`](https://github.com/DavideCarvalho/adonis-agora-media/commit/e7c436805d0e05281f6891d8c132fceccc58c505) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Image placeholders and blur.**
- New `transformers.placeholder()` — a metadata-only transformer that persists, on `record.conversions.placeholder.meta`, a tiny WebP preview as a `data:` URL, the original's dimensions (after EXIF orientation) and its dominant colour. Enough to render a blur-up placeholder with the right aspect ratio in the same response as the image URL, with no extra request or client decoder. Eager by default; skips non-`image/*` and SVG records with `meta: {}`. Needs the `sharp` peer (loaded lazily). Exported as `PlaceholderTransformer` with its `ImagePlaceholder` / `PlaceholderEngine` types.
- `placeholderOf(record)` reads that placeholder off any `MediaRecord` (whatever the transformer's name), and `storeSingleFile` / `storeSingleFileWith` now also return the record `id` and its `placeholder` (or `null`).
- `ConversionPreset.blur` — gaussian blur sigma applied after the resize, for blurred variants served as files.
- **Fix:** the sharp processor now auto-orients from EXIF before resizing. Phone photos taken in portrait used to come out sideways in every conversion, because the output drops the EXIF orientation tag that made the original display upright. Existing conversions are not regenerated.
## 0.19.0
### Minor Changes
- [#171](https://github.com/DavideCarvalho/adonis-agora-media/pull/171) [`637411b`](https://github.com/DavideCarvalho/adonis-agora-media/commit/637411b387062f27ba1261c72e928f8dd64ab0cc) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Drop Node.js 20 and 22: `engines.node` is now `>=24`. Node 20 reached end-of-life on 2026-04-30, and AdonisJS 7, which these packages require as a peer, needs Node 24 or later (`@adonisjs/core` declares `engines.node >=24.0.0`). The supported lines are the ones Node still maintains that AdonisJS 7 accepts: 24 and 26, both tested in CI.
## 0.18.2
### Patch Changes
- [#165](https://github.com/DavideCarvalho/adonis-agora-media/pull/165) [`54b80c2`](https://github.com/DavideCarvalho/adonis-agora-media/commit/54b80c221b74428fafd3f4e3c50b1d12fd1dc8c5) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Normalize truncated MIME declarations at the TUS and direct-upload gates too
`attach` / `attachExisting` already resolve a bare top-level type (`"text"` for `report.csv`) from the file extension, but the earlier, byte-free gates did not: TUS `POST` answered `415` and `DirectUploadManager.initiate` threw `MimeNotAllowedError` for the very same upload that `attach` would accept. Both gates now share the same resolver (against the TUS `filename` / the direct-upload key), and record the normalized type — TUS sniffs the first chunk against it, direct uploads stamp it as the object's `Content-Type`. The whitelist stays authoritative: an unresolvable or non-whitelisted result is still rejected with the allowed list.
## 0.18.1
### Patch Changes
- [`1a987d7`](https://github.com/DavideCarvalho/adonis-agora-media/commit/1a987d70e19904cf561e4610e2b044910ed95aa0) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix the `TransformerContext` docblock, which sketched a conversion prefix missing the collection segment `outputPrefix` documents correctly
## 0.18.0
### Minor Changes
- [#80](https://github.com/DavideCarvalho/adonis-agora-media/pull/80) [`e83f7d2`](https://github.com/DavideCarvalho/adonis-agora-media/commit/e83f7d2ca0d57ca2af770d7b9385b18fb96c60c2) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Breaking (0.x minor):** the dashboard's paginated listings now use the ecosystem's shared **cursor** pagination interface, the same one `@adonis-agora/filter` defines — `{ after, first }` in, `{ …items, nextCursor, prevCursor, hasNext, hasPrev }` out. Every `@adonis-agora/*` library is converging on that interface so a caller learns it once.
Filter defines two mechanisms — offset and cursor. This package adopts the **cursor** one (not offset), because its listings are backed by S3's `ListObjectsV2` continuation token and, for `/collections`, a `createdAt`/`id` keyset. Those are opaque, forward-only handles to *what comes next*: there is no way to compute an offset or seek to page 7, so cursor is the honest match rather than a workaround.
**Forward-only, deliberately.** Filter's `CursorParams` also carries `before` / `last`; this package does **not** accept them — better a compile error than a silently ignored parameter — and pins `prevCursor: null` / `hasPrev: false` in every response. Those two fields stay present so the page *is* the ecosystem's `CursorPage` shape rather than a near-miss of it. Walk forward and keep the pages you've seen (which is what the console SPA does).
What changed:
- `DashboardService.objects(disk, { prefix?, cursor?, limit? })` → `objects(disk, { prefix?, after?, first? })`. Its result `{ folders, files, cursor? }` → `{ folders, files, nextCursor, prevCursor, hasNext, hasPrev }`. `objects` keeps **two** payload arrays instead of a single `items`: a delimiter listing returns folders (common prefixes) *and* files in the same page, and merging them would lose that distinction — its type is `CursorPageInfo & { folders, files }`, i.e. filter's page envelope with a two-part payload.
- `DashboardService.collections({ …filters, cursor?, limit? })` → `collections({ …filters, after?, first? })`, returning `CursorPage<MediaEntry>` verbatim (`items` + the envelope) instead of `{ items, nextCursor }`.
- Routes: `GET /objects` and `GET /collections` now read `?after=&first=` instead of `?cursor=&limit=`.
- New exported types on both `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard/types`: `CursorParams`, `CursorPage<T>`, `CursorPageInfo`.
- Page sizes are unchanged — the SPA still asks for 50 per page, only the parameter name moved.
Not changed: `MediaStore.list` and the `ExtendedDisk.list` driver keep their `{ cursor, limit }` → `{ items, nextCursor }` / `{ folders, files, cursor }` vocabulary. Those are persistence/driver SPIs that custom stores and disks implement, not listing APIs a client calls; the dashboard maps `after` → `cursor` and `first` → `limit` at its boundary.
Migration — a hand-rolled route over `DashboardService`:
```ts
// before
const page = await dashboard.objects('s3', {
prefix: request.input('prefix'),
cursor: request.input('cursor'),
limit: 100,
})
render(page.folders, page.files)
const more = page.cursor
// after
const page = await dashboard.objects('s3', {
prefix: request.input('prefix'),
after: request.input('after'),
first: 100,
})
render(page.folders, page.files)
const more = page.hasNext ? page.nextCursor : null // prevCursor is always null: forward-only
```
And a browser client call:
```ts
// before
await client.collections({ ownerType: 'Post', cursor: page.nextCursor ?? undefined, limit: 50 })
// after
await client.collections({ ownerType: 'Post', after: page.nextCursor ?? undefined, first: 50 })
```
## 0.17.0
### Minor Changes
- [#78](https://github.com/DavideCarvalho/adonis-agora-media/pull/78) [`b042623`](https://github.com/DavideCarvalho/adonis-agora-media/commit/b042623f1ae31713d0485361a9e60f483bf68c9f) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console: `objectUrls` follows the core `delivery.mode` when unset.
A host already streaming every read through the app (`delivery.mode: 'proxy'` in
`config/media.ts`) has declared its store unreachable from a browser — minting the console a
signed URL for the internal endpoint anyway handed it a link that resolves nowhere. With no
explicit `objectUrls` in `config/media_dashboard.ts`, the console now implies `'proxy'` from a
proxy delivery mode and keeps `'auto'` otherwise. An explicit `objectUrls` always wins, so
nothing moves for hosts that set it.
## 0.16.0
### Minor Changes
- [#76](https://github.com/DavideCarvalho/adonis-agora-media/pull/76) [`eb15100`](https://github.com/DavideCarvalho/adonis-agora-media/commit/eb15100f5b9cda54d1cbd5a4378a4a1d0f80774c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console: new `objectUrls` option — report object URLs through the console's own proxy, for a store
the browser cannot reach.
Every object the console shows carries a `url`: what "Open ↗" links to, and the `src` of the image
/ video / audio previews. It was always a short-lived signed URL straight to the object store, which
silently assumes the browser has a route to that store. On a deployment where it does not — a
private bucket on an internal network, a MinIO addressed by an in-cluster hostname, a policy against
client-to-bucket traffic — that URL is signed for the INTERNAL endpoint and resolves nowhere in a
browser (`ERR_NAME_NOT_RESOLVED`). The console had the bytes available same-origin the whole time
(`GET /object/raw`, which the PDF and text previews already use) and linked past them anyway.
`objectUrls: 'proxy'` in `config/media_dashboard.ts` makes `GET /object` (and the per-conversion
variant URLs of `GET /media-record`) report `<apiBasePath>/object/raw?disk&key` instead — same
origin, same auth as the rest of the console. `'auto'`, the default, is the previous behaviour
unchanged, so nothing moves for a store the browser can reach.
Same option name and same two values as the NestJS sibling console, so the two answer "the bucket
is not reachable from the browser" identically.
## 0.15.1
### Patch Changes
- [#70](https://github.com/DavideCarvalho/adonis-agora-media/pull/70) [`42c33b5`](https://github.com/DavideCarvalho/adonis-agora-media/commit/42c33b5f2a2acefb041867c9384cb2c6e5785120) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Security: a client-supplied upload `fileName` could escape its storage prefix via path traversal —
fixed.
`MediaLibrary#layoutPath` (used by `attach`/`attachExisting`) and the default `keyFor` of both
`DirectUploadHandler` and `TusUploadHandler` interpolated the caller's `fileName` straight into a
storage key: `${owner}/${collection}/${id}/${fileName}` or `uploads/${token}/${fileName}`. A file
name of `../../../../etc/passwd` (or an absolute path) walked the resulting key outside its intended
prefix, the same class of bug transformer output paths were already guarded against via
`assertSafeArtifactPath`.
The same problem existed in the separate, older adonis-attachment-style API:
`AttachmentManager#createFromFile` (`attachment.ts`) built its storage key as
`${keyPrefix}/${id}/${fileName}` from the same unsanitized, client-supplied `fileName`. That call
site gets the identical fix below. (`single_file_store.ts`'s `storeSingleFile`/`storeSingleFileWith`
build no storage key of their own — they delegate to `MediaLibrary.attach`, so they were already
covered once `#layoutPath` was fixed.)
Every one of those call sites now runs the file name through a new `sanitizeFileName` helper first:
it must be exactly one path segment — no `/` or `\`, not empty, not `.`/`..`, and free of control
characters — or it throws `UnsafeFileNameError` (`E_MEDIA_UNSAFE_FILE_NAME`). `DirectUploadHandler`
and `TusUploadHandler` map that to a `400` instead of leaking a storage-layer crash;
`AttachmentManager#createFromFile` throws it directly, the same way `MediaLibrary.attach` does, for
the caller to handle. Ordinary file names (including unicode ones) are unaffected; only
path-traversal- and absolute-path-shaped names are rejected.
## 0.15.0
### Minor Changes
- [#67](https://github.com/DavideCarvalho/adonis-agora-media/pull/67) [`ede5aba`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ede5aba7acf0b83c8c2338eeb521b34df6bf785a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Console: a refused page navigation now gets a real page instead of `{"error":"Unauthorized"}`,
and an `authorize` refusal is a `403` everywhere.
When `authorize` refuses, opening the console used to answer the browser with the same JSON the
API gets. It now serves a built-in access-denied page in the console's own visual language — the
status, a sentence explaining the refusal and a "Back to app" link. An `authorize` hook that
redirects still wins.
The status of that refusal changes from `401 { error: 'Unauthorized' }` to
`403 { error: 'Forbidden' }` on the API too — the hook knew who was asking and said no, which is
what every other Agora console already answers. The SPA is unaffected: it decides whether to show
its login screen from `GET /me` (ungated) and the session guard's `401 { auth: { modes } }`, which
are unchanged. Only a client scripted against the old `401` for an `authorize` denial notices.
The page carries no inline `<script>`, so a nonce'd `script-src` CSP cannot break it; its inline
`<style>` takes `@adonisjs/shield`'s request nonce when one exists.
New `accessDenied` option on `config/media_dashboard.ts` to customise it — an object (`brand`,
`title`, `message`, `homeHref`, `accent`, labels) to tweak the built-in page, or a function
`(info, ctx) => html | void` to render it yourself or redirect.
Also fixed: when `authorize` wrote a redirect on an API request, the guard still ran the route
handler on top of the `302`; it now stands down like the SPA routes do.
## 0.14.1
### Patch Changes
- [#63](https://github.com/DavideCarvalho/adonis-agora-media/pull/63) [`a90e230`](https://github.com/DavideCarvalho/adonis-agora-media/commit/a90e230d3fea035345238922052d0988bd3c4c2a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Dashboard: every API request 404 under a nonce CSP — fixed.
The provider used to hand the SPA its bootstrap (API base, uploads base, tus base, actions) as an
inline `<script>` setting `window.__MEDIA_DASHBOARD__`. A host with `script-src 'self' 'nonce-…'`
(`@adonisjs/shield`'s `@nonce`, the recommended setup) drops that script silently; the SPA then fell
back to `/media/dashboard/api`, and on any other mount path every request from a console that
rendered perfectly well answered 404. The bootstrap now travels as a
`<script type="application/json">` data block, which is never executed and so cannot be refused.
Nothing to change on the host; the global is still honoured as a fallback.
## 0.14.0
### Minor Changes
- [`0851b04`](https://github.com/DavideCarvalho/adonis-agora-media/commit/0851b0472ef8914e9d54ea1fbe27767ed2d7e521) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - feat(media): auto-create the `media` table on first use (ecosystem convention)
`LucidMediaStore` now auto-creates its table by default (`autoCreateSchema: true`),
matching `@adonis-agora/authz` and `@adonis-agora/durable` — a lib owns its own schema.
Exports `createMediaTables` / `dropMediaTables` from the package root (and the
`@adonis-agora/media/stores/lucid-schema` subpath) so an app that prefers explicit
control can set `autoCreateSchema: false` and run the same DDL from a migration.
## 0.13.0
### Minor Changes
- [`dbae909`](https://github.com/DavideCarvalho/adonis-agora-media/commit/dbae909703578e6aa8cc231cf5a33005e136feb4) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Add an `authorize` option to the media dashboard config — an access-decision hook
gating the whole console (SPA + JSON API), same shape as the other `@adonis-agora`
dashboards (telescope, durable, agent):
```ts
// config/media_dashboard.ts
import { defineConfig } from "@adonis-agora/media/dashboard";
import { authorizeByRoles } from "@adonis-agora/authz";
export default defineConfig({
authorize: authorizeByRoles({ roles: ["ADMIN"] }),
});
```
- Receives the real `HttpContext`; return `true` to allow, `false` to deny.
- Runs **before** `middleware` and composes with the built-in `auth` session guard
(all must pass).
- A denied request answers `401`/`403` — or honors a redirect the hook wrote (a
`location` header), so a hook can send visitors to the app's login page.
- A throwing hook fails closed (denied), never leaks the console.
- When omitted, behavior is unchanged (console open unless you gate with
`middleware`/`auth`).
New exported type: `DashboardAuthorize`.
## 0.12.2
### Patch Changes
- [#57](https://github.com/DavideCarvalho/adonis-agora-media/pull/57) [`331f53f`](https://github.com/DavideCarvalho/adonis-agora-media/commit/331f53f6294f3b7e4261bdbf65fb8090063aa673) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ship TanStack Intent agent skills with every package. Each package now publishes a
`skills/` directory (`media-*` SKILL.md files) that lands in `node_modules` on install, so
AI coding agents can discover them via `npx @tanstack/intent list`; adds `@tanstack/intent`
as a devDependency for `intent validate` in CI.
## 0.12.1
### Patch Changes
- [#52](https://github.com/DavideCarvalho/adonis-agora-media/pull/52) [`4d9651d`](https://github.com/DavideCarvalho/adonis-agora-media/commit/4d9651d29863f2823f426a38588305528e8da699) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Fixes a hard `npm install` failure.** Two peer ranges used a caret over a 0.x dependency, which under semver does not cross a minor — `^0.4.0` means `>=0.4.0 <0.5.0`. Every later minor of those peers fell out of range.
pnpm downgrades an unsatisfied peer to a warning, so this was invisible inside the monorepo. **npm treats it as `ERESOLVE` and refuses to install**, even though both peers are declared optional:
```
While resolving: @adonis-agora/media@0.12.0
Found: @adonis-agora/telescope@0.8.1
Conflicting peer dependency: @adonis-agora/telescope@0.4.0
```
- `@adonis-agora/telescope`: `^0.4.0` → `>=0.4.0 <1.0.0`. Telescope is at 0.8.1, so any consumer on a current telescope could not install this package under npm. The floor stays at 0.4.0: bisecting the published tarballs shows the extension contract `mediaTelescopeExtension()` implements has been type-compatible since 0.1.0, so 0.4.0 was never too high — only the ceiling was wrong.
- `sharp`: `^0.33.0` → `>=0.33.0 <1.0.0`. Same defect, same `ERESOLVE`; sharp is at 0.35.3. The processor only uses `resize`/`toFormat`/`quality`/`toBuffer`, verified end to end against sharp 0.35.3 outside the monorepo.
No runtime behaviour changes, and no dependency is bumped — this only widens what a consumer is _allowed_ to have installed.
## 0.12.0
### Minor Changes
- [#46](https://github.com/DavideCarvalho/adonis-agora-media/pull/46) [`e2baf99`](https://github.com/DavideCarvalho/adonis-agora-media/commit/e2baf993dae1a7d3574128085abe1cf48087a023) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - **Behaviour change — omitting `disk` now really uses Drive's default disk.** Read this if your `config/media.ts` does not set `disk`.
The documented fallback ("omit `disk` and the provider uses the `default` of your `config/drive.ts`") had never worked in any environment. `MediaProvider` read it as `app.config.get('drive').default`, but `app.config.get('drive')` returns the value your config file exported — Drive's `defineConfig()` returns an **unresolved `ConfigProvider`** (`{ type: 'provider', resolver }`), so `.default` was always `undefined` and the fallback always returned the literal string `'default'`. (Reading `.config.default` instead does not help either: `{ config: { default, fakes, services } }` is the shape the provider's resolver _returns_, never the shape of the provider itself.) The provider now resolves the config provider — the same thing `@adonisjs/drive`'s own provider does before it builds its manager — and reads the default disk name off the resolved config. Drive's `DriveManager` cannot be asked instead: it keeps that config in a `#private` field and exposes no accessor.
**Am I affected?** Look at the `default` key of your `config/drive.ts`:
- `default: 'default'` (or you set `disk` in `config/media.ts`, or you have no Drive config at all) → nothing changes.
- `default` is anything else _and_ your `services` map has **no** disk named `default` → media was hard-broken for you (every disk operation threw inside flydrive, because it was asked for a service named `'default'` that does not exist). This release fixes it; there is nothing to migrate.
- `default` is anything else _and_ your `services` map **does** have a disk named `default` → **this moves where your files are written and read.** New objects now go to your real Drive default (e.g. `s3`) instead of the disk named `default`.
**Migration.** Objects already written under the `'default'` disk will not be found on the new disk — nothing copies them. Media records persist their own `disk`, so rows attached before this upgrade keep resolving to `'default'` and stay readable as long as that disk still exists in `config/drive.ts`; anything that recomputes a location from the _current_ default (or any object you wrote outside the media record store) will look on the new disk and miss. To keep the old behaviour exactly, pin it explicitly:
```ts
// config/media.ts
export default defineConfig({
disk: "default", // was implicit before this release
});
```
Otherwise, move the existing objects to your real default disk (or point that Drive service at the same bucket/location) before upgrading.
This is a minor, not a major: the package is pre-1.0, where minor is the breaking-change channel, and a `1.0.0` would signal an API stability this package has not declared. The affected surface is narrow (a host that both omits `disk` and keeps a Drive disk literally named `default` alongside a different Drive `default`), the alternative for most affected hosts was a crash, and pinning the old behaviour is a one-line config change.
## 0.11.0
### Minor Changes
- [`ad61387`](https://github.com/DavideCarvalho/adonis-agora-media/commit/ad61387aba714ba85ce6a6cf810b97259db46a93) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - The management console now ships **embedded** — `@adonis-agora/media/dashboard_provider` mounts the same React SPA + JSON API `@adonis-agora/media-dashboard` always has, straight from this package. `node ace configure @adonis-agora/media` registers it automatically (alongside publishing `config/media_dashboard.ts`); no separate `@adonis-agora/media-dashboard` install is required to get the console.
New subpath exports:
- `@adonis-agora/media/dashboard_provider` — the provider (routes: SPA + assets, JSON API, session auth). Reads the same `media_dashboard` config key `@adonis-agora/media-dashboard`'s provider always did, so an existing `config/media_dashboard.ts` keeps working unchanged if you switch to this provider.
- `@adonis-agora/media/dashboard` — `defineConfig`/`MediaDashboardConfig` for authoring `config/media_dashboard.ts`, `DashboardService`/`DashboardError`, the built-in session-auth helpers (`resolveConsoleAuth`, `signSessionCookie`, `verifySessionCookie`), `ObjectInsightProvider`/`sanitizeInsight`, and the dashboard's JSON API types.
`MediaDashboardConfig` also gains `enabled` (default `true`) — set `false` to register the provider without mounting any route.
At build time, `pnpm build` copies `@adonis-agora/media-dashboard`'s built SPA (`dist/spa`) into this package's own `dist/assets/spa`, mirroring `@adonis-agora/durable`'s embedded-dashboard pattern. `@adonis-agora/media-dashboard` remains published, standalone-installable, and its own provider (`@adonis-agora/media-dashboard/media_dashboard_provider`) still works — see that package's own changeset for what changed there. Register only one of the two dashboard providers in a given app.
## 0.10.4
### Patch Changes
- [`a06b2df`](https://github.com/DavideCarvalho/adonis-media/commit/a06b2df5194259be83fa08e8af15e7f9b07c48b3) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Widen the `@adonisjs/drive` peer dependency from `^3.0.0` to `^3.0.0 || ^4.0.0`.
Verified compatible by running the real test suite against `@adonisjs/drive@4` (the package's dev dependency is bumped accordingly). No source changes were needed — this is a non-breaking relaxation of the accepted peer range, so consumers can adopt Drive v4 without waiting on a major bump here.
## 0.10.3
### Patch Changes
- [`fdfafea`](https://github.com/DavideCarvalho/adonis-media/commit/fdfafeabf618b2787a970c4b104af822dcec03fe) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `services/main` no longer throws when imported before `MediaProvider.register()`
The `@adonis-agora/media/services/main` singleton used a provider-captured `getBootedApp()` with a
top-level `await` — importing it before `MediaProvider.register()` ran (e.g. the ace command loader
reading command metadata during `node ace list`) threw `app accessed before MediaProvider registered`.
It now follows the ecosystem-standard pattern used by `@adonisjs/lucid`, `@adonisjs/drive` and
`@adonisjs/queue`: read the app from `@adonisjs/core/services/app` (whose binding is set by
`bin/server`/`bin/console` before any command module is imported) and capture the `MediaManager`
inside `app.booted(...)`. Importing the singleton is now safe at any time; the manager resolves once
the app boots.
## 0.10.2
### Patch Changes
- [`4ca013b`](https://github.com/DavideCarvalho/adonis-media/commit/4ca013b722fc621c5465e4ad766166d373c6b05d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Normalize generic/truncated MIME declarations from the file extension, and list the accepted types in the rejection
**Better error message.** `MimeNotAllowedError` (code `E_MEDIA_MIME_NOT_ALLOWED`) now includes the collection's `acceptsMimeTypes`, so a rejected upload is instantly diagnosable: `MIME type "text" is not allowed in collection "dataset". Allowed: text/csv, text/plain.` The error also carries the list on a new `accepted` field.
**MIME normalization.** Adonis multipart sometimes reports a bare top-level type (`"text"` instead of `"text/csv"`), which used to be rejected outright. Now `attach` / `attachExisting` treat a generic or non-whitelisted declaration as ambiguous and try to pin a concrete MIME from the file extension via a small built-in map (`.csv` → `text/csv`, `.tsv`, `.txt`, `.xlsx`/`.xls`, `.json`, raster images, `.svg`, `.pdf`, common video containers). When the extension resolves to a type the collection **does** whitelist, that normalized value is what the record stores (and what the disk's `Content-Type` and the content-signature check use). The whitelist stays authoritative — the resolved type must be on it, and the magic-byte check still runs — so nothing is loosened; an unresolvable or non-whitelisted result still throws `MimeNotAllowedError` with the allowed list.
## 0.10.1
### Patch Changes
- [`1a5bac3`](https://github.com/DavideCarvalho/adonis-media/commit/1a5bac365b7ed806a08c65a7b30c2c39f056b72d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix the direct-upload `policy` default export being usable as a class.
`uploads.direct.routes.policy` is a lazy `() => import(...)`, and the idiomatic AdonisJS policy is a `default export class`. Until now the provider handed the module's default export straight to the handler **without instantiating it**, so a class policy crashed at runtime — the handler called `policy.onInitiate(...)` on the constructor, not on an instance. The provider now instantiates a class default export (no arguments) and passes a ready object through unchanged, so both forms work.
The config seam is typed accordingly: the new `DirectUploadPolicyModule` accepts either a policy class or a ready policy object. It is typed `<any, any>` on purpose — `DirectUploadPolicy` is invariant in its context and record generics, so `<unknown, unknown>` would reject every concretely-typed policy; the `any` is contained at this config boundary and the handler still sees a fully-typed policy.
## 0.10.0
### Minor Changes
- [#23](https://github.com/DavideCarvalho/adonis-media/pull/23) [`77337c8`](https://github.com/DavideCarvalho/adonis-media/commit/77337c8ecde9589f9a006600420327eae5b6a0f2) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `DirectUploadPolicy` — the business-logic extension point for session-backed direct uploads.
The 0.9.0 `media.direct` flow knew how to move bytes straight to S3 and persist the session, but every consuming app still had to wrap the built-in routes to answer the questions that are always the same shape yet always app-specific: _is this caller allowed to upload here, does the declared file pass my rules, which record do I create up front, and what do I do once the bytes land?_ `DirectUploadPolicy` lifts that seam into the lib. An app implements one object — `onInitiate` (validate + open the multipart upload + return the `InitiateDecision`: key, collection/disk overrides, visibility, part size, metadata, an optional JSON `response` merged into the 201, and an optional `rollback` ran if the initiate later fails), `resolveComplete` (map the session id back to the app's pending record + the `attachExisting` target) and `onComplete` (run after the bytes are attached — flip status, probe duration, dispatch the transcode job — and return the response body) — plus the optional `onInitiated` (persist the session id on the record), `onAbort` (clean up the pending record) and `mapError` (translate a thrown error into a typed HTTP response, e.g. a validation failure → 422 or incomplete-parts / session-not-found → 409).
The policy is wired through two new `uploads.direct.routes` config seams: `policy` (a lazy `() => import(...)` so the app's models load only when an upload actually happens) and `middleware`. **The built-in routes remain unguarded by default** — exactly as before — so an app that wants auth sets `middleware: [middleware.auth()]` itself; the lib never silently adds a guard. The provider forwards the request context into the handler (`handle(toRequest(ctx), ctx)`) and adopts the completed bytes via `completeDirectUploadToLibrary`, so the collection whitelist is still re-verified against the **real** bytes on complete. A per-decision `disk`/`collection` falls back to the manager-level default when the policy doesn't override it.
Also new: `traceMedia` observability hooks that republish the direct-upload lifecycle as spans through `@adonis-agora/diagnostics`' global `TRACE_SLOT` **structurally** — no hard dependency, no-op when diagnostics is absent.
## 0.9.0
### Minor Changes
- [#20](https://github.com/DavideCarvalho/adonis-media/pull/20) [`a44014e`](https://github.com/DavideCarvalho/adonis-media/commit/a44014eb05c1aea460c163b1dd68c98bee01c284) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Session-backed direct uploads (`media.direct`) and a hand-rolled SigV4 presigner with split internal/public endpoints
**Why a third upload flow.** For video-sized files the deciding cost is bandwidth _through the app_. The TUS path resumes beautifully but streams every chunk client→app→S3 — 2× the bytes, and the app pays for both directions. The raw direct primitives (`media.uploads.initiateDirect` & friends) send bytes straight to S3, but they are stateless: `uploadId`, the part size and every collected `ETag` live only in the client's memory, so a page reload orphans the upload — and every consuming app was growing its own tracking table to compensate. `DirectUploadManager` (`media.direct`, config `uploads.direct`) combines the halves: the browser `PUT`s multipart parts straight to S3 through presigned URLs (the app moves **no** payload), while the session — `uploadId`, the agreed `partSize`, every confirmed part ETag — persists in the existing `UploadSessionStore` SPI. Same SPI, and with `uploadSessions.lucid()` the same tables, as TUS: **zero new migrations**; a part-size marker in the session metadata keeps the two flows from ever misreading each other's sessions in a shared store. TUS remains the right tool when the disk isn't S3 or bytes must flow through the app; direct sessions when they mustn't.
The lifecycle is deliberately front-loaded and resumable at every step:
- **`initiate`** validates part-size geometry (S3's 5 MiB floor and 10,000-part cap — caught here as the new `UploadPartSizeError`, instead of as S3's `EntityTooSmall` _after_ the whole file crossed the wire) and, given a `collection`, the declared `contentType` against that collection's `acceptsMimeTypes` — read from the same registry `attach` uses, so the gate and the barrier cannot drift — before the multipart upload even opens. Then it persists the session and presigns every part URL in one local batch.
- **`confirmPart`** records each uploaded part's ETag server-side — the resume currency. Everything else is disposable client state.
- **`status`** is the resume answer: confirmed ETags plus **fresh** presigned URLs for the parts still missing — which is also why the presign TTL no longer has to be sized to "the whole upload on a slow connection"; an expired URL costs one status round-trip, not the upload.
- **`complete(id, parts?)`** merges caller-supplied and confirmed parts and fails fast naming the exact missing part numbers (`UploadPartsIncompleteError`) instead of letting S3 return an opaque `InvalidPart`; **`abort`** frees the parts S3 is storing (best-effort — a lifecycle-reaped upload must still be deletable locally); expired sessions are reaped on access exactly like TUS.
`DirectUploadHandler` is the framework-neutral HTTP half in the `TusUploadHandler` mold — the provider mounts it under `uploads.direct.routes` (default `/media/uploads/direct/sessions`), it performs **no authorization** (the app guards the route), and the client sends a `fileName`, never a key: the key is resolved server-side via `keyFor`. `MediaManager.completeDirectUploadToLibrary(sessionId, input, parts?)` mirrors `completeUploadToLibrary`: complete + `attachExisting` in one step, zero-copy, with the collection whitelist re-validated against the **real** bytes (`verifyContentAgainstWhitelist` on a 16-byte head read) — the initiate gate checked what the client _declared_; this remains the barrier that checks what it _sent_.
**Presigned URLs are now hand-rolled SigV4 (query auth, `UNSIGNED-PAYLOAD`) — the `@aws-sdk/s3-request-presigner` peer is gone.** Presigning is pure local crypto (an HMAC chain over a canonical request; no round-trip to S3), so the SDK package bought nothing except a hard coupling of the signature to the client's configured endpoint. That coupling is precisely what breaks browser-consumed URLs behind a private network: SigV4 bakes the `Host` into the signature, and a URL signed for the internal MinIO FQDN is invalid on the public one — with the SDK the only fix is constructing a second client per endpoint. Owning the signer makes it a parameter: the new `publicEndpoint` option on `disks.s3()` signs **browser-facing** URLs (direct-upload part `PUT`s, signed `GET`s) for the public host while server-side operations — including the ListObjectsV2 XML-fallback fetch — stay on the internal `endpoint`. The signer (`presignS3Url`, exported) is verified byte-for-byte against AWS's published `examplebucket` presigned-GET test vector, plus an independently recomputed `UploadPart` vector locked as a regression pin; strict RFC 3986 encoding (including the `!'()*` set `encodeURIComponent` skips) and STS session tokens are covered. Credentials and region still resolve from the SDK client's own config, so every credential source (static, env, shared config, IAM role) keeps working.
Also new: typed `UploadPartOutOfRangeError` (a confirmed part number outside the agreed slicing) and `DirectUploadsNotConfiguredError` (accessing `media.direct` without `uploads.direct`), both alongside the errors above; `direct.partSize`/`direct.presignTtlSeconds` fall back to the shared `uploads.*` knobs, with a 20 MiB default part size (direct parts occupy no app memory, so a bigger part only enlarges the retry unit). Requires bucket CORS that allows `PUT` from the app's origin and exposes the `ETag` response header — the browser must read it to confirm parts.
- [#21](https://github.com/DavideCarvalho/adonis-media/pull/21) [`75649a9`](https://github.com/DavideCarvalho/adonis-media/commit/75649a9c6793f9f8fc83da07ee2418ab9ff8432b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Transformers — transformações de conteúdo plugáveis persistidas como conversions — com HLS de vídeo como implementação de referência
**O contrato `Transformer`.** Conversions de imagem respondem "mesma imagem, outro tamanho/formato". Tudo o mais que deriva de uma mídia — um pacote HLS, uma faixa de áudio extraída, metadados sondados, um blurhash — agora passa por um contrato único: um `Transformer` recebe um `TransformerContext` (o record, leitura do original via `getBytes`/`getStream`, o `storage` para assets auxiliares em outros disks) e produz artefatos + metadados persistidos como uma conversion nomeada no `MediaRecord`. O contrato foi validado contra os shapes possíveis antes de nascer: N artefatos com entry (HLS), 1 artefato (otimizar imagem, extrair áudio), **zero artefato** (probe/placeholder — só `meta`), input auxiliar (watermark via `context.storage`) e requisito de runtime declarável (`TransformerRuntimeMissingError` tipado para WebCodecs/peer ausente).
O sandbox é do context, não do transformer: todo `write(relativePath, contents)` cai sob o prefixo `…/conversions/<name>/`, é validado (sem `..`/caminho absoluto — `TransformerOutputError`) e **registrado** — a lista `files` persistida vem do que foi de fato escrito, nunca da contabilidade do transformer. É isso que torna um pacote de centenas de segmentos deletável (batch via `deleteMany` em disks capazes) e servível arquivo a arquivo sem aritmética de path sobre input do caller. `MediaConversion` ganhou o shape para isso: `path`/`disk` agora opcionais (transform metadata-only não tem artefato), mais `prefix`, `files` e `meta` — as conversions de imagem existentes seguem `{ path, disk }` sem migração (colunas JSON).
**Registro e disparo.** Transformers declaram-se por collection (`transformers: [transformers.hls()]`), no mesmo namespace de nomes das presets — colisão falha no boot com `TransformerConflictError`. Vídeo é pesado e assíncrono por natureza, então nada roda no attach por padrão: o app dispara `media.library.transform(id, 'hls')` do job dele (a lib não assume sistema de filas). A chamada é **idempotente** — conversion existente ⇒ skip — e falha no meio varre os artefatos parciais e nunca persiste entry, então retry recomeça limpo. `eager: true` (para transforms baratos) roda dentro de `attach` **e** `attachExisting` — o caminho do finalize TUS via `completeUploadToLibrary`, fechando o fluxo "TUS larga os bytes, transformers derivam depois" sem fiação extra — com o mesmo rollback das conversions eager (mídia nova desfeita inteira, a anterior de uma collection `single` fica de pé). Leitura nunca gera transform: `url()`/`deliver()` numa conversion de transformer ausente lançam `TransformNotReadyError` em vez de prender um request atrás de um remux (presets de imagem continuam lazy).
**`transformers.hls()` — o transformer de vídeo.** Remuxa o vídeo para HLS (segmentos MPEG-TS + playlists de mídia atrás de um master) com [mediabunny](https://mediabunny.dev) — TypeScript puro, **sem binário ffmpeg**, peer OPCIONAL importado só no primeiro `transform()` (padrão `processors.sharp()`/`disks.s3()`; ausente ⇒ `TransformerRuntimeMissingError` com hint de install, não `ERR_MODULE_NOT_FOUND` cinco imports abaixo). Incorpora os gotchas provados em produção no protótipo do eduliberta:
- **Remux-only por padrão, com o porquê documentado**: encodar exige WebCodecs, que o Node não expõe. h264/aac copia sem re-encode (sem perda, rápido); codec que o MPEG-TS não carrega (vp9/av1) falha com `HlsSourceUnsupportedError` listando codec e razão por track — definitivo para o arquivo, não retryável.
- **O trim do AAC priming**: áudio AAC com edit list começa em timestamp NEGATIVO; o default do mediabunny corta em t=0, o que tiraria a track do fast path de cópia. A conversão corta no `getFirstTimestamp()` real — todas as tracks deslocam igual, sync intacto, tudo continua stream-copy.
- **WebCodecs injetável**: `transformers.hls({ webcodecs: () => import('@napi-rs/webcodecs') })` instala a implementação em `globalThis` (só o que falta; nativo nunca é sobrescrito) e destrava o fallback de re-encode do mediabunny para fontes incompatíveis. `resolveWebCodecsSupport()` reporta `native`/`injected`/`absent`. Multi-qualidade (ladder 360p/480p/720p via fan-out) fica como evolução documentada no roadmap sobre esse mesmo seam — não é fingida hoje.
Meta persistida: duração, resolução, codecs, contagem de segmentos/playlists, targetDuration. O engine é injetável (`HlsRemuxEngine`), então a orquestração inteira (temp files, upload streaming com contentLength, content types) é testada sem mediabunny — e um teste de integração roda o mediabunny REAL contra uma fixture h264/aac de 12 KB no CI (JS puro, funciona no ubuntu-latest), provando o caminho de produção inclusive o trim.
**`transformers.probe()` — o transformer metadata-only.** Sonda duração/resolução/codecs/sample rate e persiste só `meta`, zero artefato — a prova real do shape "sem artefato" do contrato, e o substituto do serviço manual de "baixa o arquivo e lê a duração" que todo app de mídia acaba criando.
**Delivery HLS-aware.** Playlists são armazenadas com referências relativas ao layout do storage e precisam de rewrite a cada serve. `rewriteHlsPlaylist(content, rewrite)` cobre todos os lugares onde o RFC 8216 põe uma URI — linhas de URI, atributos `URI="…"` de `#EXT-X-MEDIA` (renditions de áudio), `#EXT-X-MAP`, `#EXT-X-I-FRAME-STREAM-INF`, `#EXT-X-KEY` — reescreve só referências **relativas** (absolutas/rooted ficam como estão), preserva o resto byte a byte (CRLF incluso) e aceita rewriter async. Em cima dela, `HlsDeliveryHandler` é a rota-metade framework-agnóstica no padrão `MediaDeliveryHandler`/`TusUploadHandler`: o app monta UMA rota `(:mediaId, :file?)` com o middleware dele — **a lib não decide autorização** — e o handler serve o pacote inteiro: playlist pedida ⇒ conteúdo reescrito (sub-playlists via `urlForPlaylist` do app, para cada hop voltar pela auth; segmentos via `urlForSegment` ou, por padrão, **presigned URL direto do disk** com TTL — o caso comum pronto); segmento pedido ⇒ `redirect` presigned ou `stream` proxied (`segmentDelivery`). Arquivo pedido é validado por pertencimento à lista `files` persistida — traversal estruturalmente impossível.
**Tipos inferidos da config.** `defineConfig` agora é `<const T>` e preserva nomes literais; `InferTransformers<typeof config>` / `InferConversions<typeof config>` extraem as unions de nomes (presets + transformers) para tipar payloads de job e rotas — o padrão `InferConverters` do @jrmc/adonis-attachment, sem `as const`.
**Testing kit**: `FakeTransformer` (registra contexts, escreve artefatos configurados, `behavior` custom) ao lado do `FakeImageProcessor`.
**Cortes explícitos** (registrados no roadmap, não neste PR): multi-qualidade/ladder (exige o WebCodecs injetado; seam pronto), PosterFrame (exige decoder — idem), watermark/audio-extract/image-optimize/placeholder/transcription (o contrato acomoda os seis shapes; nada de stubs mortos), DRM/EXT-X-KEY com criptografia, HLS live/low-latency (só VOD), decorator Lucid `@media` no model do app (API desenhada no roadmap; o shape novo de `MediaConversion` já a suporta sem refactor) e a rota de delivery nomeada com inferência Tuyau + helpers Edge (idem).
Sem breaking para consumidores existentes além do type de `MediaConversion` (`path`/`disk` opcionais — 0.x, sem shim): stores existentes leem os records antigos como sempre.
- [#19](https://github.com/DavideCarvalho/adonis-media/pull/19) [`f81478e`](https://github.com/DavideCarvalho/adonis-media/commit/f81478e7a683347fa4ba56c9fb8d5614c2e95477) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Magic-byte signatures for the common video containers — and with them, video collections finally get a real whitelist
The signature table covered PNG/JPEG/GIF/WEBP/PDF and **no video format**. That had two concrete consequences for any collection gating video:
- No video was ever _detectable_, so a whitelist like `['video/mp4']` could never be **closed** (see 0.8.0): the closed-whitelist rejection for unrecognisable content simply never activated, and anything without a known signature — a `.txt`, an executable, random bytes — sailed through `attach`/`attachExisting`/TUS as long as the caller declared `video/mp4`.
- `attachExisting` could not catch content disguised as a video: a PNG uploaded as `clip.mp4` produced no `ContentTypeMismatchError`, because the detector had no idea what an MP4 looks like.
The table now recognises:
- **`video/mp4`** — ISO-BMFF `ftyp` box (bytes 4–7; the first 4 bytes are the box _size_ and vary per file, so they are skipped — the existing `[offset, hex]` parts mechanism already expresses this) with a major brand from the recognised set: `isom`, `iso2`–`iso6`, `mp41`, `mp42`, `avc1`, `av01`, `dash`. One table entry per brand, the GIF87a/GIF89a pattern.
- **`video/quicktime`** — the same `ftyp` box with major brand `qt `. Same container, different type: a `.mov` relabeled `video/mp4` is now a positive **mismatch**, not a pass.
- **`video/webm`** / **`video/x-matroska`** — EBML magic `1A45DFA3` at offset 0, discriminated by the `DocType` element (`webm` vs `matroska`). DocType sits inside a variable-length EBML header, so its offset depends on the muxer — the one thing fixed offsets cannot express. The signature mechanism gained a minimal `scan` field: a byte run (element id + size + doc type string, so it cannot fire on stray text) that must appear _anywhere_ in the head, checked only **after** the fixed parts already identified the container. No EBML parser, no new dependency.
- **`video/x-msvideo`** — `RIFF` + `AVI ` form type (bytes 4–7 are the chunk size and skipped, exactly like WEBP).
- **`video/mp2t`** — MPEG transport stream. There is no magic number, only the `0x47` sync byte opening every 188-byte packet; one byte would collide with anything starting with `G`, so the sync byte is required at the start of the first **two** packets (offsets 0 and 188). It is the weakest signature and sits last in the table, so it can never shadow a stronger match.
`SIGNATURE_HEAD_BYTES` grows from 16 to **189** (the second TS sync byte). All the sniffing paths already read exactly this constant and handle short payloads: `attach` still peeks and replays the head without buffering the payload, `attachExisting` still tears the disk stream down after one short read, and a head shorter than a signature's deepest offset degrades to _unrecognised_, never to a false positive.
Deliberate non-guesses, so a legitimate file never turns into a false mismatch: an `ftyp` brand outside the set above (3GPP's `3gp*`, Apple's `M4A `/`M4V `) and an EBML DocType that is neither `webm` nor `matroska` stay **unrecognised** — under an open whitelist they fall back to the declared type exactly as before.
**Behaviour change to review if you gate video:** a whitelist made up entirely of the types above — `['video/mp4']` being the canonical case — was open and is now **closed**. Three things follow:
1. Content whose signature contradicts the declared type is rejected with `ContentTypeMismatchError` (`E_MEDIA_CONTENT_TYPE_MISMATCH`) — the PNG-disguised-as-MP4 case, previously accepted.
2. Content matching _no_ signature is rejected with `ContentSignatureUnrecognizedError` (`E_MEDIA_CONTENT_SIGNATURE_UNRECOGNIZED`), per the 0.8.0 closed-whitelist rule that never activated for video before.
3. Legitimate videos whose real container differs from the declared type — `.mov`/`.mkv`/`.avi` files uploaded under a blanket `video/mp4` — now fail instead of slipping through. If your collection genuinely accepts them, list what you accept: `acceptsMimeTypes: ['video/mp4', 'video/quicktime', 'video/webm']`.
Applies uniformly to `attach`, `attachExisting` and the TUS first-chunk check, which all share `verifyContentAgainstWhitelist`.
## 0.8.2
### Patch Changes
- [#17](https://github.com/DavideCarvalho/adonis-media/pull/17) [`e911880`](https://github.com/DavideCarvalho/adonis-media/commit/e911880969a28dd6bdbc0c56181462628eec1a4d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Corrige dois pontos onde este pacote ainda capturava um singleton do `@adonisjs/core` via `import`
de módulo em vez de recebê-lo do provider — o mesmo formato de dual-package hazard que já havia
derrubado o `Database` do Lucid em produção (ver o changeset `lucid-string-token`), só que agora nos
singletons `app` e `router` do próprio core.
**1 — `app` capturado eager em `services/main.ts` e `single_file_store.ts`.** Ambos faziam
`import app from '@adonisjs/core/services/app'` no topo do módulo. Esse binding só é preenchido via
`setApp()` chamado pelo Ignitor da app hospedeira; se a árvore de dependências contiver DUAS cópias
físicas de `@adonisjs/core` (pnpm workspace hoisting, pins divergentes, ou até a mesma versão
resolvida sob peer-sets diferentes), a cópia que este pacote importa nunca recebe esse `setApp()` — o
`app` fica `undefined` e qualquer uso quebra com um `Cannot read properties of undefined` opaco.
A correção segue o padrão já usado pelo `@adonis-agora/authz` (`services/booted_app.ts`): o
`MediaProvider.register()` agora captura a instância de `ApplicationService` que a própria aplicação
lhe entrega — que é sempre a cópia correta, seja qual for a duplicação na árvore — e a expõe via um
módulo interno (`src/services/booted_app.ts`) para `services/main.ts` e `single_file_store.ts`
lerem. Nenhuma mudança de API: `media.library.attach(...)` e as funções `storeSingleFile` /
`removeSingleFile` / `isSingleFileStoreAvailable` continuam idênticas por fora.
**2 — `router` resolvido eager e usado síncrono em `providers/media_provider.ts`.** O provider
importava `router` de `@adonisjs/core/services/router` no topo do módulo e chamava `router.get(...)`
/ `router.post(...)` direto dentro de `boot()`. Esse serviço específico só é atribuído dentro de um
hook `app.booted(...)` no próprio módulo `services/router.ts` do core — que dispara estritamente
DEPOIS do `boot()` de todos os providers. Ou seja, mesmo numa árvore com uma única cópia do core,
usar esse import de forma síncrona em `boot()` já é uma corrida contra o próprio mecanismo que o
preenche; numa árvore duplicada o problema se soma ao caso 1.
A montagem das rotas (`/media/uploads/direct/*`, `/media/uploads/proxy`, `/media/uploads/tus/*`)
agora é adiada para dentro de `app.booted(...)` — o mesmo padrão já documentado e em produção no
`DashboardProvider` do `@adonis-agora/durable`. Verificado que isso é seguro para o ciclo de vida do
Adonis: os hooks `booted` de TODOS os providers disparam antes do `Server#boot()` do
`@adonisjs/http-server` (que roda dentro de `app.start()`) chamar `router.commit()` — o último ponto
em que rotas ainda podem ser adicionadas. Dentro do hook, o `router` é resolvido pelo container
(`app.container.make('router')`) a partir do `this.app` do provider, imune à duplicação da mesma
forma que o caso 1.
Nenhuma mudança de comportamento observável: as mesmas rotas são montadas, só que um instante mais
tarde no boot (antes do servidor HTTP subir, nunca depois).
Também adicionado `prepack` ao `package.json` do pacote publicável, espelhando o `build`.
## 0.8.1
### Patch Changes
- [#14](https://github.com/DavideCarvalho/adonis-media/pull/14) [`9224651`](https://github.com/DavideCarvalho/adonis-media/commit/922465168256b7b248347639edaa322cf53cfeec) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Resolve the Lucid `Database` by its string alias `'lucid.db'` instead of importing
`@adonisjs/lucid/services/db`, making the library immune to the dual-package hazard.
The service module resolves the `Database` **class** and uses it as the container token, while
Lucid's provider registers `container.singleton(Database, ...)` keyed on that same class object. A
class token only matches when the consumer and the booting provider loaded the _same physical copy_
of `@adonisjs/lucid`. When a host app's tree contains two copies — different version pins, or even
the same version resolved under different peer sets, which pnpm materializes as separate directories
— the tokens differ, no binding is found, and the container tries to _construct_ `Database`, which
has no `@inject()`:
```
RuntimeException: Cannot construct "[class Database]" class.
Container is not able to resolve its dependencies. Did you forget to use @inject() decorator?
```
This took down every TUS upload in a production app while its local test suite passed, because the
duplication existed only in the `pnpm deploy` artifact and not in the workspace.
`'lucid.db'` is a string, so it cannot be duplicated: whichever copy boots registers the alias, and
any copy resolves it. The library no longer depends on the host app's dependency tree being
perfectly deduplicated. Both `stores.lucid()` and `uploadSessions.lucid()` are fixed, and a
regression test asserts on the resolved _token_ rather than the returned store — asserting on the
store would pass with either implementation and let the hazard back in silently.
No API change: both factories already received the application in their context.
## 0.8.0
### Minor Changes
- [#12](https://github.com/DavideCarvalho/adonis-media/pull/12) [`92006a0`](https://github.com/DavideCarvalho/adonis-media/commit/92006a032290c6d7e61d4b34184553127992ea5c) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Collection-aware TUS validation, a stricter closed-whitelist rule, and a fix for a non-deterministic Drive resolution race
**Fix: the Drive manager was captured before it existed.** The provider read `(await import('@adonisjs/drive/services/main')).default` once, while building the `MediaManager` singleton. Drive's service module only assigns that manager inside `await app.booted(...)`, which resolves immediately when the app has not booted yet — so the value captured was `undefined`, permanently, and every media call died with `Cannot read properties of undefined (reading 'use')`. It depended on whether the import won the race against boot, which made it non-deterministic: one run 500s, the identical rerun passes. The Drive manager is now resolved **lazily, at the first disk resolution that actually needs it**, and memoized, so it is still resolved exactly once — just not too early. An app whose disks all come from `config.disks` never touches Drive at all, and resolving genuinely before boot now throws `DriveNotReadyError` (`E_MEDIA_DRIVE_NOT_READY`) instead of a bare `TypeError`. The resolver is exported as `createDriveBackedResolver` for wiring media outside AdonisJS.
**`TusUploadHandler` can enforce a collection's `acceptsMimeTypes`.** `acceptsMimeTypes` belongs to a collection and used to apply only at `attach`, while TUS knew nothing about collections and accepted any binary (only `maxSize`) — so a user uploaded a whole 20 MB file over a resumable protocol and learned it was the wrong type at finalize. Set `uploads.resumable.routes.collection` (or pass `collection` + `collections` to the handler) and the whitelist is enforced at the two earliest points the protocol allows:
- **`POST`** — the `filetype` the client declares in `Upload-Metadata`, rejected with `415` before a single byte is uploaded, with no session created.
- **first `PATCH`** — the real magic-byte signature of the leading bytes, using the existing detector. Catches a client that lied in `filetype`; the session and any partial object are aborted, so the liar pays for one chunk instead of the whole file. Later chunks are not sniffed.
You name the collection, never the MIME list: the collection config stays the single source of truth, so the upload gate and the attach-time check cannot drift. This is bandwidth economy and fast feedback, **not** the security boundary — `attach` / `attachExisting` re-validate the assembled object and remain the final barrier. `MediaManager.collections` now exposes the registry, and `resumable.status()` additionally returns the declared `contentType`.
**Unrecognised signatures are now rejected under a closed whitelist.** Treating "no signature matched" as "no evidence" is right for SVG/CSV/text, but it leaked work to apps: a collection accepting only `application/pdf` still let a `.txt` through `attach`/`attachExisting`, so the consuming app had to reimplement `detectMimeType(...) === undefined` by hand. Now, if **every** type in `acceptsMimeTypes` is signature-detectable, unrecognisable content cannot be any of them and is rejected with the new `ContentSignatureUnrecognizedError` (`E_MEDIA_CONTENT_SIGNATURE_UNRECOGNIZED`), distinct from `ContentTypeMismatchError`. If **any** accepted type has no signature (`image/svg+xml`, `text/csv`, `text/plain`, office formats), the previous permissive behaviour is unchanged. Applies to `attach`, `attachExisting` and the TUS first-chunk check alike; `isDetectableMimeType`, `isClosedSignatureWhitelist` and `verifyContentAgainstWhitelist` are exported so the same reasoning is available outside the library.
## 0.7.0
### Minor Changes
- [#10](https://github.com/DavideCarvalho/adonis-media/pull/10) [`afdc1f4`](https://github.com/DavideCarvalho/adonis-media/commit/afdc1f4ec0b46d5b8ed29e3e586e443dd28d940d) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Configurable delivery, and `acceptsMimeTypes` now validates the real file content
**Configurable delivery (`delivery`).** The library had a configurable strategy for writes (`uploads.mode`) but nothing for reads, so every consuming app re-derived the same decision by hand — and on a private bucket whose storage isn't internet-reachable, hand-rolled its own streaming route. New `delivery: { mode, signedTtlSeconds }` config (`'auto' | 'public' | 'signed' | 'proxy'`, default `auto`) plus `MediaLibrary.deliver(id, options?)`, returning a discriminated union: `{ kind: 'redirect', url }` for `public`/`signed`, `{ kind: 'stream', stream, mimeType, size, fileName }` for `proxy`.
`MediaDeliveryHandler` is the framework-agnostic route half, mirroring `TusUploadHandler`: your app mounts one route with its own middleware and delegates. Like `TusUploadHandler`, **it performs no authorization** — guard the route before calling `handle`, which is also why the provider mounts no delivery route of its own.
`auto` resolves by asking the disk for the object's visibility (`Disk.getVisibility`, optional and implemented by every Drive disk): public ⇒ `public`, otherwise ⇒ `signed`. A disk that can't answer falls back to `signed`. The bundled `disks.s3()` gained a declarative `visibility` option (default `private`) to answer it without an ACL round-trip.
**Real content validation.** A collection's `acceptsMimeTypes` used to check the caller-declared `mimeType` — which the app itself writes, routinely hardcoded — so it validated nothing about the bytes. It now also detects the type from the file's magic-byte signature and rejects content that contradicts the declaration, with a new `ContentTypeMismatchError` (`E_MEDIA_CONTENT_TYPE_MISMATCH`). Content with no recognisable signature (SVG, CSV, text, office formats) falls back to the declared type rather than being rejected.
Only the first 16 bytes are read, never the whole file: `attach` peeks the head and replays it in front of the rest, so a `Readable` payload stays streaming, and `attachExisting` does a short disk read that is torn down immediately — adopting a large object in place still never downloads it. The signature table (PNG, JPEG, GIF, WEBP, PDF) is embedded; no new dependency.
## 0.6.0
### Minor Changes
- [#8](https://github.com/DavideCarvalho/adonis-media/pull/8) [`5ffebf8`](https://github.com/DavideCarvalho/adonis-media/commit/5ffebf8173a5aa69a83eb13675927da2107fa323) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Bridge already-stored objects into the media library without copying their bytes.
- `MediaLibrary.attachExisting({ ownerType, ownerId, collection, key, disk?, fileName, mimeType, size?, ... })` registers an object that already exists on a disk as a `MediaRecord` — zero-copy: the bytes are never downloaded or rewritten, and `size` is resolved from the object's metadata when omitted. Everything after storage matches `attach()` (collection resolution, `acceptsMimeTypes`, `single: true` atomic replace, ordering, eager conversions, `attach` diagnostics), which both paths now share. A missing key throws the new `MediaObjectMissingError`. Opt into `moveIntoLayout: true` to relocate the object into the library's key layout via the disk's native server-side move (`ExtendedDisk`, e.g. `disks.s3()`); it never streams bytes through the app to emulate one.
- `MediaManager.completeUploadToLibrary(sessionId, input)` finishes a resumable (TUS) session and attaches the assembled object in one step. `resumable.complete()` is unchanged and remains the raw primitive.
- `MediaLibrary.for(...)` bindings expose `attachExisting` alongside `attach`.
## 0.5.0
### Minor Changes
- [#6](https://github.com/DavideCarvalho/adonis-media/pull/6) [`256a11e`](https://github.com/DavideCarvalho/adonis-media/commit/256a11e034118435b2c29a1b7ac7c0c6c05ac5b6) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Add the `@adonis-agora/media/single-file` helper (`storeSingleFile` / `removeSingleFile` / `isSingleFileStoreAvailable`) for storing exactly one file per owner through a `single: true` collection, returning the stable public URL (plus an optional `thumb` conversion URL). Lets other packages delegate single-file uploads such as avatars to media without taking a hard dependency on it.
## 0.4.0
### Minor Changes
- Parity sync from nestjs-media: harden S3 GetObject streams against connection death (no more permanent hang), caller-supplied deterministic `id` on `attach` for idempotent overwrites, lazy `stubsRoot` (importing the package is side-effect-free), and a media-specific Telescope watcher recording richer per-operation entries + claiming its channels.
## 0.3.2
### Patch Changes
- [`e6cbb1a`](https://github.com/DavideCarvalho/adonis-media/commit/e6cbb1aca6c30a203dd2949e825b9ed79309dd5a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `attach` numa collection `single` não destrói mais a mídia anterior quando uma conversion eager falha.
A ordem era: grava bytes → salva registro → **apaga a anterior** → gera as conversions eager. O
docblock do próprio método prometia o contrário ("a failed write leaves the old media intact"), mas
a conversion rodava depois do delete. Um upload que o processador não consegue decodificar — um PNG
truncado, por exemplo — apagava a mídia antiga e então lançava, e como o chamador nunca chegava a
persistir o id novo, o dono ficava **sem nada**.
As conversions eager agora rodam antes do delete, e uma falha nelas reverte a mídia nova inteira
(bytes, conversions já escritas e a linha), deixando a anterior de pé.
## 0.3.1
### Patch Changes
- [`e019163`](https://github.com/DavideCarvalho/adonis-media/commit/e019163ae2c1d35c0fed48352c6cfa3ae04f246b) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Conserta o `node ace configure @adonis-agora/media`, que nunca funcionou em nenhuma versão.
Dois bugs independentes, os dois provados contra o compilador real:
- **O hook não era alcançável.** O `configure.ts` existia e o `package.json` exportava
`./configure`, mas o ace chega no hook pelo entry point principal — e o `src/index.ts` não o
reexportava. `import('@adonis-agora/media').configure` era `undefined`.
- **Nenhum stub renderizava.** O tempura trata crase como início de template literal, inclusive
dentro de comentário. Os 3 stubs usavam crase no docblock e morriam com `Unexpected identifier`
antes de gerar qualquer arquivo. As crases dos comentários viraram aspas simples; os template
literals de verdade do código do stub continuam intactos.
Nada no build pegava isso: stub é dado, o tsc nunca o compila, e nenhum teste os tocava. Agora
um teste renderiza todo stub pelo tempura e afirma que o index reexporta o `configure`.
## 0.3.0
### Minor Changes
- [`aa73ece`](https://github.com/DavideCarvalho/adonis-media/commit/aa73ecef27a829287fdf18597f66afa20b7d7e5a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - `signedUrl` agora aceita as opções de resposta do disk (`contentDisposition`, `contentType`).
**Breaking:** o 3º parâmetro posicional virou um objeto de opções.
- `library.signedUrl(id, '1h', 'thumbnail')` → `library.signedUrl(id, '1h', { conversion: 'thumbnail' })`
- `attachments.signedUrl(att, '1h', 'thumb')` → `attachments.signedUrl(att, '1h', { variant: 'thumb' })`
Forçar download com um nome de arquivo (`attachment; filename="..."`) é o caso canônico de URL
assinada e não tinha como ser expresso pela library — só pelo disk, o que obrigava o chamador a
conhecer disk e path.
## 0.2.1
### Patch Changes
- [`00b6ed9`](https://github.com/DavideCarvalho/adonis-media/commit/00b6ed976c5afb43c93f91be939611b8a371914a) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Fix: streaming a file to an S3 disk always failed
The streaming fast-path (a `Readable` with a known size and no conversions, added in 0.2.0)
never worked against real S3 — every write threw:
```
Invalid value "undefined" for header "x-amz-decoded-content-length"
```
S3 cannot size a stream, so it needs `ContentLength` up front, and `S3Disk.putStream` never
sent it. `MediaLibrary.attach` and `AttachmentManager.createFromFile` made it worse: both
_gate_ the fast-path on `input.size` being known and then dropped that size instead of
passing it to the disk. So the one path that had the size threw it away, and the buffered
path (which doesn't need it) is the only one that worked.
`DiskWriteOptions` gains `contentLength`; both call sites forward the size that made them
eligible; `S3Disk.putStream` sends it as `ContentLength` and throws a named error up front
when it is missing, instead of failing deep inside the AWS SDK's header layer.
If you implement a custom `Disk`, `putStream` now receives `contentLength` in its options.
Ignoring it stays valid for disks that can size their own payload.
Why the tests missed it: `s3_disk.spec.ts` asserted with `aws-sdk-client-mock`, which
intercepts the command _before_ the SDK's header middleware runs, so the mocked call
happily accepted a payload the real SDK rejects. The library/attachment tests use the
in-memory disk, which holds the bytes and never needs the declaration. Both now assert the
size reaches the disk, and the in-memory disk records the `contentLength` it was handed —
but the bug was only ever visible against a live S3/MinIO.
## 0.2.0
### Minor Changes
- [`803e1b7`](https://github.com/DavideCarvalho/adonis-media/commit/803e1b719fefd47349518e32900a72c56927add8) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - S3 disk, direct/resumable uploads, cross-owner listing, Telescope, and fail-fast store resolution
**Storage**
- `disks.s3({ bucket, region?, credentials?, endpoint?, forcePathStyle?, keyPrefix?, publicBaseUrl? })`
— an S3 disk with the extended operations the library needs. The AWS SDK is an
optional peer, imported lazily only when this disk is selected. `endpoint` +
`forcePathStyle` make it work against MinIO and R2, not just AWS.
- `services/main` — an idiomatic singleton import (`import media from
'@adonis-agora/media/services/main'`).
**Uploads**
- Direct-to-S3 multipart, in `proxy` and `direct` modes, via
`uploads: { mode, partSize, presignTtlSeconds }` and the
`initiateDirectUpload` / `completeDirectUpload` / `abortDirectUpload` / `proxyUpload`
methods on the manager.
- Resumable uploads over the TUS protocol (`uploads.resumable`), with an in-memory or
Lucid session store (`upload_sessions/lucid`).
- Built-in routes for both are **opt-in** (`routes.enabled`, default `false`) and take the
object key from the request. They are a development convenience: in a real app leave them
off and mount your own routes over the manager methods, resolving the key server-side per
user/tenant so a client cannot point an upload at someone else's object.
**Reads**
- `media.store.list(options)` — cursor-paginated cross-owner listing (newest first,
default page 50, max 200), for admin/collection views. Owner-scoped reads stay on
`media.library`.
- `./telescope` — a Telescope watcher extension (optional peer).
**Robustness** — these change behavior:
- Naming a `store` that has no matching factory now **throws** `StoreNotConfiguredError`
instead of silently falling back to the in-memory store. The old fallback looked fine and
then lost every record on restart. Only the zero-config path (no `store` at all) still
resolves to memory.
- The Lucid store writes via an atomic `insert().onConflict('id').merge()` upsert instead of
read-then-branch.
- `ownerId` accepts `string | number` on `attach`/`list`, coerced internally — no more
`String(post.id)` at the call site.
- A failed store write now best-effort deletes the object it just wrote, instead of leaving
an orphan on the disk. Single-file collections delete the previous media only _after_ the
new record commits, so a failed write keeps the old file.
- A `Readable` with a known `size` and no conversions streams through `putStream` rather than
buffering the whole file in memory.
- Typed `VariantNotFoundError` / `StoreNotConfiguredError` replace bare `Error`s.
- Dropped the internal `publishMedia` export and the empty `MemoryStoreConfig` type.