@develit-services/rbac 0.3.0 → 0.5.0
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/dist/export/worker.cjs +95 -51
- package/dist/export/worker.d.cts +14 -7
- package/dist/export/worker.d.mts +14 -7
- package/dist/export/worker.d.ts +14 -7
- package/dist/export/worker.mjs +95 -51
- package/dist/export/wrangler.cjs +6 -1
- package/dist/export/wrangler.d.cts +4 -0
- package/dist/export/wrangler.d.mts +4 -0
- package/dist/export/wrangler.d.ts +4 -0
- package/dist/export/wrangler.mjs +6 -1
- package/dist/shared/{rbac.ihzxYB9Z.mjs → rbac.2_i8g_mW.mjs} +27 -10
- package/dist/shared/{rbac.DrhiDe1P.d.ts → rbac.BrefTsLW.d.ts} +23 -7
- package/dist/shared/{rbac.DbnJpvqK.d.mts → rbac.CG3CtEwh.d.mts} +23 -7
- package/dist/shared/{rbac.B4wUvd3l.d.cts → rbac.DBpIRbd3.d.cts} +23 -7
- package/dist/shared/{rbac.BZDCYlSt.cjs → rbac.JCf4hSCf.cjs} +32 -9
- package/dist/types.cjs +7 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.mjs +1 -1
- package/package.json +3 -3
package/dist/export/worker.cjs
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
const backendSdk = require('@develit-io/backend-sdk');
|
|
6
6
|
const database_schema = require('../shared/rbac.Cra1T2nC.cjs');
|
|
7
7
|
const drizzleOrm = require('drizzle-orm');
|
|
8
|
-
const verifyScope = require('../shared/rbac.
|
|
8
|
+
const verifyScope = require('../shared/rbac.JCf4hSCf.cjs');
|
|
9
9
|
const zod = require('zod');
|
|
10
10
|
const cloudflare_workers = require('cloudflare:workers');
|
|
11
11
|
const d1 = require('drizzle-orm/d1');
|
|
@@ -480,8 +480,15 @@ let RbacServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
480
480
|
{ successMessage: "Scope successfully granted to user." },
|
|
481
481
|
async ({ userId, scope, resourceId }) => {
|
|
482
482
|
this.validateScope(scope);
|
|
483
|
-
const
|
|
484
|
-
|
|
483
|
+
const userScopes = await getScopesByUserQuery({ db: this.db, userId });
|
|
484
|
+
const matchingScopes = userScopes.filter((s) => s.scope === scope);
|
|
485
|
+
if (!resourceId && matchingScopes.find((s) => !s.resourceId)) {
|
|
486
|
+
throw backendSdk.createInternalError(null, {
|
|
487
|
+
message: "Scope already assigned to user.",
|
|
488
|
+
status: 409
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
if (resourceId && matchingScopes.some((s) => s.resourceId === resourceId)) {
|
|
485
492
|
throw backendSdk.createInternalError(null, {
|
|
486
493
|
message: "Scope already assigned to user.",
|
|
487
494
|
status: 409
|
|
@@ -506,7 +513,16 @@ let RbacServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
506
513
|
for (const scope of scopes) {
|
|
507
514
|
this.validateScope(scope.scope);
|
|
508
515
|
const userScopes = await getScopesByUserQuery({ db: this.db, userId });
|
|
509
|
-
|
|
516
|
+
const matchingScopes = userScopes.filter(
|
|
517
|
+
(s) => s.scope === scope.scope
|
|
518
|
+
);
|
|
519
|
+
if (!scope.resourceId && matchingScopes.find((s) => !s.resourceId)) {
|
|
520
|
+
throw backendSdk.createInternalError(null, {
|
|
521
|
+
message: "Scope already assigned to user.",
|
|
522
|
+
status: 409
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
if (scope.resourceId && matchingScopes.some((s) => s.resourceId === scope.resourceId)) {
|
|
510
526
|
throw backendSdk.createInternalError(null, {
|
|
511
527
|
message: "Scope already assigned to user.",
|
|
512
528
|
status: 409
|
|
@@ -661,10 +677,24 @@ let RbacServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
661
677
|
{ data: input, schema: verifyScope.verifyAccessInputSchema },
|
|
662
678
|
{ successMessage: "Access verification completed." },
|
|
663
679
|
async ({ userId, accessRequests, jwt }) => {
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
680
|
+
const collectScopes = (condition) => {
|
|
681
|
+
if (verifyScope.isScopeObject(condition)) {
|
|
682
|
+
return [condition];
|
|
683
|
+
}
|
|
684
|
+
if (verifyScope.isOrCondition(condition)) {
|
|
685
|
+
return condition.or.flatMap(collectScopes);
|
|
686
|
+
}
|
|
687
|
+
if (verifyScope.isAndCondition(condition)) {
|
|
688
|
+
return condition.and.flatMap(collectScopes);
|
|
667
689
|
}
|
|
690
|
+
if (verifyScope.isImplicitAndCondition(condition)) {
|
|
691
|
+
return condition.flatMap(collectScopes);
|
|
692
|
+
}
|
|
693
|
+
return [];
|
|
694
|
+
};
|
|
695
|
+
const allScopeObjects = collectScopes(accessRequests);
|
|
696
|
+
for (const scopeObj of allScopeObjects) {
|
|
697
|
+
this.validateScope(scopeObj.scope);
|
|
668
698
|
}
|
|
669
699
|
const userPermissionsResponse = await this.getUserPermissions({
|
|
670
700
|
userId
|
|
@@ -679,59 +709,71 @@ let RbacServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
|
|
|
679
709
|
...userPermissionsResponse.data.roleScopes,
|
|
680
710
|
...userPermissionsResponse.data.scopes
|
|
681
711
|
];
|
|
682
|
-
if (
|
|
712
|
+
if (allScopeObjects.length === 0) {
|
|
683
713
|
return {
|
|
684
714
|
isVerified: true
|
|
685
715
|
};
|
|
686
716
|
}
|
|
687
|
-
const
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
request.resourcePath
|
|
704
|
-
);
|
|
705
|
-
const allPlaceholdersMatch = placeholders.every(
|
|
706
|
-
(placeholder) => {
|
|
707
|
-
const extractedValue = extractedResources[`${placeholder.type}.${placeholder.path}`];
|
|
708
|
-
const jwtParam = placeholder.type === "jwt" ? jwt : void 0;
|
|
709
|
-
const expectedValue = getValueByKey(
|
|
710
|
-
placeholder.type,
|
|
711
|
-
placeholder.path,
|
|
712
|
-
jwtParam
|
|
713
|
-
);
|
|
714
|
-
if (expectedValue === void 0) {
|
|
715
|
-
return false;
|
|
716
|
-
}
|
|
717
|
-
return String(extractedValue) === String(expectedValue);
|
|
718
|
-
}
|
|
719
|
-
);
|
|
720
|
-
const resourceIdMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
721
|
-
resourceMatches = allPlaceholdersMatch && resourceIdMatches;
|
|
722
|
-
} else {
|
|
723
|
-
resourceMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
724
|
-
}
|
|
725
|
-
return scopesMatch && resourceMatches;
|
|
726
|
-
});
|
|
727
|
-
});
|
|
728
|
-
});
|
|
717
|
+
const evaluateCondition = (condition) => {
|
|
718
|
+
if (verifyScope.isScopeObject(condition)) {
|
|
719
|
+
return this.verifySingleScope(condition, allScopes, jwt);
|
|
720
|
+
}
|
|
721
|
+
if (verifyScope.isOrCondition(condition)) {
|
|
722
|
+
return condition.or.some(evaluateCondition);
|
|
723
|
+
}
|
|
724
|
+
if (verifyScope.isAndCondition(condition)) {
|
|
725
|
+
return condition.and.every(evaluateCondition);
|
|
726
|
+
}
|
|
727
|
+
if (verifyScope.isImplicitAndCondition(condition)) {
|
|
728
|
+
return condition.every(evaluateCondition);
|
|
729
|
+
}
|
|
730
|
+
return false;
|
|
731
|
+
};
|
|
732
|
+
const isVerified = evaluateCondition(accessRequests);
|
|
729
733
|
return {
|
|
730
|
-
isVerified
|
|
734
|
+
isVerified
|
|
731
735
|
};
|
|
732
736
|
}
|
|
733
737
|
);
|
|
734
738
|
}
|
|
739
|
+
verifySingleScope(request, allScopes, jwt) {
|
|
740
|
+
const placeholders = parseScopeTemplate(request.scope);
|
|
741
|
+
return allScopes.some((userScope) => {
|
|
742
|
+
const scopesMatch = userScope.scope === request.scope;
|
|
743
|
+
let resourceMatches = false;
|
|
744
|
+
if (placeholders.length > 0) {
|
|
745
|
+
if (!request.resourcePath) {
|
|
746
|
+
throw backendSdk.createInternalError(null, {
|
|
747
|
+
message: `Resource path is required when scope '${request.scope}' contains placeholders`,
|
|
748
|
+
status: 400,
|
|
749
|
+
code: "RESOURCE_PATH_REQUIRED"
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
const extractedResources = extractResourcesFromPath(
|
|
753
|
+
request.scope,
|
|
754
|
+
request.resourcePath
|
|
755
|
+
);
|
|
756
|
+
const allPlaceholdersMatch = placeholders.every((placeholder) => {
|
|
757
|
+
const extractedValue = extractedResources[`${placeholder.type}.${placeholder.path}`];
|
|
758
|
+
const jwtParam = placeholder.type === "jwt" ? jwt : void 0;
|
|
759
|
+
const expectedValue = getValueByKey(
|
|
760
|
+
placeholder.type,
|
|
761
|
+
placeholder.path,
|
|
762
|
+
jwtParam
|
|
763
|
+
);
|
|
764
|
+
if (expectedValue === void 0) {
|
|
765
|
+
return false;
|
|
766
|
+
}
|
|
767
|
+
return String(extractedValue) === String(expectedValue);
|
|
768
|
+
});
|
|
769
|
+
const resourceIdMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
770
|
+
resourceMatches = allPlaceholdersMatch && resourceIdMatches;
|
|
771
|
+
} else {
|
|
772
|
+
resourceMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
773
|
+
}
|
|
774
|
+
return scopesMatch && resourceMatches;
|
|
775
|
+
});
|
|
776
|
+
}
|
|
735
777
|
async deleteRole(input) {
|
|
736
778
|
return this.handleAction(
|
|
737
779
|
{ data: input, schema: verifyScope.deleteRoleInputSchema },
|
|
@@ -816,6 +858,7 @@ const organizationScopedKeys = (scopes) => {
|
|
|
816
858
|
return out;
|
|
817
859
|
};
|
|
818
860
|
const TEST_SCOPES = [
|
|
861
|
+
"test.admin",
|
|
819
862
|
"test.read",
|
|
820
863
|
"test.edit",
|
|
821
864
|
"test.delete",
|
|
@@ -1016,6 +1059,7 @@ const LABELED_SCOPES = [
|
|
|
1016
1059
|
{ label: "Smazat logy rol\xED", value: "roles.logs.delete" },
|
|
1017
1060
|
{ label: "Zobrazit u\u017Eivatele p\u0159i\u0159azen\xE9 k rol\xEDm", value: "roles.users.read" },
|
|
1018
1061
|
// Test scopes
|
|
1062
|
+
{ label: "Test: Admin", value: "test.admin" },
|
|
1019
1063
|
{ label: "Test: Read", value: "test.read" },
|
|
1020
1064
|
{ label: "Test: Edit", value: "test.edit" },
|
|
1021
1065
|
{ label: "Test: Delete", value: "test.delete" },
|
package/dist/export/worker.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { L as LabeledScope$1, t as tables, C as CreateRoleInput, a as CreateRoleOutput, A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, V as VerifyAccessInput, r as VerifyAccessOutput, D as DeleteRoleInput, s as DeleteRoleOutput, U as UpdateRoleInput, u as UpdateRoleOutput } from '../shared/rbac.
|
|
3
|
+
import { L as LabeledScope$1, t as tables, C as CreateRoleInput, a as CreateRoleOutput, A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, V as VerifyAccessInput, r as VerifyAccessOutput, D as DeleteRoleInput, s as DeleteRoleOutput, U as UpdateRoleInput, u as UpdateRoleOutput } from '../shared/rbac.DBpIRbd3.cjs';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import 'zod';
|
|
@@ -8,6 +8,16 @@ import 'drizzle-orm';
|
|
|
8
8
|
import '../shared/rbac.CqpxM3E5.cjs';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
|
+
type TypedScopeObject<TScopes extends readonly LabeledScope$1[]> = {
|
|
12
|
+
scope: TScopes[number]['value'];
|
|
13
|
+
resourceId?: string;
|
|
14
|
+
resourcePath?: string;
|
|
15
|
+
};
|
|
16
|
+
type TypedScopeCondition<TScopes extends readonly LabeledScope$1[]> = TypedScopeObject<TScopes> | {
|
|
17
|
+
or: TypedScopeCondition<TScopes>[];
|
|
18
|
+
} | {
|
|
19
|
+
and: TypedScopeCondition<TScopes>[];
|
|
20
|
+
} | TypedScopeCondition<TScopes>[];
|
|
11
21
|
declare const RbacServiceBase_base: (abstract new (ctx: ExecutionContext, env: RbacEnv) => WorkerEntrypoint<RbacEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
12
22
|
declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = LabeledScope$1[]> extends RbacServiceBase_base {
|
|
13
23
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -26,12 +36,9 @@ declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = Labele
|
|
|
26
36
|
getPermissions(): Promise<IRPCResponse<GetPermissionsOutput>>;
|
|
27
37
|
getUserPermissions(input: GetUserPermissionsInput): Promise<IRPCResponse<GetUserPermissionsOutput>>;
|
|
28
38
|
verifyAccess(input: Omit<VerifyAccessInput, 'accessRequests'> & {
|
|
29
|
-
accessRequests:
|
|
30
|
-
scope: TScopes[number]['value'];
|
|
31
|
-
resourceId?: string;
|
|
32
|
-
resourcePath?: string;
|
|
33
|
-
}>>;
|
|
39
|
+
accessRequests: TypedScopeCondition<TScopes>;
|
|
34
40
|
}): Promise<IRPCResponse<VerifyAccessOutput>>;
|
|
41
|
+
private verifySingleScope;
|
|
35
42
|
deleteRole(input: DeleteRoleInput): Promise<IRPCResponse<DeleteRoleOutput>>;
|
|
36
43
|
updateRole(input: UpdateRoleInput): Promise<IRPCResponse<UpdateRoleOutput>>;
|
|
37
44
|
}
|
|
@@ -39,7 +46,7 @@ declare function defineRbacService<const TScopes extends readonly LabeledScope$1
|
|
|
39
46
|
scopes: TScopes;
|
|
40
47
|
}): new (ctx: ExecutionContext, env: RbacEnv) => RbacServiceBase<TScopes>;
|
|
41
48
|
|
|
42
|
-
declare const SCOPES: readonly ["tickets.read", "tickets.create", "tickets.edit", "tickets.delete", "tickets.archive", "tickets.automations.pause", "tickets.automations.resume", "tickets.dependencies.read", "tickets.dependencies.create", "tickets.dependencies.edit", "tickets.dependencies.delete", "tickets.confirmation.send", "tickets.confirmation.download", "tickets.payments.create", "tickets.payments.read", "tickets.payments.edit", "tickets.payments.delete", "tickets.payments.confirmation.send", "tickets.payments.confirmation.download", "tickets.logs.read", "tickets.logs.create", "tickets.logs.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.archive", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.pause", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.resume", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "clients.read", "clients.create", "clients.edit", "clients.delete", "clients.pin.read", "clients.pin.edit", "clients.trader.edit", "clients.logs.read", "clients.logs.create", "clients.logs.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.read", "clients.{jwt.user.rawUserMetaData.organizationId}.create", "clients.{jwt.user.rawUserMetaData.organizationId}.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.read", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.trader.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.read", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.create", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "users.read", "users.create", "users.edit", "users.delete", "users.ban", "users.password.reset.send", "users.password.edit", "users.2fa.enable", "users.2fa.disable", "users.roles.read", "users.roles.edit", "users.scopes.read", "users.scopes.assign", "users.scopes.delete", "users.logs.read", "users.logs.create", "users.logs.delete", "users.{jwt.user.rawUserMetaData.organizationId}.read", "users.{jwt.user.rawUserMetaData.organizationId}.create", "users.{jwt.user.rawUserMetaData.organizationId}.edit", "users.{jwt.user.rawUserMetaData.organizationId}.delete", "users.{jwt.user.rawUserMetaData.organizationId}.ban", "users.{jwt.user.rawUserMetaData.organizationId}.password.reset.send", "users.{jwt.user.rawUserMetaData.organizationId}.password.edit", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.enable", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.disable", "users.{jwt.user.rawUserMetaData.organizationId}.roles.read", "users.{jwt.user.rawUserMetaData.organizationId}.roles.edit", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.read", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.assign", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.delete", "users.{jwt.user.rawUserMetaData.organizationId}.logs.read", "users.{jwt.user.rawUserMetaData.organizationId}.logs.create", "users.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "traders.read", "traders.create", "traders.edit", "traders.delete", "traders.logs", "roles.read", "roles.create", "roles.edit", "roles.delete", "roles.scopes.assign", "roles.scopes.delete", "roles.logs.read", "roles.logs.create", "roles.logs.delete", "roles.users.read", "test.read", "test.edit", "test.delete", "test.{jwt.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.edit", "test.{param.resourceId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.resource.{jwt.user.rawUserMetaData.organizationId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.branch.{jwt.userData.organizationBranchId}.read", "test.{invalid}.scope", "test.{}.scope", "test.{jwt.}.scope", "test.{.key}.scope"];
|
|
49
|
+
declare const SCOPES: readonly ["tickets.read", "tickets.create", "tickets.edit", "tickets.delete", "tickets.archive", "tickets.automations.pause", "tickets.automations.resume", "tickets.dependencies.read", "tickets.dependencies.create", "tickets.dependencies.edit", "tickets.dependencies.delete", "tickets.confirmation.send", "tickets.confirmation.download", "tickets.payments.create", "tickets.payments.read", "tickets.payments.edit", "tickets.payments.delete", "tickets.payments.confirmation.send", "tickets.payments.confirmation.download", "tickets.logs.read", "tickets.logs.create", "tickets.logs.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.archive", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.pause", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.resume", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "clients.read", "clients.create", "clients.edit", "clients.delete", "clients.pin.read", "clients.pin.edit", "clients.trader.edit", "clients.logs.read", "clients.logs.create", "clients.logs.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.read", "clients.{jwt.user.rawUserMetaData.organizationId}.create", "clients.{jwt.user.rawUserMetaData.organizationId}.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.read", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.trader.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.read", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.create", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "users.read", "users.create", "users.edit", "users.delete", "users.ban", "users.password.reset.send", "users.password.edit", "users.2fa.enable", "users.2fa.disable", "users.roles.read", "users.roles.edit", "users.scopes.read", "users.scopes.assign", "users.scopes.delete", "users.logs.read", "users.logs.create", "users.logs.delete", "users.{jwt.user.rawUserMetaData.organizationId}.read", "users.{jwt.user.rawUserMetaData.organizationId}.create", "users.{jwt.user.rawUserMetaData.organizationId}.edit", "users.{jwt.user.rawUserMetaData.organizationId}.delete", "users.{jwt.user.rawUserMetaData.organizationId}.ban", "users.{jwt.user.rawUserMetaData.organizationId}.password.reset.send", "users.{jwt.user.rawUserMetaData.organizationId}.password.edit", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.enable", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.disable", "users.{jwt.user.rawUserMetaData.organizationId}.roles.read", "users.{jwt.user.rawUserMetaData.organizationId}.roles.edit", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.read", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.assign", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.delete", "users.{jwt.user.rawUserMetaData.organizationId}.logs.read", "users.{jwt.user.rawUserMetaData.organizationId}.logs.create", "users.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "traders.read", "traders.create", "traders.edit", "traders.delete", "traders.logs", "roles.read", "roles.create", "roles.edit", "roles.delete", "roles.scopes.assign", "roles.scopes.delete", "roles.logs.read", "roles.logs.create", "roles.logs.delete", "roles.users.read", "test.admin", "test.read", "test.edit", "test.delete", "test.{jwt.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.edit", "test.{param.resourceId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.resource.{jwt.user.rawUserMetaData.organizationId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.branch.{jwt.userData.organizationBranchId}.read", "test.{invalid}.scope", "test.{}.scope", "test.{jwt.}.scope", "test.{.key}.scope"];
|
|
43
50
|
type LabeledScope = {
|
|
44
51
|
label: string;
|
|
45
52
|
value: (typeof SCOPES)[number];
|
package/dist/export/worker.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { L as LabeledScope$1, t as tables, C as CreateRoleInput, a as CreateRoleOutput, A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, V as VerifyAccessInput, r as VerifyAccessOutput, D as DeleteRoleInput, s as DeleteRoleOutput, U as UpdateRoleInput, u as UpdateRoleOutput } from '../shared/rbac.
|
|
3
|
+
import { L as LabeledScope$1, t as tables, C as CreateRoleInput, a as CreateRoleOutput, A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, V as VerifyAccessInput, r as VerifyAccessOutput, D as DeleteRoleInput, s as DeleteRoleOutput, U as UpdateRoleInput, u as UpdateRoleOutput } from '../shared/rbac.CG3CtEwh.mjs';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import 'zod';
|
|
@@ -8,6 +8,16 @@ import 'drizzle-orm';
|
|
|
8
8
|
import '../shared/rbac.CqpxM3E5.mjs';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
|
+
type TypedScopeObject<TScopes extends readonly LabeledScope$1[]> = {
|
|
12
|
+
scope: TScopes[number]['value'];
|
|
13
|
+
resourceId?: string;
|
|
14
|
+
resourcePath?: string;
|
|
15
|
+
};
|
|
16
|
+
type TypedScopeCondition<TScopes extends readonly LabeledScope$1[]> = TypedScopeObject<TScopes> | {
|
|
17
|
+
or: TypedScopeCondition<TScopes>[];
|
|
18
|
+
} | {
|
|
19
|
+
and: TypedScopeCondition<TScopes>[];
|
|
20
|
+
} | TypedScopeCondition<TScopes>[];
|
|
11
21
|
declare const RbacServiceBase_base: (abstract new (ctx: ExecutionContext, env: RbacEnv) => WorkerEntrypoint<RbacEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
12
22
|
declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = LabeledScope$1[]> extends RbacServiceBase_base {
|
|
13
23
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -26,12 +36,9 @@ declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = Labele
|
|
|
26
36
|
getPermissions(): Promise<IRPCResponse<GetPermissionsOutput>>;
|
|
27
37
|
getUserPermissions(input: GetUserPermissionsInput): Promise<IRPCResponse<GetUserPermissionsOutput>>;
|
|
28
38
|
verifyAccess(input: Omit<VerifyAccessInput, 'accessRequests'> & {
|
|
29
|
-
accessRequests:
|
|
30
|
-
scope: TScopes[number]['value'];
|
|
31
|
-
resourceId?: string;
|
|
32
|
-
resourcePath?: string;
|
|
33
|
-
}>>;
|
|
39
|
+
accessRequests: TypedScopeCondition<TScopes>;
|
|
34
40
|
}): Promise<IRPCResponse<VerifyAccessOutput>>;
|
|
41
|
+
private verifySingleScope;
|
|
35
42
|
deleteRole(input: DeleteRoleInput): Promise<IRPCResponse<DeleteRoleOutput>>;
|
|
36
43
|
updateRole(input: UpdateRoleInput): Promise<IRPCResponse<UpdateRoleOutput>>;
|
|
37
44
|
}
|
|
@@ -39,7 +46,7 @@ declare function defineRbacService<const TScopes extends readonly LabeledScope$1
|
|
|
39
46
|
scopes: TScopes;
|
|
40
47
|
}): new (ctx: ExecutionContext, env: RbacEnv) => RbacServiceBase<TScopes>;
|
|
41
48
|
|
|
42
|
-
declare const SCOPES: readonly ["tickets.read", "tickets.create", "tickets.edit", "tickets.delete", "tickets.archive", "tickets.automations.pause", "tickets.automations.resume", "tickets.dependencies.read", "tickets.dependencies.create", "tickets.dependencies.edit", "tickets.dependencies.delete", "tickets.confirmation.send", "tickets.confirmation.download", "tickets.payments.create", "tickets.payments.read", "tickets.payments.edit", "tickets.payments.delete", "tickets.payments.confirmation.send", "tickets.payments.confirmation.download", "tickets.logs.read", "tickets.logs.create", "tickets.logs.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.archive", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.pause", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.resume", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "clients.read", "clients.create", "clients.edit", "clients.delete", "clients.pin.read", "clients.pin.edit", "clients.trader.edit", "clients.logs.read", "clients.logs.create", "clients.logs.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.read", "clients.{jwt.user.rawUserMetaData.organizationId}.create", "clients.{jwt.user.rawUserMetaData.organizationId}.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.read", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.trader.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.read", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.create", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "users.read", "users.create", "users.edit", "users.delete", "users.ban", "users.password.reset.send", "users.password.edit", "users.2fa.enable", "users.2fa.disable", "users.roles.read", "users.roles.edit", "users.scopes.read", "users.scopes.assign", "users.scopes.delete", "users.logs.read", "users.logs.create", "users.logs.delete", "users.{jwt.user.rawUserMetaData.organizationId}.read", "users.{jwt.user.rawUserMetaData.organizationId}.create", "users.{jwt.user.rawUserMetaData.organizationId}.edit", "users.{jwt.user.rawUserMetaData.organizationId}.delete", "users.{jwt.user.rawUserMetaData.organizationId}.ban", "users.{jwt.user.rawUserMetaData.organizationId}.password.reset.send", "users.{jwt.user.rawUserMetaData.organizationId}.password.edit", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.enable", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.disable", "users.{jwt.user.rawUserMetaData.organizationId}.roles.read", "users.{jwt.user.rawUserMetaData.organizationId}.roles.edit", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.read", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.assign", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.delete", "users.{jwt.user.rawUserMetaData.organizationId}.logs.read", "users.{jwt.user.rawUserMetaData.organizationId}.logs.create", "users.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "traders.read", "traders.create", "traders.edit", "traders.delete", "traders.logs", "roles.read", "roles.create", "roles.edit", "roles.delete", "roles.scopes.assign", "roles.scopes.delete", "roles.logs.read", "roles.logs.create", "roles.logs.delete", "roles.users.read", "test.read", "test.edit", "test.delete", "test.{jwt.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.edit", "test.{param.resourceId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.resource.{jwt.user.rawUserMetaData.organizationId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.branch.{jwt.userData.organizationBranchId}.read", "test.{invalid}.scope", "test.{}.scope", "test.{jwt.}.scope", "test.{.key}.scope"];
|
|
49
|
+
declare const SCOPES: readonly ["tickets.read", "tickets.create", "tickets.edit", "tickets.delete", "tickets.archive", "tickets.automations.pause", "tickets.automations.resume", "tickets.dependencies.read", "tickets.dependencies.create", "tickets.dependencies.edit", "tickets.dependencies.delete", "tickets.confirmation.send", "tickets.confirmation.download", "tickets.payments.create", "tickets.payments.read", "tickets.payments.edit", "tickets.payments.delete", "tickets.payments.confirmation.send", "tickets.payments.confirmation.download", "tickets.logs.read", "tickets.logs.create", "tickets.logs.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.archive", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.pause", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.resume", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "clients.read", "clients.create", "clients.edit", "clients.delete", "clients.pin.read", "clients.pin.edit", "clients.trader.edit", "clients.logs.read", "clients.logs.create", "clients.logs.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.read", "clients.{jwt.user.rawUserMetaData.organizationId}.create", "clients.{jwt.user.rawUserMetaData.organizationId}.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.read", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.trader.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.read", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.create", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "users.read", "users.create", "users.edit", "users.delete", "users.ban", "users.password.reset.send", "users.password.edit", "users.2fa.enable", "users.2fa.disable", "users.roles.read", "users.roles.edit", "users.scopes.read", "users.scopes.assign", "users.scopes.delete", "users.logs.read", "users.logs.create", "users.logs.delete", "users.{jwt.user.rawUserMetaData.organizationId}.read", "users.{jwt.user.rawUserMetaData.organizationId}.create", "users.{jwt.user.rawUserMetaData.organizationId}.edit", "users.{jwt.user.rawUserMetaData.organizationId}.delete", "users.{jwt.user.rawUserMetaData.organizationId}.ban", "users.{jwt.user.rawUserMetaData.organizationId}.password.reset.send", "users.{jwt.user.rawUserMetaData.organizationId}.password.edit", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.enable", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.disable", "users.{jwt.user.rawUserMetaData.organizationId}.roles.read", "users.{jwt.user.rawUserMetaData.organizationId}.roles.edit", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.read", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.assign", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.delete", "users.{jwt.user.rawUserMetaData.organizationId}.logs.read", "users.{jwt.user.rawUserMetaData.organizationId}.logs.create", "users.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "traders.read", "traders.create", "traders.edit", "traders.delete", "traders.logs", "roles.read", "roles.create", "roles.edit", "roles.delete", "roles.scopes.assign", "roles.scopes.delete", "roles.logs.read", "roles.logs.create", "roles.logs.delete", "roles.users.read", "test.admin", "test.read", "test.edit", "test.delete", "test.{jwt.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.edit", "test.{param.resourceId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.resource.{jwt.user.rawUserMetaData.organizationId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.branch.{jwt.userData.organizationBranchId}.read", "test.{invalid}.scope", "test.{}.scope", "test.{jwt.}.scope", "test.{.key}.scope"];
|
|
43
50
|
type LabeledScope = {
|
|
44
51
|
label: string;
|
|
45
52
|
value: (typeof SCOPES)[number];
|
package/dist/export/worker.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _develit_io_backend_sdk from '@develit-io/backend-sdk';
|
|
2
2
|
import { IRPCResponse } from '@develit-io/backend-sdk';
|
|
3
|
-
import { L as LabeledScope$1, t as tables, C as CreateRoleInput, a as CreateRoleOutput, A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, V as VerifyAccessInput, r as VerifyAccessOutput, D as DeleteRoleInput, s as DeleteRoleOutput, U as UpdateRoleInput, u as UpdateRoleOutput } from '../shared/rbac.
|
|
3
|
+
import { L as LabeledScope$1, t as tables, C as CreateRoleInput, a as CreateRoleOutput, A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, V as VerifyAccessInput, r as VerifyAccessOutput, D as DeleteRoleInput, s as DeleteRoleOutput, U as UpdateRoleInput, u as UpdateRoleOutput } from '../shared/rbac.BrefTsLW.js';
|
|
4
4
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
5
5
|
import { DrizzleD1Database } from 'drizzle-orm/d1';
|
|
6
6
|
import 'zod';
|
|
@@ -8,6 +8,16 @@ import 'drizzle-orm';
|
|
|
8
8
|
import '../shared/rbac.CqpxM3E5.js';
|
|
9
9
|
import 'drizzle-orm/sqlite-core';
|
|
10
10
|
|
|
11
|
+
type TypedScopeObject<TScopes extends readonly LabeledScope$1[]> = {
|
|
12
|
+
scope: TScopes[number]['value'];
|
|
13
|
+
resourceId?: string;
|
|
14
|
+
resourcePath?: string;
|
|
15
|
+
};
|
|
16
|
+
type TypedScopeCondition<TScopes extends readonly LabeledScope$1[]> = TypedScopeObject<TScopes> | {
|
|
17
|
+
or: TypedScopeCondition<TScopes>[];
|
|
18
|
+
} | {
|
|
19
|
+
and: TypedScopeCondition<TScopes>[];
|
|
20
|
+
} | TypedScopeCondition<TScopes>[];
|
|
11
21
|
declare const RbacServiceBase_base: (abstract new (ctx: ExecutionContext, env: RbacEnv) => WorkerEntrypoint<RbacEnv, {}>) & (abstract new (...args: any[]) => _develit_io_backend_sdk.DevelitWorkerMethods);
|
|
12
22
|
declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = LabeledScope$1[]> extends RbacServiceBase_base {
|
|
13
23
|
readonly db: DrizzleD1Database<typeof tables>;
|
|
@@ -26,12 +36,9 @@ declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = Labele
|
|
|
26
36
|
getPermissions(): Promise<IRPCResponse<GetPermissionsOutput>>;
|
|
27
37
|
getUserPermissions(input: GetUserPermissionsInput): Promise<IRPCResponse<GetUserPermissionsOutput>>;
|
|
28
38
|
verifyAccess(input: Omit<VerifyAccessInput, 'accessRequests'> & {
|
|
29
|
-
accessRequests:
|
|
30
|
-
scope: TScopes[number]['value'];
|
|
31
|
-
resourceId?: string;
|
|
32
|
-
resourcePath?: string;
|
|
33
|
-
}>>;
|
|
39
|
+
accessRequests: TypedScopeCondition<TScopes>;
|
|
34
40
|
}): Promise<IRPCResponse<VerifyAccessOutput>>;
|
|
41
|
+
private verifySingleScope;
|
|
35
42
|
deleteRole(input: DeleteRoleInput): Promise<IRPCResponse<DeleteRoleOutput>>;
|
|
36
43
|
updateRole(input: UpdateRoleInput): Promise<IRPCResponse<UpdateRoleOutput>>;
|
|
37
44
|
}
|
|
@@ -39,7 +46,7 @@ declare function defineRbacService<const TScopes extends readonly LabeledScope$1
|
|
|
39
46
|
scopes: TScopes;
|
|
40
47
|
}): new (ctx: ExecutionContext, env: RbacEnv) => RbacServiceBase<TScopes>;
|
|
41
48
|
|
|
42
|
-
declare const SCOPES: readonly ["tickets.read", "tickets.create", "tickets.edit", "tickets.delete", "tickets.archive", "tickets.automations.pause", "tickets.automations.resume", "tickets.dependencies.read", "tickets.dependencies.create", "tickets.dependencies.edit", "tickets.dependencies.delete", "tickets.confirmation.send", "tickets.confirmation.download", "tickets.payments.create", "tickets.payments.read", "tickets.payments.edit", "tickets.payments.delete", "tickets.payments.confirmation.send", "tickets.payments.confirmation.download", "tickets.logs.read", "tickets.logs.create", "tickets.logs.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.archive", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.pause", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.resume", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "clients.read", "clients.create", "clients.edit", "clients.delete", "clients.pin.read", "clients.pin.edit", "clients.trader.edit", "clients.logs.read", "clients.logs.create", "clients.logs.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.read", "clients.{jwt.user.rawUserMetaData.organizationId}.create", "clients.{jwt.user.rawUserMetaData.organizationId}.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.read", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.trader.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.read", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.create", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "users.read", "users.create", "users.edit", "users.delete", "users.ban", "users.password.reset.send", "users.password.edit", "users.2fa.enable", "users.2fa.disable", "users.roles.read", "users.roles.edit", "users.scopes.read", "users.scopes.assign", "users.scopes.delete", "users.logs.read", "users.logs.create", "users.logs.delete", "users.{jwt.user.rawUserMetaData.organizationId}.read", "users.{jwt.user.rawUserMetaData.organizationId}.create", "users.{jwt.user.rawUserMetaData.organizationId}.edit", "users.{jwt.user.rawUserMetaData.organizationId}.delete", "users.{jwt.user.rawUserMetaData.organizationId}.ban", "users.{jwt.user.rawUserMetaData.organizationId}.password.reset.send", "users.{jwt.user.rawUserMetaData.organizationId}.password.edit", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.enable", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.disable", "users.{jwt.user.rawUserMetaData.organizationId}.roles.read", "users.{jwt.user.rawUserMetaData.organizationId}.roles.edit", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.read", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.assign", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.delete", "users.{jwt.user.rawUserMetaData.organizationId}.logs.read", "users.{jwt.user.rawUserMetaData.organizationId}.logs.create", "users.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "traders.read", "traders.create", "traders.edit", "traders.delete", "traders.logs", "roles.read", "roles.create", "roles.edit", "roles.delete", "roles.scopes.assign", "roles.scopes.delete", "roles.logs.read", "roles.logs.create", "roles.logs.delete", "roles.users.read", "test.read", "test.edit", "test.delete", "test.{jwt.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.edit", "test.{param.resourceId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.resource.{jwt.user.rawUserMetaData.organizationId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.branch.{jwt.userData.organizationBranchId}.read", "test.{invalid}.scope", "test.{}.scope", "test.{jwt.}.scope", "test.{.key}.scope"];
|
|
49
|
+
declare const SCOPES: readonly ["tickets.read", "tickets.create", "tickets.edit", "tickets.delete", "tickets.archive", "tickets.automations.pause", "tickets.automations.resume", "tickets.dependencies.read", "tickets.dependencies.create", "tickets.dependencies.edit", "tickets.dependencies.delete", "tickets.confirmation.send", "tickets.confirmation.download", "tickets.payments.create", "tickets.payments.read", "tickets.payments.edit", "tickets.payments.delete", "tickets.payments.confirmation.send", "tickets.payments.confirmation.download", "tickets.logs.read", "tickets.logs.create", "tickets.logs.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.archive", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.pause", "tickets.{jwt.user.rawUserMetaData.organizationId}.automations.resume", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.dependencies.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.edit", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.delete", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.send", "tickets.{jwt.user.rawUserMetaData.organizationId}.payments.confirmation.download", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.read", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.create", "tickets.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "clients.read", "clients.create", "clients.edit", "clients.delete", "clients.pin.read", "clients.pin.edit", "clients.trader.edit", "clients.logs.read", "clients.logs.create", "clients.logs.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.read", "clients.{jwt.user.rawUserMetaData.organizationId}.create", "clients.{jwt.user.rawUserMetaData.organizationId}.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.delete", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.read", "clients.{jwt.user.rawUserMetaData.organizationId}.pin.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.trader.edit", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.read", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.create", "clients.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "users.read", "users.create", "users.edit", "users.delete", "users.ban", "users.password.reset.send", "users.password.edit", "users.2fa.enable", "users.2fa.disable", "users.roles.read", "users.roles.edit", "users.scopes.read", "users.scopes.assign", "users.scopes.delete", "users.logs.read", "users.logs.create", "users.logs.delete", "users.{jwt.user.rawUserMetaData.organizationId}.read", "users.{jwt.user.rawUserMetaData.organizationId}.create", "users.{jwt.user.rawUserMetaData.organizationId}.edit", "users.{jwt.user.rawUserMetaData.organizationId}.delete", "users.{jwt.user.rawUserMetaData.organizationId}.ban", "users.{jwt.user.rawUserMetaData.organizationId}.password.reset.send", "users.{jwt.user.rawUserMetaData.organizationId}.password.edit", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.enable", "users.{jwt.user.rawUserMetaData.organizationId}.2fa.disable", "users.{jwt.user.rawUserMetaData.organizationId}.roles.read", "users.{jwt.user.rawUserMetaData.organizationId}.roles.edit", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.read", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.assign", "users.{jwt.user.rawUserMetaData.organizationId}.scopes.delete", "users.{jwt.user.rawUserMetaData.organizationId}.logs.read", "users.{jwt.user.rawUserMetaData.organizationId}.logs.create", "users.{jwt.user.rawUserMetaData.organizationId}.logs.delete", "traders.read", "traders.create", "traders.edit", "traders.delete", "traders.logs", "roles.read", "roles.create", "roles.edit", "roles.delete", "roles.scopes.assign", "roles.scopes.delete", "roles.logs.read", "roles.logs.create", "roles.logs.delete", "roles.users.read", "test.admin", "test.read", "test.edit", "test.delete", "test.{jwt.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.read", "test.{jwt.user.rawUserMetaData.organizationId}.edit", "test.{param.resourceId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.resource.{jwt.user.rawUserMetaData.organizationId}.read", "test.organization.{jwt.user.rawUserMetaData.organizationId}.branch.{jwt.userData.organizationBranchId}.read", "test.{invalid}.scope", "test.{}.scope", "test.{jwt.}.scope", "test.{.key}.scope"];
|
|
43
50
|
type LabeledScope = {
|
|
44
51
|
label: string;
|
|
45
52
|
value: (typeof SCOPES)[number];
|
package/dist/export/worker.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { uuidv4, first, createInternalError, develitWorker, action, service } from '@develit-io/backend-sdk';
|
|
2
2
|
import { s as schema } from '../shared/rbac.D5OV7UPA.mjs';
|
|
3
3
|
import { eq, and, count, inArray } from 'drizzle-orm';
|
|
4
|
-
import { c as createRoleInputSchema, a as assignRoleToUserInputSchema, b as assignRolesToUserInputSchema, r as revokeRoleFromUserInputSchema, f as grantScopeToUserInputSchema, h as grantScopesToUserInputSchema, j as revokeScopeFromUserInputSchema, e as grantScopeToRoleInputSchema, i as revokeScopeFromRoleInputSchema, g as getUserPermissionsInputSchema, v as verifyAccessInputSchema, d as deleteRoleInputSchema, u as updateRoleInputSchema } from '../shared/rbac.
|
|
4
|
+
import { c as createRoleInputSchema, a as assignRoleToUserInputSchema, b as assignRolesToUserInputSchema, r as revokeRoleFromUserInputSchema, f as grantScopeToUserInputSchema, h as grantScopesToUserInputSchema, j as revokeScopeFromUserInputSchema, e as grantScopeToRoleInputSchema, i as revokeScopeFromRoleInputSchema, g as getUserPermissionsInputSchema, v as verifyAccessInputSchema, d as deleteRoleInputSchema, u as updateRoleInputSchema, l as isScopeObject, m as isOrCondition, n as isAndCondition, o as isImplicitAndCondition } from '../shared/rbac.2_i8g_mW.mjs';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
7
7
|
import { drizzle } from 'drizzle-orm/d1';
|
|
@@ -476,8 +476,15 @@ let RbacServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
476
476
|
{ successMessage: "Scope successfully granted to user." },
|
|
477
477
|
async ({ userId, scope, resourceId }) => {
|
|
478
478
|
this.validateScope(scope);
|
|
479
|
-
const
|
|
480
|
-
|
|
479
|
+
const userScopes = await getScopesByUserQuery({ db: this.db, userId });
|
|
480
|
+
const matchingScopes = userScopes.filter((s) => s.scope === scope);
|
|
481
|
+
if (!resourceId && matchingScopes.find((s) => !s.resourceId)) {
|
|
482
|
+
throw createInternalError(null, {
|
|
483
|
+
message: "Scope already assigned to user.",
|
|
484
|
+
status: 409
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
if (resourceId && matchingScopes.some((s) => s.resourceId === resourceId)) {
|
|
481
488
|
throw createInternalError(null, {
|
|
482
489
|
message: "Scope already assigned to user.",
|
|
483
490
|
status: 409
|
|
@@ -502,7 +509,16 @@ let RbacServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
502
509
|
for (const scope of scopes) {
|
|
503
510
|
this.validateScope(scope.scope);
|
|
504
511
|
const userScopes = await getScopesByUserQuery({ db: this.db, userId });
|
|
505
|
-
|
|
512
|
+
const matchingScopes = userScopes.filter(
|
|
513
|
+
(s) => s.scope === scope.scope
|
|
514
|
+
);
|
|
515
|
+
if (!scope.resourceId && matchingScopes.find((s) => !s.resourceId)) {
|
|
516
|
+
throw createInternalError(null, {
|
|
517
|
+
message: "Scope already assigned to user.",
|
|
518
|
+
status: 409
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
if (scope.resourceId && matchingScopes.some((s) => s.resourceId === scope.resourceId)) {
|
|
506
522
|
throw createInternalError(null, {
|
|
507
523
|
message: "Scope already assigned to user.",
|
|
508
524
|
status: 409
|
|
@@ -657,10 +673,24 @@ let RbacServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
657
673
|
{ data: input, schema: verifyAccessInputSchema },
|
|
658
674
|
{ successMessage: "Access verification completed." },
|
|
659
675
|
async ({ userId, accessRequests, jwt }) => {
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
676
|
+
const collectScopes = (condition) => {
|
|
677
|
+
if (isScopeObject(condition)) {
|
|
678
|
+
return [condition];
|
|
679
|
+
}
|
|
680
|
+
if (isOrCondition(condition)) {
|
|
681
|
+
return condition.or.flatMap(collectScopes);
|
|
682
|
+
}
|
|
683
|
+
if (isAndCondition(condition)) {
|
|
684
|
+
return condition.and.flatMap(collectScopes);
|
|
663
685
|
}
|
|
686
|
+
if (isImplicitAndCondition(condition)) {
|
|
687
|
+
return condition.flatMap(collectScopes);
|
|
688
|
+
}
|
|
689
|
+
return [];
|
|
690
|
+
};
|
|
691
|
+
const allScopeObjects = collectScopes(accessRequests);
|
|
692
|
+
for (const scopeObj of allScopeObjects) {
|
|
693
|
+
this.validateScope(scopeObj.scope);
|
|
664
694
|
}
|
|
665
695
|
const userPermissionsResponse = await this.getUserPermissions({
|
|
666
696
|
userId
|
|
@@ -675,59 +705,71 @@ let RbacServiceBase = class extends develitWorker(WorkerEntrypoint) {
|
|
|
675
705
|
...userPermissionsResponse.data.roleScopes,
|
|
676
706
|
...userPermissionsResponse.data.scopes
|
|
677
707
|
];
|
|
678
|
-
if (
|
|
708
|
+
if (allScopeObjects.length === 0) {
|
|
679
709
|
return {
|
|
680
710
|
isVerified: true
|
|
681
711
|
};
|
|
682
712
|
}
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
request.resourcePath
|
|
700
|
-
);
|
|
701
|
-
const allPlaceholdersMatch = placeholders.every(
|
|
702
|
-
(placeholder) => {
|
|
703
|
-
const extractedValue = extractedResources[`${placeholder.type}.${placeholder.path}`];
|
|
704
|
-
const jwtParam = placeholder.type === "jwt" ? jwt : void 0;
|
|
705
|
-
const expectedValue = getValueByKey(
|
|
706
|
-
placeholder.type,
|
|
707
|
-
placeholder.path,
|
|
708
|
-
jwtParam
|
|
709
|
-
);
|
|
710
|
-
if (expectedValue === void 0) {
|
|
711
|
-
return false;
|
|
712
|
-
}
|
|
713
|
-
return String(extractedValue) === String(expectedValue);
|
|
714
|
-
}
|
|
715
|
-
);
|
|
716
|
-
const resourceIdMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
717
|
-
resourceMatches = allPlaceholdersMatch && resourceIdMatches;
|
|
718
|
-
} else {
|
|
719
|
-
resourceMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
720
|
-
}
|
|
721
|
-
return scopesMatch && resourceMatches;
|
|
722
|
-
});
|
|
723
|
-
});
|
|
724
|
-
});
|
|
713
|
+
const evaluateCondition = (condition) => {
|
|
714
|
+
if (isScopeObject(condition)) {
|
|
715
|
+
return this.verifySingleScope(condition, allScopes, jwt);
|
|
716
|
+
}
|
|
717
|
+
if (isOrCondition(condition)) {
|
|
718
|
+
return condition.or.some(evaluateCondition);
|
|
719
|
+
}
|
|
720
|
+
if (isAndCondition(condition)) {
|
|
721
|
+
return condition.and.every(evaluateCondition);
|
|
722
|
+
}
|
|
723
|
+
if (isImplicitAndCondition(condition)) {
|
|
724
|
+
return condition.every(evaluateCondition);
|
|
725
|
+
}
|
|
726
|
+
return false;
|
|
727
|
+
};
|
|
728
|
+
const isVerified = evaluateCondition(accessRequests);
|
|
725
729
|
return {
|
|
726
|
-
isVerified
|
|
730
|
+
isVerified
|
|
727
731
|
};
|
|
728
732
|
}
|
|
729
733
|
);
|
|
730
734
|
}
|
|
735
|
+
verifySingleScope(request, allScopes, jwt) {
|
|
736
|
+
const placeholders = parseScopeTemplate(request.scope);
|
|
737
|
+
return allScopes.some((userScope) => {
|
|
738
|
+
const scopesMatch = userScope.scope === request.scope;
|
|
739
|
+
let resourceMatches = false;
|
|
740
|
+
if (placeholders.length > 0) {
|
|
741
|
+
if (!request.resourcePath) {
|
|
742
|
+
throw createInternalError(null, {
|
|
743
|
+
message: `Resource path is required when scope '${request.scope}' contains placeholders`,
|
|
744
|
+
status: 400,
|
|
745
|
+
code: "RESOURCE_PATH_REQUIRED"
|
|
746
|
+
});
|
|
747
|
+
}
|
|
748
|
+
const extractedResources = extractResourcesFromPath(
|
|
749
|
+
request.scope,
|
|
750
|
+
request.resourcePath
|
|
751
|
+
);
|
|
752
|
+
const allPlaceholdersMatch = placeholders.every((placeholder) => {
|
|
753
|
+
const extractedValue = extractedResources[`${placeholder.type}.${placeholder.path}`];
|
|
754
|
+
const jwtParam = placeholder.type === "jwt" ? jwt : void 0;
|
|
755
|
+
const expectedValue = getValueByKey(
|
|
756
|
+
placeholder.type,
|
|
757
|
+
placeholder.path,
|
|
758
|
+
jwtParam
|
|
759
|
+
);
|
|
760
|
+
if (expectedValue === void 0) {
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
return String(extractedValue) === String(expectedValue);
|
|
764
|
+
});
|
|
765
|
+
const resourceIdMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
766
|
+
resourceMatches = allPlaceholdersMatch && resourceIdMatches;
|
|
767
|
+
} else {
|
|
768
|
+
resourceMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
|
|
769
|
+
}
|
|
770
|
+
return scopesMatch && resourceMatches;
|
|
771
|
+
});
|
|
772
|
+
}
|
|
731
773
|
async deleteRole(input) {
|
|
732
774
|
return this.handleAction(
|
|
733
775
|
{ data: input, schema: deleteRoleInputSchema },
|
|
@@ -812,6 +854,7 @@ const organizationScopedKeys = (scopes) => {
|
|
|
812
854
|
return out;
|
|
813
855
|
};
|
|
814
856
|
const TEST_SCOPES = [
|
|
857
|
+
"test.admin",
|
|
815
858
|
"test.read",
|
|
816
859
|
"test.edit",
|
|
817
860
|
"test.delete",
|
|
@@ -1012,6 +1055,7 @@ const LABELED_SCOPES = [
|
|
|
1012
1055
|
{ label: "Smazat logy rol\xED", value: "roles.logs.delete" },
|
|
1013
1056
|
{ label: "Zobrazit u\u017Eivatele p\u0159i\u0159azen\xE9 k rol\xEDm", value: "roles.users.read" },
|
|
1014
1057
|
// Test scopes
|
|
1058
|
+
{ label: "Test: Admin", value: "test.admin" },
|
|
1015
1059
|
{ label: "Test: Read", value: "test.read" },
|
|
1016
1060
|
{ label: "Test: Edit", value: "test.edit" },
|
|
1017
1061
|
{ label: "Test: Delete", value: "test.delete" },
|
package/dist/export/wrangler.cjs
CHANGED
|
@@ -10,10 +10,15 @@ function defineRbacServiceWrangler(config) {
|
|
|
10
10
|
name
|
|
11
11
|
}),
|
|
12
12
|
vars: {
|
|
13
|
-
// Variables
|
|
14
13
|
...envs.local.vars,
|
|
15
14
|
ENVIRONMENT: "localhost"
|
|
16
15
|
},
|
|
16
|
+
services: [
|
|
17
|
+
{
|
|
18
|
+
binding: "SECRETS_STORE",
|
|
19
|
+
service: `${project}-secrets-store`
|
|
20
|
+
}
|
|
21
|
+
],
|
|
17
22
|
d1_databases: [
|
|
18
23
|
{
|
|
19
24
|
binding: "RBAC_D1",
|
|
@@ -5,6 +5,10 @@ declare function defineRbacServiceWrangler(config: RbacServiceWranglerConfig): {
|
|
|
5
5
|
ENVIRONMENT: string;
|
|
6
6
|
SERVICE_CONFIG_INCLUDE_CONFIRMATION: boolean;
|
|
7
7
|
};
|
|
8
|
+
services: {
|
|
9
|
+
binding: string;
|
|
10
|
+
service: string;
|
|
11
|
+
}[];
|
|
8
12
|
d1_databases: {
|
|
9
13
|
binding: string;
|
|
10
14
|
database_name: string;
|
|
@@ -5,6 +5,10 @@ declare function defineRbacServiceWrangler(config: RbacServiceWranglerConfig): {
|
|
|
5
5
|
ENVIRONMENT: string;
|
|
6
6
|
SERVICE_CONFIG_INCLUDE_CONFIRMATION: boolean;
|
|
7
7
|
};
|
|
8
|
+
services: {
|
|
9
|
+
binding: string;
|
|
10
|
+
service: string;
|
|
11
|
+
}[];
|
|
8
12
|
d1_databases: {
|
|
9
13
|
binding: string;
|
|
10
14
|
database_name: string;
|
|
@@ -5,6 +5,10 @@ declare function defineRbacServiceWrangler(config: RbacServiceWranglerConfig): {
|
|
|
5
5
|
ENVIRONMENT: string;
|
|
6
6
|
SERVICE_CONFIG_INCLUDE_CONFIRMATION: boolean;
|
|
7
7
|
};
|
|
8
|
+
services: {
|
|
9
|
+
binding: string;
|
|
10
|
+
service: string;
|
|
11
|
+
}[];
|
|
8
12
|
d1_databases: {
|
|
9
13
|
binding: string;
|
|
10
14
|
database_name: string;
|
package/dist/export/wrangler.mjs
CHANGED
|
@@ -8,10 +8,15 @@ function defineRbacServiceWrangler(config) {
|
|
|
8
8
|
name
|
|
9
9
|
}),
|
|
10
10
|
vars: {
|
|
11
|
-
// Variables
|
|
12
11
|
...envs.local.vars,
|
|
13
12
|
ENVIRONMENT: "localhost"
|
|
14
13
|
},
|
|
14
|
+
services: [
|
|
15
|
+
{
|
|
16
|
+
binding: "SECRETS_STORE",
|
|
17
|
+
service: `${project}-secrets-store`
|
|
18
|
+
}
|
|
19
|
+
],
|
|
15
20
|
d1_databases: [
|
|
16
21
|
{
|
|
17
22
|
binding: "RBAC_D1",
|
|
@@ -135,19 +135,36 @@ const coercedUserSchema = jwtUserSchema.extend({
|
|
|
135
135
|
const coercedJwtPayloadSchema = jwtPayloadSchema.extend({
|
|
136
136
|
user: coercedUserSchema
|
|
137
137
|
});
|
|
138
|
+
const scopeObjectSchema = z.object({
|
|
139
|
+
scope: z.string(),
|
|
140
|
+
resourceId: z.string().optional(),
|
|
141
|
+
resourcePath: z.string().optional()
|
|
142
|
+
});
|
|
143
|
+
const scopeConditionSchema = z.lazy(
|
|
144
|
+
() => z.union([
|
|
145
|
+
scopeObjectSchema,
|
|
146
|
+
z.object({ or: z.array(scopeConditionSchema) }),
|
|
147
|
+
z.object({ and: z.array(scopeConditionSchema) }),
|
|
148
|
+
z.array(scopeConditionSchema)
|
|
149
|
+
])
|
|
150
|
+
);
|
|
138
151
|
const verifyAccessInputSchema = z.object({
|
|
139
152
|
userId: z.uuid(),
|
|
140
|
-
accessRequests:
|
|
141
|
-
z.array(
|
|
142
|
-
z.object({
|
|
143
|
-
scope: z.string(),
|
|
144
|
-
resourceId: z.string().optional(),
|
|
145
|
-
resourcePath: z.string().optional()
|
|
146
|
-
})
|
|
147
|
-
)
|
|
148
|
-
),
|
|
153
|
+
accessRequests: scopeConditionSchema,
|
|
149
154
|
jwt: coercedJwtPayloadSchema.optional()
|
|
150
155
|
});
|
|
156
|
+
function isScopeObject(condition) {
|
|
157
|
+
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "scope" in condition && !("or" in condition) && !("and" in condition);
|
|
158
|
+
}
|
|
159
|
+
function isOrCondition(condition) {
|
|
160
|
+
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "or" in condition;
|
|
161
|
+
}
|
|
162
|
+
function isAndCondition(condition) {
|
|
163
|
+
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "and" in condition;
|
|
164
|
+
}
|
|
165
|
+
function isImplicitAndCondition(condition) {
|
|
166
|
+
return Array.isArray(condition);
|
|
167
|
+
}
|
|
151
168
|
|
|
152
169
|
const verifyScopeInputSchema = z.object({
|
|
153
170
|
scopes: z.array(z.string()),
|
|
@@ -163,4 +180,4 @@ const verifyScopeOutputSchema = z.object({
|
|
|
163
180
|
isVerified: z.boolean().default(false)
|
|
164
181
|
});
|
|
165
182
|
|
|
166
|
-
export { assignRoleToUserInputSchema as a, assignRolesToUserInputSchema as b, createRoleInputSchema as c, deleteRoleInputSchema as d, grantScopeToRoleInputSchema as e, grantScopeToUserInputSchema as f, getUserPermissionsInputSchema as g, grantScopesToUserInputSchema as h, revokeScopeFromRoleInputSchema as i, revokeScopeFromUserInputSchema as j,
|
|
183
|
+
export { assignRoleToUserInputSchema as a, assignRolesToUserInputSchema as b, createRoleInputSchema as c, deleteRoleInputSchema as d, grantScopeToRoleInputSchema as e, grantScopeToUserInputSchema as f, getUserPermissionsInputSchema as g, grantScopesToUserInputSchema as h, revokeScopeFromRoleInputSchema as i, revokeScopeFromUserInputSchema as j, scopeConditionSchema as k, isScopeObject as l, isOrCondition as m, isAndCondition as n, isImplicitAndCondition as o, verifyScopeInputSchema as p, verifyScopeOutputSchema as q, revokeRoleFromUserInputSchema as r, scopeObjectSchema as s, updateRoleInputSchema as u, verifyAccessInputSchema as v };
|
|
@@ -188,13 +188,21 @@ interface UpdateRoleInput extends z.infer<typeof updateRoleInputSchema> {
|
|
|
188
188
|
interface UpdateRoleOutput {
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
declare const scopeObjectSchema: z.ZodObject<{
|
|
192
|
+
scope: z.ZodString;
|
|
193
|
+
resourceId: z.ZodOptional<z.ZodString>;
|
|
194
|
+
resourcePath: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
type ScopeObject = z.infer<typeof scopeObjectSchema>;
|
|
197
|
+
type ScopeCondition = ScopeObject | {
|
|
198
|
+
or: ScopeCondition[];
|
|
199
|
+
} | {
|
|
200
|
+
and: ScopeCondition[];
|
|
201
|
+
} | ScopeCondition[];
|
|
202
|
+
declare const scopeConditionSchema: z.ZodType<ScopeCondition>;
|
|
191
203
|
declare const verifyAccessInputSchema: z.ZodObject<{
|
|
192
204
|
userId: z.ZodUUID;
|
|
193
|
-
accessRequests: z.
|
|
194
|
-
scope: z.ZodString;
|
|
195
|
-
resourceId: z.ZodOptional<z.ZodString>;
|
|
196
|
-
resourcePath: z.ZodOptional<z.ZodString>;
|
|
197
|
-
}, z.core.$strip>>>;
|
|
205
|
+
accessRequests: z.ZodType<ScopeCondition, unknown, z.core.$ZodTypeInternals<ScopeCondition, unknown>>;
|
|
198
206
|
jwt: z.ZodOptional<z.ZodObject<{
|
|
199
207
|
sub: z.ZodString;
|
|
200
208
|
iat: z.ZodNumber;
|
|
@@ -233,6 +241,14 @@ interface VerifyAccessInput extends z.infer<typeof verifyAccessInputSchema> {
|
|
|
233
241
|
interface VerifyAccessOutput {
|
|
234
242
|
isVerified: boolean;
|
|
235
243
|
}
|
|
244
|
+
declare function isScopeObject(condition: ScopeCondition): condition is ScopeObject;
|
|
245
|
+
declare function isOrCondition(condition: ScopeCondition): condition is {
|
|
246
|
+
or: ScopeCondition[];
|
|
247
|
+
};
|
|
248
|
+
declare function isAndCondition(condition: ScopeCondition): condition is {
|
|
249
|
+
and: ScopeCondition[];
|
|
250
|
+
};
|
|
251
|
+
declare function isImplicitAndCondition(condition: ScopeCondition): condition is ScopeCondition[];
|
|
236
252
|
|
|
237
|
-
export { assignRoleToUserInputSchema as H, assignRolesToUserInputSchema as I, createRoleInputSchema as J, deleteRoleInputSchema as K, getUserPermissionsInputSchema as M, grantScopeToRoleInputSchema as N, grantScopeToUserInputSchema as O, grantScopesToUserInputSchema as P, revokeRoleFromUserInputSchema as Q, revokeScopeFromRoleInputSchema as T, revokeScopeFromUserInputSchema as W, updateRoleInputSchema as X,
|
|
238
|
-
export type { AssignRoleToUserInput as A, UserRoleInsertType as B, CreateRoleInput as C, DeleteRoleInput as D, UserScopeSelectType as E, UserScopeInsertType as F, GrantScopeToUserInput as G, LabeledScope as L, RevokeRoleFromUserInput as R, Scope as S, UpdateRoleInput as U, VerifyAccessInput as V, CreateRoleOutput as a, AssignRoleToUserOutput as b, AssignRolesToUserInput as c, AssignRolesToUserOutput as d, RevokeRoleFromUserOutput as e, GrantScopeToUserOutput as f, GrantScopesToUserInput as g, GrantScopesToUserOutput as h, RevokeScopeFromUserInput as i, RevokeScopeFromUserOutput as j, GrantScopeToRoleInput as k, GrantScopeToRoleOutput as l, RevokeScopeFromRoleInput as m, RevokeScopeFromRoleOutput as n, GetPermissionsOutput as o, GetUserPermissionsInput as p, GetUserPermissionsOutput as q, VerifyAccessOutput as r, DeleteRoleOutput as s, UpdateRoleOutput as u, RoleScopeSelectType as v, RoleScopeInsertType as w, RoleSelectType as x, RoleInsertType as y, UserRoleSelectType as z };
|
|
253
|
+
export { scopeConditionSchema as $, assignRoleToUserInputSchema as H, assignRolesToUserInputSchema as I, createRoleInputSchema as J, deleteRoleInputSchema as K, getUserPermissionsInputSchema as M, grantScopeToRoleInputSchema as N, grantScopeToUserInputSchema as O, grantScopesToUserInputSchema as P, revokeRoleFromUserInputSchema as Q, revokeScopeFromRoleInputSchema as T, revokeScopeFromUserInputSchema as W, updateRoleInputSchema as X, scopeObjectSchema as Y, verifyAccessInputSchema as a0, isScopeObject as a1, isOrCondition as a2, isAndCondition as a3, isImplicitAndCondition as a4, tables as t };
|
|
254
|
+
export type { AssignRoleToUserInput as A, UserRoleInsertType as B, CreateRoleInput as C, DeleteRoleInput as D, UserScopeSelectType as E, UserScopeInsertType as F, GrantScopeToUserInput as G, LabeledScope as L, RevokeRoleFromUserInput as R, Scope as S, UpdateRoleInput as U, VerifyAccessInput as V, ScopeObject as Z, ScopeCondition as _, CreateRoleOutput as a, AssignRoleToUserOutput as b, AssignRolesToUserInput as c, AssignRolesToUserOutput as d, RevokeRoleFromUserOutput as e, GrantScopeToUserOutput as f, GrantScopesToUserInput as g, GrantScopesToUserOutput as h, RevokeScopeFromUserInput as i, RevokeScopeFromUserOutput as j, GrantScopeToRoleInput as k, GrantScopeToRoleOutput as l, RevokeScopeFromRoleInput as m, RevokeScopeFromRoleOutput as n, GetPermissionsOutput as o, GetUserPermissionsInput as p, GetUserPermissionsOutput as q, VerifyAccessOutput as r, DeleteRoleOutput as s, UpdateRoleOutput as u, RoleScopeSelectType as v, RoleScopeInsertType as w, RoleSelectType as x, RoleInsertType as y, UserRoleSelectType as z };
|
|
@@ -188,13 +188,21 @@ interface UpdateRoleInput extends z.infer<typeof updateRoleInputSchema> {
|
|
|
188
188
|
interface UpdateRoleOutput {
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
declare const scopeObjectSchema: z.ZodObject<{
|
|
192
|
+
scope: z.ZodString;
|
|
193
|
+
resourceId: z.ZodOptional<z.ZodString>;
|
|
194
|
+
resourcePath: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
type ScopeObject = z.infer<typeof scopeObjectSchema>;
|
|
197
|
+
type ScopeCondition = ScopeObject | {
|
|
198
|
+
or: ScopeCondition[];
|
|
199
|
+
} | {
|
|
200
|
+
and: ScopeCondition[];
|
|
201
|
+
} | ScopeCondition[];
|
|
202
|
+
declare const scopeConditionSchema: z.ZodType<ScopeCondition>;
|
|
191
203
|
declare const verifyAccessInputSchema: z.ZodObject<{
|
|
192
204
|
userId: z.ZodUUID;
|
|
193
|
-
accessRequests: z.
|
|
194
|
-
scope: z.ZodString;
|
|
195
|
-
resourceId: z.ZodOptional<z.ZodString>;
|
|
196
|
-
resourcePath: z.ZodOptional<z.ZodString>;
|
|
197
|
-
}, z.core.$strip>>>;
|
|
205
|
+
accessRequests: z.ZodType<ScopeCondition, unknown, z.core.$ZodTypeInternals<ScopeCondition, unknown>>;
|
|
198
206
|
jwt: z.ZodOptional<z.ZodObject<{
|
|
199
207
|
sub: z.ZodString;
|
|
200
208
|
iat: z.ZodNumber;
|
|
@@ -233,6 +241,14 @@ interface VerifyAccessInput extends z.infer<typeof verifyAccessInputSchema> {
|
|
|
233
241
|
interface VerifyAccessOutput {
|
|
234
242
|
isVerified: boolean;
|
|
235
243
|
}
|
|
244
|
+
declare function isScopeObject(condition: ScopeCondition): condition is ScopeObject;
|
|
245
|
+
declare function isOrCondition(condition: ScopeCondition): condition is {
|
|
246
|
+
or: ScopeCondition[];
|
|
247
|
+
};
|
|
248
|
+
declare function isAndCondition(condition: ScopeCondition): condition is {
|
|
249
|
+
and: ScopeCondition[];
|
|
250
|
+
};
|
|
251
|
+
declare function isImplicitAndCondition(condition: ScopeCondition): condition is ScopeCondition[];
|
|
236
252
|
|
|
237
|
-
export { assignRoleToUserInputSchema as H, assignRolesToUserInputSchema as I, createRoleInputSchema as J, deleteRoleInputSchema as K, getUserPermissionsInputSchema as M, grantScopeToRoleInputSchema as N, grantScopeToUserInputSchema as O, grantScopesToUserInputSchema as P, revokeRoleFromUserInputSchema as Q, revokeScopeFromRoleInputSchema as T, revokeScopeFromUserInputSchema as W, updateRoleInputSchema as X,
|
|
238
|
-
export type { AssignRoleToUserInput as A, UserRoleInsertType as B, CreateRoleInput as C, DeleteRoleInput as D, UserScopeSelectType as E, UserScopeInsertType as F, GrantScopeToUserInput as G, LabeledScope as L, RevokeRoleFromUserInput as R, Scope as S, UpdateRoleInput as U, VerifyAccessInput as V, CreateRoleOutput as a, AssignRoleToUserOutput as b, AssignRolesToUserInput as c, AssignRolesToUserOutput as d, RevokeRoleFromUserOutput as e, GrantScopeToUserOutput as f, GrantScopesToUserInput as g, GrantScopesToUserOutput as h, RevokeScopeFromUserInput as i, RevokeScopeFromUserOutput as j, GrantScopeToRoleInput as k, GrantScopeToRoleOutput as l, RevokeScopeFromRoleInput as m, RevokeScopeFromRoleOutput as n, GetPermissionsOutput as o, GetUserPermissionsInput as p, GetUserPermissionsOutput as q, VerifyAccessOutput as r, DeleteRoleOutput as s, UpdateRoleOutput as u, RoleScopeSelectType as v, RoleScopeInsertType as w, RoleSelectType as x, RoleInsertType as y, UserRoleSelectType as z };
|
|
253
|
+
export { scopeConditionSchema as $, assignRoleToUserInputSchema as H, assignRolesToUserInputSchema as I, createRoleInputSchema as J, deleteRoleInputSchema as K, getUserPermissionsInputSchema as M, grantScopeToRoleInputSchema as N, grantScopeToUserInputSchema as O, grantScopesToUserInputSchema as P, revokeRoleFromUserInputSchema as Q, revokeScopeFromRoleInputSchema as T, revokeScopeFromUserInputSchema as W, updateRoleInputSchema as X, scopeObjectSchema as Y, verifyAccessInputSchema as a0, isScopeObject as a1, isOrCondition as a2, isAndCondition as a3, isImplicitAndCondition as a4, tables as t };
|
|
254
|
+
export type { AssignRoleToUserInput as A, UserRoleInsertType as B, CreateRoleInput as C, DeleteRoleInput as D, UserScopeSelectType as E, UserScopeInsertType as F, GrantScopeToUserInput as G, LabeledScope as L, RevokeRoleFromUserInput as R, Scope as S, UpdateRoleInput as U, VerifyAccessInput as V, ScopeObject as Z, ScopeCondition as _, CreateRoleOutput as a, AssignRoleToUserOutput as b, AssignRolesToUserInput as c, AssignRolesToUserOutput as d, RevokeRoleFromUserOutput as e, GrantScopeToUserOutput as f, GrantScopesToUserInput as g, GrantScopesToUserOutput as h, RevokeScopeFromUserInput as i, RevokeScopeFromUserOutput as j, GrantScopeToRoleInput as k, GrantScopeToRoleOutput as l, RevokeScopeFromRoleInput as m, RevokeScopeFromRoleOutput as n, GetPermissionsOutput as o, GetUserPermissionsInput as p, GetUserPermissionsOutput as q, VerifyAccessOutput as r, DeleteRoleOutput as s, UpdateRoleOutput as u, RoleScopeSelectType as v, RoleScopeInsertType as w, RoleSelectType as x, RoleInsertType as y, UserRoleSelectType as z };
|
|
@@ -188,13 +188,21 @@ interface UpdateRoleInput extends z.infer<typeof updateRoleInputSchema> {
|
|
|
188
188
|
interface UpdateRoleOutput {
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
declare const scopeObjectSchema: z.ZodObject<{
|
|
192
|
+
scope: z.ZodString;
|
|
193
|
+
resourceId: z.ZodOptional<z.ZodString>;
|
|
194
|
+
resourcePath: z.ZodOptional<z.ZodString>;
|
|
195
|
+
}, z.core.$strip>;
|
|
196
|
+
type ScopeObject = z.infer<typeof scopeObjectSchema>;
|
|
197
|
+
type ScopeCondition = ScopeObject | {
|
|
198
|
+
or: ScopeCondition[];
|
|
199
|
+
} | {
|
|
200
|
+
and: ScopeCondition[];
|
|
201
|
+
} | ScopeCondition[];
|
|
202
|
+
declare const scopeConditionSchema: z.ZodType<ScopeCondition>;
|
|
191
203
|
declare const verifyAccessInputSchema: z.ZodObject<{
|
|
192
204
|
userId: z.ZodUUID;
|
|
193
|
-
accessRequests: z.
|
|
194
|
-
scope: z.ZodString;
|
|
195
|
-
resourceId: z.ZodOptional<z.ZodString>;
|
|
196
|
-
resourcePath: z.ZodOptional<z.ZodString>;
|
|
197
|
-
}, z.core.$strip>>>;
|
|
205
|
+
accessRequests: z.ZodType<ScopeCondition, unknown, z.core.$ZodTypeInternals<ScopeCondition, unknown>>;
|
|
198
206
|
jwt: z.ZodOptional<z.ZodObject<{
|
|
199
207
|
sub: z.ZodString;
|
|
200
208
|
iat: z.ZodNumber;
|
|
@@ -233,6 +241,14 @@ interface VerifyAccessInput extends z.infer<typeof verifyAccessInputSchema> {
|
|
|
233
241
|
interface VerifyAccessOutput {
|
|
234
242
|
isVerified: boolean;
|
|
235
243
|
}
|
|
244
|
+
declare function isScopeObject(condition: ScopeCondition): condition is ScopeObject;
|
|
245
|
+
declare function isOrCondition(condition: ScopeCondition): condition is {
|
|
246
|
+
or: ScopeCondition[];
|
|
247
|
+
};
|
|
248
|
+
declare function isAndCondition(condition: ScopeCondition): condition is {
|
|
249
|
+
and: ScopeCondition[];
|
|
250
|
+
};
|
|
251
|
+
declare function isImplicitAndCondition(condition: ScopeCondition): condition is ScopeCondition[];
|
|
236
252
|
|
|
237
|
-
export { assignRoleToUserInputSchema as H, assignRolesToUserInputSchema as I, createRoleInputSchema as J, deleteRoleInputSchema as K, getUserPermissionsInputSchema as M, grantScopeToRoleInputSchema as N, grantScopeToUserInputSchema as O, grantScopesToUserInputSchema as P, revokeRoleFromUserInputSchema as Q, revokeScopeFromRoleInputSchema as T, revokeScopeFromUserInputSchema as W, updateRoleInputSchema as X,
|
|
238
|
-
export type { AssignRoleToUserInput as A, UserRoleInsertType as B, CreateRoleInput as C, DeleteRoleInput as D, UserScopeSelectType as E, UserScopeInsertType as F, GrantScopeToUserInput as G, LabeledScope as L, RevokeRoleFromUserInput as R, Scope as S, UpdateRoleInput as U, VerifyAccessInput as V, CreateRoleOutput as a, AssignRoleToUserOutput as b, AssignRolesToUserInput as c, AssignRolesToUserOutput as d, RevokeRoleFromUserOutput as e, GrantScopeToUserOutput as f, GrantScopesToUserInput as g, GrantScopesToUserOutput as h, RevokeScopeFromUserInput as i, RevokeScopeFromUserOutput as j, GrantScopeToRoleInput as k, GrantScopeToRoleOutput as l, RevokeScopeFromRoleInput as m, RevokeScopeFromRoleOutput as n, GetPermissionsOutput as o, GetUserPermissionsInput as p, GetUserPermissionsOutput as q, VerifyAccessOutput as r, DeleteRoleOutput as s, UpdateRoleOutput as u, RoleScopeSelectType as v, RoleScopeInsertType as w, RoleSelectType as x, RoleInsertType as y, UserRoleSelectType as z };
|
|
253
|
+
export { scopeConditionSchema as $, assignRoleToUserInputSchema as H, assignRolesToUserInputSchema as I, createRoleInputSchema as J, deleteRoleInputSchema as K, getUserPermissionsInputSchema as M, grantScopeToRoleInputSchema as N, grantScopeToUserInputSchema as O, grantScopesToUserInputSchema as P, revokeRoleFromUserInputSchema as Q, revokeScopeFromRoleInputSchema as T, revokeScopeFromUserInputSchema as W, updateRoleInputSchema as X, scopeObjectSchema as Y, verifyAccessInputSchema as a0, isScopeObject as a1, isOrCondition as a2, isAndCondition as a3, isImplicitAndCondition as a4, tables as t };
|
|
254
|
+
export type { AssignRoleToUserInput as A, UserRoleInsertType as B, CreateRoleInput as C, DeleteRoleInput as D, UserScopeSelectType as E, UserScopeInsertType as F, GrantScopeToUserInput as G, LabeledScope as L, RevokeRoleFromUserInput as R, Scope as S, UpdateRoleInput as U, VerifyAccessInput as V, ScopeObject as Z, ScopeCondition as _, CreateRoleOutput as a, AssignRoleToUserOutput as b, AssignRolesToUserInput as c, AssignRolesToUserOutput as d, RevokeRoleFromUserOutput as e, GrantScopeToUserOutput as f, GrantScopesToUserInput as g, GrantScopesToUserOutput as h, RevokeScopeFromUserInput as i, RevokeScopeFromUserOutput as j, GrantScopeToRoleInput as k, GrantScopeToRoleOutput as l, RevokeScopeFromRoleInput as m, RevokeScopeFromRoleOutput as n, GetPermissionsOutput as o, GetUserPermissionsInput as p, GetUserPermissionsOutput as q, VerifyAccessOutput as r, DeleteRoleOutput as s, UpdateRoleOutput as u, RoleScopeSelectType as v, RoleScopeInsertType as w, RoleSelectType as x, RoleInsertType as y, UserRoleSelectType as z };
|
|
@@ -137,19 +137,36 @@ const coercedUserSchema = jwtUserSchema.extend({
|
|
|
137
137
|
const coercedJwtPayloadSchema = jwtPayloadSchema.extend({
|
|
138
138
|
user: coercedUserSchema
|
|
139
139
|
});
|
|
140
|
+
const scopeObjectSchema = zod.z.object({
|
|
141
|
+
scope: zod.z.string(),
|
|
142
|
+
resourceId: zod.z.string().optional(),
|
|
143
|
+
resourcePath: zod.z.string().optional()
|
|
144
|
+
});
|
|
145
|
+
const scopeConditionSchema = zod.z.lazy(
|
|
146
|
+
() => zod.z.union([
|
|
147
|
+
scopeObjectSchema,
|
|
148
|
+
zod.z.object({ or: zod.z.array(scopeConditionSchema) }),
|
|
149
|
+
zod.z.object({ and: zod.z.array(scopeConditionSchema) }),
|
|
150
|
+
zod.z.array(scopeConditionSchema)
|
|
151
|
+
])
|
|
152
|
+
);
|
|
140
153
|
const verifyAccessInputSchema = zod.z.object({
|
|
141
154
|
userId: zod.z.uuid(),
|
|
142
|
-
accessRequests:
|
|
143
|
-
zod.z.array(
|
|
144
|
-
zod.z.object({
|
|
145
|
-
scope: zod.z.string(),
|
|
146
|
-
resourceId: zod.z.string().optional(),
|
|
147
|
-
resourcePath: zod.z.string().optional()
|
|
148
|
-
})
|
|
149
|
-
)
|
|
150
|
-
),
|
|
155
|
+
accessRequests: scopeConditionSchema,
|
|
151
156
|
jwt: coercedJwtPayloadSchema.optional()
|
|
152
157
|
});
|
|
158
|
+
function isScopeObject(condition) {
|
|
159
|
+
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "scope" in condition && !("or" in condition) && !("and" in condition);
|
|
160
|
+
}
|
|
161
|
+
function isOrCondition(condition) {
|
|
162
|
+
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "or" in condition;
|
|
163
|
+
}
|
|
164
|
+
function isAndCondition(condition) {
|
|
165
|
+
return typeof condition === "object" && condition !== null && !Array.isArray(condition) && "and" in condition;
|
|
166
|
+
}
|
|
167
|
+
function isImplicitAndCondition(condition) {
|
|
168
|
+
return Array.isArray(condition);
|
|
169
|
+
}
|
|
153
170
|
|
|
154
171
|
const verifyScopeInputSchema = zod.z.object({
|
|
155
172
|
scopes: zod.z.array(zod.z.string()),
|
|
@@ -173,9 +190,15 @@ exports.getUserPermissionsInputSchema = getUserPermissionsInputSchema;
|
|
|
173
190
|
exports.grantScopeToRoleInputSchema = grantScopeToRoleInputSchema;
|
|
174
191
|
exports.grantScopeToUserInputSchema = grantScopeToUserInputSchema;
|
|
175
192
|
exports.grantScopesToUserInputSchema = grantScopesToUserInputSchema;
|
|
193
|
+
exports.isAndCondition = isAndCondition;
|
|
194
|
+
exports.isImplicitAndCondition = isImplicitAndCondition;
|
|
195
|
+
exports.isOrCondition = isOrCondition;
|
|
196
|
+
exports.isScopeObject = isScopeObject;
|
|
176
197
|
exports.revokeRoleFromUserInputSchema = revokeRoleFromUserInputSchema;
|
|
177
198
|
exports.revokeScopeFromRoleInputSchema = revokeScopeFromRoleInputSchema;
|
|
178
199
|
exports.revokeScopeFromUserInputSchema = revokeScopeFromUserInputSchema;
|
|
200
|
+
exports.scopeConditionSchema = scopeConditionSchema;
|
|
201
|
+
exports.scopeObjectSchema = scopeObjectSchema;
|
|
179
202
|
exports.updateRoleInputSchema = updateRoleInputSchema;
|
|
180
203
|
exports.verifyAccessInputSchema = verifyAccessInputSchema;
|
|
181
204
|
exports.verifyScopeInputSchema = verifyScopeInputSchema;
|
package/dist/types.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const verifyScope = require('./shared/rbac.
|
|
3
|
+
const verifyScope = require('./shared/rbac.JCf4hSCf.cjs');
|
|
4
4
|
require('zod');
|
|
5
5
|
|
|
6
6
|
|
|
@@ -13,9 +13,15 @@ exports.getUserPermissionsInputSchema = verifyScope.getUserPermissionsInputSchem
|
|
|
13
13
|
exports.grantScopeToRoleInputSchema = verifyScope.grantScopeToRoleInputSchema;
|
|
14
14
|
exports.grantScopeToUserInputSchema = verifyScope.grantScopeToUserInputSchema;
|
|
15
15
|
exports.grantScopesToUserInputSchema = verifyScope.grantScopesToUserInputSchema;
|
|
16
|
+
exports.isAndCondition = verifyScope.isAndCondition;
|
|
17
|
+
exports.isImplicitAndCondition = verifyScope.isImplicitAndCondition;
|
|
18
|
+
exports.isOrCondition = verifyScope.isOrCondition;
|
|
19
|
+
exports.isScopeObject = verifyScope.isScopeObject;
|
|
16
20
|
exports.revokeRoleFromUserInputSchema = verifyScope.revokeRoleFromUserInputSchema;
|
|
17
21
|
exports.revokeScopeFromRoleInputSchema = verifyScope.revokeScopeFromRoleInputSchema;
|
|
18
22
|
exports.revokeScopeFromUserInputSchema = verifyScope.revokeScopeFromUserInputSchema;
|
|
23
|
+
exports.scopeConditionSchema = verifyScope.scopeConditionSchema;
|
|
24
|
+
exports.scopeObjectSchema = verifyScope.scopeObjectSchema;
|
|
19
25
|
exports.updateRoleInputSchema = verifyScope.updateRoleInputSchema;
|
|
20
26
|
exports.verifyAccessInputSchema = verifyScope.verifyAccessInputSchema;
|
|
21
27
|
exports.verifyScopeInputSchema = verifyScope.verifyScopeInputSchema;
|
package/dist/types.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, C as CreateRoleInput, a as CreateRoleOutput, D as DeleteRoleInput, s as DeleteRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, L as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, y as RoleInsertType, w as RoleScopeInsertType, v as RoleScopeSelectType, x as RoleSelectType, S as Scope, U as UpdateRoleInput, u as UpdateRoleOutput, B as UserRoleInsertType, z as UserRoleSelectType, F as UserScopeInsertType, E as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, H as assignRoleToUserInputSchema, I as assignRolesToUserInputSchema, J as createRoleInputSchema, K as deleteRoleInputSchema, M as getUserPermissionsInputSchema, N as grantScopeToRoleInputSchema, O as grantScopeToUserInputSchema, P as grantScopesToUserInputSchema, Q as revokeRoleFromUserInputSchema, T as revokeScopeFromRoleInputSchema, W as revokeScopeFromUserInputSchema, X as updateRoleInputSchema,
|
|
1
|
+
export { A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, C as CreateRoleInput, a as CreateRoleOutput, D as DeleteRoleInput, s as DeleteRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, L as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, y as RoleInsertType, w as RoleScopeInsertType, v as RoleScopeSelectType, x as RoleSelectType, S as Scope, _ as ScopeCondition, Z as ScopeObject, U as UpdateRoleInput, u as UpdateRoleOutput, B as UserRoleInsertType, z as UserRoleSelectType, F as UserScopeInsertType, E as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, H as assignRoleToUserInputSchema, I as assignRolesToUserInputSchema, J as createRoleInputSchema, K as deleteRoleInputSchema, M as getUserPermissionsInputSchema, N as grantScopeToRoleInputSchema, O as grantScopeToUserInputSchema, P as grantScopesToUserInputSchema, a3 as isAndCondition, a4 as isImplicitAndCondition, a2 as isOrCondition, a1 as isScopeObject, Q as revokeRoleFromUserInputSchema, T as revokeScopeFromRoleInputSchema, W as revokeScopeFromUserInputSchema, $ as scopeConditionSchema, Y as scopeObjectSchema, X as updateRoleInputSchema, a0 as verifyAccessInputSchema } from './shared/rbac.DBpIRbd3.cjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export { b as RbacServiceEnv, a as RbacServiceEnvironmentConfig, R as RbacServiceWranglerConfig } from './shared/rbac.ClMKyW8J.cjs';
|
|
4
4
|
import 'drizzle-orm';
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, C as CreateRoleInput, a as CreateRoleOutput, D as DeleteRoleInput, s as DeleteRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, L as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, y as RoleInsertType, w as RoleScopeInsertType, v as RoleScopeSelectType, x as RoleSelectType, S as Scope, U as UpdateRoleInput, u as UpdateRoleOutput, B as UserRoleInsertType, z as UserRoleSelectType, F as UserScopeInsertType, E as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, H as assignRoleToUserInputSchema, I as assignRolesToUserInputSchema, J as createRoleInputSchema, K as deleteRoleInputSchema, M as getUserPermissionsInputSchema, N as grantScopeToRoleInputSchema, O as grantScopeToUserInputSchema, P as grantScopesToUserInputSchema, Q as revokeRoleFromUserInputSchema, T as revokeScopeFromRoleInputSchema, W as revokeScopeFromUserInputSchema, X as updateRoleInputSchema,
|
|
1
|
+
export { A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, C as CreateRoleInput, a as CreateRoleOutput, D as DeleteRoleInput, s as DeleteRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, L as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, y as RoleInsertType, w as RoleScopeInsertType, v as RoleScopeSelectType, x as RoleSelectType, S as Scope, _ as ScopeCondition, Z as ScopeObject, U as UpdateRoleInput, u as UpdateRoleOutput, B as UserRoleInsertType, z as UserRoleSelectType, F as UserScopeInsertType, E as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, H as assignRoleToUserInputSchema, I as assignRolesToUserInputSchema, J as createRoleInputSchema, K as deleteRoleInputSchema, M as getUserPermissionsInputSchema, N as grantScopeToRoleInputSchema, O as grantScopeToUserInputSchema, P as grantScopesToUserInputSchema, a3 as isAndCondition, a4 as isImplicitAndCondition, a2 as isOrCondition, a1 as isScopeObject, Q as revokeRoleFromUserInputSchema, T as revokeScopeFromRoleInputSchema, W as revokeScopeFromUserInputSchema, $ as scopeConditionSchema, Y as scopeObjectSchema, X as updateRoleInputSchema, a0 as verifyAccessInputSchema } from './shared/rbac.CG3CtEwh.mjs';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export { b as RbacServiceEnv, a as RbacServiceEnvironmentConfig, R as RbacServiceWranglerConfig } from './shared/rbac.ClMKyW8J.mjs';
|
|
4
4
|
import 'drizzle-orm';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, C as CreateRoleInput, a as CreateRoleOutput, D as DeleteRoleInput, s as DeleteRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, L as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, y as RoleInsertType, w as RoleScopeInsertType, v as RoleScopeSelectType, x as RoleSelectType, S as Scope, U as UpdateRoleInput, u as UpdateRoleOutput, B as UserRoleInsertType, z as UserRoleSelectType, F as UserScopeInsertType, E as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, H as assignRoleToUserInputSchema, I as assignRolesToUserInputSchema, J as createRoleInputSchema, K as deleteRoleInputSchema, M as getUserPermissionsInputSchema, N as grantScopeToRoleInputSchema, O as grantScopeToUserInputSchema, P as grantScopesToUserInputSchema, Q as revokeRoleFromUserInputSchema, T as revokeScopeFromRoleInputSchema, W as revokeScopeFromUserInputSchema, X as updateRoleInputSchema,
|
|
1
|
+
export { A as AssignRoleToUserInput, b as AssignRoleToUserOutput, c as AssignRolesToUserInput, d as AssignRolesToUserOutput, C as CreateRoleInput, a as CreateRoleOutput, D as DeleteRoleInput, s as DeleteRoleOutput, o as GetPermissionsOutput, p as GetUserPermissionsInput, q as GetUserPermissionsOutput, k as GrantScopeToRoleInput, l as GrantScopeToRoleOutput, G as GrantScopeToUserInput, f as GrantScopeToUserOutput, g as GrantScopesToUserInput, h as GrantScopesToUserOutput, L as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, y as RoleInsertType, w as RoleScopeInsertType, v as RoleScopeSelectType, x as RoleSelectType, S as Scope, _ as ScopeCondition, Z as ScopeObject, U as UpdateRoleInput, u as UpdateRoleOutput, B as UserRoleInsertType, z as UserRoleSelectType, F as UserScopeInsertType, E as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, H as assignRoleToUserInputSchema, I as assignRolesToUserInputSchema, J as createRoleInputSchema, K as deleteRoleInputSchema, M as getUserPermissionsInputSchema, N as grantScopeToRoleInputSchema, O as grantScopeToUserInputSchema, P as grantScopesToUserInputSchema, a3 as isAndCondition, a4 as isImplicitAndCondition, a2 as isOrCondition, a1 as isScopeObject, Q as revokeRoleFromUserInputSchema, T as revokeScopeFromRoleInputSchema, W as revokeScopeFromUserInputSchema, $ as scopeConditionSchema, Y as scopeObjectSchema, X as updateRoleInputSchema, a0 as verifyAccessInputSchema } from './shared/rbac.BrefTsLW.js';
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
export { b as RbacServiceEnv, a as RbacServiceEnvironmentConfig, R as RbacServiceWranglerConfig } from './shared/rbac.ClMKyW8J.js';
|
|
4
4
|
import 'drizzle-orm';
|
package/dist/types.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { a as assignRoleToUserInputSchema, b as assignRolesToUserInputSchema, c as createRoleInputSchema, d as deleteRoleInputSchema, g as getUserPermissionsInputSchema, e as grantScopeToRoleInputSchema, f as grantScopeToUserInputSchema, h as grantScopesToUserInputSchema, r as revokeRoleFromUserInputSchema, i as revokeScopeFromRoleInputSchema, j as revokeScopeFromUserInputSchema, u as updateRoleInputSchema, v as verifyAccessInputSchema,
|
|
1
|
+
export { a as assignRoleToUserInputSchema, b as assignRolesToUserInputSchema, c as createRoleInputSchema, d as deleteRoleInputSchema, g as getUserPermissionsInputSchema, e as grantScopeToRoleInputSchema, f as grantScopeToUserInputSchema, h as grantScopesToUserInputSchema, n as isAndCondition, o as isImplicitAndCondition, m as isOrCondition, l as isScopeObject, r as revokeRoleFromUserInputSchema, i as revokeScopeFromRoleInputSchema, j as revokeScopeFromUserInputSchema, k as scopeConditionSchema, s as scopeObjectSchema, u as updateRoleInputSchema, v as verifyAccessInputSchema, p as verifyScopeInputSchema, q as verifyScopeOutputSchema } from './shared/rbac.2_i8g_mW.mjs';
|
|
2
2
|
import 'zod';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@develit-services/rbac",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"author": "Develit.io s.r.o.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
"./dist"
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
|
-
"dev": "wrangler dev --port 9237 --persist-to ../../.wrangler/state",
|
|
33
|
+
"dev": "wrangler dev --port 9237 --persist-to ../../.wrangler/state -c ./wrangler.jsonc -c ../../apps/secrets-store/wrangler.jsonc",
|
|
34
34
|
"wrangler:generate": "bunx develit wrangler:generate --types",
|
|
35
35
|
"db:init": "wrangler d1 execute develit-rbac --local --persist-to ../../.wrangler/state --command=\"SELECT 'Creating database...' AS status;\"",
|
|
36
36
|
"db:generate": "drizzle-kit generate",
|
|
37
37
|
"db:migrate": "drizzle-kit migrate",
|
|
38
38
|
"db:explore": "drizzle-kit studio",
|
|
39
|
-
"types": "
|
|
39
|
+
"types": "bash typegen.sh",
|
|
40
40
|
"lint": "biome check",
|
|
41
41
|
"lint:fix": "biome check --fix",
|
|
42
42
|
"test": "vitest",
|