authula 0.3.1 → 0.3.2

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.
@@ -250,6 +250,211 @@ declare class AdminPlugin implements Plugin {
250
250
  };
251
251
  }
252
252
  //#endregion
253
+ //#region src/plugins/access-control/types.d.ts
254
+ declare const roleSchema: z.ZodObject<{
255
+ id: z.ZodString;
256
+ name: z.ZodString;
257
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
258
+ isSystem: z.ZodBoolean;
259
+ createdAt: z.ZodISODateTime;
260
+ updatedAt: z.ZodISODateTime;
261
+ }, z.core.$strip>;
262
+ type Role = z.infer<typeof roleSchema>;
263
+ declare const permissionSchema: z.ZodObject<{
264
+ id: z.ZodString;
265
+ key: z.ZodString;
266
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
267
+ isSystem: z.ZodBoolean;
268
+ createdAt: z.ZodISODateTime;
269
+ updatedAt: z.ZodISODateTime;
270
+ }, z.core.$strip>;
271
+ type Permission = z.infer<typeof permissionSchema>;
272
+ declare const permissionGrantSourceSchema: z.ZodObject<{
273
+ roleId: z.ZodString;
274
+ roleName: z.ZodString;
275
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
277
+ }, z.core.$strip>;
278
+ type PermissionGrantSource = z.infer<typeof permissionGrantSourceSchema>;
279
+ declare const userPermissionInfoSchema: z.ZodObject<{
280
+ permissionId: z.ZodString;
281
+ permissionKey: z.ZodString;
282
+ permissionDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
283
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
284
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
285
+ sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
286
+ roleId: z.ZodString;
287
+ roleName: z.ZodString;
288
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
289
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
290
+ }, z.core.$strip>>>;
291
+ }, z.core.$strip>;
292
+ type UserPermissionInfo = z.infer<typeof userPermissionInfoSchema>;
293
+ declare const userRoleInfoSchema: z.ZodObject<{
294
+ roleId: z.ZodString;
295
+ roleName: z.ZodString;
296
+ roleDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
297
+ assignedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
298
+ assignedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
299
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
300
+ }, z.core.$strip>;
301
+ type UserRoleInfo = z.infer<typeof userRoleInfoSchema>;
302
+ declare const roleDetailsSchema: z.ZodObject<{
303
+ role: z.ZodObject<{
304
+ id: z.ZodString;
305
+ name: z.ZodString;
306
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
307
+ isSystem: z.ZodBoolean;
308
+ createdAt: z.ZodISODateTime;
309
+ updatedAt: z.ZodISODateTime;
310
+ }, z.core.$strip>;
311
+ permissions: z.ZodArray<z.ZodObject<{
312
+ permissionId: z.ZodString;
313
+ permissionKey: z.ZodString;
314
+ permissionDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
315
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
316
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
317
+ sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
318
+ roleId: z.ZodString;
319
+ roleName: z.ZodString;
320
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
321
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
322
+ }, z.core.$strip>>>;
323
+ }, z.core.$strip>>;
324
+ }, z.core.$strip>;
325
+ type RoleDetails = z.infer<typeof roleDetailsSchema>;
326
+ declare const getUserPermissionsResponseSchema: z.ZodObject<{
327
+ permissions: z.ZodArray<z.ZodObject<{
328
+ permissionId: z.ZodString;
329
+ permissionKey: z.ZodString;
330
+ permissionDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
331
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
332
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
333
+ sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
334
+ roleId: z.ZodString;
335
+ roleName: z.ZodString;
336
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
337
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
338
+ }, z.core.$strip>>>;
339
+ }, z.core.$strip>>;
340
+ }, z.core.$strip>;
341
+ type GetUserPermissionsResponse = z.infer<typeof getUserPermissionsResponseSchema>;
342
+ declare const checkUserPermissionsResponseSchema: z.ZodObject<{
343
+ hasPermissions: z.ZodBoolean;
344
+ }, z.core.$strip>;
345
+ type CheckUserPermissionsResponse = z.infer<typeof checkUserPermissionsResponseSchema>;
346
+ type CreateRoleRequest = {
347
+ name: string;
348
+ description?: string | null;
349
+ isSystem: boolean;
350
+ };
351
+ type CreateRoleResponse = {
352
+ role: Role;
353
+ };
354
+ type UpdateRoleRequest = {
355
+ name?: string | null;
356
+ description?: string | null;
357
+ };
358
+ type UpdateRoleResponse = {
359
+ role: Role;
360
+ };
361
+ type DeleteRoleResponse = {
362
+ message: string;
363
+ };
364
+ type CreatePermissionRequest = {
365
+ key: string;
366
+ description?: string | null;
367
+ isSystem: boolean;
368
+ };
369
+ type CreatePermissionResponse = {
370
+ permission: Permission;
371
+ };
372
+ type UpdatePermissionRequest = {
373
+ description?: string | null;
374
+ };
375
+ type UpdatePermissionResponse = {
376
+ permission: Permission;
377
+ };
378
+ type DeletePermissionResponse = {
379
+ message: string;
380
+ };
381
+ type AddRolePermissionRequest = {
382
+ permissionId: string;
383
+ };
384
+ type AddRolePermissionResponse = {
385
+ message: string;
386
+ };
387
+ type ReplaceRolePermissionsRequest = {
388
+ permissionIds: string[];
389
+ };
390
+ type ReplaceRolePermissionResponse = {
391
+ message: string;
392
+ };
393
+ type RemoveRolePermissionResponse = {
394
+ message: string;
395
+ };
396
+ type AssignUserRoleRequest = {
397
+ roleId: string;
398
+ expiresAt?: string | null;
399
+ };
400
+ type ReplaceUserRolesRequest = {
401
+ roleIds: string[];
402
+ };
403
+ type ReplaceUserRolesResponse = {
404
+ message: string;
405
+ };
406
+ type AssignUserRoleResponse = {
407
+ message: string;
408
+ };
409
+ type RemoveUserRoleResponse = {
410
+ message: string;
411
+ };
412
+ type CheckUserPermissionsRequest = {
413
+ permissionKeys: string[];
414
+ };
415
+ type UserWithPermissions = {
416
+ user: User;
417
+ permissions: UserPermissionInfo[];
418
+ };
419
+ type UserAuthorizationProfile = {
420
+ user: User;
421
+ roles: UserRoleInfo[];
422
+ permissions: UserPermissionInfo[];
423
+ };
424
+ type UserWithRoles = {
425
+ user: User;
426
+ roles: UserRoleInfo[];
427
+ };
428
+ //#endregion
429
+ //#region src/plugins/access-control/plugin.d.ts
430
+ declare class AccessControlPlugin implements Plugin {
431
+ readonly id = "accessControl";
432
+ constructor();
433
+ init(client: AuthulaClient): {
434
+ createRole: (data: CreateRoleRequest) => Promise<CreateRoleResponse>;
435
+ getAllRoles: () => Promise<Role[]>;
436
+ getRoleByName: (roleName: string) => Promise<Role>;
437
+ getRoleById: (roleId: string) => Promise<RoleDetails>;
438
+ updateRole: (roleId: string, data: UpdateRoleRequest) => Promise<UpdateRoleResponse>;
439
+ deleteRole: (roleId: string) => Promise<DeleteRoleResponse>;
440
+ createPermission: (data: CreatePermissionRequest) => Promise<CreatePermissionResponse>;
441
+ getAllPermissions: () => Promise<Permission[]>;
442
+ getPermissionById: (permissionId: string) => Promise<Permission>;
443
+ updatePermission: (permissionId: string, data: UpdatePermissionRequest) => Promise<UpdatePermissionResponse>;
444
+ deletePermission: (permissionId: string) => Promise<DeletePermissionResponse>;
445
+ addRolePermission: (roleId: string, data: AddRolePermissionRequest) => Promise<AddRolePermissionResponse>;
446
+ getRolePermissions: (roleId: string) => Promise<UserPermissionInfo[]>;
447
+ replaceRolePermissions: (roleId: string, data: ReplaceRolePermissionsRequest) => Promise<ReplaceRolePermissionResponse>;
448
+ removeRolePermission: (roleId: string, permissionId: string) => Promise<RemoveRolePermissionResponse>;
449
+ getUserRoles: (userId: string) => Promise<UserRoleInfo[]>;
450
+ assignUserRole: (userId: string, data: AssignUserRoleRequest) => Promise<AssignUserRoleResponse>;
451
+ replaceUserRoles: (userId: string, data: ReplaceUserRolesRequest) => Promise<ReplaceUserRolesResponse>;
452
+ removeUserRole: (userId: string, roleId: string) => Promise<RemoveUserRoleResponse>;
453
+ getUserPermissions: (userId: string) => Promise<GetUserPermissionsResponse>;
454
+ checkUserPermissions: (userId: string, data: CheckUserPermissionsRequest) => Promise<CheckUserPermissionsResponse>;
455
+ };
456
+ }
457
+ //#endregion
253
458
  //#region src/plugins/bearer/types.d.ts
