@develit-services/rbac 0.0.2 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,145 @@
1
+ import { z } from 'zod';
2
+
3
+ const assignRoleToUserInputSchema = z.object({
4
+ userId: z.uuid(),
5
+ roleId: z.uuid()
6
+ });
7
+
8
+ const assignRolesToUserInputSchema = z.object({
9
+ userId: z.uuid(),
10
+ roles: z.array(z.uuid())
11
+ });
12
+
13
+ const createRoleInputSchema = z.object({
14
+ name: z.string()
15
+ });
16
+
17
+ const deleteRoleInputSchema = z.object({
18
+ id: z.uuid()
19
+ });
20
+
21
+ const getUserPermissionsInputSchema = z.object({
22
+ userId: z.uuid()
23
+ });
24
+
25
+ const grantScopeToRoleInputSchema = z.object({
26
+ roleId: z.uuid(),
27
+ scope: z.string(),
28
+ resourceId: z.string().optional()
29
+ });
30
+
31
+ const grantScopeToUserInputSchema = z.object({
32
+ userId: z.uuid(),
33
+ scope: z.string(),
34
+ resourceId: z.string().optional()
35
+ });
36
+
37
+ const grantScopesToUserInputSchema = z.object({
38
+ userId: z.uuid(),
39
+ scopes: z.array(
40
+ z.object({
41
+ scope: z.string(),
42
+ resourceId: z.string().optional()
43
+ })
44
+ )
45
+ });
46
+
47
+ const revokeRoleFromUserInputSchema = z.object({
48
+ userId: z.uuid(),
49
+ roleId: z.uuid()
50
+ });
51
+
52
+ const revokeScopeFromRoleInputSchema = z.object({
53
+ roleId: z.uuid(),
54
+ scope: z.string(),
55
+ resourceId: z.string().optional()
56
+ });
57
+
58
+ const revokeScopeFromUserInputSchema = z.object({
59
+ userId: z.uuid(),
60
+ scope: z.string(),
61
+ resourceId: z.string().optional()
62
+ });
63
+
64
+ const updateRoleInputSchema = z.object({
65
+ id: z.uuid(),
66
+ name: z.string()
67
+ });
68
+
69
+ const userDataSchema = z.object({
70
+ referenceId: z.string(),
71
+ email: z.string().optional(),
72
+ role: z.string().optional()
73
+ });
74
+ const jwtPayloadSchema = z.object({
75
+ sub: z.string(),
76
+ user: z.object({
77
+ id: z.uuid(),
78
+ createdAt: z.date().nullable(),
79
+ updatedAt: z.date().nullable(),
80
+ deletedAt: z.date().nullable(),
81
+ role: z.string(),
82
+ email: z.email(),
83
+ rawAppMetaData: z.any(),
84
+ rawUserMetaData: z.any(),
85
+ isSuperAdmin: z.boolean().default(false),
86
+ isSsoUser: z.boolean().default(false),
87
+ lastSignInAt: z.date().nullable().optional(),
88
+ emailConfirmedAt: z.date().nullable().optional(),
89
+ confirmationSentAt: z.date().nullable().optional(),
90
+ recoverySentAt: z.date().nullable().optional(),
91
+ emailChangeToken: z.string().nullable().optional(),
92
+ emailChangeSentAt: z.date().nullable().optional(),
93
+ isBanned: z.boolean().default(false).nullable().optional()
94
+ }),
95
+ iat: z.number(),
96
+ exp: z.number(),
97
+ userData: userDataSchema.optional()
98
+ });
99
+
100
+ const verifyAccessInputSchema = z.object({
101
+ userId: z.uuid(),
102
+ accessRequests: z.array(
103
+ z.object({
104
+ scope: z.string(),
105
+ resourceId: z.string().optional(),
106
+ resourcePath: z.string().optional()
107
+ })
108
+ ),
109
+ jwt: jwtPayloadSchema.extend({
110
+ createdAt: z.coerce.date().nullable().optional(),
111
+ updatedAt: z.coerce.date().nullable().optional(),
112
+ deletedAt: z.coerce.date().nullable().optional(),
113
+ lastSignInAt: z.coerce.date().nullable().optional(),
114
+ emailConfirmedAt: z.coerce.date().nullable().optional(),
115
+ confirmationSentAt: z.coerce.date().nullable().optional(),
116
+ recoverySentAt: z.coerce.date().nullable().optional(),
117
+ emailChangeSentAt: z.coerce.date().nullable().optional(),
118
+ user: jwtPayloadSchema.shape.user.extend({
119
+ createdAt: z.coerce.date().nullable().optional(),
120
+ updatedAt: z.coerce.date().nullable().optional(),
121
+ deletedAt: z.coerce.date().nullable().optional(),
122
+ lastSignInAt: z.coerce.date().nullable().optional(),
123
+ emailConfirmedAt: z.coerce.date().nullable().optional(),
124
+ confirmationSentAt: z.coerce.date().nullable().optional(),
125
+ recoverySentAt: z.coerce.date().nullable().optional(),
126
+ emailChangeSentAt: z.coerce.date().nullable().optional()
127
+ })
128
+ }).optional()
129
+ });
130
+
131
+ const verifyScopeInputSchema = z.object({
132
+ scopes: z.array(z.string()),
133
+ resourceId: z.string().optional(),
134
+ jwt: z.object({
135
+ sub: z.uuid(),
136
+ rbac: z.object({
137
+ roles: z.array(z.string()).optional()
138
+ })
139
+ })
140
+ });
141
+ const verifyScopeOutputSchema = z.object({
142
+ isVerified: z.boolean().default(false)
143
+ });
144
+
145
+ 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, verifyScopeInputSchema as k, verifyScopeOutputSchema as l, revokeRoleFromUserInputSchema as r, updateRoleInputSchema as u, verifyAccessInputSchema as v };
package/dist/types.cjs CHANGED
@@ -1,12 +1,10 @@
1
1
  'use strict';
