/**
 * Service-tenant auth, in the shape every Agora control plane uses: a tenant presents a bearer token
 * (`authkitTenantToken(...)` from `@adonis-agora/authkit-client`), the control plane verifies it
 * (`authkitTenantVerifier(...)`), and the partition and capabilities come from the verified token,
 * never from the request.
 */
/** What a control plane trusts about a request: derived from the verified token. */
export interface VerifiedTenant {
    /** The application (the partition). The ONLY source of the app a request acts for. */
    partition: string;
    /** `media:read`, `media:write`. */
    capabilities: string[];
    /** The service-tenant client behind the token, when it says. */
    clientId?: string;
}
/** What a verifier receives. Only `token` is trusted, once verified. */
export interface TenantAuthRequest {
    token?: string | undefined;
    /** The partition the caller claims (`x-media-app`). Advisory only: the token decides. */
    partition?: string | undefined;
    /** Same as `partition`. Advisory only. */
    tenant?: string | undefined;
    /** Same as `partition`. Advisory only. */
    app?: string | undefined;
}
/** The function form of `verifyTenant`. Authkit's `authkitTenantVerifier()` is one. */
export type TenantVerifier = (request: TenantAuthRequest) => VerifiedTenant | null | Promise<VerifiedTenant | null>;
/** A class instance implementing `verify`. */
export interface TenantVerifierObject {
    verify(request: TenantAuthRequest): VerifiedTenant | null | Promise<VerifiedTenant | null>;
}
/** A lazily imported verifier module. */
export interface TenantVerifierModule {
    default?: TenantVerifier | TenantVerifierObject | (new () => TenantVerifierObject);
    verify?: TenantVerifier | TenantVerifierObject;
    tenantVerifier?: TenantVerifier | TenantVerifierObject;
}
/** The accepted forms: a function, a class instance, a class, or a lazy `() => import(...)`. */
export type TenantVerifierInput = TenantVerifier | TenantVerifierObject | (new () => TenantVerifierObject) | (() => Promise<TenantVerifierModule> | TenantVerifierModule);
/**
 * Validates a verifier's answer. `null` refuses; `{ partition, capabilities }` accepts; anything else
 * throws, so a malformed answer is never taken for an accepted tenant. Capabilities are not
 * defaulted: a verifier must say what the token may do.
 */
export declare function checkVerifiedTenant(result: unknown): VerifiedTenant | null;
/** Turns any `verifyTenant` form into the function the control plane calls. */
export declare function resolveTenantVerifier(input: TenantVerifierInput): (request: TenantAuthRequest) => Promise<VerifiedTenant | null>;
/** Where a tenant gets the bearer token it presents to the control plane. */
export interface TenantToken {
    get(): Promise<string>;
    /** Drops a cached token (after a 401), so the next `get` fetches a fresh one. */
    reset?(): void;
}
/**
 * A fixed secret, a function returning a token (`authkitTenantToken(...)` from
 * `@adonis-agora/authkit-client`, whose `reset()` a 401 calls), or an object with `get()`.
 */
export type TenantTokenSource = string | (() => Promise<string>) | {
    get(): Promise<string>;
    reset?(): void;
    invalidate?(): void;
};
/** Normalizes every accepted token source into {@link TenantToken}. */
export declare function resolveTenantToken(source: TenantTokenSource): TenantToken;
/**
 * A person's own access token, verified: who they are, what the token may do. What
 * `controlPlane.accounts.verifyUser` returns — `inProcessAccessTokenVerifier(...)` (authkit-server)
 * and `verifyAccessToken(...)` (authkit-client) both answer this shape.
 */
export interface VerifiedUser {
    /** The account (`sub`): the only owner a person's token writes to. */
    sub: string;
    scopes?: readonly string[] | undefined;
    /** The OIDC client the token was issued to. */
    clientId?: string | undefined;
    /** Set on an impersonation token (`act`); such a token never writes someone's files. */
    actor?: unknown;
}
/** `Authorization: Bearer <token>`, or `undefined`. */
export declare function bearerOf(header: string | undefined): string | undefined;
/** One app's shared secret, and what it may do (default: read and write). */
export interface SharedSecretTenant {
    secret: string;
    capabilities?: string[];
}
/**
 * One shared secret per app, compared in constant time: the app names itself with `x-media-app`
 * (the tenant client sends its `partition`), the secret proves it. For setups without authkit.
 *
 * ```ts
 * verifyTenant: sharedSecretVerifier({ partitions: { 'entre-textos': env.get('MEDIA_ET_SECRET') } })
 * ```
 */
export declare function sharedSecretVerifier(options: {
    partitions: Record<string, string | SharedSecretTenant>;
}): TenantVerifier;
//# sourceMappingURL=auth.d.ts.map