@develit-services/rbac 0.2.3 → 0.3.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.
@@ -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.B2KUW5xp.cjs');
8
+ const verifyScope = require('../shared/rbac.BZDCYlSt.cjs');
9
9
  const zod = require('zod');
10
10
  const cloudflare_workers = require('cloudflare:workers');
11
11
  const d1 = require('drizzle-orm/d1');
@@ -658,12 +658,13 @@ let RbacServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
658
658
  }
659
659
  async verifyAccess(input) {
660
660
  return this.handleAction(
661
- // TODO: This input schema is just copied from auth and is not 100% type safe
662
661
  { data: input, schema: verifyScope.verifyAccessInputSchema },
663
662
  { successMessage: "Access verification completed." },
664
663
  async ({ userId, accessRequests, jwt }) => {
665
- for (const request of accessRequests) {
666
- this.validateScope(request.scope);
664
+ for (const requestGroup of accessRequests) {
665
+ for (const request of requestGroup) {
666
+ this.validateScope(request.scope);
667
+ }
667
668
  }
668
669
  const userPermissionsResponse = await this.getUserPermissions({
669
670
  userId
@@ -678,46 +679,55 @@ let RbacServiceBase = class extends backendSdk.develitWorker(cloudflare_workers.
678
679
  ...userPermissionsResponse.data.roleScopes,
679
680
  ...userPermissionsResponse.data.scopes
680
681
  ];
681
- const allAccessRequestsSatisfied = accessRequests.every((request) => {
682
- const placeholders = parseScopeTemplate(request.scope);
683
- return allScopes.some((userScope) => {
684
- const scopesMatch = userScope.scope === request.scope;
685
- let resourceMatches = false;
686
- if (placeholders.length > 0) {
687
- if (!request.resourcePath) {
688
- throw backendSdk.createInternalError(null, {
689
- message: `Resource path is required when scope '${request.scope}' contains placeholders`,
690
- status: 400,
691
- code: "RESOURCE_PATH_REQUIRED"
692
- });
693
- }
694
- const extractedResources = extractResourcesFromPath(
695
- request.scope,
696
- request.resourcePath
697
- );
698
- const allPlaceholdersMatch = placeholders.every((placeholder) => {
699
- const extractedValue = extractedResources[`${placeholder.type}.${placeholder.path}`];
700
- const jwtParam = placeholder.type === "jwt" ? jwt : void 0;
701
- const expectedValue = getValueByKey(
702
- placeholder.type,
703
- placeholder.path,
704
- jwtParam
705
- );
706
- if (expectedValue === void 0) {
707
- return false;
682
+ if (accessRequests.length === 0) {
683
+ return {
684
+ isVerified: true
685
+ };
686
+ }
687
+ const anyGroupSatisfied = accessRequests.some((requestGroup) => {
688
+ return requestGroup.every((request) => {
689
+ const placeholders = parseScopeTemplate(request.scope);
690
+ return allScopes.some((userScope) => {
691
+ const scopesMatch = userScope.scope === request.scope;
692
+ let resourceMatches = false;
693
+ if (placeholders.length > 0) {
694
+ if (!request.resourcePath) {
695
+ throw backendSdk.createInternalError(null, {
696
+ message: `Resource path is required when scope '${request.scope}' contains placeholders`,
697
+ status: 400,
698
+ code: "RESOURCE_PATH_REQUIRED"
699
+ });
708
700
  }
709
- return String(extractedValue) === String(expectedValue);
710
- });
711
- const resourceIdMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
712
- resourceMatches = allPlaceholdersMatch && resourceIdMatches;
713
- } else {
714
- resourceMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
715
- }
716
- return scopesMatch && resourceMatches;
701
+ const extractedResources = extractResourcesFromPath(
702
+ request.scope,
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
+ });
717
727
  });
718
728
  });
719
729
  return {
720
- isVerified: allAccessRequestsSatisfied
730
+ isVerified: anyGroupSatisfied
721
731
  };
722
732
  }
723
733
  );
@@ -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.DB0xguAY.cjs';
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.B4wUvd3l.cjs';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import 'zod';
@@ -26,11 +26,11 @@ declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = Labele
26
26
  getPermissions(): Promise<IRPCResponse<GetPermissionsOutput>>;
27
27
  getUserPermissions(input: GetUserPermissionsInput): Promise<IRPCResponse<GetUserPermissionsOutput>>;
28
28
  verifyAccess(input: Omit<VerifyAccessInput, 'accessRequests'> & {
29
- accessRequests: Array<{
29
+ accessRequests: Array<Array<{
30
30
  scope: TScopes[number]['value'];
31
31
  resourceId?: string;
32
32
  resourcePath?: string;
33
- }>;
33
+ }>>;
34
34
  }): Promise<IRPCResponse<VerifyAccessOutput>>;
35
35
  deleteRole(input: DeleteRoleInput): Promise<IRPCResponse<DeleteRoleOutput>>;
36
36
  updateRole(input: UpdateRoleInput): Promise<IRPCResponse<UpdateRoleOutput>>;
@@ -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.CocWK7y6.mjs';
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.DbnJpvqK.mjs';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import 'zod';
@@ -26,11 +26,11 @@ declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = Labele
26
26
  getPermissions(): Promise<IRPCResponse<GetPermissionsOutput>>;
27
27
  getUserPermissions(input: GetUserPermissionsInput): Promise<IRPCResponse<GetUserPermissionsOutput>>;
28
28
  verifyAccess(input: Omit<VerifyAccessInput, 'accessRequests'> & {
29
- accessRequests: Array<{
29
+ accessRequests: Array<Array<{
30
30
  scope: TScopes[number]['value'];
31
31
  resourceId?: string;
32
32
  resourcePath?: string;
33
- }>;
33
+ }>>;
34
34
  }): Promise<IRPCResponse<VerifyAccessOutput>>;
35
35
  deleteRole(input: DeleteRoleInput): Promise<IRPCResponse<DeleteRoleOutput>>;
36
36
  updateRole(input: UpdateRoleInput): Promise<IRPCResponse<UpdateRoleOutput>>;
@@ -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.CAcqvrNj.js';
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.DrhiDe1P.js';
4
4
  import { WorkerEntrypoint } from 'cloudflare:workers';
5
5
  import { DrizzleD1Database } from 'drizzle-orm/d1';
6
6
  import 'zod';
@@ -26,11 +26,11 @@ declare class RbacServiceBase<TScopes extends readonly LabeledScope$1[] = Labele
26
26
  getPermissions(): Promise<IRPCResponse<GetPermissionsOutput>>;
27
27
  getUserPermissions(input: GetUserPermissionsInput): Promise<IRPCResponse<GetUserPermissionsOutput>>;
28
28
  verifyAccess(input: Omit<VerifyAccessInput, 'accessRequests'> & {
29
- accessRequests: Array<{
29
+ accessRequests: Array<Array<{
30
30
  scope: TScopes[number]['value'];
31
31
  resourceId?: string;
32
32
  resourcePath?: string;
33
- }>;
33
+ }>>;
34
34
  }): Promise<IRPCResponse<VerifyAccessOutput>>;
35
35
  deleteRole(input: DeleteRoleInput): Promise<IRPCResponse<DeleteRoleOutput>>;
36
36
  updateRole(input: UpdateRoleInput): Promise<IRPCResponse<UpdateRoleOutput>>;
@@ -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.CUCczegz.mjs';
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.ihzxYB9Z.mjs';
5
5
  import { z } from 'zod';
6
6
  import { WorkerEntrypoint } from 'cloudflare:workers';
7
7
  import { drizzle } from 'drizzle-orm/d1';
@@ -654,12 +654,13 @@ let RbacServiceBase = class extends develitWorker(WorkerEntrypoint) {
654
654
  }
655
655
  async verifyAccess(input) {
656
656
  return this.handleAction(
657
- // TODO: This input schema is just copied from auth and is not 100% type safe
658
657
  { data: input, schema: verifyAccessInputSchema },
659
658
  { successMessage: "Access verification completed." },
660
659
  async ({ userId, accessRequests, jwt }) => {
661
- for (const request of accessRequests) {
662
- this.validateScope(request.scope);
660
+ for (const requestGroup of accessRequests) {
661
+ for (const request of requestGroup) {
662
+ this.validateScope(request.scope);
663
+ }
663
664
  }
664
665
  const userPermissionsResponse = await this.getUserPermissions({
665
666
  userId
@@ -674,46 +675,55 @@ let RbacServiceBase = class extends develitWorker(WorkerEntrypoint) {
674
675
  ...userPermissionsResponse.data.roleScopes,
675
676
  ...userPermissionsResponse.data.scopes
676
677
  ];
677
- const allAccessRequestsSatisfied = accessRequests.every((request) => {
678
- const placeholders = parseScopeTemplate(request.scope);
679
- return allScopes.some((userScope) => {
680
- const scopesMatch = userScope.scope === request.scope;
681
- let resourceMatches = false;
682
- if (placeholders.length > 0) {
683
- if (!request.resourcePath) {
684
- throw createInternalError(null, {
685
- message: `Resource path is required when scope '${request.scope}' contains placeholders`,
686
- status: 400,
687
- code: "RESOURCE_PATH_REQUIRED"
688
- });
689
- }
690
- const extractedResources = extractResourcesFromPath(
691
- request.scope,
692
- request.resourcePath
693
- );
694
- const allPlaceholdersMatch = placeholders.every((placeholder) => {
695
- const extractedValue = extractedResources[`${placeholder.type}.${placeholder.path}`];
696
- const jwtParam = placeholder.type === "jwt" ? jwt : void 0;
697
- const expectedValue = getValueByKey(
698
- placeholder.type,
699
- placeholder.path,
700
- jwtParam
701
- );
702
- if (expectedValue === void 0) {
703
- return false;
678
+ if (accessRequests.length === 0) {
679
+ return {
680
+ isVerified: true
681
+ };
682
+ }
683
+ const anyGroupSatisfied = accessRequests.some((requestGroup) => {
684
+ return requestGroup.every((request) => {
685
+ const placeholders = parseScopeTemplate(request.scope);
686
+ return allScopes.some((userScope) => {
687
+ const scopesMatch = userScope.scope === request.scope;
688
+ let resourceMatches = false;
689
+ if (placeholders.length > 0) {
690
+ if (!request.resourcePath) {
691
+ throw createInternalError(null, {
692
+ message: `Resource path is required when scope '${request.scope}' contains placeholders`,
693
+ status: 400,
694
+ code: "RESOURCE_PATH_REQUIRED"
695
+ });
704
696
  }
705
- return String(extractedValue) === String(expectedValue);
706
- });
707
- const resourceIdMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
708
- resourceMatches = allPlaceholdersMatch && resourceIdMatches;
709
- } else {
710
- resourceMatches = userScope.resourceId === null || userScope.resourceId === request.resourceId;
711
- }
712
- return scopesMatch && resourceMatches;
697
+ const extractedResources = extractResourcesFromPath(
698
+ request.scope,
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
+ });
713
723
  });
714
724
  });
715
725
  return {
716
- isVerified: allAccessRequestsSatisfied
726
+ isVerified: anyGroupSatisfied
717
727
  };
718
728
  }
719
729
  );
@@ -190,11 +190,11 @@ interface UpdateRoleOutput {
190
190
 
191
191
  declare const verifyAccessInputSchema: z.ZodObject<{
192
192
  userId: z.ZodUUID;
193
- accessRequests: z.ZodArray<z.ZodObject<{
193
+ accessRequests: z.ZodArray<z.ZodArray<z.ZodObject<{
194
194
  scope: z.ZodString;
195
195
  resourceId: z.ZodOptional<z.ZodString>;
196
196
  resourcePath: z.ZodOptional<z.ZodString>;
197
- }, z.core.$strip>>;
197
+ }, z.core.$strip>>>;
198
198
  jwt: z.ZodOptional<z.ZodObject<{
199
199
  sub: z.ZodString;
200
200
  iat: z.ZodNumber;
@@ -140,11 +140,13 @@ const coercedJwtPayloadSchema = jwtPayloadSchema.extend({
140
140
  const verifyAccessInputSchema = zod.z.object({
141
141
  userId: zod.z.uuid(),
142
142
  accessRequests: zod.z.array(
143
- zod.z.object({
144
- scope: zod.z.string(),
145
- resourceId: zod.z.string().optional(),
146
- resourcePath: zod.z.string().optional()
147
- })
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
+ )
148
150
  ),
149
151
  jwt: coercedJwtPayloadSchema.optional()
150
152
  });
@@ -190,11 +190,11 @@ interface UpdateRoleOutput {
190
190
 
191
191
  declare const verifyAccessInputSchema: z.ZodObject<{
192
192
  userId: z.ZodUUID;
193
- accessRequests: z.ZodArray<z.ZodObject<{
193
+ accessRequests: z.ZodArray<z.ZodArray<z.ZodObject<{
194
194
  scope: z.ZodString;
195
195
  resourceId: z.ZodOptional<z.ZodString>;
196
196
  resourcePath: z.ZodOptional<z.ZodString>;
197
- }, z.core.$strip>>;
197
+ }, z.core.$strip>>>;
198
198
  jwt: z.ZodOptional<z.ZodObject<{
199
199
  sub: z.ZodString;
200
200
  iat: z.ZodNumber;
@@ -190,11 +190,11 @@ interface UpdateRoleOutput {
190
190
 
191
191
  declare const verifyAccessInputSchema: z.ZodObject<{
192
192
  userId: z.ZodUUID;
193
- accessRequests: z.ZodArray<z.ZodObject<{
193
+ accessRequests: z.ZodArray<z.ZodArray<z.ZodObject<{
194
194
  scope: z.ZodString;
195
195
  resourceId: z.ZodOptional<z.ZodString>;
196
196
  resourcePath: z.ZodOptional<z.ZodString>;
197
- }, z.core.$strip>>;
197
+ }, z.core.$strip>>>;
198
198
  jwt: z.ZodOptional<z.ZodObject<{
199
199
  sub: z.ZodString;
200
200
  iat: z.ZodNumber;
@@ -138,11 +138,13 @@ const coercedJwtPayloadSchema = jwtPayloadSchema.extend({
138
138
  const verifyAccessInputSchema = z.object({
139
139
  userId: z.uuid(),
140
140
  accessRequests: z.array(
141
- z.object({
142
- scope: z.string(),
143
- resourceId: z.string().optional(),
144
- resourcePath: z.string().optional()
145
- })
141
+ z.array(
142
+ z.object({
143
+ scope: z.string(),
144
+ resourceId: z.string().optional(),
145
+ resourcePath: z.string().optional()
146
+ })
147
+ )
146
148
  ),
147
149
  jwt: coercedJwtPayloadSchema.optional()
148
150
  });
package/dist/types.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const verifyScope = require('./shared/rbac.B2KUW5xp.cjs');
3
+ const verifyScope = require('./shared/rbac.BZDCYlSt.cjs');
4
4
  require('zod');
5
5
 
6
6
 
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, Y as verifyAccessInputSchema } from './shared/rbac.DB0xguAY.cjs';
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, Y as verifyAccessInputSchema } from './shared/rbac.B4wUvd3l.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, Y as verifyAccessInputSchema } from './shared/rbac.CocWK7y6.mjs';
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, Y as verifyAccessInputSchema } from './shared/rbac.DbnJpvqK.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, Y as verifyAccessInputSchema } from './shared/rbac.CAcqvrNj.js';
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, Y as verifyAccessInputSchema } from './shared/rbac.DrhiDe1P.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, k as verifyScopeInputSchema, l as verifyScopeOutputSchema } from './shared/rbac.CUCczegz.mjs';
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, k as verifyScopeInputSchema, l as verifyScopeOutputSchema } from './shared/rbac.ihzxYB9Z.mjs';
2
2
  import 'zod';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/rbac",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {