authula 0.3.3 → 0.4.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.
@@ -1,7 +1,156 @@
1
- import { r as sessionSchema, t as wrappedFetch } from "../fetch-B4O1awi2.js";
1
+ import { r as sessionSchema, t as wrappedFetch } from "../fetch-CDNq42ed.js";
2
2
  import { z } from "zod";
3
3
  import { parse } from "cookie";
4
4
 
5
+ //#region src/plugins/access-control/plugin.ts
6
+ var AccessControlPlugin = class {
7
+ id = "accessControl";
8
+ constructor() {}
9
+ init(client) {
10
+ return {
11
+ createRole: async (data) => {
12
+ return wrappedFetch(client, `/access-control/roles`, {
13
+ method: "POST",
14
+ body: data
15
+ });
16
+ },
17
+ getAllRoles: async () => {
18
+ return wrappedFetch(client, `/access-control/roles`, { method: "GET" });
19
+ },
20
+ getRoleByName: async (roleName) => {
21
+ return wrappedFetch(client, `/access-control/roles/by-name/${roleName}`, { method: "GET" });
22
+ },
23
+ getRoleById: async (roleId) => {
24
+ return wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "GET" });
25
+ },
26
+ updateRole: async (roleId, data) => {
27
+ return wrappedFetch(client, `/access-control/roles/${roleId}`, {
28
+ method: "PATCH",
29
+ body: data
30
+ });
31
+ },
32
+ deleteRole: async (roleId) => {
33
+ return wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "DELETE" });
34
+ },
35
+ createPermission: async (data) => {
36
+ return wrappedFetch(client, `/access-control/permissions`, {
37
+ method: "POST",
38
+ body: data
39
+ });
40
+ },
41
+ getAllPermissions: async () => {
42
+ return wrappedFetch(client, `/access-control/permissions`, { method: "GET" });
43
+ },
44
+ getPermissionById: async (permissionId) => {
45
+ return wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "GET" });
46
+ },
47
+ updatePermission: async (permissionId, data) => {
48
+ return wrappedFetch(client, `/access-control/permissions/${permissionId}`, {
49
+ method: "PATCH",
50
+ body: data
51
+ });
52
+ },
53
+ deletePermission: async (permissionId) => {
54
+ return wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "DELETE" });
55
+ },
56
+ addRolePermission: async (roleId, data) => {
57
+ return wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
58
+ method: "POST",
59
+ body: data
60
+ });
61
+ },
62
+ getRolePermissions: async (roleId) => {
63
+ return wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, { method: "GET" });
64
+ },
65
+ replaceRolePermissions: async (roleId, data) => {
66
+ return wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
67
+ method: "PUT",
68
+ body: data
69
+ });
70
+ },
71
+ removeRolePermission: async (roleId, permissionId) => {
72
+ return wrappedFetch(client, `/access-control/roles/${roleId}/permissions/${permissionId}`, { method: "DELETE" });
73
+ },
74
+ getUserRoles: async (userId) => {
75
+ return wrappedFetch(client, `/access-control/users/${userId}/roles`, { method: "GET" });
76
+ },
77
+ assignUserRole: async (userId, data) => {
78
+ return wrappedFetch(client, `/access-control/users/${userId}/roles`, {
79
+ method: "POST",
80
+ body: data
81
+ });
82
+ },
83
+ replaceUserRoles: async (userId, data) => {
84
+ return wrappedFetch(client, `/access-control/users/${userId}/roles`, {
85
+ method: "PUT",
86
+ body: data
87
+ });
88
+ },
89
+ removeUserRole: async (userId, roleId) => {
90
+ return wrappedFetch(client, `/access-control/users/${userId}/roles/${roleId}`, { method: "DELETE" });
91
+ },
92
+ getUserPermissions: async (userId) => {
93
+ return wrappedFetch(client, `/access-control/users/${userId}/permissions`, { method: "GET" });
94
+ },
95
+ checkUserPermissions: async (userId, data) => {
96
+ return wrappedFetch(client, `/access-control/users/${userId}/permissions/check`, {
97
+ method: "POST",
98
+ body: data
99
+ });
100
+ }
101
+ };
102
+ }
103
+ };
104
+
105
+ //#endregion
106
+ //#region src/plugins/access-control/types.ts
107
+ const roleSchema = z.object({
108
+ id: z.string().nonempty(),
109
+ name: z.string().nonempty(),
110
+ description: z.string().nullish(),
111
+ weight: z.number(),
112
+ isSystem: z.boolean(),
113
+ createdAt: z.iso.datetime(),
114
+ updatedAt: z.iso.datetime()
115
+ });
116
+ const permissionSchema = z.object({
117
+ id: z.string().nonempty(),
118
+ key: z.string().nonempty(),
119
+ description: z.string().nullish(),
120
+ isSystem: z.boolean(),
121
+ createdAt: z.iso.datetime(),
122
+ updatedAt: z.iso.datetime()
123
+ });
124
+ const permissionGrantSourceSchema = z.object({
125
+ roleId: z.string().nonempty(),
126
+ roleName: z.string().nonempty(),
127
+ grantedByUserId: z.string().nullish(),
128
+ grantedAt: z.iso.datetime().nullish()
129
+ });
130
+ const userPermissionInfoSchema = z.object({
131
+ permissionId: z.string().nonempty(),
132
+ permissionKey: z.string().nonempty(),
133
+ permissionDescription: z.string().nullish(),
134
+ grantedByUserId: z.string().nullish(),
135
+ grantedAt: z.iso.datetime().nullish(),
136
+ sources: z.array(permissionGrantSourceSchema).optional()
137
+ });
138
+ const userRoleInfoSchema = z.object({
139
+ roleId: z.string().nonempty(),
140
+ roleName: z.string().nonempty(),
141
+ roleDescription: z.string().nullish(),
142
+ assignedByUserId: z.string().nullish(),
143
+ assignedAt: z.iso.datetime().nullish(),
144
+ expiresAt: z.iso.datetime().nullish()
145
+ });
146
+ const roleDetailsSchema = z.object({
147
+ role: roleSchema,
148
+ permissions: z.array(userPermissionInfoSchema)
149
+ });
150
+ const getUserPermissionsResponseSchema = z.object({ permissions: z.array(userPermissionInfoSchema) });
151
+ const checkUserPermissionsResponseSchema = z.object({ hasPermissions: z.boolean() });
152
+
153
+ //#endregion
5
154
  //#region src/plugins/admin/plugin.ts
