@omnitron-dev/access 0.3.5 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -70
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,85 +1,35 @@
|
|
|
1
1
|
# @omnitron-dev/access
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
No runtime dependencies, Node built-ins, decorators, network clients or global state.
|
|
3
|
+
Pure role hierarchies, permission matching and session policies for servers, browsers and workers. Applications provide identity and enforcement; this package evaluates policy without network or storage dependencies.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
import { createRoleHierarchy } from '@omnitron-dev/access/roles';
|
|
8
|
-
import { createPermissionChecker } from '@omnitron-dev/access/permissions';
|
|
5
|
+
## Capabilities
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
reviewer: { level: 2, inherits: ['reader'] },
|
|
14
|
-
owner: { level: 3, inherits: ['author', 'reviewer'], assignable: false },
|
|
15
|
-
});
|
|
7
|
+
- Immutable role hierarchies with explicit inheritance and assignment rules.
|
|
8
|
+
- Permission checks in explicit or hierarchical mode.
|
|
9
|
+
- Optional platform roles and MFA, session-age and timezone-aware session policies.
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
roles.canModerateRole(['owner'], 'author'); // true; peers cannot moderate each other
|
|
11
|
+
## Quick start
|
|
19
12
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
allows('documents.read.all'); // false
|
|
13
|
+
```sh
|
|
14
|
+
pnpm add @omnitron-dev/access
|
|
23
15
|
```
|
|
24
16
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
| Import | Responsibility |
|
|
28
|
-
| --- | --- |
|
|
29
|
-
| `@omnitron-dev/access` | Pure role and permission primitives |
|
|
30
|
-
| `@omnitron-dev/access/roles` | Application-defined, immutable role hierarchy |
|
|
31
|
-
| `@omnitron-dev/access/permissions` | Matching, compiled checks, registry helpers and types |
|
|
32
|
-
| `@omnitron-dev/access/platform` | Optional five-role platform preset |
|
|
33
|
-
| `@omnitron-dev/access/session-policy` | Pure MFA, absolute session age and timezone-aware access windows |
|
|
34
|
-
|
|
35
|
-
The platform preset provides `user`, `moderator`, `security`, `admin` and
|
|
36
|
-
`superadmin`. Security and moderation have separate inheritance. Unknown roles
|
|
37
|
-
have rank `-1` and cannot be visibility, moderation or assignment targets.
|
|
38
|
-
Expansion preserves independent claims without granting them rank. The retired
|
|
39
|
-
`boss` claim expands to `user` for compatibility; service identity is established
|
|
40
|
-
by the authentication adapter, never by this hierarchy.
|
|
41
|
-
|
|
42
|
-
## Matching and enforcement
|
|
43
|
-
|
|
44
|
-
`hierarchical` (the default) lets a concrete parent grant its descendants:
|
|
45
|
-
`documents` grants `documents.read`. `explicit` requires an exact key, `*`, or
|
|
46
|
-
a suffix wildcard such as `documents.*`. Colons are literal characters.
|
|
47
|
-
Select the mode deliberately at each application boundary. Titan's Netron
|
|
48
|
-
helpers use explicit mode; the compatibility `titan-auth/access` entry uses
|
|
49
|
-
hierarchical mode by default. Neither migration broadens existing authority.
|
|
17
|
+
```ts
|
|
18
|
+
import { createPermissionChecker } from '@omnitron-dev/access/permissions';
|
|
50
19
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
call. `resolvePermissions` returns recognised effective keys in registry order;
|
|
56
|
-
`expandWildcards` retains concrete grants verbatim for compatibility.
|
|
20
|
+
const allows = createPermissionChecker(['documents.read', 'media.*'], 'explicit');
|
|
21
|
+
console.log(allows('documents.read')); // true
|
|
22
|
+
console.log(allows('documents.write')); // false
|
|
23
|
+
```
|
|
57
24
|
|
|
58
|
-
|
|
59
|
-
the applicable registry before storing them. Enforce authentication, tenant
|
|
60
|
-
ownership, resource state and grant delegation on the server. A browser check
|
|
61
|
-
only controls affordances. An assignment list is not an authorization gate:
|
|
62
|
-
check the target's current rank, then validate the requested role and ownership.
|
|
25
|
+
`explicit` requires an exact grant, `*`, or a suffix wildcard. The default `hierarchical` mode also grants descendants of a concrete parent. Choose the mode at each boundary and rebuild a compiled checker when grants change.
|
|
63
26
|
|
|
64
|
-
|
|
27
|
+
Use `./roles` for application-defined hierarchies, `./platform` for the optional platform preset, and `./session-policy` for pure session evaluation. Unknown or malformed policy controls fail closed. A browser check controls presentation; server handlers still enforce authentication, tenant ownership and current permissions.
|
|
65
28
|
|
|
66
|
-
|
|
67
|
-
`expandRoleSet` as the shared-session preset's `roleExpander`. Token issuers and
|
|
68
|
-
verifiers must share the same definition. Opaque sessions can use the pure policy
|
|
69
|
-
without JWT or Titan Auth. Storage, Redis and database adapters are independent.
|
|
29
|
+
## Documentation
|
|
70
30
|
|
|
71
|
-
|
|
72
|
-
narrow entry points. Importing permission helpers does not instantiate a role
|
|
73
|
-
preset. Application-owned adapters and catalogs remain outside the package.
|
|
31
|
+
[Access policy guide](https://omnitron.dev/docs/auth/access-policy) · [Public API](src/index.ts) · [Exports](package.json)
|
|
74
32
|
|
|
75
|
-
|
|
76
|
-
session facts against optional `requireMfa`, `maxSessionDuration` (minutes), and
|
|
77
|
-
`timeWindows` (`days`, `startHour`, `endHour`, IANA `timezone`). Time windows may
|
|
78
|
-
cross midnight; their days name the starting day. End hours are exclusive, with
|
|
79
|
-
24 representing midnight. Unknown or malformed controls fail closed.
|
|
80
|
-
Persist proof that MFA was completed for the session; enrollment is not proof.
|
|
81
|
-
Evaluate on each protected request and renewal, using the original session
|
|
82
|
-
creation time. This pure helper owns neither clocks, session storage nor tokens.
|
|
33
|
+
## License
|
|
83
34
|
|
|
84
|
-
|
|
85
|
-
configuration, migration and enforcement examples.
|
|
35
|
+
[MIT](../../LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omnitron-dev/access",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"description": "Dependency-free role hierarchies and permission policies for browsers and servers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"url": "git+https://github.com/omnitron-dev/omni.git",
|
|
53
53
|
"directory": "packages/access"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1ae8568eebc2581e2cc2428bd3ca1cf570ed3f03",
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "../../scripts/build-package.sh -p ./tsconfig.json",
|
|
58
58
|
"typecheck": "tsc --noEmit",
|