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