@nest-boot/auth 8.0.5-beta.2 → 8.0.5-beta.4

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.
Files changed (157) hide show
  1. package/README.md +33 -22
  2. package/dist/abilities/auth.ability.d.ts +6 -0
  3. package/dist/abilities/{user.ability.js → auth.ability.js} +4 -4
  4. package/dist/abilities/auth.ability.js.map +1 -0
  5. package/dist/abilities/index.d.ts +1 -2
  6. package/dist/abilities/index.js +1 -2
  7. package/dist/abilities/index.js.map +1 -1
  8. package/dist/auth-module-options.interface.d.ts +3 -0
  9. package/dist/auth.guard.d.ts +3 -9
  10. package/dist/auth.guard.js +13 -38
  11. package/dist/auth.guard.js.map +1 -1
  12. package/dist/auth.module.js +0 -6
  13. package/dist/auth.module.js.map +1 -1
  14. package/dist/decorators/can.decorator.d.ts +3 -11
  15. package/dist/decorators/can.decorator.js +8 -14
  16. package/dist/decorators/can.decorator.js.map +1 -1
  17. package/dist/decorators/index.d.ts +0 -2
  18. package/dist/decorators/index.js +0 -2
  19. package/dist/decorators/index.js.map +1 -1
  20. package/dist/entities/account.entity.d.ts +1 -1
  21. package/dist/entities/account.entity.js +1 -1
  22. package/dist/entities/invitation.entity.d.ts +2 -0
  23. package/dist/entities/invitation.entity.js +9 -0
  24. package/dist/entities/invitation.entity.js.map +1 -1
  25. package/dist/entities/member.entity.d.ts +2 -0
  26. package/dist/entities/member.entity.js +9 -0
  27. package/dist/entities/member.entity.js.map +1 -1
  28. package/dist/entities/workspace-api-key.entity.d.ts +2 -0
  29. package/dist/entities/workspace-api-key.entity.js +9 -0
  30. package/dist/entities/workspace-api-key.entity.js.map +1 -1
  31. package/dist/index.d.ts +4 -8
  32. package/dist/index.js +4 -8
  33. package/dist/index.js.map +1 -1
  34. package/dist/infrastructure/api-key-lifecycle.d.ts +14 -0
  35. package/dist/infrastructure/api-key-lifecycle.js +19 -0
  36. package/dist/infrastructure/api-key-lifecycle.js.map +1 -1
  37. package/dist/infrastructure/auth-ability.factory.d.ts +4 -9
  38. package/dist/infrastructure/auth-ability.factory.js +35 -32
  39. package/dist/infrastructure/auth-ability.factory.js.map +1 -1
  40. package/dist/infrastructure/auth-service.providers.js +9 -11
  41. package/dist/infrastructure/auth-service.providers.js.map +1 -1
  42. package/dist/infrastructure/request-identity.d.ts +16 -4
  43. package/dist/infrastructure/request-identity.js +61 -40
  44. package/dist/infrastructure/request-identity.js.map +1 -1
  45. package/dist/interfaces/ability-context.interface.d.ts +16 -0
  46. package/dist/interfaces/ability-context.interface.js +2 -0
  47. package/dist/interfaces/ability-context.interface.js.map +1 -0
  48. package/dist/interfaces/ability-rules.interface.d.ts +8 -2
  49. package/dist/interfaces/auth-module-api-key-options.interface.d.ts +1 -1
  50. package/dist/interfaces/auth-module-user-options.interface.d.ts +0 -3
  51. package/dist/interfaces/auth-module-workspace-options.interface.d.ts +0 -3
  52. package/dist/interfaces/{user-can-metadata.interface.d.ts → can-metadata.interface.d.ts} +2 -2
  53. package/dist/interfaces/can-metadata.interface.js +2 -0
  54. package/dist/interfaces/can-metadata.interface.js.map +1 -0
  55. package/dist/permission.constants.d.ts +2 -4
  56. package/dist/permission.constants.js +2 -4
  57. package/dist/permission.constants.js.map +1 -1
  58. package/dist/resolvers/auth.resolver.d.ts +2 -4
  59. package/dist/resolvers/auth.resolver.js +5 -16
  60. package/dist/resolvers/auth.resolver.js.map +1 -1
  61. package/dist/services/account.service.d.ts +1 -3
  62. package/dist/services/account.service.js +4 -7
  63. package/dist/services/account.service.js.map +1 -1
  64. package/dist/services/invitation.service.d.ts +1 -3
  65. package/dist/services/invitation.service.js +38 -45
  66. package/dist/services/invitation.service.js.map +1 -1
  67. package/dist/services/member.service.d.ts +2 -4
  68. package/dist/services/member.service.js +63 -60
  69. package/dist/services/member.service.js.map +1 -1
  70. package/dist/services/session.service.d.ts +1 -4
  71. package/dist/services/session.service.js +12 -16
  72. package/dist/services/session.service.js.map +1 -1
  73. package/dist/services/user-api-key.service.d.ts +3 -7
  74. package/dist/services/user-api-key.service.js +52 -73
  75. package/dist/services/user-api-key.service.js.map +1 -1
  76. package/dist/services/user-deletion.service.js.map +1 -1
  77. package/dist/services/user.service.d.ts +1 -3
  78. package/dist/services/user.service.js +46 -44
  79. package/dist/services/user.service.js.map +1 -1
  80. package/dist/services/workspace-api-key.service.d.ts +3 -7
  81. package/dist/services/workspace-api-key.service.js +51 -76
  82. package/dist/services/workspace-api-key.service.js.map +1 -1
  83. package/dist/services/workspace.service.d.ts +2 -4
  84. package/dist/services/workspace.service.js +36 -30
  85. package/dist/services/workspace.service.js.map +1 -1
  86. package/dist/tsconfig.tsbuildinfo +1 -1
  87. package/dist/types/build-ability-callback.type.d.ts +4 -0
  88. package/dist/types/build-ability-callback.type.js +2 -0
  89. package/dist/types/build-ability-callback.type.js.map +1 -0
  90. package/dist/user.constants.d.ts +5 -5
  91. package/dist/user.constants.js +11 -13
  92. package/dist/user.constants.js.map +1 -1
  93. package/dist/utils/api-key-permissions.util.d.ts +2 -0
  94. package/dist/utils/api-key-permissions.util.js +10 -2
  95. package/dist/utils/api-key-permissions.util.js.map +1 -1
  96. package/dist/utils/assert-can.util.d.ts +3 -0
  97. package/dist/utils/assert-can.util.js +8 -0
  98. package/dist/utils/assert-can.util.js.map +1 -0
  99. package/dist/utils/build-request-ability.util.d.ts +3 -6
  100. package/dist/utils/build-request-ability.util.js +25 -15
  101. package/dist/utils/build-request-ability.util.js.map +1 -1
  102. package/dist/utils/can.util.d.ts +2 -3
  103. package/dist/utils/can.util.js +9 -7
  104. package/dist/utils/can.util.js.map +1 -1
  105. package/dist/utils/extend-ability.util.d.ts +5 -1
  106. package/dist/utils/extend-ability.util.js +13 -6
  107. package/dist/utils/extend-ability.util.js.map +1 -1
  108. package/dist/utils/get-ability.util.d.ts +5 -0
  109. package/dist/utils/get-ability.util.js +20 -0
  110. package/dist/utils/get-ability.util.js.map +1 -0
  111. package/dist/utils/permission-grants.util.d.ts +9 -0
  112. package/dist/utils/permission-grants.util.js +25 -0
  113. package/dist/utils/permission-grants.util.js.map +1 -0
  114. package/dist/workspace.constants.d.ts +7 -7
  115. package/dist/workspace.constants.js +18 -18
  116. package/dist/workspace.constants.js.map +1 -1
  117. package/package.json +8 -8
  118. package/dist/abilities/user.ability.d.ts +0 -8
  119. package/dist/abilities/user.ability.js.map +0 -1
  120. package/dist/abilities/workspace.ability.d.ts +0 -8
  121. package/dist/abilities/workspace.ability.js +0 -13
  122. package/dist/abilities/workspace.ability.js.map +0 -1
  123. package/dist/decorators/user-can.decorator.d.ts +0 -13
  124. package/dist/decorators/user-can.decorator.js +0 -21
  125. package/dist/decorators/user-can.decorator.js.map +0 -1
  126. package/dist/decorators/workspace-can.decorator.d.ts +0 -13
  127. package/dist/decorators/workspace-can.decorator.js +0 -21
  128. package/dist/decorators/workspace-can.decorator.js.map +0 -1
  129. package/dist/interfaces/can-options.interface.d.ts +0 -5
  130. package/dist/interfaces/can-options.interface.js +0 -2
  131. package/dist/interfaces/can-options.interface.js.map +0 -1
  132. package/dist/interfaces/user-can-metadata.interface.js +0 -2
  133. package/dist/interfaces/user-can-metadata.interface.js.map +0 -1
  134. package/dist/interfaces/workspace-can-metadata.interface.d.ts +0 -9
  135. package/dist/interfaces/workspace-can-metadata.interface.js +0 -2
  136. package/dist/interfaces/workspace-can-metadata.interface.js.map +0 -1
  137. package/dist/services/access-control.service.d.ts +0 -52
  138. package/dist/services/access-control.service.js +0 -201
  139. package/dist/services/access-control.service.js.map +0 -1
  140. package/dist/types/build-user-ability-callback.type.d.ts +0 -10
  141. package/dist/types/build-user-ability-callback.type.js +0 -2
  142. package/dist/types/build-user-ability-callback.type.js.map +0 -1
  143. package/dist/types/build-workspace-ability-callback.type.d.ts +0 -10
  144. package/dist/types/build-workspace-ability-callback.type.js +0 -2
  145. package/dist/types/build-workspace-ability-callback.type.js.map +0 -1
  146. package/dist/utils/get-user-ability.util.d.ts +0 -3
  147. package/dist/utils/get-user-ability.util.js +0 -14
  148. package/dist/utils/get-user-ability.util.js.map +0 -1
  149. package/dist/utils/get-workspace-ability.util.d.ts +0 -3
  150. package/dist/utils/get-workspace-ability.util.js +0 -14
  151. package/dist/utils/get-workspace-ability.util.js.map +0 -1
  152. package/dist/utils/user-can.util.d.ts +0 -3
  153. package/dist/utils/user-can.util.js +0 -9
  154. package/dist/utils/user-can.util.js.map +0 -1
  155. package/dist/utils/workspace-can.util.d.ts +0 -3
  156. package/dist/utils/workspace-can.util.js +0 -10
  157. package/dist/utils/workspace-can.util.js.map +0 -1
