@adonis-agora/media 0.30.0 → 1.0.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +4 -5
  3. package/dist/assets/spa/assets/index-DOnygWEb.js +12 -0
  4. package/dist/assets/spa/assets/index-DOnygWEb.js.map +1 -0
  5. package/dist/assets/spa/assets/index-XkvYeRIj.css +2 -0
  6. package/dist/assets/spa/index.html +2 -2
  7. package/dist/configure.d.ts +1 -2
  8. package/dist/configure.d.ts.map +1 -1
  9. package/dist/configure.js +1 -2
  10. package/dist/configure.js.map +1 -1
  11. package/dist/providers/dashboard_provider.d.ts +1 -2
  12. package/dist/providers/dashboard_provider.d.ts.map +1 -1
  13. package/dist/providers/dashboard_provider.js +63 -220
  14. package/dist/providers/dashboard_provider.js.map +1 -1
  15. package/dist/src/dashboard/access_denied_page.d.ts +5 -7
  16. package/dist/src/dashboard/access_denied_page.d.ts.map +1 -1
  17. package/dist/src/dashboard/access_denied_page.js +2 -6
  18. package/dist/src/dashboard/access_denied_page.js.map +1 -1
  19. package/dist/src/dashboard/console_authorize.d.ts +75 -0
  20. package/dist/src/dashboard/console_authorize.d.ts.map +1 -0
  21. package/dist/src/dashboard/console_authorize.js +97 -0
  22. package/dist/src/dashboard/console_authorize.js.map +1 -0
  23. package/dist/src/dashboard/define_config.d.ts +20 -55
  24. package/dist/src/dashboard/define_config.d.ts.map +1 -1
  25. package/dist/src/dashboard/define_config.js.map +1 -1
  26. package/dist/src/dashboard/index.d.ts +4 -4
  27. package/dist/src/dashboard/index.d.ts.map +1 -1
  28. package/dist/src/dashboard/index.js +1 -2
  29. package/dist/src/dashboard/index.js.map +1 -1
  30. package/dist/src/dashboard/service.d.ts +7 -0
  31. package/dist/src/dashboard/service.d.ts.map +1 -1
  32. package/dist/src/dashboard/service.js +31 -5
  33. package/dist/src/dashboard/service.js.map +1 -1
  34. package/dist/src/dashboard/spa.d.ts +4 -9
  35. package/dist/src/dashboard/spa.d.ts.map +1 -1
  36. package/dist/src/dashboard/spa.js +4 -9
  37. package/dist/src/dashboard/spa.js.map +1 -1
  38. package/dist/src/dashboard/types.d.ts +0 -17
  39. package/dist/src/dashboard/types.d.ts.map +1 -1
  40. package/dist/src/stores/lucid-schema.d.ts.map +1 -1
  41. package/dist/src/stores/lucid-schema.js +11 -0
  42. package/dist/src/stores/lucid-schema.js.map +1 -1
  43. package/dist/stubs/config/media_dashboard.stub +8 -20
  44. package/package.json +10 -10
  45. package/dist/assets/spa/assets/index-B48tE8sr.js +0 -12
  46. package/dist/assets/spa/assets/index-B48tE8sr.js.map +0 -1
  47. package/dist/assets/spa/assets/index-CjblUKFX.css +0 -2
  48. package/dist/src/dashboard/auth.d.ts +0 -76
  49. package/dist/src/dashboard/auth.d.ts.map +0 -1
  50. package/dist/src/dashboard/auth.js +0 -134
  51. package/dist/src/dashboard/auth.js.map +0 -1
  52. package/dist/src/dashboard/cookie.d.ts +0 -20
  53. package/dist/src/dashboard/cookie.d.ts.map +0 -1
  54. package/dist/src/dashboard/cookie.js +0 -44
  55. package/dist/src/dashboard/cookie.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,40 @@
1
1
  # @adonis-agora/media
2
2
 