254
459
  type BearerPluginOptions = {
255
460
  headerName?: string;
@@ -457,5 +662,5 @@ declare class TOTPPlugin implements Plugin {
457
662
  };
458
663
  }
459
664
  //#endregion
460
- export { AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CreateAccountRequest, CreateAccountResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EmailPasswordPlugin, EnableResponse, GenerateBackupCodesResponse, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserAccountsResponse, GetUserAdminSessionsResponse, GetUserByIdResponse, GetUserStateResponse, Impersonation, JWKSKey, JWTAlgorithm, JWTPlugin, JWTTokensResponse, MagicLinkExchangeRequest, MagicLinkPlugin, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, OAuth2Plugin, OAuth2ProviderType, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, SendEmailVerificationRequest, SignInRequest, SignInWithOAuth2Request, SignInWithOAuth2Response, SignUpRequest, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, TOTPPlugin, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyEmailRequest, VerifyTOTPRequest, VerifyTOTPResponse, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
665
+ export { AccessControlPlugin, AddRolePermissionRequest, AddRolePermissionResponse, AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, AssignUserRoleRequest, AssignUserRoleResponse, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CheckUserPermissionsRequest, CheckUserPermissionsResponse, CreateAccountRequest, CreateAccountResponse, CreatePermissionRequest, CreatePermissionResponse, CreateRoleRequest, CreateRoleResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeletePermissionResponse, DeleteRoleResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EmailPasswordPlugin, EnableResponse, GenerateBackupCodesResponse, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserAccountsResponse, GetUserAdminSessionsResponse, GetUserByIdResponse, GetUserPermissionsResponse, GetUserStateResponse, Impersonation, JWKSKey, JWTAlgorithm, JWTPlugin, JWTTokensResponse, MagicLinkExchangeRequest, MagicLinkPlugin, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, OAuth2Plugin, OAuth2ProviderType, Permission, PermissionGrantSource, RemoveRolePermissionResponse, RemoveUserRoleResponse, ReplaceRolePermissionResponse, ReplaceRolePermissionsRequest, ReplaceUserRolesRequest, ReplaceUserRolesResponse, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, Role, RoleDetails, SendEmailVerificationRequest, SignInRequest, SignInWithOAuth2Request, SignInWithOAuth2Response, SignUpRequest, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, TOTPPlugin, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdatePermissionRequest, UpdatePermissionResponse, UpdateRoleRequest, UpdateRoleResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, UserAuthorizationProfile, UserPermissionInfo, UserRoleInfo, UserWithPermissions, UserWithRoles, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyEmailRequest, VerifyTOTPRequest, VerifyTOTPResponse, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, checkUserPermissionsResponseSchema, getUserPermissionsResponseSchema, impersonationSchema, permissionGrantSourceSchema, permissionSchema, roleDetailsSchema, roleSchema, userPermissionInfoSchema, userRoleInfoSchema };
461
666
  //# sourceMappingURL=index.d.cts.map
@@ -250,6 +250,211 @@ declare class AdminPlugin implements Plugin {
250
250
  };
251
251
  }