@@ -0,0 +1,4 @@
1
+ import type { AbilityContext } from "../interfaces/ability-context.interface.js";
2
+ import type { AbilityRules } from "../interfaces/ability-rules.interface.js";
3
+ /** Synchronously extends one request ability with permission-bound business rules. */
4
+ export type BuildAbilityCallback<UserPermission extends string = string, WorkspacePermission extends string = string> = (rules: AbilityRules<UserPermission, WorkspacePermission>, context: AbilityContext<UserPermission, WorkspacePermission>) => void;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=build-ability-callback.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-ability-callback.type.js","sourceRoot":"","sources":["../../src/types/build-ability-callback.type.ts"],"names":[],"mappings":""}
@@ -3,11 +3,11 @@ export declare const DEFAULT_USER_ROLE = "user";
3
3
  /** Roles classified as administrators by default. */
4
4
  export declare const DEFAULT_USER_ADMIN_ROLES: readonly ["admin"];
5
5
  /** Permissions available to the default user roles. */
6
- export declare const DEFAULT_USER_PERMISSIONS: readonly ["user:create", "user:list", "user:set-role", "user:ban", "user:impersonate", "user:impersonate-admins", "user:delete", "user:set-password", "user:set-email", "user:get", "user:update", "session:list", "session:revoke", "session:delete", "api-key:read", "api-key:create", "api-key:update", "api-key:delete"];
7
- /** Default user roles modelled after Better Auth's admin access control. */
6
+ export declare const DEFAULT_USER_PERMISSIONS: readonly ["user:create", "user:read", "user:set-roles", "user:set-permissions", "user:ban", "user:impersonate", "user:impersonate-admin", "user:delete", "user:set-password", "user:set-email", "user:update", "session:read", "session:revoke", "user-api-key:read", "user-api-key:write", "workspace:create"];
7
+ /** Explicit default grants for user-scoped administration and workspace creation. */
8
8
  export declare const DEFAULT_USER_ROLES: {
9
9
  /** Grants every default user permission. */
10
- readonly admin: readonly ["user:create", "user:list", "user:set-role", "user:ban", "user:impersonate", "user:impersonate-admins", "user:delete", "user:set-password", "user:set-email", "user:get", "user:update", "session:list", "session:revoke", "session:delete", "api-key:read", "api-key:create", "api-key:update", "api-key:delete"];
11
- /** Grants no user permissions. */
12
- readonly user: readonly [];
10
+ readonly admin: readonly ["user:create", "user:read", "user:set-roles", "user:set-permissions", "user:ban", "user:impersonate", "user:impersonate-admin", "user:delete", "user:set-password", "user:set-email", "user:update", "session:read", "session:revoke", "user-api-key:read", "user-api-key:write", "workspace:create"];
11
+ /** Allows signed-in users to create workspaces, without user-administration grants. */
12
+ readonly user: readonly ["workspace:create"];
13
13
  };
