Documentation
    Preparing search index...

    Interface PermissionAdapter

    Host UI, time, cancellation, and storage adapters for scoped approvals.

    interface PermissionAdapter {
        createCancellation: () => ApprovalCancellation;
        defaultDecision?: (
            request: PermissionRequest,
            missing: readonly PermissionRequirement[],
        ) => "allow" | "deny" | "ask";
        extensions?: readonly `extension:${string}`[];
        maxGrants?: number;
        maxGrantsPerPrincipal?: number;
        maxPending?: number;
        maxRequirements?: number;
        now: () => number;
        onRateLimit?: (event: PermissionRateEvent) => void;
        onStorageError?: (failure: PermissionStorageFailure) => void;
        persistence?: PermissionPersistence;
        prompt?: (prompt: ApprovalPrompt) => Promise<ApprovalAnswer>;
        promptRateLimiter?: TemporalPolicy;
        rateLimiter?: TemporalPolicy;
        schedule: (callback: () => void, delayMs: number) => () => void;
        timeoutMs?: number;
    }

    Hierarchy

    • Pick<
          ApprovalCoordinatorOptions,
          | "prompt"
          | "defaultDecision"
          | "createCancellation"
          | "schedule"
          | "extensions"
          | "maxRequirements"
          | "maxGrants"
          | "maxGrantsPerPrincipal"
          | "maxPending"
          | "timeoutMs",
      >
      • PermissionAdapter
    Index

    Properties

    createCancellation: () => ApprovalCancellation
    defaultDecision?: (
        request: PermissionRequest,
        missing: readonly PermissionRequirement[],
    ) => "allow" | "deny" | "ask"

    Host default rules for scopes no stored decision covers, consulted before the prompt budget and the prompt, and again wherever access is rechecked. allow admits the request without writing a grant: the rule itself is the answer, so changing it takes effect on the next check (kehto/web#513). deny refuses without a grant; ask or a thrown error prompts. Stored denials, ACL restrictions, domain availability, and operation budgets still apply. It runs on every check, so keep it cheap and side-effect free.

    extensions?: readonly `extension:${string}`[]
    maxGrants?: number

    Most grants the policy may hold. Default MAX_PERMISSION_GRANTS (2048), at most MAX_PERMISSION_GRANTS_CEILING.

    maxGrantsPerPrincipal?: number

    Most grants one napplet (by permissionRuleSubject, across its artifact versions) may hold. Default MAX_PERMISSION_GRANTS_PER_PRINCIPAL (512), clamped to maxGrants, at most MAX_PERMISSION_GRANTS_CEILING.

    maxPending?: number

    Requests awaiting a decision (queue wait and prompt), default 64.

    maxRequirements?: number

    Most requirements one request may carry, counting implicit interface requirements. Default MAX_PERMISSION_REQUIREMENTS (128), at most MAX_PERMISSION_REQUIREMENTS_CEILING.

    now: () => number
    onRateLimit?: (event: PermissionRateEvent) => void

    Budget diagnostics omit payloads, URLs, and stored permission records.

    onStorageError?: (failure: PermissionStorageFailure) => void
    persistence?: PermissionPersistence

    Durable storage. Without it, persistent decisions fail explicitly.

    prompt?: (prompt: ApprovalPrompt) => Promise<ApprovalAnswer>
    promptRateLimiter?: TemporalPolicy

    Blocking UI-spam budgets, separate from operation budgets.

    rateLimiter?: TemporalPolicy

    Independent temporal policy; approvals cannot override it.

    schedule: (callback: () => void, delayMs: number) => () => void

    Schedule a deadline and return its cancellation function.

    timeoutMs?: number

    Bound on the approval phase only, default 60000 ms: queue wait behind an equivalent prompt, the prompt, and grant commit. Execution is not bounded here; the domain owns its operation deadline (for NAP-CVM, timeoutMs).