3
+ ## 1.0.0-rc.1
4
+
5
+ ### Major Changes
6
+
7
+ - [#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.
8
+
9
+ `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`.
10
+
11
+ 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' }`.
12
+
13
+ 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.
14
+
15
+ The `DashboardAuthorize`, `AuthorizeResult` and `AuthorizeDecision` types are replaced by `ConsoleAuthorize`, `ConsoleAuthorizeResult` and `ConsoleAuthorizer`, exported from `@adonis-agora/media/dashboard` together with `resolveConsoleAuthorize` and `authorizeByToken`.
16
+
17
+ 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`).
18
+
19
+ `@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.
20
+
21
+ ## 1.0.0-rc.0
22
+
23
+ ### Major Changes
24
+
25
+ - [#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.
26
+
27
+ - Node.js 24 or later is required (`engines.node: ">=24"`, unchanged).
28
+ - `@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).
29
+
30
+ ### Patch Changes
31
+
32
+ - [#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:
33
+
34
+ - 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.
35
+ - 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.
36
+ - `FolderBody` is exported from `@adonis-agora/media/dashboard` and `@adonis-agora/media-dashboard`.
37
+
3
38
  ## 0.30.0
4
39
 
5
40
  ### Minor Changes
package/README.md CHANGED
@@ -31,7 +31,7 @@ The package uses **subpath exports** (the Agora idiom), so heavy backends stay o
31
31
  | `@adonis-agora/media/services/main` | the app-bound `MediaManager` singleton — `import media from '@adonis-agora/media/services/main'`, importable at any time (it resolves lazily on first use) |
32
32
  | `@adonis-agora/media/media_provider` | the service provider (binds `MediaManager`, mounts optional upload/TUS routes) |
33
33
  | `@adonis-agora/media/dashboard_provider` | the embedded management-console provider (React SPA + JSON API) |
34
- | `@adonis-agora/media/dashboard` | `defineConfig` + types for `config/media_dashboard.ts`, `DashboardService`, the session-auth helpers, `ObjectInsightProvider` |
34
+ | `@adonis-agora/media/dashboard` | `defineConfig` + types for `config/media_dashboard.ts`, `DashboardService`, the `authorize` contract (`authorizeByToken`), `ObjectInsightProvider` |
35
35
  | `@adonis-agora/media/configure` | `node ace configure` hook |
36
36
  | `@adonis-agora/media/single-file` | `storeSingleFile` / `removeSingleFile` / `storeSingleFileWith` / `removeSingleFileWith` / `isSingleFileStoreAvailable` — lets other packages delegate single-file uploads (e.g. avatars) to media without a hard dependency |
37
37
  | `@adonis-agora/media/stores/lucid` | the Lucid `MediaStore` (`@adonisjs/lucid` peer) |
@@ -319,7 +319,8 @@ export default defineConfig({
319
319
  basePath: '/media/dashboard', // where the SPA mounts (default)
320
320
  actions: true, // enable copy/move/delete (default: false — read-only)
321
321
  disks: ['s3', 'backups'], // browsable disks (default: derived from media config)
322
- middleware: middleware.auth(), // gate the whole console — SPA + API
322
+ authorize: (ctx) => ctx.auth.user?.isAdmin === true, // who may open it — SPA + API
323
+ middleware: middleware.auth(), // runs after authorize
323
324
  })
324
325
  ```
325
326
 
@@ -327,9 +328,7 @@ The console reads/writes through the real `@adonis-agora/media` surface (disk
327
328
  `list`/`stat`/`copy`/`move`/`deleteMany`, the resumable session store, the `MediaStore`) — nothing
328
329
  about storage is reimplemented. Full config reference, routes, and folder-operations semantics are
329
330
  documented in [`@adonis-agora/media-dashboard`](https://github.com/DavideCarvalho/adonis-agora-media/tree/master/packages/dashboard),
330
- which is now the **build-time source** of the console's SPA bundle (embedded here at build time) and
331
- remains installable **standalone** — its own provider is a thin delegate to this one, kept for hosts
332
- that already register it directly. Don't register both providers in the same app.
331
+ which is the **build-time source** of the console's SPA bundle (embedded here at build time).
333
332
 
334
333
  ## Diagnostics
335
334