6
155
  var AdminPlugin = class {
7
156
  id = "admin";
@@ -173,155 +322,6 @@ const impersonationSchema = z.object({
173
322
  updatedAt: z.iso.datetime()
174
323
  });
175
324
 
176
- //#endregion
177
- //#region src/plugins/access-control/plugin.ts
178
- var AccessControlPlugin = class {
179
- id = "accessControl";
180
- constructor() {}
181
- init(client) {
182
- return {
183
- createRole: async (data) => {
184
- return wrappedFetch(client, `/access-control/roles`, {
185
- method: "POST",
186
- body: data
187
- });
188
- },
189
- getAllRoles: async () => {
190
- return wrappedFetch(client, `/access-control/roles`, { method: "GET" });
191
- },
192
- getRoleByName: async (roleName) => {
193
- return wrappedFetch(client, `/access-control/roles/by-name/${roleName}`, { method: "GET" });
194
- },
195
- getRoleById: async (roleId) => {
196
- return wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "GET" });
197
- },
198
- updateRole: async (roleId, data) => {
199
- return wrappedFetch(client, `/access-control/roles/${roleId}`, {
200
- method: "PATCH",
201
- body: data
202
- });
203
- },
204
- deleteRole: async (roleId) => {
205
- return wrappedFetch(client, `/access-control/roles/${roleId}`, { method: "DELETE" });
206
- },
207
- createPermission: async (data) => {
208
- return wrappedFetch(client, `/access-control/permissions`, {
209
- method: "POST",
210
- body: data
211
- });
212
- },
213
- getAllPermissions: async () => {
214
- return wrappedFetch(client, `/access-control/permissions`, { method: "GET" });
215
- },
216
- getPermissionById: async (permissionId) => {
217
- return wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "GET" });
218
- },
219
- updatePermission: async (permissionId, data) => {
220
- return wrappedFetch(client, `/access-control/permissions/${permissionId}`, {
221
- method: "PATCH",
222
- body: data
223
- });
224
- },
225
- deletePermission: async (permissionId) => {
226
- return wrappedFetch(client, `/access-control/permissions/${permissionId}`, { method: "DELETE" });
227
- },
228
- addRolePermission: async (roleId, data) => {
229
- return wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
230
- method: "POST",
231
- body: data
232
- });
233
- },
234
- getRolePermissions: async (roleId) => {
235
- return wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, { method: "GET" });
236
- },
237
- replaceRolePermissions: async (roleId, data) => {
238
- return wrappedFetch(client, `/access-control/roles/${roleId}/permissions`, {
239
- method: "PUT",
240
- body: data
241
- });
242
- },
243
- removeRolePermission: async (roleId, permissionId) => {
244
- return wrappedFetch(client, `/access-control/roles/${roleId}/permissions/${permissionId}`, { method: "DELETE" });
245
- },
246
- getUserRoles: async (userId) => {
247
- return wrappedFetch(client, `/access-control/users/${userId}/roles`, { method: "GET" });
248
- },
249
- assignUserRole: async (userId, data) => {
250
- return wrappedFetch(client, `/access-control/users/${userId}/roles`, {
251
- method: "POST",
252
- body: data
253
- });
254
- },
255
- replaceUserRoles: async (userId, data) => {
256
- return wrappedFetch(client, `/access-control/users/${userId}/roles`, {
257
- method: "PUT",
258
- body: data
259
- });
260
- },
261
- removeUserRole: async (userId, roleId) => {
262
- return wrappedFetch(client, `/access-control/users/${userId}/roles/${roleId}`, { method: "DELETE" });
263
- },
264
- getUserPermissions: async (userId) => {
265
- return wrappedFetch(client, `/access-control/users/${userId}/permissions`, { method: "GET" });
266
- },
267
- checkUserPermissions: async (userId, data) => {
268
- return wrappedFetch(client, `/access-control/users/${userId}/permissions/check`, {
269
- method: "POST",
270
- body: data
271
- });
272
- }
273
- };
274
- }
275
- };
276
-
277
- //#endregion
278
- //#region src/plugins/access-control/types.ts
279
- const roleSchema = z.object({
280
- id: z.string().nonempty(),
281
- name: z.string().nonempty(),
282
- description: z.string().nullish(),
283
- weight: z.number(),
284
- isSystem: z.boolean(),
285
- createdAt: z.iso.datetime(),
286
- updatedAt: z.iso.datetime()
287
- });
288
- const permissionSchema = z.object({
289
- id: z.string().nonempty(),
290
- key: z.string().nonempty(),
291
- description: z.string().nullish(),
292
- isSystem: z.boolean(),
293
- createdAt: z.iso.datetime(),
294
- updatedAt: z.iso.datetime()
295
- });
296
- const permissionGrantSourceSchema = z.object({
297
- roleId: z.string().nonempty(),
298
- roleName: z.string().nonempty(),
299
- grantedByUserId: z.string().nullish(),
300
- grantedAt: z.iso.datetime().nullish()
301
- });
302
- const userPermissionInfoSchema = z.object({
303
- permissionId: z.string().nonempty(),
304
- permissionKey: z.string().nonempty(),
305
- permissionDescription: z.string().nullish(),
306
- grantedByUserId: z.string().nullish(),
307
- grantedAt: z.iso.datetime().nullish(),
308
- sources: z.array(permissionGrantSourceSchema).optional()
309
- });
310
- const userRoleInfoSchema = z.object({
311
- roleId: z.string().nonempty(),
312
- roleName: z.string().nonempty(),
313
- roleDescription: z.string().nullish(),
314
- assignedByUserId: z.string().nullish(),
315
- assignedAt: z.iso.datetime().nullish(),
316
- expiresAt: z.iso.datetime().nullish()
317
- });
318
- const roleDetailsSchema = z.object({
319
- role: roleSchema,
320
- permissions: z.array(userPermissionInfoSchema)
321
- });
322
- const getUserPermissionsResponseSchema = z.object({ permissions: z.array(userPermissionInfoSchema) });
323
- const checkUserPermissionsResponseSchema = z.object({ hasPermissions: z.boolean() });
324
-
325
325
  //#endregion
