@incoqnito.io/ts-iq-core
v2.0.0
Published
A typescript module containing foundational utilities like common data structures and capabilities to facilitate background tasks
Keywords
Readme
Signals
This group of features consists of Signals and what to do with them. One can either wait for a signal or emit it. Waiting fo a signal will last until the signal gets emitted. While this is rather academic on the surface one can implement plenty of multithreading-like systems with this primitive:
- ServiceQueue/ServiceQueueImpl - a queue which services its entries in the background.
- JobQueue/JobQueueImpl - a queue which funnels and de-duplicates its jobs.
- TimeoutQueue - a queue which elements get (optionally processed) and removed after their timeout expires
- CountDownLatch - a resource one can wait for which will resolve when a given number of instances happened modeled by counting down a number.
- Mutex/ReentrantMutex - synchronization primitives
data structures
- LinkedList
- MarkDeleteCache
- BasicMemoryCache
utility functions
- repeatOnInterval
- repeatAtTime
Access Control System
Interfaces and Logic to model various access control styles
namespace: ACS
This consists of interfaces one can implement on their own access primitives as well as the logic to make use of them.
function: hasRole
For a pure role-based system. Checks if the given entity (i.e. user, group) has a specific role.
function: doesAllow
For permission based systems. Checks of the given entity (i.e. user, group) has the given grant (a permission on a resource). This can work in two modes:
- checkDenies: false - searches for an allowed grant (a permission on a resource) ignoring any denied-grant. Allows access when finding an allowed grat and denies access when ther is no matching allow grant in this entites hirarchy. Useful if denies are not used in the system because this is much faster.
- checkDenies: true - searches for an allowed grant (a permission on a resource) but denying access when finding either a deny grant or no allow grant at all.
This function also checks grants given by roles but this can be disabled if desired.
function: collectAllGrants
This returns a list of all grants (allowed and denied) given to the given entity up its hirarchy and roles.
function: hasAccess
For resource/container based systems. Checks if the given entity (i.e. user, group) has the given allowed permission on the given resource and has not a denied permission on that resource. This function also checks grants given by roles but this can be disabled if desired. Optional this can be parallelized which will split the checks up the hirarchies into more Promises with the tradeoff of a higher memory consumption and a bit more total runtime.
namespace: ACSBaseImpl
This contains various base implementations for the interfaces in the ACS namespace. Those are mainly used for testing but may be useful outside of that scope.