@@ -5,29 +5,27 @@ export const DEFAULT_USER_ADMIN_ROLES = ["admin"];
5
5
  /** Permissions available to the default user roles. */
6
6
  export const DEFAULT_USER_PERMISSIONS = [
7
7
  "user:create",
8
- "user:list",
9
- "user:set-role",
8
+ "user:read",
9
+ "user:set-roles",
10
+ "user:set-permissions",
10
11
  "user:ban",
11
12
  "user:impersonate",
12
- "user:impersonate-admins",
13
+ "user:impersonate-admin",
13
14
  "user:delete",
14
15
  "user:set-password",
15
16
  "user:set-email",
16
- "user:get",
17
17
  "user:update",
18
- "session:list",
18
+ "session:read",
19
19
  "session:revoke",
20
- "session:delete",
21
- "api-key:read",
22
- "api-key:create",
23
- "api-key:update",
24
- "api-key:delete",
20
+ "user-api-key:read",
21
+ "user-api-key:write",
22
+ "workspace:create",
25
23
  ];
26
- /** Default user roles modelled after Better Auth's admin access control. */
24
+ /** Explicit default grants for user-scoped administration and workspace creation. */
27
25
  export const DEFAULT_USER_ROLES = {
28
26
  /** Grants every default user permission. */
29
27
  admin: DEFAULT_USER_PERMISSIONS,
30
- /** Grants no user permissions. */
31
- user: [],
28
+ /** Allows signed-in users to create workspaces, without user-administration grants. */
29
+ user: ["workspace:create"],
32
30
  };
33
31
  //# sourceMappingURL=user.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"user.constants.js","sourceRoot":"","sources":["../src/user.constants.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,qDAAqD;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAO,CAAU,CAAC;AAE3D,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,aAAa;IACb,WAAW;IACX,eAAe;IACf,UAAU;IACV,kBAAkB;IAClB,yBAAyB;IACzB,aAAa;IACb,mBAAmB;IACnB,gBAAgB;IAChB,UAAU;IACV,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAEX,4EAA4E;AAC5E,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,4CAA4C;IAC5C,KAAK,EAAE,wBAAwB;IAC/B,kCAAkC;IAClC,IAAI,EAAE,EAAE;CAC0B,CAAC"}
1
+ {"version":3,"file":"user.constants.js","sourceRoot":"","sources":["../src/user.constants.ts"],"names":[],"mappings":"AAEA,yCAAyC;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAExC,qDAAqD;AACrD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAO,CAAU,CAAC;AAE3D,uDAAuD;AACvD,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,aAAa;IACb,WAAW;IACX,gBAAgB;IAChB,sBAAsB;IACtB,UAAU;IACV,kBAAkB;IAClB,wBAAwB;IACxB,aAAa;IACb,mBAAmB;IACnB,gBAAgB;IAChB,aAAa;IACb,cAAc;IACd,gBAAgB;IAChB,mBAAmB;IACnB,oBAAoB;IACpB,kBAAkB;CACV,CAAC;AAEX,qFAAqF;AACrF,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,4CAA4C;IAC5C,KAAK,EAAE,wBAAwB;IAC/B,uFAAuF;IACvF,IAAI,EAAE,CAAC,kBAAkB,CAAC;CACQ,CAAC"}
@@ -5,3 +5,5 @@ export declare function resolveApiKeyPermissionCatalog(options: AuthModuleOption
5
5
  readonly allowed: readonly string[];
6
6
  readonly defaults: readonly string[];
7
7
  };
8
+ /** Applies scope defaults, validates catalog values, and enforces the configured key ceiling. @internal */
9
+ export declare function normalizeApiKeyPermissions(options: AuthModuleOptions, scope: "user" | "workspace", requested: readonly string[] | null | undefined): string[];
@@ -1,3 +1,5 @@
1
+ import { normalizeAuthPermissions } from "./auth-role.util.js";
2
+ import { assertPermissionCeiling } from "./permission-grants.util.js";
1
3
  import { resolveAuthCatalog } from "./resolve-auth-catalog.util.js";
2
4
  const catalogs = new WeakMap();
3
5
  /** Returns the owner's complete enum catalog and the subset configurable on API keys. */
@@ -17,11 +19,17 @@ export function resolveApiKeyPermissionCatalog(options, scope) {
17
19
  defaults: Object.freeze([
18
20
  ...(options.apiKey?.[scope]?.defaultPermissions ?? []),
19
21
  ]),
20
- allowed: Object.freeze(permissions.filter((permission) => allowlist.has(permission) &&
21
- (scope !== "workspace" || permission !== "invitation:create"))),
22
+ allowed: Object.freeze(permissions.filter((permission) => allowlist.has(permission))),
22
23
  });
23
24
  scopes[scope] = catalog;
24
25
  catalogs.set(options, scopes);
25
26
  return catalog;
26
27
  }