252
252
  //#endregion
253
+ //#region src/plugins/access-control/types.d.ts
254
+ declare const roleSchema: z.ZodObject<{
255
+ id: z.ZodString;
256
+ name: z.ZodString;
257
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
258
+ isSystem: z.ZodBoolean;
259
+ createdAt: z.ZodISODateTime;
260
+ updatedAt: z.ZodISODateTime;
261
+ }, z.core.$strip>;
262
+ type Role = z.infer<typeof roleSchema>;
263
+ declare const permissionSchema: z.ZodObject<{
264
+ id: z.ZodString;
265
+ key: z.ZodString;
266
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
267
+ isSystem: z.ZodBoolean;
268
+ createdAt: z.ZodISODateTime;
269
+ updatedAt: z.ZodISODateTime;
270
+ }, z.core.$strip>;
271
+ type Permission = z.infer<typeof permissionSchema>;
272
+ declare const permissionGrantSourceSchema: z.ZodObject<{
273
+ roleId: z.ZodString;
274
+ roleName: z.ZodString;
275
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
276
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
277
+ }, z.core.$strip>;
278
+ type PermissionGrantSource = z.infer<typeof permissionGrantSourceSchema>;
279
+ declare const userPermissionInfoSchema: z.ZodObject<{
280
+ permissionId: z.ZodString;
281
+ permissionKey: z.ZodString;
282
+ permissionDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
283
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
284
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
285
+ sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
286
+ roleId: z.ZodString;
287
+ roleName: z.ZodString;
288
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
289
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
290
+ }, z.core.$strip>>>;
291
+ }, z.core.$strip>;
292
+ type UserPermissionInfo = z.infer<typeof userPermissionInfoSchema>;
293
+ declare const userRoleInfoSchema: z.ZodObject<{
294
+ roleId: z.ZodString;
295
+ roleName: z.ZodString;
296
+ roleDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
297
+ assignedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
298
+ assignedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
299
+ expiresAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
300
+ }, z.core.$strip>;
301
+ type UserRoleInfo = z.infer<typeof userRoleInfoSchema>;
302
+ declare const roleDetailsSchema: z.ZodObject<{
303
+ role: z.ZodObject<{
304
+ id: z.ZodString;
305
+ name: z.ZodString;
306
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
307
+ isSystem: z.ZodBoolean;
308
+ createdAt: z.ZodISODateTime;
309
+ updatedAt: z.ZodISODateTime;
310
+ }, z.core.$strip>;
311
+ permissions: z.ZodArray<z.ZodObject<{
312
+ permissionId: z.ZodString;
313
+ permissionKey: z.ZodString;
314
+ permissionDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
315
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
316
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
317
+ sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
318
+ roleId: z.ZodString;
319
+ roleName: z.ZodString;
320
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
321
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
322
+ }, z.core.$strip>>>;
323
+ }, z.core.$strip>>;
324
+ }, z.core.$strip>;
325
+ type RoleDetails = z.infer<typeof roleDetailsSchema>;
326
+ declare const getUserPermissionsResponseSchema: z.ZodObject<{
327
+ permissions: z.ZodArray<z.ZodObject<{
328
+ permissionId: z.ZodString;
329
+ permissionKey: z.ZodString;
330
+ permissionDescription: z.ZodOptional<z.ZodNullable<z.ZodString>>;
331
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
332
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
333
+ sources: z.ZodOptional<z.ZodArray<z.ZodObject<{
334
+ roleId: z.ZodString;
335
+ roleName: z.ZodString;
336
+ grantedByUserId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
337
+ grantedAt: z.ZodOptional<z.ZodNullable<z.ZodISODateTime>>;
338
+ }, z.core.$strip>>>;
339
+ }, z.core.$strip>>;
340
+ }, z.core.$strip>;
341
+ type GetUserPermissionsResponse = z.infer<typeof getUserPermissionsResponseSchema>;
342
+ declare const checkUserPermissionsResponseSchema: z.ZodObject<{
343
+ hasPermissions: z.ZodBoolean;
344
+ }, z.core.$strip>;
345
+ type CheckUserPermissionsResponse = z.infer<typeof checkUserPermissionsResponseSchema>;
346
+ type CreateRoleRequest = {
347
+ name: string;
348
+ description?: string | null;
349
+ isSystem: boolean;
350
+ };
351
+ type CreateRoleResponse = {
352
+ role: Role;
353
+ };
354
+ type UpdateRoleRequest = {
355
+ name?: string | null;
356
+ description?: string | null;
357
+ };
358
+ type UpdateRoleResponse = {
359
+ role: Role;
360
+ };
361
+ type DeleteRoleResponse = {
362
+ message: string;
363
+ };
364
+ type CreatePermissionRequest = {
365
+ key: string;
366
+ description?: string | null;
367
+ isSystem: boolean;
368
+ };
369
+ type CreatePermissionResponse = {
370
+ permission: Permission;
371
+ };
372
+ type UpdatePermissionRequest = {
373
+ description?: string | null;
374
+ };
375
+ type UpdatePermissionResponse = {
376
+ permission: Permission;
377
+ };
378
+ type DeletePermissionResponse = {
379
+ message: string;
380
+ };
381
+ type AddRolePermissionRequest = {
382
+ permissionId: string;
383
+ };
384
+ type AddRolePermissionResponse = {
385
+ message: string;
386
+ };
387
+ type ReplaceRolePermissionsRequest = {
388
+ permissionIds: string[];
389
+ };
390
+ type ReplaceRolePermissionResponse = {
391
+ message: string;
392
+ };
393
+ type RemoveRolePermissionResponse = {
394
+ message: string;
395
+ };
396
+ type AssignUserRoleRequest = {
397
+ roleId: string;
398
+ expiresAt?: string | null;
399
+ };
400
+ type ReplaceUserRolesRequest = {
401
+ roleIds: string[];
402
+ };
403
+ type ReplaceUserRolesResponse = {
404
+ message: string;
405
+ };
406
+ type AssignUserRoleResponse = {
407
+ message: string;
408
+ };
409
+ type RemoveUserRoleResponse = {
410
+ message: string;
411
+ };
412
+ type CheckUserPermissionsRequest = {
413
+ permissionKeys: string[];
414
+ };
415
+ type UserWithPermissions = {
416
+ user: User;
417
+ permissions: UserPermissionInfo[];
418
+ };
419
+ type UserAuthorizationProfile = {
420
+ user: User;
421
+ roles: UserRoleInfo[];
422
+ permissions: UserPermissionInfo[];
423
+ };
424
+ type UserWithRoles = {
425
+ user: User;
426
+ roles: UserRoleInfo[];
427
+ };
428
+ //#endregion
429
+ //#region src/plugins/access-control/plugin.d.ts
430
+ declare class AccessControlPlugin implements Plugin {
431
+ readonly id = "accessControl";
432
+ constructor();
433
+ init(client: AuthulaClient): {
434
+ createRole: (data: CreateRoleRequest) => Promise<CreateRoleResponse>;
435
+ getAllRoles: () => Promise<Role[]>;
436
+ getRoleByName: (roleName: string) => Promise<Role>;
437
+ getRoleById: (roleId: string) => Promise<RoleDetails>;
438
+ updateRole: (roleId: string, data: UpdateRoleRequest) => Promise<UpdateRoleResponse>;
439
+ deleteRole: (roleId: string) => Promise<DeleteRoleResponse>;
440
+ createPermission: (data: CreatePermissionRequest) => Promise<CreatePermissionResponse>;
441
+ getAllPermissions: () => Promise<Permission[]>;
442
+ getPermissionById: (permissionId: string) => Promise<Permission>;
443
+ updatePermission: (permissionId: string, data: UpdatePermissionRequest) => Promise<UpdatePermissionResponse>;
444
+ deletePermission: (permissionId: string) => Promise<DeletePermissionResponse>;
445
+ addRolePermission: (roleId: string, data: AddRolePermissionRequest) => Promise<AddRolePermissionResponse>;
446
+ getRolePermissions: (roleId: string) => Promise<UserPermissionInfo[]>;
447
+ replaceRolePermissions: (roleId: string, data: ReplaceRolePermissionsRequest) => Promise<ReplaceRolePermissionResponse>;
448
+ removeRolePermission: (roleId: string, permissionId: string) => Promise<RemoveRolePermissionResponse>;
449
+ getUserRoles: (userId: string) => Promise<UserRoleInfo[]>;
450
+ assignUserRole: (userId: string, data: AssignUserRoleRequest) => Promise<AssignUserRoleResponse>;
451
+ replaceUserRoles: (userId: string, data: ReplaceUserRolesRequest) => Promise<ReplaceUserRolesResponse>;
452
+ removeUserRole: (userId: string, roleId: string) => Promise<RemoveUserRoleResponse>;
453
+ getUserPermissions: (userId: string) => Promise<GetUserPermissionsResponse>;
454
+ checkUserPermissions: (userId: string, data: CheckUserPermissionsRequest) => Promise<CheckUserPermissionsResponse>;
455
+ };
456
+ }
457
+ //#endregion
253
458
  //#region src/plugins/bearer/types.d.ts
