@adonis-agora/media 1.0.0-rc.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 (39) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +3 -2
  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/providers/dashboard_provider.d.ts.map +1 -1
  8. package/dist/providers/dashboard_provider.js +62 -218
  9. package/dist/providers/dashboard_provider.js.map +1 -1
  10. package/dist/src/dashboard/access_denied_page.d.ts +5 -7
  11. package/dist/src/dashboard/access_denied_page.d.ts.map +1 -1
  12. package/dist/src/dashboard/access_denied_page.js +2 -6
  13. package/dist/src/dashboard/access_denied_page.js.map +1 -1
  14. package/dist/src/dashboard/console_authorize.d.ts +75 -0
  15. package/dist/src/dashboard/console_authorize.d.ts.map +1 -0
  16. package/dist/src/dashboard/console_authorize.js +97 -0
  17. package/dist/src/dashboard/console_authorize.js.map +1 -0
  18. package/dist/src/dashboard/define_config.d.ts +19 -51
  19. package/dist/src/dashboard/define_config.d.ts.map +1 -1
  20. package/dist/src/dashboard/define_config.js.map +1 -1
  21. package/dist/src/dashboard/index.d.ts +4 -4
  22. package/dist/src/dashboard/index.d.ts.map +1 -1
  23. package/dist/src/dashboard/index.js +1 -2
  24. package/dist/src/dashboard/index.js.map +1 -1
  25. package/dist/src/dashboard/types.d.ts +0 -17
  26. package/dist/src/dashboard/types.d.ts.map +1 -1
  27. package/dist/stubs/config/media_dashboard.stub +8 -20
  28. package/package.json +3 -3
  29. package/dist/assets/spa/assets/index-C-7cKQuV.js +0 -12
  30. package/dist/assets/spa/assets/index-C-7cKQuV.js.map +0 -1
  31. package/dist/assets/spa/assets/index-Db6cSeO5.css +0 -2
  32. package/dist/src/dashboard/auth.d.ts +0 -76
  33. package/dist/src/dashboard/auth.d.ts.map +0 -1
  34. package/dist/src/dashboard/auth.js +0 -134
  35. package/dist/src/dashboard/auth.js.map +0 -1
  36. package/dist/src/dashboard/cookie.d.ts +0 -20
  37. package/dist/src/dashboard/cookie.d.ts.map +0 -1
  38. package/dist/src/dashboard/cookie.js +0 -44
  39. package/dist/src/dashboard/cookie.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
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
+
3
21
  ## 1.0.0-rc.0
4
22
 
5
23
  ### Major 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