@nest-boot/auth 8.0.5-beta.3 → 8.0.5-beta.5

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 (158) hide show
  1. package/README.md +27 -7
  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 +3 -100
  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 +23 -21
  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/better-auth-adapter.d.ts +13 -0
  43. package/dist/infrastructure/better-auth-adapter.js +9 -0
  44. package/dist/infrastructure/better-auth-adapter.js.map +1 -0
  45. package/dist/infrastructure/create-auth-instance.d.ts +10 -0
  46. package/dist/infrastructure/create-auth-instance.js +105 -0
  47. package/dist/infrastructure/create-auth-instance.js.map +1 -0
  48. package/dist/infrastructure/request-identity.d.ts +16 -4
  49. package/dist/infrastructure/request-identity.js +61 -40
  50. package/dist/infrastructure/request-identity.js.map +1 -1
  51. package/dist/interfaces/ability-context.interface.d.ts +16 -0
  52. package/dist/interfaces/ability-context.interface.js +2 -0
  53. package/dist/interfaces/ability-context.interface.js.map +1 -0
  54. package/dist/interfaces/ability-rules.interface.d.ts +8 -2
  55. package/dist/interfaces/auth-module-user-options.interface.d.ts +0 -3
  56. package/dist/interfaces/auth-module-workspace-options.interface.d.ts +0 -3
  57. package/dist/interfaces/{user-can-metadata.interface.d.ts → can-metadata.interface.d.ts} +2 -2
  58. package/dist/interfaces/can-metadata.interface.js +2 -0
  59. package/dist/interfaces/can-metadata.interface.js.map +1 -0
  60. package/dist/permission.constants.d.ts +2 -4
  61. package/dist/permission.constants.js +2 -4
  62. package/dist/permission.constants.js.map +1 -1
  63. package/dist/resolvers/auth.resolver.d.ts +2 -4
  64. package/dist/resolvers/auth.resolver.js +5 -16
  65. package/dist/resolvers/auth.resolver.js.map +1 -1
  66. package/dist/services/account.service.d.ts +1 -3
  67. package/dist/services/account.service.js +4 -7
  68. package/dist/services/account.service.js.map +1 -1
  69. package/dist/services/auth.service.js +2 -1
  70. package/dist/services/auth.service.js.map +1 -1
  71. package/dist/services/invitation.service.d.ts +1 -3
  72. package/dist/services/invitation.service.js +32 -32
  73. package/dist/services/invitation.service.js.map +1 -1
  74. package/dist/services/member.service.d.ts +1 -3
  75. package/dist/services/member.service.js +50 -51
  76. package/dist/services/member.service.js.map +1 -1
  77. package/dist/services/session.service.d.ts +1 -4
  78. package/dist/services/session.service.js +13 -16
  79. package/dist/services/session.service.js.map +1 -1
  80. package/dist/services/user-api-key.service.d.ts +3 -7
  81. package/dist/services/user-api-key.service.js +52 -73
  82. package/dist/services/user-api-key.service.js.map +1 -1
  83. package/dist/services/user-deletion.service.js.map +1 -1
  84. package/dist/services/user.service.d.ts +1 -3
  85. package/dist/services/user.service.js +38 -42
  86. package/dist/services/user.service.js.map +1 -1
  87. package/dist/services/workspace-api-key.service.d.ts +3 -7
  88. package/dist/services/workspace-api-key.service.js +50 -71
  89. package/dist/services/workspace-api-key.service.js.map +1 -1
  90. package/dist/services/workspace.service.d.ts +1 -3
  91. package/dist/services/workspace.service.js +22 -24
  92. package/dist/services/workspace.service.js.map +1 -1
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/types/build-ability-callback.type.d.ts +4 -0
  95. package/dist/types/build-ability-callback.type.js +2 -0
  96. package/dist/types/build-ability-callback.type.js.map +1 -0
  97. package/dist/utils/api-key-permissions.util.d.ts +2 -0
  98. package/dist/utils/api-key-permissions.util.js +9 -0
  99. package/dist/utils/api-key-permissions.util.js.map +1 -1
  100. package/dist/utils/assert-can.util.d.ts +3 -0
  101. package/dist/utils/assert-can.util.js +8 -0
  102. package/dist/utils/assert-can.util.js.map +1 -0
  103. package/dist/utils/build-request-ability.util.d.ts +3 -6
  104. package/dist/utils/build-request-ability.util.js +25 -15
  105. package/dist/utils/build-request-ability.util.js.map +1 -1
  106. package/dist/utils/can.util.d.ts +2 -3
  107. package/dist/utils/can.util.js +9 -7
  108. package/dist/utils/can.util.js.map +1 -1
  109. package/dist/utils/extend-ability.util.d.ts +5 -1
  110. package/dist/utils/extend-ability.util.js +13 -6
  111. package/dist/utils/extend-ability.util.js.map +1 -1
  112. package/dist/utils/get-ability.util.d.ts +5 -0
  113. package/dist/utils/get-ability.util.js +20 -0
  114. package/dist/utils/get-ability.util.js.map +1 -0
  115. package/dist/utils/permission-grants.util.d.ts +9 -0
  116. package/dist/utils/permission-grants.util.js +25 -0
  117. package/dist/utils/permission-grants.util.js.map +1 -0
  118. package/package.json +8 -8
  119. package/dist/abilities/user.ability.d.ts +0 -8
  120. package/dist/abilities/user.ability.js.map +0 -1
  121. package/dist/abilities/workspace.ability.d.ts +0 -8
  122. package/dist/abilities/workspace.ability.js +0 -13
  123. package/dist/abilities/workspace.ability.js.map +0 -1
  124. package/dist/decorators/user-can.decorator.d.ts +0 -13
  125. package/dist/decorators/user-can.decorator.js +0 -21
  126. package/dist/decorators/user-can.decorator.js.map +0 -1
  127. package/dist/decorators/workspace-can.decorator.d.ts +0 -13
  128. package/dist/decorators/workspace-can.decorator.js +0 -21
  129. package/dist/decorators/workspace-can.decorator.js.map +0 -1
  130. package/dist/interfaces/can-options.interface.d.ts +0 -5
  131. package/dist/interfaces/can-options.interface.js +0 -2
  132. package/dist/interfaces/can-options.interface.js.map +0 -1
  133. package/dist/interfaces/user-can-metadata.interface.js +0 -2
  134. package/dist/interfaces/user-can-metadata.interface.js.map +0 -1
  135. package/dist/interfaces/workspace-can-metadata.interface.d.ts +0 -9
  136. package/dist/interfaces/workspace-can-metadata.interface.js +0 -2
  137. package/dist/interfaces/workspace-can-metadata.interface.js.map +0 -1
  138. package/dist/services/access-control.service.d.ts +0 -54
  139. package/dist/services/access-control.service.js +0 -208
  140. package/dist/services/access-control.service.js.map +0 -1
  141. package/dist/types/build-user-ability-callback.type.d.ts +0 -10
  142. package/dist/types/build-user-ability-callback.type.js +0 -2
  143. package/dist/types/build-user-ability-callback.type.js.map +0 -1
  144. package/dist/types/build-workspace-ability-callback.type.d.ts +0 -10
  145. package/dist/types/build-workspace-ability-callback.type.js +0 -2
  146. package/dist/types/build-workspace-ability-callback.type.js.map +0 -1
  147. package/dist/utils/get-user-ability.util.d.ts +0 -3
  148. package/dist/utils/get-user-ability.util.js +0 -14
  149. package/dist/utils/get-user-ability.util.js.map +0 -1
  150. package/dist/utils/get-workspace-ability.util.d.ts +0 -3
  151. package/dist/utils/get-workspace-ability.util.js +0 -14
  152. package/dist/utils/get-workspace-ability.util.js.map +0 -1
  153. package/dist/utils/user-can.util.d.ts +0 -3
  154. package/dist/utils/user-can.util.js +0 -9
  155. package/dist/utils/user-can.util.js.map +0 -1
  156. package/dist/utils/workspace-can.util.d.ts +0 -3
  157. package/dist/utils/workspace-can.util.js +0 -10
  158. package/dist/utils/workspace-can.util.js.map +0 -1
