@lenso/authorization 0.0.0-stage → 0.2.1

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.
@@ -0,0 +1,32 @@
1
+ import {
2
+ authorizationRoleGraphs2
3
+ } from "../index-4znahyqj.js";
4
+ import {
5
+ createStore
6
+ } from "../index-t6xdqvqs.js";
7
+
8
+ // src/drizzle/pg.ts
9
+ import { and, eq, sql } from "drizzle-orm";
10
+ function postgresRoleStore(db, namespace, actions) {
11
+ return createStore(namespace, actions, async (_evaluation) => {
12
+ const [row] = await db.select().from(authorizationRoleGraphs2).where(eq(authorizationRoleGraphs2.namespace, namespace)).limit(1);
13
+ return row;
14
+ }, async (snapshot) => {
15
+ await db.insert(authorizationRoleGraphs2).values({
16
+ namespace,
17
+ revision: snapshot.revision,
18
+ graph: sql`${JSON.stringify(snapshot.graph)}::text::jsonb`
19
+ }).onConflictDoNothing();
20
+ }, async (expectedRevision, snapshot) => {
21
+ const rows = await db.update(authorizationRoleGraphs2).set({
22
+ revision: snapshot.revision,
23
+ graph: sql`${JSON.stringify(snapshot.graph)}::text::jsonb`
24
+ }).where(and(eq(authorizationRoleGraphs2.namespace, namespace), eq(authorizationRoleGraphs2.revision, expectedRevision))).returning({
25
+ namespace: authorizationRoleGraphs2.namespace
26
+ });
27
+ return rows.length === 1;
28
+ });
29
+ }
30
+ export {
31
+ postgresRoleStore
32
+ };
@@ -0,0 +1,61 @@
1
+ import type { RoleGraph } from "../types";
2
+ export declare const authorizationRoleGraphs: import("drizzle-orm/pg-core").PgTableWithColumns<{
3
+ name: "authorization_role_graphs";
4
+ schema: undefined;
5
+ columns: {
6
+ namespace: import("drizzle-orm/pg-core").PgColumn<{
7
+ name: "namespace";
8
+ tableName: "authorization_role_graphs";
9
+ dataType: "string";
10
+ columnType: "PgText";
11
+ data: string;
12
+ driverParam: string;
13
+ notNull: true;
14
+ hasDefault: false;
15
+ isPrimaryKey: true;
16
+ isAutoincrement: false;
17
+ hasRuntimeDefault: false;
18
+ enumValues: [string, ...string[]];
19
+ baseColumn: never;
20
+ identity: undefined;
21
+ generated: undefined;
22
+ }, {}, {}>;
23
+ revision: import("drizzle-orm/pg-core").PgColumn<{
24
+ name: "revision";
25
+ tableName: "authorization_role_graphs";
26
+ dataType: "string";
27
+ columnType: "PgText";
28
+ data: string;
29
+ driverParam: string;
30
+ notNull: true;
31
+ hasDefault: false;
32
+ isPrimaryKey: false;
33
+ isAutoincrement: false;
34
+ hasRuntimeDefault: false;
35
+ enumValues: [string, ...string[]];
36
+ baseColumn: never;
37
+ identity: undefined;
38
+ generated: undefined;
39
+ }, {}, {}>;
40
+ graph: import("drizzle-orm/pg-core").PgColumn<{
41
+ name: "graph";
42
+ tableName: "authorization_role_graphs";
43
+ dataType: "json";
44
+ columnType: "PgJsonb";
45
+ data: RoleGraph<string>;
46
+ driverParam: unknown;
47
+ notNull: true;
48
+ hasDefault: false;
49
+ isPrimaryKey: false;
50
+ isAutoincrement: false;
51
+ hasRuntimeDefault: false;
52
+ enumValues: undefined;
53
+ baseColumn: never;
54
+ identity: undefined;
55
+ generated: undefined;
56
+ }, {}, {
57
+ $type: RoleGraph<string>;
58
+ }>;
59
+ };
60
+ dialect: 'pg';
61
+ }>;
@@ -0,0 +1,6 @@
1
+ import {
2
+ authorizationRoleGraphs2
3
+ } from "../index-4znahyqj.js";
4
+ export {
5
+ authorizationRoleGraphs2 as authorizationRoleGraphs
6
+ };
@@ -0,0 +1,65 @@
1
+ import type { RoleGraph } from "../types";
2
+ export declare const authorizationRoleGraphs: import("drizzle-orm/sqlite-core").SQLiteTableWithColumns<{
3
+ name: "authorization_role_graphs";
4
+ schema: undefined;
5
+ columns: {
6
+ namespace: import("drizzle-orm/sqlite-core").SQLiteColumn<{
7
+ name: "namespace";
8
+ tableName: "authorization_role_graphs";
9
+ dataType: "string";
10
+ columnType: "SQLiteText";
11
+ data: string;
12
+ driverParam: string;
13
+ notNull: true;
14
+ hasDefault: false;
15
+ isPrimaryKey: true;
16
+ isAutoincrement: false;
17
+ hasRuntimeDefault: false;
18
+ enumValues: [string, ...string[]];
19
+ baseColumn: never;
20
+ identity: undefined;
21
+ generated: undefined;
22
+ }, {}, {
23
+ length: number | undefined;
24
+ }>;
25
+ revision: import("drizzle-orm/sqlite-core").SQLiteColumn<{
26
+ name: "revision";
27
+ tableName: "authorization_role_graphs";
28
+ dataType: "string";
29
+ columnType: "SQLiteText";
30
+ data: string;
31
+ driverParam: string;
32
+ notNull: true;
33
+ hasDefault: false;
34
+ isPrimaryKey: false;
35
+ isAutoincrement: false;
36
+ hasRuntimeDefault: false;
37
+ enumValues: [string, ...string[]];
38
+ baseColumn: never;
39
+ identity: undefined;
40
+ generated: undefined;
41
+ }, {}, {
42
+ length: number | undefined;
43
+ }>;
44
+ graph: import("drizzle-orm/sqlite-core").SQLiteColumn<{
45
+ name: "graph";
46
+ tableName: "authorization_role_graphs";
47
+ dataType: "json";
48
+ columnType: "SQLiteTextJson";
49
+ data: RoleGraph<string>;
50
+ driverParam: string;
51
+ notNull: true;
52
+ hasDefault: false;
53
+ isPrimaryKey: false;
54
+ isAutoincrement: false;
55
+ hasRuntimeDefault: false;
56
+ enumValues: undefined;
57
+ baseColumn: never;
58
+ identity: undefined;
59
+ generated: undefined;
60
+ }, {}, {
61
+ $type: RoleGraph<string>;
62
+ }>;
63
+ };
64
+ dialect: 'sqlite';
65
+ }>;
@@ -0,0 +1,6 @@
1
+ import {
2
+ authorizationRoleGraphs3
3
+ } from "../index-qjqy8v4k.js";
4
+ export {
5
+ authorizationRoleGraphs3 as authorizationRoleGraphs
6
+ };
@@ -0,0 +1,8 @@
1
+ import type { Evaluation, RoleSnapshot, RoleStore } from "../types";
2
+ export declare function decodeSnapshot<A extends string>(revision: unknown, graph: unknown, actions: readonly A[]): RoleSnapshot<A>;
3
+ export declare function createStore<A extends string>(namespace: string, actions: readonly A[], readRow: (evaluation: Evaluation) => Promise<{
4
+ revision: unknown;
5
+ graph: unknown;
6
+ } | undefined>, insert: (snapshot: RoleSnapshot<A>) => Promise<void>, update: (expectedRevision: string, snapshot: RoleSnapshot<A>) => Promise<boolean>): RoleStore<A> & {
7
+ initialize(snapshot: RoleSnapshot<A>): Promise<void>;
8
+ };
@@ -0,0 +1,11 @@
1
+ import type { BunSQLiteDatabase } from "drizzle-orm/bun-sqlite";
2
+ import type { DrizzleD1Database } from "drizzle-orm/d1";
3
+ import type { RoleSnapshot, RoleStore } from "../types";
4
+ type SqliteDb<TSchema extends Record<string, unknown>> = BunSQLiteDatabase<TSchema> | DrizzleD1Database<TSchema>;
5
+ export declare function sqliteStore<A extends string, TSchema extends Record<string, unknown>>(db: SqliteDb<TSchema>, namespace: string, actions: readonly A[]): RoleStore<A> & {
6
+ initialize(snapshot: RoleSnapshot<A>): Promise<void>;
7
+ };
8
+ export declare function sqliteRoleStore<A extends string = string, TSchema extends Record<string, unknown> = Record<string, unknown>>(db: BunSQLiteDatabase<TSchema>, namespace: string, actions: readonly A[]): RoleStore<A> & {
9
+ initialize(snapshot: RoleSnapshot<A>): Promise<void>;
10
+ };
11
+ export {};
@@ -0,0 +1,9 @@
1
+ import {
2
+ sqliteStore2,
3
+ sqliteRoleStore2
4
+ } from "../index-pmwmdjss.js";
5
+ import"../index-qjqy8v4k.js";
6
+ export {
7
+ sqliteRoleStore2 as sqliteRoleStore,
8
+ sqliteStore2 as sqliteStore
9
+ };
@@ -0,0 +1,6 @@
1
+ export declare class AuthorizationError extends Error {
2
+ constructor();
3
+ }
4
+ export declare class AuthorizationConfigurationError extends Error {
5
+ constructor();
6
+ }
@@ -0,0 +1,9 @@
1
+ // src/drizzle/schema-pg.ts
2
+ import { jsonb, pgTable, text } from "drizzle-orm/pg-core";
3
+ var authorizationRoleGraphs2 = pgTable("authorization_role_graphs", {
4
+ namespace: text("namespace").primaryKey(),
5
+ revision: text("revision").notNull(),
6
+ graph: jsonb("graph").$type().notNull()
7
+ });
8
+
9
+ export { authorizationRoleGraphs2 };
@@ -0,0 +1,224 @@
1
+ // src/conditions.ts
2
+ function all2(...conditions) {
3
+ return { kind: "all", conditions };
4
+ }
5
+ function any2(...conditions) {
6
+ return { kind: "any", conditions };
7
+ }
8
+ function predicate2(test) {
9
+ return { kind: "predicate", test };
10
+ }
11
+ function attribute2(source, key, operator, value) {
12
+ return { kind: "attribute", source, key, operator, value };
13
+ }
14
+ function relation2(name, target) {
15
+ return { kind: "relation", relation: name, ...target ? { target } : {} };
16
+ }
17
+ function sameScope2(left, right) {
18
+ return left.type === right.type && left.id === right.id;
19
+ }
20
+ function matchesPermission2(permission, request) {
21
+ return permission.action === request.action && permission.resourceType === request.resource.type && sameScope2(permission.scope, request.resource.scope) && (permission.resourceId === undefined || permission.resourceId === request.resource.id);
22
+ }
23
+
24
+ // src/snapshot.ts
25
+ function snapshot(value, limits = { maxNodes: 1e4, maxDepth: 64 }) {
26
+ let nodes = 0;
27
+ const visiting = new Set;
28
+ function copy(item, depth) {
29
+ if (++nodes > limits.maxNodes || depth > limits.maxDepth)
30
+ throw new Error("Invalid facts");
31
+ if (item === null || item === undefined || typeof item === "string" || typeof item === "boolean")
32
+ return item;
33
+ if (typeof item === "number" && Number.isFinite(item))
34
+ return item;
35
+ if (typeof item !== "object" || visiting.has(item))
36
+ throw new Error("Invalid facts");
37
+ if (!Array.isArray(item) && ![Object.prototype, null].includes(Object.getPrototypeOf(item)))
38
+ throw new Error("Invalid facts");
39
+ visiting.add(item);
40
+ const result = Array.isArray(item) ? [] : {};
41
+ for (const key of Reflect.ownKeys(item)) {
42
+ if (Array.isArray(item) && key === "length")
43
+ continue;
44
+ const property = Object.getOwnPropertyDescriptor(item, key);
45
+ if (typeof key !== "string" || !property.enumerable || !("value" in property))
46
+ throw new Error("Invalid facts");
47
+ Object.defineProperty(result, key, {
48
+ value: copy(property.value, depth + 1),
49
+ enumerable: true
50
+ });
51
+ }
52
+ visiting.delete(item);
53
+ return Object.freeze(result);
54
+ }
55
+ return copy(value, 0);
56
+ }
57
+
58
+ // src/rbac.ts
59
+ class RoleGraphError2 extends Error {
60
+ constructor() {
61
+ super("Invalid role graph");
62
+ this.name = "RoleGraphError";
63
+ }
64
+ }
65
+ var MAX_ROLES = 512;
66
+ var MAX_BINDINGS = 4096;
67
+ var MAX_ITEMS = 512;
68
+ var text = (value) => typeof value === "string" && value.length > 0 && value.length <= 256;
69
+ var scopeValid = (scope) => !!scope && text(scope.type) && text(scope.id);
70
+ var samePrincipal = (a, b) => a.realmId === b.realmId && a.subjectId === b.subjectId && a.kind === b.kind;
71
+ var principalValid = (p) => !!p && text(p.realmId) && text(p.subjectId) && text(p.kind);
72
+ var key = (scope, id) => JSON.stringify([scope.type, scope.id, id]);
73
+ var permissionKey = (p) => JSON.stringify([p.action, p.resourceType, p.scope.type, p.scope.id, p.resourceId ?? null]);
74
+ function permissionCovers(ceiling, permission) {
75
+ return ceiling.action === permission.action && ceiling.resourceType === permission.resourceType && sameScope2(ceiling.scope, permission.scope) && (ceiling.resourceId === undefined || ceiling.resourceId === permission.resourceId);
76
+ }
77
+ function validateRoleGraph2(graph, actions) {
78
+ const fail = () => {
79
+ throw new RoleGraphError2;
80
+ };
81
+ if (!Array.isArray(actions) || actions.length === 0 || actions.length > MAX_ITEMS || actions.some((a) => !text(a)) || new Set(actions).size !== actions.length)
82
+ fail();
83
+ if (!graph || !Array.isArray(graph.roles) || !Array.isArray(graph.bindings) || graph.roles.length > MAX_ROLES || graph.bindings.length > MAX_BINDINGS)
84
+ fail();
85
+ const known = new Set(actions);
86
+ const roles = new Map;
87
+ for (const role of graph.roles) {
88
+ if (!role || !text(role.id) || !scopeValid(role.scope) || !Array.isArray(role.permissions) || role.permissions.length > MAX_ITEMS || role.inherits !== undefined && (!Array.isArray(role.inherits) || role.inherits.length > MAX_ROLES))
89
+ fail();
90
+ const k = key(role.scope, role.id);
91
+ if (roles.has(k))
92
+ fail();
93
+ roles.set(k, role);
94
+ const permissions = new Set;
95
+ for (const p of role.permissions) {
96
+ if (!p || !known.has(p.action) || !text(p.resourceType) || !scopeValid(p.scope) || !sameScope2(role.scope, p.scope) || p.resourceId !== undefined && !text(p.resourceId))
97
+ fail();
98
+ const pk = permissionKey(p);
99
+ if (permissions.has(pk))
100
+ fail();
101
+ permissions.add(pk);
102
+ }
103
+ if (new Set(role.inherits ?? []).size !== (role.inherits ?? []).length)
104
+ fail();
105
+ }
106
+ const visited = new Set;
107
+ const visiting = new Set;
108
+ const visit = (k) => {
109
+ if (visiting.has(k))
110
+ fail();
111
+ if (visited.has(k))
112
+ return;
113
+ const role = roles.get(k);
114
+ if (!role)
115
+ fail();
116
+ visiting.add(k);
117
+ for (const id of role.inherits ?? []) {
118
+ if (!text(id))
119
+ fail();
120
+ visit(key(role.scope, id));
121
+ }
122
+ visiting.delete(k);
123
+ visited.add(k);
124
+ };
125
+ for (const k of roles.keys())
126
+ visit(k);
127
+ const bindings = new Set;
128
+ for (const b of graph.bindings) {
129
+ if (!b || !text(b.id) || bindings.has(b.id) || !principalValid(b.principal) || !scopeValid(b.scope) || !text(b.roleId) || !roles.has(key(b.scope, b.roleId)) || b.expiresAt !== undefined && (!Number.isSafeInteger(b.expiresAt) || b.expiresAt < 0))
130
+ fail();
131
+ bindings.add(b.id);
132
+ }
133
+ }
134
+ function effectiveRolePermissions2(graph, roleId, scope) {
135
+ const pending = [roleId];
136
+ const visited = new Set;
137
+ const permissions = new Map;
138
+ while (pending.length) {
139
+ const id = pending.pop();
140
+ if (visited.has(id))
141
+ continue;
142
+ if (visited.size >= MAX_ROLES)
143
+ throw new RoleGraphError2;
144
+ visited.add(id);
145
+ const role = graph.roles.find((r) => r.id === id && sameScope2(r.scope, scope));
146
+ if (!role || role.permissions.length > MAX_ITEMS || (role.inherits?.length ?? 0) > MAX_ROLES) {
147
+ throw new RoleGraphError2;
148
+ }
149
+ for (const p of role.permissions)
150
+ permissions.set(permissionKey(p), p);
151
+ pending.push(...role.inherits ?? []);
152
+ }
153
+ return [...permissions.values()];
154
+ }
155
+ function effectivePermissions2(graph, principal, scope, now) {
156
+ if (!Number.isFinite(now))
157
+ return [];
158
+ const permissions = new Map;
159
+ for (const b of graph.bindings) {
160
+ if (samePrincipal(b.principal, principal) && sameScope2(b.scope, scope) && (b.expiresAt === undefined || b.expiresAt > now)) {
161
+ for (const p of effectiveRolePermissions2(graph, b.roleId, scope)) {
162
+ permissions.set(permissionKey(p), p);
163
+ }
164
+ }
165
+ }
166
+ return [...permissions.values()];
167
+ }
168
+ function immutableRoleSnapshot(value, actions) {
169
+ try {
170
+ const copy = snapshot(value, { maxNodes: 4000000, maxDepth: 32 });
171
+ if (!text(copy.revision))
172
+ throw new RoleGraphError2;
173
+ validateRoleGraph2(copy.graph, actions);
174
+ return copy;
175
+ } catch {
176
+ throw new RoleGraphError2;
177
+ }
178
+ }
179
+ function memoryRoleStore2(graph, actions) {
180
+ const known = [...actions];
181
+ let current = immutableRoleSnapshot({ revision: crypto.randomUUID(), graph }, known);
182
+ return {
183
+ read: () => current,
184
+ compareAndSwap(expected, next, evaluation) {
185
+ if (evaluation.signal.aborted || expected !== current.revision)
186
+ return false;
187
+ const candidate = immutableRoleSnapshot(next, known);
188
+ if (candidate.revision === current.revision)
189
+ throw new RoleGraphError2;
190
+ current = candidate;
191
+ return true;
192
+ }
193
+ };
194
+ }
195
+ function rbacPredicate2(options) {
196
+ const actions = [...options.actions];
197
+ validateRoleGraph2({ roles: [], bindings: [] }, actions);
198
+ const store = options.store ?? memoryRoleStore2(options.graph, actions);
199
+ return async (request, evaluation) => {
200
+ if (!request.principal || !actions.includes(request.action) || evaluation.signal.aborted || !Number.isFinite(evaluation.now))
201
+ return false;
202
+ try {
203
+ const current = immutableRoleSnapshot(await store.read(evaluation), actions);
204
+ if (evaluation.signal.aborted)
205
+ return false;
206
+ return effectivePermissions2(current.graph, request.principal, request.resource.scope, evaluation.now).some((p) => permissionCovers(p, {
207
+ action: request.action,
208
+ resourceType: request.resource.type,
209
+ resourceId: request.resource.id,
210
+ scope: request.resource.scope
211
+ }));
212
+ } catch {
213
+ throw new RoleGraphError2;
214
+ }
215
+ };
216
+ }
217
+ function rbacPolicy2(options) {
218
+ const test = rbacPredicate2(options);
219
+ return {
220
+ evaluate: async (request, evaluation) => await test(request, evaluation) ? "allow" : "abstain"
221
+ };
222
+ }
223
+
224
+ export { all2, any2, predicate2, attribute2, relation2, sameScope2, matchesPermission2, snapshot, RoleGraphError2, samePrincipal, permissionCovers, validateRoleGraph2, effectiveRolePermissions2, effectivePermissions2, immutableRoleSnapshot, memoryRoleStore2, rbacPredicate2, rbacPolicy2 };
@@ -0,0 +1,16 @@
1
+ // src/errors.ts
2
+ class AuthorizationError2 extends Error {
3
+ constructor() {
4
+ super("Access denied.");
5
+ this.name = "AuthorizationError";
6
+ }
7
+ }
8
+
9
+ class AuthorizationConfigurationError2 extends Error {
10
+ constructor() {
11
+ super("Invalid authorization configuration.");
12
+ this.name = "AuthorizationConfigurationError";
13
+ }
14
+ }
15
+
16
+ export { AuthorizationError2, AuthorizationConfigurationError2 };
@@ -0,0 +1,32 @@
1
+ import {
2
+ authorizationRoleGraphs3
3
+ } from "./index-qjqy8v4k.js";
4
+ import {
5
+ createStore
6
+ } from "./index-t6xdqvqs.js";
7
+
8
+ // src/drizzle/sqlite.ts
9
+ import { and, eq } from "drizzle-orm";
10
+ function sqliteStore2(db, namespace, actions) {
11
+ return createStore(namespace, actions, async (_evaluation) => {
12
+ const [row] = await db.select().from(authorizationRoleGraphs3).where(eq(authorizationRoleGraphs3.namespace, namespace)).limit(1).all();
13
+ return row;
14
+ }, async (snapshot) => {
15
+ await db.insert(authorizationRoleGraphs3).values({
16
+ namespace,
17
+ revision: snapshot.revision,
18
+ graph: snapshot.graph
19
+ }).onConflictDoNothing().run();
20
+ }, async (expectedRevision, snapshot) => {
21
+ const rows = await db.update(authorizationRoleGraphs3).set({
22
+ revision: snapshot.revision,
23
+ graph: snapshot.graph
24
+ }).where(and(eq(authorizationRoleGraphs3.namespace, namespace), eq(authorizationRoleGraphs3.revision, expectedRevision))).returning().all();
25
+ return rows.length === 1;
26
+ });
27
+ }
28
+ function sqliteRoleStore2(db, namespace, actions) {
29
+ return sqliteStore2(db, namespace, actions);
30
+ }
31
+
32
+ export { sqliteStore2, sqliteRoleStore2 };
@@ -0,0 +1,9 @@
1
+ // src/drizzle/schema-sqlite.ts
2
+ import { sqliteTable, text } from "drizzle-orm/sqlite-core";
3
+ var authorizationRoleGraphs3 = sqliteTable("authorization_role_graphs", {
4
+ namespace: text("namespace").primaryKey(),
5
+ revision: text("revision").notNull(),
6
+ graph: text("graph", { mode: "json" }).$type().notNull()
7
+ });
8
+
9
+ export { authorizationRoleGraphs3 };
@@ -0,0 +1,56 @@
1
+ import {
2
+ RoleGraphError2,
3
+ immutableRoleSnapshot
4
+ } from "./index-5k98eatm.js";
5
+
6
+ // src/drizzle/shared.ts
7
+ function decodeSnapshot(revision, graph, actions) {
8
+ try {
9
+ const value = typeof graph === "string" ? JSON.parse(graph) : graph;
10
+ return immutableRoleSnapshot({ revision, graph: value }, actions);
11
+ } catch {
12
+ throw new RoleGraphError2;
13
+ }
14
+ }
15
+ function createStore(namespace, actions, readRow, insert, update) {
16
+ if (typeof namespace !== "string" || !namespace.length || namespace.length > 256)
17
+ throw new RoleGraphError2;
18
+ const known = Object.freeze([...actions]);
19
+ immutableRoleSnapshot({ revision: "validation", graph: { roles: [], bindings: [] } }, known);
20
+ return {
21
+ async read(evaluation) {
22
+ try {
23
+ evaluation.signal.throwIfAborted();
24
+ const row = await readRow(evaluation);
25
+ evaluation.signal.throwIfAborted();
26
+ if (!row)
27
+ throw new RoleGraphError2;
28
+ return decodeSnapshot(row.revision, row.graph, known);
29
+ } catch {
30
+ throw new RoleGraphError2;
31
+ }
32
+ },
33
+ async compareAndSwap(expectedRevision, next, evaluation) {
34
+ try {
35
+ evaluation.signal.throwIfAborted();
36
+ if (typeof expectedRevision !== "string" || !expectedRevision.length || expectedRevision.length > 256 || next.revision === expectedRevision)
37
+ throw new RoleGraphError2;
38
+ const candidate = immutableRoleSnapshot(next, known);
39
+ const changed = await update(expectedRevision, candidate);
40
+ evaluation.signal.throwIfAborted();
41
+ return changed;
42
+ } catch {
43
+ throw new RoleGraphError2;
44
+ }
45
+ },
46
+ async initialize(value) {
47
+ try {
48
+ await insert(immutableRoleSnapshot(value, known));
49
+ } catch {
50
+ throw new RoleGraphError2;
51
+ }
52
+ }
53
+ };
54
+ }
55
+
56
+ export { createStore };
@@ -0,0 +1,9 @@
1
+ export type * from "./types";
2
+ export { createAuthorization } from "./core";
3
+ export { AuthorizationError, AuthorizationConfigurationError } from "./errors";
4
+ export { all, any, predicate, attribute, relation, sameScope, matchesPermission, } from "./conditions";
5
+ export { authorizeList } from "./list";
6
+ export { rbacPolicy, rbacPredicate, validateRoleGraph, effectiveRolePermissions, effectivePermissions, memoryRoleStore, RoleGraphError, } from "./rbac";
7
+ export type { RbacOptions } from "./rbac";
8
+ export { createRoleManagement, RoleManagementError } from "./management";
9
+ export type { ManagementAction, ManagementRequest, GrantAuthority, RoleManagementOptions, RoleMutationResult, } from "./management";