UNPKG

@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

36 lines • 1.74 kB
import type { MediaAccessRequest, MediaAuthorizer } from '../access.js'; /** The bits of `@adonis-agora/authz`'s service this integration uses (typed structurally). */ interface AuthzService { can(user: unknown, permission: string, options?: { scope?: unknown; }): Promise<boolean>; hasAnyRole(user: unknown, roles: string[], options?: { scope?: unknown; }): Promise<boolean>; } export interface AuthzRuleOptions { /** Explicit authz tenant scope for the check. Default: authz's own resolvers (`resolveTenant`). */ scope?: (request: MediaAccessRequest) => unknown; /** @internal test seam: how the authz service is loaded. */ load?: () => Promise<AuthzService>; } /** * Media authorizers backed by `@adonis-agora/authz` (an optional peer, loaded on first use). * Wildcards, roles → permissions, super-admins and tenancy all apply, as in any authz check. * * ```ts * import { authorizers } from '@adonis-agora/media' * import { authz } from '@adonis-agora/media/authz' * * { name: 'prescription', access: { read: authorizers.any(authorizers.owner(), authz.can('prescriptions.read')) } } * { name: 'reports', access: { read: authz.can(({ collection, action }) => `media.${collection}.${action}`) } } * ``` */ export declare const authz: { /** The user holds `permission` (a string, or derived from the request). Anonymous ⇒ no. */ can(permission: string | ((request: MediaAccessRequest) => string), options?: AuthzRuleOptions): MediaAuthorizer; /** The user has any of these roles in authz (store roles, `resolveRoles`, token roles). */ roles(roles: readonly string[], options?: AuthzRuleOptions): MediaAuthorizer; }; export {}; //# sourceMappingURL=authz.d.ts.map