@@ -1,208 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { Reference } from "@mikro-orm/core";
14
- import { RequestContext } from "@nest-boot/request-context";
15
- import { ForbiddenException, Inject, Injectable } from "@nestjs/common";
16
- import { UserAbility } from "../abilities/user.ability.js";
17
- import { WorkspaceAbility } from "../abilities/workspace.ability.js";
18
- import { MODULE_OPTIONS_TOKEN } from "../auth.module-definition.js";
19
- import { Member } from "../entities/member.entity.js";
20
- import { Session } from "../entities/session.entity.js";
21
- import { User } from "../entities/user.entity.js";
22
- import { UserApiKey } from "../entities/user-api-key.entity.js";
23
- import { Workspace } from "../entities/workspace.entity.js";
24
- import { WorkspaceApiKey } from "../entities/workspace-api-key.entity.js";
25
- import { getCurrentApiKey } from "../utils/get-current-api-key.util.js";
26
- import { resolveRequestPermissions } from "../utils/resolve-request-permissions.util.js";
27
- /** Enforces user and workspace permissions prepared for the current request. */
28
- let AccessControlService = class AccessControlService {
29
- options;
30
- /** Creates the authorization service. */
31
- constructor(options) {
32
- this.options = options;
33
- }
34
- /** Returns whether the current principal may perform a user-scoped action. */
35
- userCan(action, subject) {
36
- return this.getUserAbility()?.can(action, subject) ?? false;
37
- }
38
- /** Returns the prepared ability only while its user identity is available. */
39
- getUserAbility() {
40
- if (!RequestContext.isActive())
41
- return null;
42
- const user = RequestContext.get(User);
43
- const apiKey = getCurrentApiKey();
44
- if (!user || (apiKey && this.isWorkspaceApiKey(apiKey)))
45
- return null;
46
- return RequestContext.get(UserAbility) ?? null;
47
- }
48
- /** Throws unless the current principal may perform a user-scoped action. */
49
- assertUserCan(action, subject) {
50
- if (!this.userCan(action, subject)) {
51
- throw new ForbiddenException(`You are not allowed to ${action} this user-scoped resource`);
52
- }
53
- }
54
- /** Returns whether the current principal may perform a workspace action. */
55
- workspaceCan(action, subject) {
56
- return this.getWorkspaceAbility()?.can(action, subject) ?? false;
57
- }
58
- /** Returns the prepared ability only while its workspace identity is available. */
59
- getWorkspaceAbility() {
60
- if (!RequestContext.isActive() || !RequestContext.get(Workspace))
61
- return null;
62
- const apiKey = getCurrentApiKey();
63
- const workspaceApiKey = apiKey && this.isWorkspaceApiKey(apiKey);
64
- const member = RequestContext.get(Member);
65
- if (!workspaceApiKey && !member)
66
- return null;
67
- return RequestContext.get(WorkspaceAbility) ?? null;
68
- }
69
- /** Throws unless the current principal may perform a workspace action. */
70
- assertWorkspaceCan(action, subject) {
71
- if (!this.workspaceCan(action, subject)) {
72
- throw new ForbiddenException(`You are not allowed to ${action} this workspace resource`);
73
- }
74
- }
75
- /** Throws unless the supplied user is the authenticated user. */
76
- assertCurrentUser(user) {
77
- const currentUser = RequestContext.isActive()
78
- ? RequestContext.get(User)
79
- : undefined;
80
- if (!currentUser || String(currentUser.id) !== String(user.id)) {
81
- throw new ForbiddenException("The operation belongs to another user");
82
- }
83
- }
84
- /** Authorizes an explicit self-service path without granting a general resource ability. */
85
- assertUserSession(user) {
86
- this.assertCurrentUser(user);
87
- if (getCurrentApiKey()) {
88
- throw new ForbiddenException("This self-service operation requires a user session");
89
- }
90
- }
91
- /** Throws unless the supplied session is the authenticated session. */
92
- assertCurrentSession(session) {
93
- const currentSession = RequestContext.isActive()
94
- ? RequestContext.get(Session)
95
- : undefined;
96
- if (currentSession?.token !== session.token) {
97
- throw new ForbiddenException("The operation belongs to another session");
98
- }
99
- }
100
- /** Throws unless the supplied workspace is selected for the current request. */
101
- assertCurrentWorkspace(workspace) {
102
- const currentWorkspace = RequestContext.isActive()
103
- ? RequestContext.get(Workspace)
104
- : undefined;
105
- if (!currentWorkspace ||
106
- String(currentWorkspace.id) !== String(workspace.id)) {
107
- throw new ForbiddenException("The operation belongs to another workspace");
108
- }
109
- }
110
- /** Throws unless the supplied member is the current workspace member. */
111
- assertCurrentMember(member) {
112
- const currentMember = RequestContext.isActive()
113
- ? RequestContext.get(Member)
114
- : undefined;
115
- if (!member ||
116
- !currentMember ||
117
- String(currentMember.id) !== String(member.id)) {
118
- throw new ForbiddenException("The operation belongs to another workspace member");
119
- }
120
- }
121
- /** Throws when a user grant exceeds the current principal's permissions. */
122
- assertCanGrantUserPermissions(requestedPermissions) {
123
- const allowed = new Set(this.getUserGrantPermissions());
124
- const excessive = requestedPermissions.filter((permission) => !allowed.has(permission));
125
- if (excessive.length > 0) {
126
- throw new ForbiddenException(`User permissions exceed issuer permissions: ${excessive.join(", ")}`);
127
- }
128
- }
129
- /** Checks the same grant ceiling used when assigning user permissions. */
130
- canGrantUserPermissions(requestedPermissions) {
131
- const allowed = new Set(this.getUserGrantPermissions());
132
- return requestedPermissions.every((permission) => allowed.has(permission));
133
- }
134
- getUserGrantPermissions() {
135
- return resolveRequestPermissions(this.options).user;
136
- }
137
- /** Throws when a workspace grant exceeds the current principal's permissions. */
138
- assertCanGrantWorkspacePermissions(requestedPermissions) {
139
- const allowed = new Set(this.getWorkspaceGrantPermissions());
140
- const excessive = requestedPermissions.filter((permission) => !allowed.has(permission));
141
- if (excessive.length > 0) {
142
- throw new ForbiddenException(`Workspace permissions exceed issuer permissions: ${excessive.join(", ")}`);
143
- }
144
- }
145
- /** Checks the same grant ceiling used when assigning workspace permissions. */
146
- canGrantWorkspacePermissions(requestedPermissions) {
147
- const allowed = new Set(this.getWorkspaceGrantPermissions());
148
- return requestedPermissions.every((permission) => allowed.has(permission));
149
- }
150
- getWorkspaceGrantPermissions() {
151
- return resolveRequestPermissions(this.options).workspace;
152
- }
153
- /** Rejects access to or delegation of credentials broader than the authenticating API key. */
154
- assertApiKeyPermissionCeiling(permissions) {
155
- const ceiling = this.getApiKeyPermissionCeiling();
156
- if (ceiling === null)
157
- return;
158
- const allowed = new Set(ceiling);
159
- const excessive = permissions.filter((permission) => !allowed.has(permission));
160
- if (excessive.length > 0) {
161
- throw new ForbiddenException(`API key permissions exceed authenticating API key permissions: ${excessive.join(", ")}`);
162
- }
163
- }
164
- /** Returns the credential ceiling shared by API-key queries, options, and writes. */
165
- getApiKeyPermissionCeiling() {
166
- return resolveRequestPermissions(this.options).apiKey;
167
- }
168
- /** Checks API-key ownership independently of the application's database policies. */
169
- assertApiKeyOwner(apiKey) {
170
- const ownerReference = apiKey instanceof UserApiKey ? apiKey.user : apiKey.workspace;
171
- if (!ownerReference) {
172
- throw new ForbiddenException("API key owner is missing");
173
- }
174
- const owner = Reference.unwrapReference(ownerReference);
175
- if (owner instanceof User) {
176
- this.assertCurrentUser(owner);
177
- return;
178
- }
179
- if (!(owner instanceof Workspace)) {
180
- throw new ForbiddenException("Unknown API key owner");
181
- }
182
- this.assertCurrentWorkspace(owner);
183
- const currentKey = RequestContext.isActive() ? getCurrentApiKey() : null;
184
- if (currentKey instanceof WorkspaceApiKey) {
185
- if (String(currentKey.workspace?.id) !== String(owner.id)) {
186
- throw new ForbiddenException("API key belongs to another workspace");
187
- }
188
- return;
189
- }
190
- const member = RequestContext.isActive()
191
- ? RequestContext.get(Member)
192
- : null;
193
- if (member?.status !== "ACTIVE" ||
194
- String(member.workspace.id) !== String(owner.id)) {
195
- throw new ForbiddenException("An active workspace member is required");
196
- }
197
- }
198
- isWorkspaceApiKey(apiKey) {
199
- return apiKey instanceof WorkspaceApiKey;
200
- }
201
- };
202
- AccessControlService = __decorate([
203
- Injectable(),
204
- __param(0, Inject(MODULE_OPTIONS_TOKEN)),
205
- __metadata("design:paramtypes", [Object])
206
- ], AccessControlService);
207
- export { AccessControlService };
208
- //# sourceMappingURL=access-control.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"access-control.service.js","sourceRoot":"","sources":["../../src/services/access-control.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,C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,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,IAAI,CAAC,CAAC,KAAK,YAAY,SAAS,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,kBAAkB,CAAC,uBAAuB,CAAC,CAAC;QACxD,CAAC;QACD,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACnC,MAAM,UAAU,GAAG,cAAc,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACzE,IAAI,UAAU,YAAY,eAAe,EAAE,CAAC;YAC1C,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC1D,MAAM,IAAI,kBAAkB,CAAC,sCAAsC,CAAC,CAAC;YACvE,CAAC;YACD,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,cAAc,CAAC,QAAQ,EAAE;YACtC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC;YAC5B,CAAC,CAAC,IAAI,CAAC;QACT,IACE,MAAM,EAAE,MAAM,KAAK,QAAQ;YAC3B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,EAChD,CAAC;YACD,MAAM,IAAI,kBAAkB,CAAC,wCAAwC,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAEO,iBAAiB,CAAC,MAAc;QACtC,OAAO,MAAM,YAAY,eAAe,CAAC;IAC3C,CAAC;CACF,CAAA;AArOY,oBAAoB;IADhC,UAAU,EAAE;IAIR,WAAA,MAAM,CAAC,oBAAoB,CAAC,CAAA;;GAHpB,oBAAoB,CAqOhC"}
@@ -1,10 +0,0 @@
1
- import type { User } from "../entities/user.entity.js";
2
- import type { AbilityRules } from "../interfaces/ability-rules.interface.js";
3
- /** Synchronously extends business abilities and restricts built-in abilities. */
4
- export type BuildUserAbilityCallback<Permission extends string = string> = (
5
- /** Permission-bound business grants and additional restrictions. */
6
- rules: AbilityRules<Permission>,
7
- /** Deduplicated permissions resolved from the user's roles and direct grants. */
8
- permissions: readonly Permission[],
9
- /** User authenticated for the current request. */
10
- user: User) => void;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=build-user-ability-callback.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-user-ability-callback.type.js","sourceRoot":"","sources":["../../src/types/build-user-ability-callback.type.ts"],"names":[],"mappings":""}
@@ -1,10 +0,0 @@
1
- import type { Workspace } from "../entities/workspace.entity.js";
2
- import type { AbilityRules } from "../interfaces/ability-rules.interface.js";
3
- /** Synchronously extends business abilities and restricts built-in abilities. */
4
- export type BuildWorkspaceAbilityCallback<Permission extends string = string> = (
5
- /** Permission-bound business grants and additional restrictions. */
6
- rules: AbilityRules<Permission>,
7
- /** Deduplicated permissions resolved from the membership's roles and direct grants. */
8
- permissions: readonly Permission[],
9
- /** Workspace selected for the current request. */
10
- workspace: Workspace) => void;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=build-workspace-ability-callback.type.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-workspace-ability-callback.type.js","sourceRoot":"","sources":["../../src/types/build-workspace-ability-callback.type.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import type { UserAbility } from "../abilities/user.ability.js";
2
- /** Reads the user ability prepared for the current request. */
3
- export declare function getUserAbility(): UserAbility;
@@ -1,14 +0,0 @@
1
- import { RequestContext } from "@nest-boot/request-context";
2
- import { ForbiddenException } from "@nestjs/common";
3
- import { AccessControlService } from "../services/access-control.service.js";
4
- /** Reads the user ability prepared for the current request. */
5
- export function getUserAbility() {
6
- const ability = RequestContext.isActive()
7
- ? RequestContext.get(AccessControlService)?.getUserAbility()
8
- : null;
9
- if (!ability) {
10
- throw new ForbiddenException("User permission ability is not available");
11
- }
12
- return ability;
13
- }
14
- //# sourceMappingURL=get-user-ability.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-user-ability.util.js","sourceRoot":"","sources":["../../src/utils/get-user-ability.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,+DAA+D;AAC/D,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE;QACvC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,cAAc,EAAE;QAC5D,CAAC,CAAC,IAAI,CAAC;IAET,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAAC,0CAA0C,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { WorkspaceAbility } from "../abilities/workspace.ability.js";
2
- /** Reads the workspace ability prepared for the current request. */
3
- export declare function getWorkspaceAbility(): WorkspaceAbility;
@@ -1,14 +0,0 @@
1
- import { RequestContext } from "@nest-boot/request-context";
2
- import { ForbiddenException } from "@nestjs/common";
3
- import { AccessControlService } from "../services/access-control.service.js";
4
- /** Reads the workspace ability prepared for the current request. */
5
- export function getWorkspaceAbility() {
6
- const ability = RequestContext.isActive()
7
- ? RequestContext.get(AccessControlService)?.getWorkspaceAbility()
8
- : null;
9
- if (!ability) {
10
- throw new ForbiddenException("Workspace permission ability is not available");
11
- }
12
- return ability;
13
- }
14
- //# sourceMappingURL=get-workspace-ability.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-workspace-ability.util.js","sourceRoot":"","sources":["../../src/utils/get-workspace-ability.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,oEAAoE;AACpE,MAAM,UAAU,mBAAmB;IACjC,MAAM,OAAO,GAAG,cAAc,CAAC,QAAQ,EAAE;QACvC,CAAC,CAAC,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,mBAAmB,EAAE;QACjE,CAAC,CAAC,IAAI,CAAC;IAET,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAC1B,+CAA+C,CAChD,CAAC;IACJ,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Subject } from "@casl/ability";
2
- /** Checks a permission with the user ability prepared for the current request. */
3
- export declare function userCan(action: string, subject: Subject): boolean;
@@ -1,9 +0,0 @@
1
- import { RequestContext } from "@nest-boot/request-context";
2
- import { AccessControlService } from "../services/access-control.service.js";
3
- /** Checks a permission with the user ability prepared for the current request. */
4
- export function userCan(action, subject) {
5
- if (!RequestContext.isActive())
6
- return false;
7
- return (RequestContext.get(AccessControlService)?.userCan(action, subject) ?? false);
8
- }
9
- //# sourceMappingURL=user-can.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"user-can.util.js","sourceRoot":"","sources":["../../src/utils/user-can.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,kFAAkF;AAClF,MAAM,UAAU,OAAO,CAAC,MAAc,EAAE,OAAgB;IACtD,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE;QAAE,OAAO,KAAK,CAAC;IAE7C,OAAO,CACL,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,KAAK,CAC5E,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { Subject } from "@casl/ability";
2
- /** Checks a permission with the workspace ability prepared for the request. */
3
- export declare function workspaceCan(action: string, subject: Subject): boolean;
@@ -1,10 +0,0 @@
1
- import { RequestContext } from "@nest-boot/request-context";
2
- import { AccessControlService } from "../services/access-control.service.js";
3
- /** Checks a permission with the workspace ability prepared for the request. */
4
- export function workspaceCan(action, subject) {
5
- if (!RequestContext.isActive())
6
- return false;
7
- return (RequestContext.get(AccessControlService)?.workspaceCan(action, subject) ??
8
- false);
9
- }
10
- //# sourceMappingURL=workspace-can.util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspace-can.util.js","sourceRoot":"","sources":["../../src/utils/workspace-can.util.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,+EAA+E;AAC/E,MAAM,UAAU,YAAY,CAAC,MAAc,EAAE,OAAgB;IAC3D,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE;QAAE,OAAO,KAAK,CAAC;IAE7C,OAAO,CACL,cAAc,CAAC,GAAG,CAAC,oBAAoB,CAAC,EAAE,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC;QACvE,KAAK,CACN,CAAC;AACJ,CAAC"}