@punks/backend-entity-manager 0.0.176 → 0.0.177
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.
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/currentUser.d.ts +2 -1
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/guards.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/symbols.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/middlewares/authentication/index.d.ts +1 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/currentUser.d.ts +2 -1
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/guards.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/symbols.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/middlewares/authentication/index.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { IAuthRole, IAuthUser } from "../abstractions";
|
|
1
|
+
import { IAuthPermission, IAuthRole, IAuthUser } from "../abstractions";
|
|
2
2
|
export type CurrentUserData = {
|
|
3
3
|
user: IAuthUser;
|
|
4
4
|
roles: IAuthRole[];
|
|
5
|
+
permissions: IAuthPermission[];
|
|
5
6
|
};
|
|
6
7
|
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AppRole, RolesGuardOptions } from "../types";
|
|
2
2
|
export declare const Public: () => import("@nestjs/common").CustomDecorator<string>;
|
|
3
3
|
export declare const Authenticated: () => import("@nestjs/common").CustomDecorator<string>;
|
|
4
|
+
export declare const Permissions: (...permissions: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
4
5
|
export declare const Roles: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
5
6
|
export declare const MemberOf: (...groups: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
6
7
|
export declare const buildRolesGuard: ({ mainRole, secondaryRoles, }: {
|
package/dist/esm/index.js
CHANGED
|
@@ -2497,9 +2497,11 @@ const CurrentUser = createParamDecorator((data, context) => {
|
|
|
2497
2497
|
}
|
|
2498
2498
|
const user = request.auth.user;
|
|
2499
2499
|
const roles = request.auth.roles;
|
|
2500
|
+
const permissions = request.auth.permissions;
|
|
2500
2501
|
return {
|
|
2501
2502
|
user,
|
|
2502
2503
|
roles,
|
|
2504
|
+
permissions,
|
|
2503
2505
|
};
|
|
2504
2506
|
});
|
|
2505
2507
|
|
|
@@ -2513,6 +2515,7 @@ const AuthenticationGuardsSymbols = {
|
|
|
2513
2515
|
Authenticated: "guard:authenticated",
|
|
2514
2516
|
Public: "guard:public",
|
|
2515
2517
|
Roles: "guard:roles",
|
|
2518
|
+
Permissions: "guard:permissions",
|
|
2516
2519
|
MemberOf: "guard:memberOf",
|
|
2517
2520
|
};
|
|
2518
2521
|
|
|
@@ -22010,9 +22013,11 @@ let AuthenticationMiddleware = class AuthenticationMiddleware {
|
|
|
22010
22013
|
if (parsedToken.isValid) {
|
|
22011
22014
|
const user = await this.getUserFromToken(parsedToken.data);
|
|
22012
22015
|
const roles = user ? await this.getUserRoles(user) : [];
|
|
22016
|
+
const permissions = user ? await this.getUserPermissions(user) : [];
|
|
22013
22017
|
req.auth = {
|
|
22014
22018
|
user,
|
|
22015
22019
|
roles,
|
|
22020
|
+
permissions,
|
|
22016
22021
|
};
|
|
22017
22022
|
}
|
|
22018
22023
|
}
|
|
@@ -22024,6 +22029,9 @@ let AuthenticationMiddleware = class AuthenticationMiddleware {
|
|
|
22024
22029
|
async getUserRoles(user) {
|
|
22025
22030
|
return await this.authService.userRolesService.getUserRoles(user.id);
|
|
22026
22031
|
}
|
|
22032
|
+
async getUserPermissions(user) {
|
|
22033
|
+
return await this.authService.userRolesService.getUserPermissions(user.id);
|
|
22034
|
+
}
|
|
22027
22035
|
extractTokenFromHeader(request) {
|
|
22028
22036
|
const [type, token] = request.headers.authorization?.split(" ") ?? [];
|
|
22029
22037
|
return type === "Bearer" ? token : undefined;
|