2
2
 
3
- const verifyScope = require('./shared/rbac.CtYOhFTw.cjs');
3
+ const verifyScope = require('./shared/rbac.CS8i19gH.cjs');
4
4
  require('zod');
5
5
 
6
6
 
7
7
 
8
- exports.LABELED_SCOPES = verifyScope.LABELED_SCOPES;
9
- exports.SCOPES = verifyScope.SCOPES;
10
8
  exports.assignRoleToUserInputSchema = verifyScope.assignRoleToUserInputSchema;
11
9
  exports.assignRolesToUserInputSchema = verifyScope.assignRolesToUserInputSchema;
12
10
  exports.createRoleInputSchema = verifyScope.createRoleInputSchema;
package/dist/types.d.cts CHANGED
@@ -1,8 +1,8 @@
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 LABELED_SCOPES, B as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, w as RoleInsertType, y as RoleScopeInsertType, x as RoleScopeSelectType, v as RoleSelectType, S as SCOPES, z as Scope, U as UpdateRoleInput, u as UpdateRoleOutput, F as UserRoleInsertType, E as UserRoleSelectType, I as UserScopeInsertType, H as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, J as assignRoleToUserInputSchema, K as assignRolesToUserInputSchema, M as createRoleInputSchema, N as deleteRoleInputSchema, O as getUserPermissionsInputSchema, P as grantScopeToRoleInputSchema, Q as grantScopeToUserInputSchema, T as grantScopesToUserInputSchema, W as revokeRoleFromUserInputSchema, X as revokeScopeFromRoleInputSchema, Y as revokeScopeFromUserInputSchema, Z as updateRoleInputSchema, _ as verifyAccessInputSchema } from './shared/rbac.CaoDccv4.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.CZnF-YgH.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';
5
- import './shared/rbac.BmuK3PNh.cjs';
5
+ import './shared/rbac.CqpxM3E5.cjs';
6
6
  import 'drizzle-orm/sqlite-core';
7
7
 