28
+ /** Applies scope defaults, validates catalog values, and enforces the configured key ceiling. @internal */
29
+ export function normalizeApiKeyPermissions(options, scope, requested) {
30
+ const { permissions, allowed, defaults } = resolveApiKeyPermissionCatalog(options, scope);
31
+ const normalized = normalizeAuthPermissions(requested === undefined ? defaults : (requested ?? []), permissions, scope === "user" ? "User API key" : "Workspace API key");
32
+ assertPermissionCeiling(normalized, allowed, "API key permissions exceed configured allowedPermissions");
33
+ return normalized;
34
+ }
27
35
  //# sourceMappingURL=api-key-permissions.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api-key-permissions.util.js","sourceRoot":"","sources":["../../src/utils/api-key-permissions.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAEpE,MAAM,QAAQ,GAAG,IAAI,OAAO,EAQzB,CAAC;AAEJ,yFAAyF;AACzF,MAAM,UAAU,8BAA8B,CAC5C,OAA0B,EAC1B,KAA2B;IAM3B,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7B,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,MAAM,KAAK,GAAG,kBAAkB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,WAAW,CAAC;IAC9D,MAAM,UAAU,GAAG,kBAAkB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,WAAW,CAAC;IACxE,MAAM,WAAW,GAAG;QAClB,GAAG,IAAI,GAAG,CAAC,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC;KACtE,CAAC;IACF,MAAM,SAAS,GAAG,IAAI,GAAG,CACvB,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,kBAAkB,IAAI,WAAW,CAC3D,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC;QACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC;YACtB,GAAG,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,kBAAkB,IAAI,EAAE,CAAC;SACvD,CAAC;QACF,OAAO,EA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} from "@casl/ability";
2
+ /** Throws unless the current request ability permits the action, object, or field. */
3
+ export declare function assertCan(action: string, subject: Subject, field?: string): void;
@@ -0,0 +1,8 @@
1
+ import { ForbiddenException } from "@nestjs/common";
2
+ import { can } from "./can.util.js";
3
+ /** Throws unless the current request ability permits the action, object, or field. */
4
+ export function assertCan(action, subject, field) {
5
+ if (!can(action, subject, field))
6
+ throw new ForbiddenException(`You are not allowed to ${action} this resource`);
7
+ }
8
+ //# sourceMappingURL=assert-can.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-can.util.js","sourceRoot":"","sources":["../../src/utils/assert-can.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,sFAAsF;AACtF,MAAM,UAAU,SAAS,CACvB,MAAc,EACd,OAAgB,EAChB,KAAc;IAEd,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC;QAC9B,MAAM,IAAI,kBAAkB,CAC1B,0BAA0B,MAAM,gBAAgB,CACjD,CAAC;AACN,CAAC"}
@@ -1,7 +1,4 @@
1
- import type { UserAbility } from "../abilities/user.ability.js";
2
- import type { WorkspaceAbility } from "../abilities/workspace.ability.js";
1
+ import type { AuthAbility } from "../abilities/auth.ability.js";
3
2
  import type { AuthModuleOptions } from "../auth-module-options.interface.js";
4
- /** Builds user abilities from the current identity, retaining API-key ceilings. */
5
- export declare function buildRequestUserAbility(options: AuthModuleOptions): UserAbility | null;
6
- /** Builds workspace abilities only while the request has an active workspace identity. */
7
- export declare function buildRequestWorkspaceAbility(options: AuthModuleOptions): WorkspaceAbility | null;
3
+ /** Builds one ability from the current identity and credential-limited permission snapshot. */
4
+ export declare function buildRequestAbility(options: AuthModuleOptions): AuthAbility;
@@ -6,20 +6,30 @@ import { WorkspaceApiKey } from "../entities/workspace-api-key.entity.js";
6
6
  import { AuthAbilityFactory } from "../infrastructure/auth-ability.factory.js";
7
7
  import { getCurrentApiKey } from "./get-current-api-key.util.js";
8
8
  import { resolveRequestPermissions } from "./resolve-request-permissions.util.js";