254
459
  type BearerPluginOptions = {
255
460
  headerName?: string;
@@ -457,5 +662,5 @@ declare class TOTPPlugin implements Plugin {
457
662
  };
458
663
  }
459
664
  //#endregion
460
- export { AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CreateAccountRequest, CreateAccountResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EmailPasswordPlugin, EnableResponse, GenerateBackupCodesResponse, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserAccountsResponse, GetUserAdminSessionsResponse, GetUserByIdResponse, GetUserStateResponse, Impersonation, JWKSKey, JWTAlgorithm, JWTPlugin, JWTTokensResponse, MagicLinkExchangeRequest, MagicLinkPlugin, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, OAuth2Plugin, OAuth2ProviderType, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, SendEmailVerificationRequest, SignInRequest, SignInWithOAuth2Request, SignInWithOAuth2Response, SignUpRequest, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, TOTPPlugin, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyEmailRequest, VerifyTOTPRequest, VerifyTOTPResponse, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
665
+ export { AccessControlPlugin, AddRolePermissionRequest, AddRolePermissionResponse, AdminPlugin, AdminSessionState, AdminUserSession, AdminUserState, AssignUserRoleRequest, AssignUserRoleResponse, BanUserRequest, BanUserResponse, BearerPlugin, BearerPluginOptions, CSRFPlugin, CSRFPluginOptions, ChangePasswordRequest, CheckUserPermissionsRequest, CheckUserPermissionsResponse, CreateAccountRequest, CreateAccountResponse, CreatePermissionRequest, CreatePermissionResponse, CreateRoleRequest, CreateRoleResponse, CreateSessionStateRequest, CreateSessionStateResponse, CreateUserRequest, CreateUserResponse, CreateUserStateRequest, CreateUserStateResponse, DeleteAccountResponse, DeletePermissionResponse, DeleteRoleResponse, DeleteSessionStateResponse, DeleteUserResponse, DeleteUserStateResponse, DisableResponse, EmailPasswordPlugin, EnableResponse, GenerateBackupCodesResponse, GetAccountByIdResponse, GetAllImpersonationsResponse, GetAllUsersResponse, GetBannedUserStatesResponse, GetImpersonationByIdResponse, GetRevokedSessionStatesResponse, GetSessionStateResponse, GetTOTPURIResponse, GetUserAccountsResponse, GetUserAdminSessionsResponse, GetUserByIdResponse, GetUserPermissionsResponse, GetUserStateResponse, Impersonation, JWKSKey, JWTAlgorithm, JWTPlugin, JWTTokensResponse, MagicLinkExchangeRequest, MagicLinkPlugin, MagicLinkSignInRequest, MagicLinkSignInResponse, MagicLinkVerifyRequest, MagicLinkVerifyResponse, OAuth2Plugin, OAuth2ProviderType, Permission, PermissionGrantSource, RemoveRolePermissionResponse, RemoveUserRoleResponse, ReplaceRolePermissionResponse, ReplaceRolePermissionsRequest, ReplaceUserRolesRequest, ReplaceUserRolesResponse, RequestEmailChangeRequest, RequestPasswordResetRequest, RevokeSessionRequest, RevokeSessionResponse, Role, RoleDetails, SendEmailVerificationRequest, SignInRequest, SignInWithOAuth2Request, SignInWithOAuth2Response, SignUpRequest, StartImpersonationRequest, StartImpersonationResponse, StopImpersonationResponse, TOTPPlugin, TokenRefreshRequest, TokenRefreshResponse, UnbanUserResponse, UpdateAccountRequest, UpdateAccountResponse, UpdatePermissionRequest, UpdatePermissionResponse, UpdateRoleRequest, UpdateRoleResponse, UpdateSessionStateRequest, UpdateSessionStateResponse, UpdateUserRequest, UpdateUserResponse, UpdateUserStateRequest, UpdateUserStateResponse, UserAuthorizationProfile, UserPermissionInfo, UserRoleInfo, UserWithPermissions, UserWithRoles, VerifyBackupCodeRequest, VerifyBackupCodeResponse, VerifyEmailRequest, VerifyTOTPRequest, VerifyTOTPResponse, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, checkUserPermissionsResponseSchema, getUserPermissionsResponseSchema, impersonationSchema, permissionGrantSourceSchema, permissionSchema, roleDetailsSchema, roleSchema, userPermissionInfoSchema, userRoleInfoSchema };
461
666
  //# sourceMappingURL=index.d.ts.map
@@ -173,6 +173,154 @@ const impersonationSchema = z.object({
173
173
  updatedAt: z.iso.datetime()
174
174
  });
175
175
 
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
+ isSystem: z.boolean(),
284
+ createdAt: z.iso.datetime(),
285
+ updatedAt: z.iso.datetime()
286
+ });
287
+ const permissionSchema = z.object({
288
+ id: z.string().nonempty(),
289
+ key: z.string().nonempty(),
290
+ description: z.string().nullish(),
291
+ isSystem: z.boolean(),
292
+ createdAt: z.iso.datetime(),
293
+ updatedAt: z.iso.datetime()
294
+ });
295
+ const permissionGrantSourceSchema = z.object({
296
+ roleId: z.string().nonempty(),
297
+ roleName: z.string().nonempty(),
298
+ grantedByUserId: z.string().nullish(),
299
+ grantedAt: z.iso.datetime().nullish()
300
+ });
301
+ const userPermissionInfoSchema = z.object({
302
+ permissionId: z.string().nonempty(),
303
+ permissionKey: z.string().nonempty(),
304
+ permissionDescription: z.string().nullish(),
305
+ grantedByUserId: z.string().nullish(),
306
+ grantedAt: z.iso.datetime().nullish(),
307
+ sources: z.array(permissionGrantSourceSchema).optional()
308
+ });
309
+ const userRoleInfoSchema = z.object({
310
+ roleId: z.string().nonempty(),
311
+ roleName: z.string().nonempty(),
312
+ roleDescription: z.string().nullish(),
313
+ assignedByUserId: z.string().nullish(),
314
+ assignedAt: z.iso.datetime().nullish(),
315
+ expiresAt: z.iso.datetime().nullish()
316
+ });
317
+ const roleDetailsSchema = z.object({
318
+ role: roleSchema,
319
+ permissions: z.array(userPermissionInfoSchema)
320
+ });
321
+ const getUserPermissionsResponseSchema = z.object({ permissions: z.array(userPermissionInfoSchema) });
322
+ const checkUserPermissionsResponseSchema = z.object({ hasPermissions: z.boolean() });
323
+
176
324
  //#endregion
177
325
  //#region src/plugins/bearer/plugin.ts
178
326
  var BearerPlugin = class {
@@ -407,5 +555,5 @@ var TOTPPlugin = class {
407
555
  };
408
556
 
409
557
  //#endregion
410
- export { AdminPlugin, BearerPlugin, CSRFPlugin, EmailPasswordPlugin, JWTPlugin, MagicLinkPlugin, OAuth2Plugin, TOTPPlugin, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, impersonationSchema };
558
+ export { AccessControlPlugin, AdminPlugin, BearerPlugin, CSRFPlugin, EmailPasswordPlugin, JWTPlugin, MagicLinkPlugin, OAuth2Plugin, TOTPPlugin, adminSessionStateSchema, adminUserSessionSchema, adminUserStateSchema, checkUserPermissionsResponseSchema, getUserPermissionsResponseSchema, impersonationSchema, permissionGrantSourceSchema, permissionSchema, roleDetailsSchema, roleSchema, userPermissionInfoSchema, userRoleInfoSchema };
411
559
  //# sourceMappingURL=index.js.map