8
8
  declare const verifyScopeInputSchema: z.ZodObject<{
package/dist/types.d.mts CHANGED
@@ -1,8 +1,8 @@
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 LABELED_SCOPES, B as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, w as RoleInsertType, y as RoleScopeInsertType, x as RoleScopeSelectType, v as RoleSelectType, S as SCOPES, z as Scope, U as UpdateRoleInput, u as UpdateRoleOutput, F as UserRoleInsertType, E as UserRoleSelectType, I as UserScopeInsertType, H as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, J as assignRoleToUserInputSchema, K as assignRolesToUserInputSchema, M as createRoleInputSchema, N as deleteRoleInputSchema, O as getUserPermissionsInputSchema, P as grantScopeToRoleInputSchema, Q as grantScopeToUserInputSchema, T as grantScopesToUserInputSchema, W as revokeRoleFromUserInputSchema, X as revokeScopeFromRoleInputSchema, Y as revokeScopeFromUserInputSchema, Z as updateRoleInputSchema, _ as verifyAccessInputSchema } from './shared/rbac.DH5084jg.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.DhS7RHC3.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';
5
- import './shared/rbac.BmuK3PNh.mjs';
5
+ import './shared/rbac.CqpxM3E5.mjs';
6
6
  import 'drizzle-orm/sqlite-core';
7
7
 
8
8
  declare const verifyScopeInputSchema: z.ZodObject<{
package/dist/types.d.ts CHANGED
@@ -1,8 +1,8 @@
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 LABELED_SCOPES, B as LabeledScope, R as RevokeRoleFromUserInput, e as RevokeRoleFromUserOutput, m as RevokeScopeFromRoleInput, n as RevokeScopeFromRoleOutput, i as RevokeScopeFromUserInput, j as RevokeScopeFromUserOutput, w as RoleInsertType, y as RoleScopeInsertType, x as RoleScopeSelectType, v as RoleSelectType, S as SCOPES, z as Scope, U as UpdateRoleInput, u as UpdateRoleOutput, F as UserRoleInsertType, E as UserRoleSelectType, I as UserScopeInsertType, H as UserScopeSelectType, V as VerifyAccessInput, r as VerifyAccessOutput, J as assignRoleToUserInputSchema, K as assignRolesToUserInputSchema, M as createRoleInputSchema, N as deleteRoleInputSchema, O as getUserPermissionsInputSchema, P as grantScopeToRoleInputSchema, Q as grantScopeToUserInputSchema, T as grantScopesToUserInputSchema, W as revokeRoleFromUserInputSchema, X as revokeScopeFromRoleInputSchema, Y as revokeScopeFromUserInputSchema, Z as updateRoleInputSchema, _ as verifyAccessInputSchema } from './shared/rbac.CHxy3VJb.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.DqMMROM3.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';
5
- import './shared/rbac.BmuK3PNh.js';
5
+ import './shared/rbac.CqpxM3E5.js';
6
6
  import 'drizzle-orm/sqlite-core';
7
7
 
8
8
  declare const verifyScopeInputSchema: z.ZodObject<{
package/dist/types.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export { L as LABELED_SCOPES, S as SCOPES, 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.CY8-sBAP.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.wzMQF48s.mjs';
2
2
  import 'zod';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@develit-services/rbac",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
4
4
  "author": "Develit.io s.r.o.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -30,30 +30,27 @@
30
30
  "./dist"
31
31
  ],
32
32
  "scripts": {
33
- "dev": "wrangler dev --port 9235 --persist-to ../../.wrangler/state",
34
- "wrangler:generate": "develit wrangler:generate",
33
+ "dev": "wrangler dev --port 9237 --persist-to ../../.wrangler/state",
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
39
  "types": "wrangler types --env-interface RbacEnv --include-runtime false",
40
- "typecheck": "tsc",
41
40
  "lint": "biome check",
42
41
  "lint:fix": "biome check --fix",
43
42
  "test": "vitest",
44
43
  "test:cov": "vitest run --coverage",
45
44
  "test:unit": "vitest unit fixtures",
46
45
  "test:int": "vitest integration",
47
- "build": "unbuild",
48
- "changelogen": "bunx changelogen@latest --bump",
49
- "release": "bun run build && bunx changelogen@latest --release --push && npm publish --access public"
46
+ "build": "unbuild"
50
47
  },
51
48
  "peerDependencies": {
52
- "@develit-io/backend-sdk": "*",
53
- "drizzle-kit": "*",
54
- "drizzle-orm": "*",
49
+ "@develit-io/backend-sdk": "9.1.6",
50
+ "drizzle-kit": "0.31.8",
51
+ "drizzle-orm": "0.45.0",
55
52
  "drizzle-seed": "*",
56
- "wrangler": "*",
57
- "zod": "*"
53
+ "wrangler": "4.50.0",
54
+ "zod": "4.1.13"
58
55
  }
59
56
  }