9
- /** Builds user abilities from the current identity, retaining API-key ceilings. */
10
- export function buildRequestUserAbility(options) {
11
- const user = RequestContext.get(User);
12
- if (!user || getCurrentApiKey() instanceof WorkspaceApiKey)
13
- return null;
14
- return AuthAbilityFactory.createUserAbility(resolveRequestPermissions(options).user, user, options.user);
15
- }
16
- /** Builds workspace abilities only while the request has an active workspace identity. */
17
- export function buildRequestWorkspaceAbility(options) {
18
- const workspace = RequestContext.get(Workspace);
19
- const member = RequestContext.get(Member);
20
- if (!workspace ||
21
- (!member && !(getCurrentApiKey() instanceof WorkspaceApiKey)))
22
- return null;
23
- return AuthAbilityFactory.createWorkspaceAbility(resolveRequestPermissions(options).workspace, workspace, options.workspace);
9
+ /** Builds one ability from the current identity and credential-limited permission snapshot. */
10
+ export function buildRequestAbility(options) {
11
+ const apiKey = getCurrentApiKey();
12
+ const workspaceKey = apiKey instanceof WorkspaceApiKey;
13
+ const user = workspaceKey ? null : (RequestContext.get(User) ?? null);
14
+ const selectedWorkspace = RequestContext.get(Workspace);
15
+ const currentMember = RequestContext.get(Member);
16
+ const member = user &&
17
+ currentMember?.status === "ACTIVE" &&
18
+ currentMember.user?.id === user.id &&
19
+ currentMember.workspace?.id === selectedWorkspace?.id
20
+ ? currentMember
21
+ : null;
22
+ const workspace = selectedWorkspace &&
23
+ (member || (workspaceKey && apiKey.workspace?.id === selectedWorkspace.id))
24
+ ? selectedWorkspace
25
+ : null;
26
+ const permissions = resolveRequestPermissions(options);
27
+ return AuthAbilityFactory.createAbility({
28
+ user,
29
+ workspace,
30
+ member,
31
+ userPermissions: user ? permissions.user : [],
32
+ workspacePermissions: workspace ? permissions.workspace : [],
33
+ }, options);
24
34
  }
25
35
  //# sourceMappingURL=build-request-ability.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-request-ability.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iB;QACjB,CAAC,MAAM,IAAI,CAAC,YAAY,IAAI,MAAM,CAAC,SAAS,EAAE,EAAE,KAAK,iBAAiB,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC,CAAC,iBAAiB;QACnB,CAAC,CAAC,IAAI,CAAC;IACX,MAAM,WAAW,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IACvD,OAAO,kBAAkB,CAAC,aAAa,CACrC;QACE,IAAI;QACJ,SAAS;QACT,MAAM;QACN,eAAe,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;QAC7C,oBAAoB,EAAE,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;KAC7D,EACD,OAAO,CACR,CAAC;AACJ,CAAC"}
@@ -1,4 +1,3 @@
1
1
  import type { Subject } from "@casl/ability";
2
- import type { CanOptions } from "../interfaces/can-options.interface.js";
3
- /** Routes a permission check to its scoped implementation. */
4
- export declare function can(action: string, subject: Subject, options?: CanOptions): boolean;
2
+ /** Checks an action, object, or field against the current request ability. */
3
+ export declare function can(action: string, subject: Subject, field?: string): boolean;
@@ -1,9 +1,11 @@
1
- import { userCan } from "./user-can.util.js";
2
- import { workspaceCan } from "./workspace-can.util.js";
3
- /** Routes a permission check to its scoped implementation. */
4
- export function can(action, subject, options = {}) {
5
- return options.scope === "user"
6
- ? userCan(action, subject)
7
- : workspaceCan(action, subject);
1
+ import { readRequestAbility } from "./get-ability.util.js";
2
+ /** Checks an action, object, or field against the current request ability. */
3
+ export function can(action, subject, field) {
4
+ const ability = readRequestAbility();
5
+ if (!ability)
6
+ return false;
7
+ return field === undefined
8
+ ? ability.can(action, subject)
9
+ : ability.can(action, subject, field);
8
10
  }
9
11
  //# sourceMappingURL=can.util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"can.util.js","sourceRoot":"","sources":["../../src/utils/can.util.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,8DAA8D;AAC9D,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,OAAgB,EAChB,UAAsB,EAAE;IAExB,OAAO,OAAO,CAAC,KAAK,KAAK,MAAM;QAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;QAC1B,CAAC,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}
1
+ {"version":3,"file":"can.util.js","sourceRoot":"","sources":["../../src/utils/can.util.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,8EAA8E;AAC9E,MAAM,UAAU,GAAG,CAAC,MAAc,EAAE,OAAgB,EAAE,KAAc;IAClE,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,OAAO,KAAK,KAAK,SAAS;QACxB,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC;QAC9B,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;AAC1C,CAAC"}
@@ -1,4 +1,8 @@
1
1
  import type { Ability, AbilityBuilder, AbilityTuple, MongoQuery } from "@casl/ability";
2
+ import type { AbilityContext } from "../interfaces/ability-context.interface.js";
2
3
  import type { AbilityRules } from "../interfaces/ability-rules.interface.js";
3
4
  /** Runs synchronous extensions without exposing the builder, mutable rules, or a build function. */
4
- export declare function extendAbility(builder: AbilityBuilder<Ability<AbilityTuple, MongoQuery>>, permissions: readonly string[], catalog: readonly string[], configure: (rules: AbilityRules) => unknown): void;
5
+ export declare function extendAbility(builder: AbilityBuilder<Ability<AbilityTuple, MongoQuery>>, context: AbilityContext, catalog: {
6
+ user: readonly string[];
7
+ workspace: readonly string[];
8
+ }, configure: (rules: AbilityRules) => unknown): void;
@@ -1,8 +1,6 @@
1
1
  import { entities } from "../entities/index.js";
2
2
  /** Runs synchronous extensions without exposing the builder, mutable rules, or a build function. */
3
- export function extendAbility(builder, permissions, catalog, configure) {
4
- const granted = new Set(permissions);
5
- const known = new Set(catalog);
3
+ export function extendAbility(builder, context, catalog, configure) {
6
4
  const restrictions = [];
7
5
  let active = true;
8
6
  const assertActive = () => {
@@ -12,8 +10,17 @@ export function extendAbility(builder, permissions, catalog, configure) {
12
10
  const rules = Object.freeze({
13
11
  can(permission, ...rule) {
14
12
  assertActive();
15
- if (!known.has(permission))
16
- throw new Error(`Unknown ability permission: ${permission}`);
13
+ if (!permission ||
14
+ typeof permission !== "object" ||
15
+ (typeof permission.user === "string") ===
16
+ (typeof permission.workspace === "string"))
17
+ throw new Error("Ability grants require exactly one user or workspace permission");
18
+ const scope = typeof permission.user === "string" ? "user" : "workspace";
19
+ const name = permission.user ?? permission.workspace;
20
+ if (typeof name !== "string")
21
+ throw new Error("Ability grants require a permission name");
22
+ if (!catalog[scope].includes(name))
23
+ throw new Error(`Unknown ${scope} ability permission: ${name}`);
17
24
  const subjects = Array.isArray(rule[1]) ? rule[1] : [rule[1]];
18
25
  if (subjects.some((target) => target === "all" ||
19
26
  entities.some((entity) => typeof target === "string"
@@ -23,7 +30,7 @@ export function extendAbility(builder, permissions, catalog, configure) {
23
30
  ("modelName" in target && target.modelName === entity.name) ||
24
31
  target.prototype instanceof entity)))
25
32
  throw new Error("Custom grants cannot target built-in auth subjects or all");
26
- if (granted.has(permission))
33
+ if (context[scope === "user" ? "userPermissions" : "workspacePermissions"].includes(name))
27
34
  addRule(builder, copyRule(rule), false);
28
35
  },
29
36
  cannot(...rule) {
@@ -1 +1 @@
1
- {"version":3,"file":"extend-ability.util.js","sourceRoot":"","sources":["../../src/utils/extend-ability.util.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,QAAQ,EAAE,MAAM,sB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/** Reads the prepared ability only while its authenticated identity is available. @internal */
3
+ export declare function readRequestAbility(): AuthAbility | null;
4
+ /** Reads the current request ability, rejecting missing identity or authorization context. */
5
+ export declare function getAbility(): AuthAbility;
@@ -0,0 +1,20 @@
1
+ import { RequestContext } from "@nest-boot/request-context";
2
+ import { ForbiddenException } from "@nestjs/common";
3
+ import { AuthAbility } from "../abilities/auth.ability.js";
4
+ import { User } from "../entities/user.entity.js";
5
+ import { getCurrentApiKey } from "./get-current-api-key.util.js";
6
+ /** Reads the prepared ability only while its authenticated identity is available. @internal */
7
+ export function readRequestAbility() {
8
+ if (!RequestContext.isActive() ||
9
+ (!RequestContext.get(User) && !getCurrentApiKey()))
10
+ return null;
11
+ return RequestContext.get(AuthAbility) ?? null;
12
+ }
13
+ /** Reads the current request ability, rejecting missing identity or authorization context. */
14
+ export function getAbility() {
15
+ const ability = readRequestAbility();
16
+ if (!ability)
17
+ throw new ForbiddenException("Permission ability is not available");
18
+ return ability;
19
+ }
20
+ //# sourceMappingURL=get-ability.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-ability.util.js","sourceRoot":"","sources":["../../src/utils/get-ability.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,+FAA+F;AAC/F,MAAM,UAAU,kBAAkB;IAChC,IACE,CAAC,cAAc,CAAC,QAAQ,EAAE;QAC1B,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAElD,OAAO,IAAI,CAAC;IACd,OAAO,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,CAAC;AACjD,CAAC;AAED,8FAA8F;AAC9F,MAAM,UAAU,UAAU;IACxB,MAAM,OAAO,GAAG,kBAAkB,EAAE,CAAC;IACrC,IAAI,CAAC,OAAO;QACV,MAAM,IAAI,kBAAkB,CAAC,qCAAqC,CAAC,CAAC;IACtE,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { AuthModuleOptions } from "../auth-module-options.interface.js";
2
+ /** Checks delegation against the shared, credential-limited permission snapshot. @internal */
3
+ export declare function canGrantPermissions(options: AuthModuleOptions, scope: "user" | "workspace", requested: readonly string[]): boolean;
4
+ /** Rejects delegation outside the caller's effective permission source. @internal */
5
+ export declare function assertCanGrantPermissions(options: AuthModuleOptions, scope: "user" | "workspace", requested: readonly string[]): void;
6
+ /** Rejects access to or delegation of keys broader than the authenticating credential. @internal */
7
+ export declare function assertApiKeyPermissionCeiling(options: AuthModuleOptions, requested: readonly string[]): void;
8
+ /** Shared subset check for configured, owner, and credential permission ceilings. @internal */
9
+ export declare function assertPermissionCeiling(requested: readonly string[], allowed: readonly string[], message: string): void;
@@ -0,0 +1,25 @@
1
+ import { ForbiddenException } from "@nestjs/common";
2
+ import { resolveRequestPermissions } from "./resolve-request-permissions.util.js";
3
+ /** Checks delegation against the shared, credential-limited permission snapshot. @internal */
4
+ export function canGrantPermissions(options, scope, requested) {
5
+ const allowed = new Set(resolveRequestPermissions(options)[scope]);
6
+ return requested.every((permission) => allowed.has(permission));
7
+ }
8
+ /** Rejects delegation outside the caller's effective permission source. @internal */
9
+ export function assertCanGrantPermissions(options, scope, requested) {
10
+ assertPermissionCeiling(requested, resolveRequestPermissions(options)[scope], `${scope === "user" ? "User" : "Workspace"} permissions exceed issuer permissions`);
11
+ }
12
+ /** Rejects access to or delegation of keys broader than the authenticating credential. @internal */
13
+ export function assertApiKeyPermissionCeiling(options, requested) {
14
+ const ceiling = resolveRequestPermissions(options).apiKey;
15
+ if (ceiling !== null)
16
+ assertPermissionCeiling(requested, ceiling, "API key permissions exceed authenticating API key permissions");
17
+ }
18
+ /** Shared subset check for configured, owner, and credential permission ceilings. @internal */
19
+ export function assertPermissionCeiling(requested, allowed, message) {
20
+ const permissions = new Set(allowed);
21
+ const excessive = requested.filter((permission) => !permissions.has(permission));
22
+ if (excessive.length)
23
+ throw new ForbiddenException(`${message}: ${excessive.join(", ")}`);
24
+ }
25
+ //# sourceMappingURL=permission-grants.util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permission-grants.util.js","sourceRoot":"","sources":["../../src/utils/permission-grants.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAElF,8FAA8F;AAC9F,MAAM,UAAU,mBAAmB,CACjC,OAA0B,EAC1B,KAA2B,EAC3B,SAA4B;IAE5B,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,OAAO,SAAS,CAAC,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,yBAAyB,CACvC,OAA0B,EAC1B,KAA2B,EAC3B,SAA4B;IAE5B,uBAAuB,CACrB,SAAS,EACT,yBAAyB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,EACzC,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,wCAAwC,CACnF,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,6BAA6B,CAC3C,OAA0B,EAC1B,SAA4B;IAE5B,MAAM,OAAO,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;IAC1D,IAAI,OAAO,KAAK,IAAI;QAClB,uBAAuB,CACrB,SAAS,EACT,OAAO,EACP,+DAA+D,CAChE,CAAC;AACN,CAAC;AAED,+FAA+F;AAC/F,MAAM,UAAU,uBAAuB,CACrC,SAA4B,EAC5B,OAA0B,EAC1B,OAAe;IAEf,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAChC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,CAC7C,CAAC;IACF,IAAI,SAAS,CAAC,MAAM;QAClB,MAAM,IAAI,kBAAkB,CAAC,GAAG,OAAO,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC"}
@@ -3,13 +3,13 @@ export declare const DEFAULT_WORKSPACE_ROLE = "member";
3
3
  /** Role assigned to workspace creators by default. */
4
4
  export declare const DEFAULT_WORKSPACE_CREATOR_ROLE = "owner";
5
5
  /** Permissions available to the default workspace roles. */
6
- export declare const DEFAULT_WORKSPACE_PERMISSIONS: readonly ["workspace:update", "workspace:delete", "member:create", "member:update", "member:delete", "invitation:create", "invitation:cancel", "api-key:read", "api-key:create", "api-key:update", "api-key:delete"];
7
- /** Default workspace roles modelled after Better Auth's organization access control. */
6
+ export declare const DEFAULT_WORKSPACE_PERMISSIONS: readonly ["workspace:read", "workspace:update", "workspace:delete", "member:read", "member:write", "member:set-roles", "member:set-permissions", "member:invite", "workspace-api-key:read", "workspace-api-key:write"];
7
+ /** Explicit grants for workspace administration and ordinary membership. */
8
8
  export declare const DEFAULT_WORKSPACE_ROLES: {
9
9
  /** Grants every default workspace permission. */
10
- readonly owner: readonly ["workspace:update", "workspace:delete", "member:create", "member:update", "member:delete", "invitation:create", "invitation:cancel", "api-key:read", "api-key:create", "api-key:update", "api-key:delete"];
11
- /** Grants workspace administration except workspace deletion. */
12
- readonly admin: readonly ["workspace:update", "member:create", "member:update", "member:delete", "invitation:create", "invitation:cancel"];
13
- /** Grants no workspace-administration permissions. */
14
- readonly member: readonly [];
10
+ readonly owner: readonly ["workspace:read", "workspace:update", "workspace:delete", "member:read", "member:write", "member:set-roles", "member:set-permissions", "member:invite", "workspace-api-key:read", "workspace-api-key:write"];
11
+ /** Grants membership/invitation administration without workspace deletion or key management. */
12
+ readonly admin: readonly ["workspace:read", "workspace:update", "member:read", "member:write", "member:set-roles", "member:set-permissions", "member:invite"];
13
+ /** Allows members to read workspace and member profiles, but not invitations. */
14
+ readonly member: readonly ["workspace:read", "member:read"];
15
15
  };
@@ -4,32 +4,32 @@ export const DEFAULT_WORKSPACE_ROLE = "member";
4
4
  export const DEFAULT_WORKSPACE_CREATOR_ROLE = "owner";
5
5
  /** Permissions available to the default workspace roles. */
6
6
  export const DEFAULT_WORKSPACE_PERMISSIONS = [
7
+ "workspace:read",
7
8
  "workspace:update",
8
9
  "workspace:delete",
9
- "member:create",
10
- "member:update",
11
- "member:delete",
12
- "invitation:create",
13
- "invitation:cancel",
14
- "api-key:read",
15
- "api-key:create",
16
- "api-key:update",
17
- "api-key:delete",
10
+ "member:read",
11
+ "member:write",
12
+ "member:set-roles",
13
+ "member:set-permissions",
14
+ "member:invite",
15
+ "workspace-api-key:read",
16
+ "workspace-api-key:write",
18
17
  ];
19
- /** Default workspace roles modelled after Better Auth's organization access control. */
18
+ /** Explicit grants for workspace administration and ordinary membership. */
20
19
  export const DEFAULT_WORKSPACE_ROLES = {
21
20
  /** Grants every default workspace permission. */
22
21
  owner: DEFAULT_WORKSPACE_PERMISSIONS,
23
- /** Grants workspace administration except workspace deletion. */
22
+ /** Grants membership/invitation administration without workspace deletion or key management. */
24
23
  admin: [
24
+ "workspace:read",
25
25
  "workspace:update",
26
- "member:create",
27
- "member:update",
28
- "member:delete",
29
- "invitation:create",
30
- "invitation:cancel",
26
+ "member:read",
27
+ "member:write",
28
+ "member:set-roles",
29
+ "member:set-permissions",
30
+ "member:invite",
31
31
  ],
32
- /** Grants no workspace-administration permissions. */
33
- member: [],
32
+ /** Allows members to read workspace and member profiles, but not invitations. */
33
+ member: ["workspace:read", "member:read"],
34
34
  };
35
35
  //# sourceMappingURL=workspace.constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.constants.js","sourceRoot":"","sources":["../src/workspace.constants.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAE/C,sDAAsD;AACtD,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAC;AAEtD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,kBAAkB;IAClB,kBAAkB;IAClB,eAAe;IACf,eAAe;IACf,eAAe;IACf,mBAAmB;IACnB,mBAAmB;IACnB,cAAc;IACd,gBAAgB;IAChB,gBAAgB;IAChB,gBAAgB;CACR,CAAC;AAEX,wFAAwF;AACxF,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iDAAiD;IACjD,KAAK,EAAE,6BAA6B;IACpC,iEAAiE;IACjE,KAAK,EAAE;QACL,kBAAkB;QAClB,eAAe;QACf,eAAe;QACf,eAAe;QACf,mBAAmB;QACnB,mBAAmB;KACpB;IACD,sDAAsD;IACtD,MAAM,EAAE,EAAE;CACwB,CAAC"}
1
+ {"version":3,"file":"workspace.constants.js","sourceRoot":"","sources":["../src/workspace.constants.ts"],"names":[],"mappings":"AAEA,6DAA6D;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAE/C,sDAAsD;AACtD,MAAM,CAAC,MAAM,8BAA8B,GAAG,OAAO,CAAC;AAEtD,4DAA4D;AAC5D,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC3C,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB;IAClB,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,wBAAwB;IACxB,eAAe;IACf,wBAAwB;IACxB,yBAAyB;CACjB,CAAC;AAEX,4EAA4E;AAC5E,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,iDAAiD;IACjD,KAAK,EAAE,6BAA6B;IACpC,gGAAgG;IAChG,KAAK,EAAE;QACL,gBAAgB;QAChB,kBAAkB;QAClB,aAAa;QACb,cAAc;QACd,kBAAkB;QAClB,wBAAwB;QACxB,eAAe;KAChB;IACD,iFAAiF;IACjF,MAAM,EAAE,CAAC,gBAAgB,EAAE,aAAa,CAAC;CACP,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-boot/auth",
3
- "version": "8.0.5-beta.2",
3
+ "version": "8.0.5-beta.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/nest-boot/nest-boot.git",
@@ -51,16 +51,16 @@
51
51
  "@nestjs/graphql": "^14.0.0",
52
52
  "graphql": "^16.11.0",
53
53
  "zod": "^4.3.6",
54
- "@nest-boot/eslint-config": "^8.0.1-beta.0",
55
54
  "@nest-boot/eslint-plugin": "^8.0.1-beta.0",
56
- "@nest-boot/graphql-connection": "^8.0.1-beta.3",
55
+ "@nest-boot/eslint-config": "^8.0.1-beta.0",
57
56
  "@nest-boot/hash": "^8.0.1-beta.0",
58
57
  "@nest-boot/mailer": "^8.0.1-beta.0",
58
+ "@nest-boot/graphql-connection": "^8.0.1-beta.3",
59
59
  "@nest-boot/middleware": "^8.0.1-beta.0",
60
60
  "@nest-boot/request-context": "^8.0.1-beta.0",
61
61
  "@nest-boot/tsconfig": "^8.0.0-beta.4",
62
- "@nest-boot/validator": "^8.0.4-beta.0",
63
- "@nest-boot/graphql": "^8.0.1-beta.0"
62
+ "@nest-boot/graphql": "^8.0.1-beta.0",
63
+ "@nest-boot/validator": "^8.0.4-beta.0"
64
64
  },
65
65
  "peerDependencies": {
66
66
  "@casl/ability": "^7.0.0",
@@ -77,12 +77,12 @@
77
77
  "graphql": "^16.0.0",
78
78
  "zod": "^4.0.0",
79
79
  "@nest-boot/graphql-connection": "^8.0.1-beta.3",
80
+ "@nest-boot/hash": "^8.0.1-beta.0",
80
81
  "@nest-boot/mailer": "^8.0.1-beta.0",
82
+ "@nest-boot/middleware": "^8.0.1-beta.0",
81
83
  "@nest-boot/request-context": "^8.0.1-beta.0",
82
- "@nest-boot/validator": "^8.0.4-beta.0",
83
- "@nest-boot/hash": "^8.0.1-beta.0",
84
84
  "@nest-boot/graphql": "^8.0.1-beta.0",
85
- "@nest-boot/middleware": "^8.0.1-beta.0"
85
+ "@nest-boot/validator": "^8.0.4-beta.0"
86
86
  },
87
87
  "publishConfig": {
88
88
  "access": "public"
@@ -1,8 +0,0 @@
1
- import { Ability, type AbilityOptions, type AbilityTuple, type MongoQuery, type RawRuleFrom } from "@casl/ability";
2
- /** CASL ability containing user-scoped authorization rules. */
3
- export declare class UserAbility extends Ability<AbilityTuple, MongoQuery> {
4
- /** Keeps user and workspace abilities nominally distinct. */
5
- private readonly userAbilityBrand;
6
- /** Creates a user ability with CASL's Mongo-style condition matching. */
7
- constructor(rules?: RawRuleFrom<AbilityTuple, MongoQuery>[], options?: AbilityOptions<AbilityTuple, MongoQuery>);
8
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"user.ability.js","sourceRoot":"","sources":["../../src/abilities/user.ability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAGP,mBAAmB,EAEnB,iBAAiB,GAElB,MAAM,eAAe,CAAC;AAEvB,+DAA+D;AAC/D,MAAM,OAAO,WAAY,SAAQ,OAAiC;IAIhE,yEAAyE;IACzE,YACE,QAAiD,EAAE,EACnD,UAAoD,EAAE;QAEtD,KAAK,CAAC,KAAK,EAAE;YACX,iBAAiB,EAAE,iBAAiB;YACpC,YAAY,EAAE,mBAAmB;YACjC,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,8 +0,0 @@
1
- import { Ability, type AbilityOptions, type AbilityTuple, type MongoQuery, type RawRuleFrom } from "@casl/ability";
2
- /** CASL ability containing workspace-scoped authorization rules. */
3
- export declare class WorkspaceAbility extends Ability<AbilityTuple, MongoQuery> {
4
- /** Keeps workspace and user abilities nominally distinct. */
5
- private readonly workspaceAbilityBrand;
6
- /** Creates a workspace ability with CASL's Mongo-style condition matching. */
7
- constructor(rules?: RawRuleFrom<AbilityTuple, MongoQuery>[], options?: AbilityOptions<AbilityTuple, MongoQuery>);
8
- }
@@ -1,13 +0,0 @@
1
- import { Ability, fieldPatternMatcher, mongoQueryMatcher, } from "@casl/ability";
2
- /** CASL ability containing workspace-scoped authorization rules. */
3
- export class WorkspaceAbility extends Ability {
4
- /** Creates a workspace ability with CASL's Mongo-style condition matching. */
5
- constructor(rules = [], options = {}) {
6
- super(rules, {
7
- conditionsMatcher: mongoQueryMatcher,
8
- fieldMatcher: fieldPatternMatcher,
9
- ...options,
10
- });
11
- }
12
- }
13
- //# sourceMappingURL=workspace.ability.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace.ability.js","sourceRoot":"","sources":["../../src/abilities/workspace.ability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EAGP,mBAAmB,EAEnB,iBAAiB,GAElB,MAAM,eAAe,CAAC;AAEvB,oEAAoE;AACpE,MAAM,OAAO,gBAAiB,SAAQ,OAAiC;IAIrE,8EAA8E;IAC9E,YACE,QAAiD,EAAE,EACnD,UAAoD,EAAE;QAEtD,KAAK,CAAC,KAAK,EAAE;YACX,iBAAiB,EAAE,iBAAiB;YACpC,YAAY,EAAE,mBAAmB;YACjC,GAAG,OAAO;SACX,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -1,13 +0,0 @@
1
- import type { Subject } from "@casl/ability";
2
- import type { CustomDecorator } from "@nestjs/common";
3
- import { USER_CAN_METADATA } from "../permission.constants.js";
4
- import type { CanSubject } from "../types/can-subject.type.js";
5
- /**
6
- * Declares a permission required in the user authorization scope. When this
7
- * decorator is repeated, every declared permission must be allowed.
8
- *
9
- * @param action - Permission action that must be allowed.
10
- * @param subject - Permission subject type or subject resolver factory to check.
11
- * @returns Nest custom metadata decorator.
12
- */
13
- export declare function UserCan<T extends Subject = Subject>(action: string, subject: CanSubject<T>): CustomDecorator<typeof USER_CAN_METADATA>;