@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
63 lines • 2.73 kB
TypeScript
import type { MediaIdentityResolver } from '../access.js';
/**
* The bits of `@adonis-agora/authkit-server` this integration uses — typed structurally so the
* media package carries no dependency on it.
*/
interface AuthkitServerModule {
getAccountId(ctx: unknown): string | null;
realAccountId(ctx: unknown): string | null;
}
/** The bits of `@adonis-agora/authkit-client` this integration uses. */
interface AuthkitClientModule {
getAuthkit(ctx: unknown): Promise<{
getIdentity(): Promise<{
userId: string;
globalRoles?: string[];
orgId?: string | null;
/** The human behind an impersonation (the token's `act` claim). */
actor?: {
sub: string;
email?: string;
} | null;
} | null>;
}>;
}
export interface AuthkitIdentityOptions {
/**
* Which side of authkit this app is:
* - `'server'` — the app IS the identity provider (`@adonis-agora/authkit-server`): the account
* comes from the console session (`getAccountId`, impersonation-aware; `realAccountId` for
* permission checks);
* - `'client'` — the app signs in against one (`@adonis-agora/authkit-client`): the identity
* comes from `ctx.authkit` (`getAuthkit(ctx).getIdentity()`), with its global roles and active
* organization;
* - `'auto'` (default) — the client when the request carries `ctx.authkit`, the server when its
* package is installed, the client otherwise.
*/
side?: 'auto' | 'server' | 'client';
/** Subject type handed to authz. Default `'user'`. */
type?: string;
/** @internal test seams: how the authkit packages are loaded. */
load?: {
server?: () => Promise<AuthkitServerModule>;
client?: () => Promise<AuthkitClientModule>;
};
}
/**
* `access.identity` for apps on authkit — who the current user is, as authkit sees them:
*
* ```ts
* // config/media.ts
* import { authkitIdentity } from '@adonis-agora/media/authkit'
* export default defineConfig({ access: { identity: authkitIdentity() } })
* ```
*
* On the server side, `id` is the account the request acts as (an impersonating admin sees the
* user's files) and `realId` the human behind it (what `@adonis-agora/media/authz` checks
* permissions for). On the client side `id` is the token's `sub` and `realId` its actor (the
* impersonating human from the `act` claim) or the `sub` when nobody impersonates, with its global
* roles and active organization as `roles` / `tenantId`.
*/
export declare function authkitIdentity(options?: AuthkitIdentityOptions): MediaIdentityResolver;
export {};
//# sourceMappingURL=authkit.d.ts.map