326
326
  //#region src/plugins/bearer/plugin.ts
327
327
  var BearerPlugin = class {
@@ -521,6 +521,118 @@ var OAuth2Plugin = class {
521
521
  }
522
522
  };
523
523
 
524
+ //#endregion
525
+ //#region src/plugins/organizations/plugin.ts
526
+ var OrganizationsPlugin = class {
527
+ id = "organizations";
528
+ init(client) {
529
+ return {
530
+ createOrganization: async (data) => {
531
+ return wrappedFetch(client, "/organizations", {
532
+ method: "POST",
533
+ body: data
534
+ });
535
+ },
536
+ getAllOrganizations: async () => {
537
+ return wrappedFetch(client, "/organizations", { method: "GET" });
538
+ },
539
+ getOrganizationById: async (organizationId) => {
540
+ return wrappedFetch(client, `/organizations/${organizationId}`, { method: "GET" });
541
+ },
542
+ updateOrganization: async (organizationId, data) => {
543
+ return wrappedFetch(client, `/organizations/${organizationId}`, {
544
+ method: "PATCH",
545
+ body: data
546
+ });
547
+ },
548
+ deleteOrganization: async (organizationId) => {
549
+ return wrappedFetch(client, `/organizations/${organizationId}`, { method: "DELETE" });
550
+ },
551
+ createOrganizationInvitation: async (organizationId, data) => {
552
+ return wrappedFetch(client, `/organizations/${organizationId}/invitations`, {
553
+ method: "POST",
554
+ body: data
555
+ });
556
+ },
557
+ getAllOrganizationInvitations: async (organizationId) => {
558
+ return wrappedFetch(client, `/organizations/${organizationId}/invitations`, { method: "GET" });
559
+ },
560
+ getOrganizationInvitation: async (organizationId, invitationId) => {
561
+ return wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}`, { method: "GET" });
562
+ },
563
+ revokeOrganizationInvitation: async (organizationId, invitationId) => {
564
+ return wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}`, { method: "PATCH" });
565
+ },
566
+ acceptOrganizationInvitation: async (organizationId, invitationId, data) => {
567
+ return wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}/accept`, {
568
+ method: "POST",
569
+ body: data
570
+ });
571
+ },
572
+ rejectOrganizationInvitation: async (organizationId, invitationId) => {
573
+ return wrappedFetch(client, `/organizations/${organizationId}/invitations/${invitationId}/reject`, { method: "POST" });
574
+ },
575
+ addOrganizationMember: async (organizationId, data) => {
576
+ return wrappedFetch(client, `/organizations/${organizationId}/members`, {
577
+ method: "POST",
578
+ body: data
579
+ });
580
+ },
581
+ getAllOrganizationMembers: async (organizationId) => {
582
+ return wrappedFetch(client, `/organizations/${organizationId}/members`, { method: "GET" });
583
+ },
584
+ getOrganizationMember: async (organizationId, memberId) => {
585
+ return wrappedFetch(client, `/organizations/${organizationId}/members/${memberId}`, { method: "GET" });
586
+ },
587
+ updateOrganizationMember: async (organizationId, memberId, data) => {
588
+ return wrappedFetch(client, `/organizations/${organizationId}/members/${memberId}`, {
589
+ method: "PATCH",
590
+ body: data
591
+ });
592
+ },
593
+ deleteOrganizationMember: async (organizationId, memberId) => {
594
+ return wrappedFetch(client, `/organizations/${organizationId}/members/${memberId}`, { method: "DELETE" });
595
+ },
596
+ createOrganizationTeam: async (organizationId, data) => {
597
+ return wrappedFetch(client, `/organizations/${organizationId}/teams`, {
598
+ method: "POST",
599
+ body: data
600
+ });
601
+ },
602
+ getAllOrganizationTeams: async (organizationId) => {
603
+ return wrappedFetch(client, `/organizations/${organizationId}/teams`, { method: "GET" });
604
+ },
605
+ getOrganizationTeam: async (organizationId, teamId) => {
606
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}`, { method: "GET" });
607
+ },
608
+ updateOrganizationTeam: async (organizationId, teamId, data) => {
609
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}`, {
610
+ method: "PATCH",
611
+ body: data
612
+ });
613
+ },
614
+ deleteOrganizationTeam: async (organizationId, teamId) => {
615
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}`, { method: "DELETE" });
616
+ },
617
+ addOrganizationTeamMember: async (organizationId, teamId, data) => {
618
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members`, {
619
+ method: "POST",
620
+ body: data
621
+ });
622
+ },
623
+ getAllOrganizationTeamMembers: async (organizationId, teamId) => {
624
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members`, { method: "GET" });
625
+ },
626
+ getOrganizationTeamMember: async (organizationId, teamId, memberId) => {
627
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members/${memberId}`, { method: "GET" });
628
+ },
629
+ deleteOrganizationTeamMember: async (organizationId, teamId, memberId) => {
630
+ return wrappedFetch(client, `/organizations/${organizationId}/teams/${teamId}/members/${memberId}`, { method: "DELETE" });
631
+ }
632
+ };
633
+ }
634
+ };
635
+
524
636
  //#endregion
525
637
  //#region src/plugins/totp/plugin.ts
526
638
  var TOTPPlugin = class {
@@ -556,5 +668,5 @@ var TOTPPlugin = class {
556
668
  };
557
669
 
558
670
  //#endregion
559
- export { AccessControlPlugin, AdminPlugin, BearerPlugin, CSRFPlugin, EmailPasswordPlugin, JWTPlugin, MagicLinkPlugin, OAuth2Plugin, TOTPPlugin, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, checkUserPermissionsResponseSchema, getUserPermissionsResponseSchema, impersonationSchema, permissionGrantSourceSchema, permissionSchema, roleDetailsSchema, roleSchema, userPermissionInfoSchema, userRoleInfoSchema };
671
+ export { AccessControlPlugin, AdminPlugin, BearerPlugin, CSRFPlugin, EmailPasswordPlugin, JWTPlugin, MagicLinkPlugin, OAuth2Plugin, OrganizationsPlugin, TOTPPlugin, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, checkUserPermissionsResponseSchema, getUserPermissionsResponseSchema, impersonationSchema, permissionGrantSourceSchema, permissionSchema, roleDetailsSchema, roleSchema, userPermissionInfoSchema, userRoleInfoSchema };
560
672
  //# sourceMappingURL=index.js.map