Documentation
    Preparing search index...

    Function admitPermissionGrants

    • Add grants from one decision, making room fairly instead of refusing (kehto/web#513). Each napplet (permissionRuleSubject) holds at most maxGrantsPerPrincipal grants, so one napplet can't fill the shared table.

      To make room it evicts only session grants, oldest first: first the same napplet's own, then, if the table is still full, the napplet holding the most grants. persistent decisions are never evicted silently, and once grants are never evicted because the operation that earned them may be about to consume them. Grants are immutable snapshots, so "oldest" is insertion order: re-approving a scope re-inserts it. Throws the putPermissionGrant limit RangeError when only persistent or once grants are left to evict.

      Parameters

      • state: PermissionState

        Current policy.

      • grants: readonly PermissionGrant[]

        Grants of one decision, all for the same principal.

      • options: PermissionPolicyOptions = {}

        Host policy bounds.

      • keep: readonly string[] = []

        Ids of grants the same decision relies on, never evicted.

      Returns PermissionAdmitResult

      The next state and the evicted session grants, for diagnostics.

      const { state: next, evicted } = admitPermissionGrants(state, [grant]);