@punks/backend-entity-manager 0.0.178 → 0.0.180
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 +10 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/abstractions/authentication.d.ts +5 -0
- package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/authentication/types.d.ts +2 -1
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/currentUser.d.ts +2 -1
- package/dist/cjs/types/platforms/nest/extensions/authentication/middlewares/authentication/index.d.ts +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/abstractions/authentication.d.ts +5 -0
- package/dist/esm/types/platforms/nest/__test__/server/infrastructure/authentication/types.d.ts +2 -1
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/currentUser.d.ts +2 -1
- package/dist/esm/types/platforms/nest/extensions/authentication/middlewares/authentication/index.d.ts +1 -0
- package/dist/index.d.ts +7 -1
- package/package.json +1 -1
|
@@ -4,6 +4,10 @@ export interface IAuthenticationUserRole {
|
|
|
4
4
|
export interface IAuthenticationUserPermission {
|
|
5
5
|
uid: string;
|
|
6
6
|
}
|
|
7
|
+
export interface IAuthenticationOrganizationalUnit {
|
|
8
|
+
id: string;
|
|
9
|
+
uid: string;
|
|
10
|
+
}
|
|
7
11
|
export interface IAuthenticationContext<TUserContextData> {
|
|
8
12
|
isAuthenticated: boolean;
|
|
9
13
|
isAnonymous: boolean;
|
|
@@ -11,6 +15,7 @@ export interface IAuthenticationContext<TUserContextData> {
|
|
|
11
15
|
userContext?: TUserContextData;
|
|
12
16
|
userRoles?: IAuthenticationUserRole[];
|
|
13
17
|
userPermissions?: IAuthenticationUserPermission[];
|
|
18
|
+
userOrganizationalUnits?: IAuthenticationOrganizationalUnit[];
|
|
14
19
|
}
|
|
15
20
|
export interface IAuthenticationContextProvider<TUserContext> {
|
|
16
21
|
getContext(): Promise<IAuthenticationContext<TUserContext>>;
|
package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/authentication/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IAuthenticationContext } from "../../../../../..";
|
|
1
|
+
import { IAuthenticationContext, IAuthenticationOrganizationalUnit } from "../../../../../..";
|
|
2
2
|
export type AppUserInfo = {
|
|
3
3
|
email: string;
|
|
4
4
|
firstName: string;
|
|
@@ -20,4 +20,5 @@ export declare class AppAuthContext implements IAuthenticationContext<AppUserCon
|
|
|
20
20
|
userContext?: AppUserContext;
|
|
21
21
|
userInfo?: AppUserInfo;
|
|
22
22
|
userRoles?: AppUserRole[];
|
|
23
|
+
userOrganizationalUnits?: IAuthenticationOrganizationalUnit[];
|
|
23
24
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { IAuthPermission, IAuthRole, IAuthUser } from "../abstractions";
|
|
1
|
+
import { IAuthOrganizationalUnit, IAuthPermission, IAuthRole, IAuthUser } from "../abstractions";
|
|
2
2
|
export type CurrentUserData = {
|
|
3
3
|
user: IAuthUser;
|
|
4
4
|
roles: IAuthRole[];
|
|
5
5
|
permissions: IAuthPermission[];
|
|
6
|
+
organizationalUnits: IAuthOrganizationalUnit[];
|
|
6
7
|
};
|
|
7
8
|
export declare const CurrentUser: (...dataOrPipes: unknown[]) => ParameterDecorator;
|
package/dist/esm/index.js
CHANGED
|
@@ -2498,10 +2498,13 @@ const CurrentUser = createParamDecorator((data, context) => {
|
|
|
2498
2498
|
const user = request.auth.user;
|
|
2499
2499
|
const roles = request.auth.roles;
|
|
2500
2500
|
const permissions = request.auth.permissions;
|
|
2501
|
+
const organizationalUnits = request.auth
|
|
2502
|
+
.organizationalUnits;
|
|
2501
2503
|
return {
|
|
2502
2504
|
user,
|
|
2503
2505
|
roles,
|
|
2504
2506
|
permissions,
|
|
2507
|
+
organizationalUnits,
|
|
2505
2508
|
};
|
|
2506
2509
|
});
|
|
2507
2510
|
|
|
@@ -22014,10 +22017,14 @@ let AuthenticationMiddleware = class AuthenticationMiddleware {
|
|
|
22014
22017
|
const user = await this.getUserFromToken(parsedToken.data);
|
|
22015
22018
|
const roles = user ? await this.getUserRoles(user) : [];
|
|
22016
22019
|
const permissions = user ? await this.getUserPermissions(user) : [];
|
|
22020
|
+
const organizationalUnits = user
|
|
22021
|
+
? await this.getUserOrganizationalUnits(user)
|
|
22022
|
+
: [];
|
|
22017
22023
|
req.auth = {
|
|
22018
22024
|
user,
|
|
22019
22025
|
roles,
|
|
22020
22026
|
permissions,
|
|
22027
|
+
organizationalUnits,
|
|
22021
22028
|
};
|
|
22022
22029
|
}
|
|
22023
22030
|
}
|
|
@@ -22032,6 +22039,9 @@ let AuthenticationMiddleware = class AuthenticationMiddleware {
|
|
|
22032
22039
|
async getUserPermissions(user) {
|
|
22033
22040
|
return await this.authService.userRolesService.getUserPermissions(user.id);
|
|
22034
22041
|
}
|
|
22042
|
+
async getUserOrganizationalUnits(user) {
|
|
22043
|
+
return await this.authService.userRolesService.getUserOrganizationalUnits(user.id);
|
|
22044
|
+
}
|
|
22035
22045
|
extractTokenFromHeader(request) {
|
|
22036
22046
|
const [type, token] = request.headers.authorization?.split(" ") ?? [];
|
|
22037
22047
|
return type === "Bearer" ? token : undefined;
|