@punks/backend-entity-manager 0.0.65 → 0.0.68
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 +220 -51
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/integrations/repository/typeorm/queryBuilder.d.ts +1 -1
- package/dist/cjs/types/platforms/nest/__test__/server/app/auth/auth.test-controller.d.ts +11 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/auth/services/auth.roles.service.d.ts +12 -0
- package/dist/cjs/types/platforms/nest/__test__/server/app/auth/{user.service.d.ts → services/auth.user.service.d.ts} +8 -8
- package/dist/cjs/types/platforms/nest/__test__/server/app/auth/services/auth.userRoles.service.d.ts +20 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/roles/role.manager.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/roles/role.models.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userRoles/userRole.models.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/__test__/server/entities/userRoles/userRole.query.d.ts +2 -1
- package/dist/cjs/types/platforms/nest/__test__/server/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/authentication/guards/auth-guard/index.d.ts +13 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/authentication/test_auth_guards.test.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/__test__/tests/authentication/test_auth_jwt.test.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/abstractions/index.d.ts +34 -12
- package/dist/cjs/types/platforms/nest/extensions/authentication/converters/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/guards.d.ts +4 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/index.d.ts +3 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/rolesService.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/symbols.d.ts +8 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/decorators/userRolesService.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-login/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-login/types.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-password-reset-request/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-password-reset-request/types.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-register/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-register/types.d.ts +3 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-token-verify/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-token-verify/types.d.ts +3 -3
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-verify-request/index.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/handlers/user-verify-request/types.d.ts +2 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/initializer/index.d.ts +5 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/middlewares/authentication/index.d.ts +10 -0
- package/dist/cjs/types/platforms/nest/extensions/authentication/module.d.ts +3 -2
- package/dist/cjs/types/platforms/nest/extensions/authentication/resolver/index.d.ts +9 -3
- package/dist/cjs/types/platforms/nest/extensions/authentication/services/authentication/index.d.ts +13 -8
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/abstractions/index.d.ts +1 -39
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/abstractions/models.d.ts +51 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/base/initializer/index.d.ts +6 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/processors/providers.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/services/index.d.ts +2 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/services/organization-initializer/index.d.ts +8 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/services/providers.d.ts +3 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/services/tenant-initializer/index.d.ts +8 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/symbols/index.d.ts +10 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/types/index.d.ts +1 -0
- package/dist/cjs/types/platforms/nest/extensions/multi-tenancy/types/templates.d.ts +20 -0
- package/dist/esm/index.js +215 -52
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/integrations/repository/typeorm/queryBuilder.d.ts +1 -1
- package/dist/esm/types/platforms/nest/__test__/server/app/auth/auth.test-controller.d.ts +11 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/auth/services/auth.roles.service.d.ts +12 -0
- package/dist/esm/types/platforms/nest/__test__/server/app/auth/{user.service.d.ts → services/auth.user.service.d.ts} +8 -8
- package/dist/esm/types/platforms/nest/__test__/server/app/auth/services/auth.userRoles.service.d.ts +20 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/roles/role.manager.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/roles/role.models.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.models.d.ts +2 -0
- package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.query.d.ts +2 -1
- package/dist/esm/types/platforms/nest/__test__/server/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/__test__/server/infrastructure/authentication/guards/auth-guard/index.d.ts +13 -0
- package/dist/esm/types/platforms/nest/__test__/tests/authentication/test_auth_guards.test.d.ts +1 -0
- package/dist/esm/types/platforms/nest/__test__/tests/authentication/test_auth_jwt.test.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/abstractions/index.d.ts +34 -12
- package/dist/esm/types/platforms/nest/extensions/authentication/converters/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/guards.d.ts +4 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/index.d.ts +3 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/rolesService.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/symbols.d.ts +8 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/decorators/userRolesService.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-login/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-login/types.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-password-reset-request/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-password-reset-request/types.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-register/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-register/types.d.ts +3 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-token-verify/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-token-verify/types.d.ts +3 -3
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-verify-request/index.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-verify-request/types.d.ts +2 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/initializer/index.d.ts +5 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/middlewares/authentication/index.d.ts +10 -0
- package/dist/esm/types/platforms/nest/extensions/authentication/module.d.ts +3 -2
- package/dist/esm/types/platforms/nest/extensions/authentication/resolver/index.d.ts +9 -3
- package/dist/esm/types/platforms/nest/extensions/authentication/services/authentication/index.d.ts +13 -8
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/abstractions/index.d.ts +1 -39
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/abstractions/models.d.ts +51 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/base/initializer/index.d.ts +6 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/processors/providers.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/services/index.d.ts +2 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/services/organization-initializer/index.d.ts +8 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/services/providers.d.ts +3 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/services/tenant-initializer/index.d.ts +8 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/symbols/index.d.ts +10 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/types/index.d.ts +1 -0
- package/dist/esm/types/platforms/nest/extensions/multi-tenancy/types/templates.d.ts +20 -0
- package/dist/index.d.ts +134 -36
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ export declare abstract class TypeOrmQueryBuilder<TEntity extends ObjectLiteral,
|
|
|
10
10
|
constructor(services: EntityServiceLocator<TEntity, unknown>);
|
|
11
11
|
search(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<IEntitiesSearchResults<TEntitySearchParameters, TEntity, TSorting, number, TFacets>>;
|
|
12
12
|
protected findPagedQueryResults(request: TEntitySearchParameters, context?: IAuthenticationContext<TUserContext>): Promise<TEntity[]>;
|
|
13
|
-
protected getRelationsToLoad(request: TEntitySearchParameters, context
|
|
13
|
+
protected getRelationsToLoad(request: TEntitySearchParameters, context: IAuthenticationContext<TUserContext> | undefined): FindOptionsRelations<TEntity> | undefined;
|
|
14
14
|
protected buildPagingParameters(request: TEntitySearchParameters): {
|
|
15
15
|
skip: number | undefined;
|
|
16
16
|
take: number | undefined;
|
package/dist/esm/types/platforms/nest/__test__/server/app/auth/services/auth.roles.service.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { IAuthRoleService } from "../../../../../extensions";
|
|
2
|
+
import { RoleEntityManager } from "../../../entities/roles/role.manager";
|
|
3
|
+
import { RoleEntity } from "../../../database/core/entities/role.entity";
|
|
4
|
+
export declare class AuthRolesService implements IAuthRoleService<RoleEntity> {
|
|
5
|
+
private readonly rolesManager;
|
|
6
|
+
constructor(rolesManager: RoleEntityManager);
|
|
7
|
+
create(data: Partial<RoleEntity>): Promise<RoleEntity>;
|
|
8
|
+
update(id: string, data: Partial<RoleEntity>): Promise<void>;
|
|
9
|
+
delete(id: string): Promise<void>;
|
|
10
|
+
getById(id: string): Promise<RoleEntity | undefined>;
|
|
11
|
+
getByUid(uid: string): Promise<RoleEntity | undefined>;
|
|
12
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UserEntity } from "
|
|
3
|
-
import { UserEntityManager } from "
|
|
4
|
-
import { AppUserContext } from "
|
|
5
|
-
import { UserRegistrationData } from "
|
|
6
|
-
import { OrganizationEntityManager } from "
|
|
7
|
-
import { UserProfileEntityManager } from "
|
|
8
|
-
export declare class AuthUserService implements
|
|
1
|
+
import { IAuthUserService } from "../../../../../extensions";
|
|
2
|
+
import { UserEntity } from "../../../database/core/entities/user.entity";
|
|
3
|
+
import { UserEntityManager } from "../../../entities/users/user.manager";
|
|
4
|
+
import { AppUserContext } from "../../../infrastructure/authentication";
|
|
5
|
+
import { UserRegistrationData } from "./../auth.dto";
|
|
6
|
+
import { OrganizationEntityManager } from "../../../entities/organizations/organization.manager";
|
|
7
|
+
import { UserProfileEntityManager } from "../../../entities/userProfiles/userProfile.manager";
|
|
8
|
+
export declare class AuthUserService implements IAuthUserService<UserEntity, AppUserContext, UserRegistrationData> {
|
|
9
9
|
private readonly userManager;
|
|
10
10
|
private readonly userProfileManager;
|
|
11
11
|
private readonly organizationsManager;
|
package/dist/esm/types/platforms/nest/__test__/server/app/auth/services/auth.userRoles.service.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { IAuthUserRolesService } from "../../../../../extensions";
|
|
2
|
+
import { UserEntityManager } from "../../../entities/users/user.manager";
|
|
3
|
+
import { UserRoleEntityManager } from "../../../entities/userRoles/userRole.manager";
|
|
4
|
+
import { RoleEntityManager } from "../../../entities/roles/role.manager";
|
|
5
|
+
import { RoleEntity } from "../../../database/core/entities/role.entity";
|
|
6
|
+
import { UserEntity } from "../../../database/core/entities/user.entity";
|
|
7
|
+
export declare class AuthUserRolesService implements IAuthUserRolesService<UserEntity, RoleEntity> {
|
|
8
|
+
private readonly rolesManager;
|
|
9
|
+
private readonly userManager;
|
|
10
|
+
private readonly userRoleManager;
|
|
11
|
+
constructor(rolesManager: RoleEntityManager, userManager: UserEntityManager, userRoleManager: UserRoleEntityManager);
|
|
12
|
+
getRoleUsers(roleId: string): Promise<UserEntity[]>;
|
|
13
|
+
getUserRoles(userId: string): Promise<RoleEntity[]>;
|
|
14
|
+
getUserRolesByUid(roleUid: string): Promise<RoleEntity[]>;
|
|
15
|
+
addUserToRole(userId: string, roleId: string): Promise<void>;
|
|
16
|
+
addUserToRoleByUid(userId: string, roleUid: string): Promise<void>;
|
|
17
|
+
removeUserFromRole(userId: string, roleId: string): Promise<void>;
|
|
18
|
+
removeUserFromRoleByUid(userId: string, roleUid: string): Promise<void>;
|
|
19
|
+
clearUserRoles(userId: string): Promise<RoleEntity[]>;
|
|
20
|
+
}
|
|
@@ -3,4 +3,5 @@ import { RoleCreateData, RoleCursor, RoleEntityId, RoleFacets, RoleSearchParamet
|
|
|
3
3
|
import { RoleEntity } from "../../database/core/entities/role.entity";
|
|
4
4
|
export declare class RoleEntityManager extends NestEntityManager<RoleEntity, RoleEntityId, RoleCreateData, RoleUpdateData, RoleSearchParameters, RoleSorting, RoleCursor, RoleFacets> {
|
|
5
5
|
constructor(registry: EntityManagerRegistry);
|
|
6
|
+
getByUid(uid: string): Promise<RoleEntity | undefined>;
|
|
6
7
|
}
|
package/dist/esm/types/platforms/nest/__test__/server/entities/userRoles/userRole.query.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FindOptionsWhere } from "typeorm";
|
|
1
|
+
import { FindOptionsRelations, FindOptionsWhere } from "typeorm";
|
|
2
2
|
import { IAuthenticationContext, EntityManagerRegistry, NestTypeOrmQueryBuilder } from "../../../../../..";
|
|
3
3
|
import { UserRoleEntity } from "../../database/core/entities/userRole.entity";
|
|
4
4
|
import { UserRoleFacets, UserRoleSearchParameters, UserRoleSorting } from "./userRole.models";
|
|
@@ -8,4 +8,5 @@ export declare class UserRoleQueryBuilder extends NestTypeOrmQueryBuilder<UserRo
|
|
|
8
8
|
protected buildContextFilter(context?: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsWhere<UserRoleEntity> | FindOptionsWhere<UserRoleEntity>[];
|
|
9
9
|
protected buildWhereClause(request: UserRoleSearchParameters): FindOptionsWhere<UserRoleEntity> | FindOptionsWhere<UserRoleEntity>[];
|
|
10
10
|
protected calculateFacets(request: UserRoleSearchParameters): Promise<UserRoleFacets | undefined>;
|
|
11
|
+
protected getRelationsToLoad(request: UserRoleSearchParameters, context: IAuthenticationContext<AppAuthContext> | undefined): FindOptionsRelations<UserRoleEntity> | undefined;
|
|
11
12
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { DataSource } from "typeorm";
|
|
2
1
|
export declare const createTestServer: (options?: {
|
|
3
2
|
createWebServer?: boolean;
|
|
4
3
|
serverStartPort?: number;
|
|
5
4
|
useAuthentication?: boolean;
|
|
5
|
+
useAuthorization?: boolean;
|
|
6
6
|
extraControllers?: any[];
|
|
7
7
|
extraProviders?: any[];
|
|
8
8
|
}) => Promise<{
|
|
9
9
|
app: import("@nestjs/common").INestApplication<any>;
|
|
10
10
|
server: import("@nestjs/testing").TestingModule;
|
|
11
|
-
dataSource: DataSource;
|
|
11
|
+
dataSource: import("typeorm").DataSource;
|
|
12
12
|
terminate: () => Promise<void>;
|
|
13
13
|
}>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CanActivate, ExecutionContext } from "@nestjs/common";
|
|
2
|
+
import { Reflector } from "@nestjs/core";
|
|
3
|
+
export declare class AuthGuard implements CanActivate {
|
|
4
|
+
private reflector;
|
|
5
|
+
constructor(reflector: Reflector);
|
|
6
|
+
canActivate(context: ExecutionContext): boolean;
|
|
7
|
+
private isRoleMatching;
|
|
8
|
+
private getIsForAllAuthenticated;
|
|
9
|
+
private getIsPublic;
|
|
10
|
+
private getAllowedRoles;
|
|
11
|
+
private getCurrentAuth;
|
|
12
|
+
private getMetadata;
|
|
13
|
+
}
|
package/dist/esm/types/platforms/nest/__test__/tests/authentication/test_auth_guards.test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface IAuthService {
|
|
2
2
|
}
|
|
3
|
-
export interface
|
|
3
|
+
export interface IAuthRole {
|
|
4
|
+
id: string;
|
|
5
|
+
uid: string;
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
export interface IAuthUserProfile {
|
|
4
9
|
firstName: string;
|
|
5
10
|
lastName: string;
|
|
6
11
|
}
|
|
7
|
-
export interface
|
|
12
|
+
export interface IAuthUserOrganization {
|
|
8
13
|
id: string;
|
|
9
14
|
uid: string;
|
|
10
15
|
name: string;
|
|
11
16
|
}
|
|
12
|
-
export interface
|
|
17
|
+
export interface IAuthUser {
|
|
13
18
|
id: string;
|
|
14
19
|
passwordHash: string;
|
|
15
20
|
passwordUpdateTimestamp?: Date;
|
|
@@ -19,13 +24,18 @@ export interface IUser {
|
|
|
19
24
|
verified: boolean;
|
|
20
25
|
verifiedTimestamp?: Date;
|
|
21
26
|
disabled: boolean;
|
|
22
|
-
profile:
|
|
23
|
-
organization?:
|
|
27
|
+
profile: IAuthUserProfile;
|
|
28
|
+
organization?: IAuthUserOrganization;
|
|
24
29
|
}
|
|
25
|
-
export interface
|
|
30
|
+
export interface IAuthUserContext {
|
|
26
31
|
organizationUid?: string;
|
|
27
32
|
}
|
|
28
|
-
export interface
|
|
33
|
+
export interface IAuthUserTokenData<TContext extends IAuthUserContext> {
|
|
34
|
+
userId: string;
|
|
35
|
+
email: string;
|
|
36
|
+
context?: TContext;
|
|
37
|
+
}
|
|
38
|
+
export interface IAuthUserService<TUser extends IAuthUser, TUserContext extends IAuthUserContext, TUserRegistrationInfo> {
|
|
29
39
|
getById(id: string): Promise<TUser>;
|
|
30
40
|
getByEmail(email: string, context?: TUserContext): Promise<TUser>;
|
|
31
41
|
getByUserName(userName: string, context?: TUserContext): Promise<TUser>;
|
|
@@ -33,8 +43,20 @@ export interface IUserService<TUser extends IUser, TUserContext extends IUserCon
|
|
|
33
43
|
delete(id: string): Promise<void>;
|
|
34
44
|
create(email: string, data: TUserRegistrationInfo, context?: TUserContext): Promise<TUser>;
|
|
35
45
|
}
|
|
36
|
-
export interface
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
export interface IAuthRoleService<TRole extends IAuthRole> {
|
|
47
|
+
create(data: Partial<TRole>): Promise<TRole>;
|
|
48
|
+
update(id: string, data: Partial<TRole>): Promise<void>;
|
|
49
|
+
delete(id: string): Promise<void>;
|
|
50
|
+
getById(id: string): Promise<TRole | undefined>;
|
|
51
|
+
getByUid(id: string): Promise<TRole | undefined>;
|
|
52
|
+
}
|
|
53
|
+
export interface IAuthUserRolesService<TUser extends IAuthUser, TRole extends IAuthRole> {
|
|
54
|
+
getRoleUsers(roleId: string): Promise<TUser[]>;
|
|
55
|
+
getUserRoles(userId: string): Promise<TRole[]>;
|
|
56
|
+
getUserRolesByUid(roleUid: string): Promise<TRole[]>;
|
|
57
|
+
addUserToRole(userId: string, roleId: string): Promise<void>;
|
|
58
|
+
addUserToRoleByUid(userId: string, roleUid: string): Promise<void>;
|
|
59
|
+
removeUserFromRole(userId: string, roleId: string): Promise<void>;
|
|
60
|
+
removeUserFromRoleByUid(userId: string, roleUid: string): Promise<void>;
|
|
61
|
+
clearUserRoles(userId: string): Promise<TRole[]>;
|
|
40
62
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const extractUserTokenData: <TContext extends
|
|
1
|
+
import { IAuthUser, IAuthUserContext, IAuthUserTokenData } from "../abstractions";
|
|
2
|
+
export declare const extractUserTokenData: <TContext extends IAuthUserContext>(user: IAuthUser, context?: TContext | undefined) => IAuthUserTokenData<TContext>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const Public: () => import("@nestjs/common").CustomDecorator<string>;
|
|
2
|
+
export declare const Authenticated: () => import("@nestjs/common").CustomDecorator<string>;
|
|
3
|
+
export declare const Roles: (...roles: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
4
|
+
export declare const MemberOf: (...groups: string[]) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
export { Authenticated, MemberOf, Public, Roles } from "./guards";
|
|
1
2
|
export { AuthenticationExtensionSymbols } from "./symbols";
|
|
3
|
+
export { WpRolesService } from "./rolesService";
|
|
2
4
|
export { WpUserService } from "./userService";
|
|
5
|
+
export { WpUserRolesService } from "./userRolesService";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WpRolesService: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
|
|
@@ -1,3 +1,11 @@
|
|
|
1
1
|
export declare const AuthenticationExtensionSymbols: {
|
|
2
2
|
UserService: symbol;
|
|
3
|
+
RolesService: symbol;
|
|
4
|
+
UserRolesService: symbol;
|
|
5
|
+
};
|
|
6
|
+
export declare const AuthenticationGuardsSymbols: {
|
|
7
|
+
Authenticated: string;
|
|
8
|
+
Public: string;
|
|
9
|
+
Roles: string;
|
|
10
|
+
MemberOf: string;
|
|
3
11
|
};
|
package/dist/esm/types/platforms/nest/extensions/authentication/decorators/userRolesService.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const WpUserRolesService: () => <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol | undefined, descriptor?: TypedPropertyDescriptor<Y> | undefined) => void;
|
package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-login/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PasswordHashingProvider } from "../../providers/password-hasher";
|
|
2
2
|
import { AuthenticationServicesResolver } from "../../resolver";
|
|
3
3
|
import { JwtProvider } from "../../providers/jwt";
|
|
4
|
-
import {
|
|
4
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
5
5
|
import { UserLoginInput, UserLoginResult } from "./types";
|
|
6
6
|
export declare class UserLoginHandler {
|
|
7
7
|
private readonly services;
|
|
8
8
|
private readonly passwordHashingProvider;
|
|
9
9
|
private readonly jwtProvider;
|
|
10
10
|
constructor(services: AuthenticationServicesResolver, passwordHashingProvider: PasswordHashingProvider, jwtProvider: JwtProvider);
|
|
11
|
-
execute<TUserContext extends
|
|
11
|
+
execute<TUserContext extends IAuthUserContext>(input: UserLoginInput<TUserContext>): Promise<UserLoginResult>;
|
|
12
12
|
private generateUserJwtToken;
|
|
13
13
|
private resolveUser;
|
|
14
14
|
}
|
package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-login/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UserLoginInput<TUserContext extends
|
|
1
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
2
|
+
export interface UserLoginInput<TUserContext extends IAuthUserContext> {
|
|
3
3
|
userName: string;
|
|
4
4
|
password: string;
|
|
5
5
|
context?: TUserContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmailService } from "../../../../services";
|
|
2
|
-
import {
|
|
2
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
3
3
|
import { AuthenticationServicesResolver } from "../../resolver";
|
|
4
4
|
import { JwtProvider } from "../../providers/jwt";
|
|
5
5
|
import { UserPasswordResetRequestInput, UserPasswordResetRequestResult } from "./types";
|
|
@@ -8,7 +8,7 @@ export declare class UserPasswordResetRequestHandler {
|
|
|
8
8
|
private readonly emailService;
|
|
9
9
|
private readonly jwtProvider;
|
|
10
10
|
constructor(services: AuthenticationServicesResolver, emailService: EmailService, jwtProvider: JwtProvider);
|
|
11
|
-
execute<TUserContext extends
|
|
11
|
+
execute<TUserContext extends IAuthUserContext>(input: UserPasswordResetRequestInput<TUserContext>): Promise<UserPasswordResetRequestResult>;
|
|
12
12
|
private sendPasswordResetEmail;
|
|
13
13
|
private generatePasswordResetToken;
|
|
14
14
|
private resolveUser;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
2
2
|
export type UserPasswordResetRequestCallbackTemplate = {
|
|
3
3
|
urlTemplate: string;
|
|
4
4
|
tokenPlaceholder: string;
|
|
5
5
|
};
|
|
6
|
-
export interface UserPasswordResetRequestInput<TUserContext extends
|
|
6
|
+
export interface UserPasswordResetRequestInput<TUserContext extends IAuthUserContext> {
|
|
7
7
|
email: string;
|
|
8
8
|
callback: UserPasswordResetRequestCallbackTemplate;
|
|
9
9
|
languageId: string;
|
package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-register/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
2
2
|
import { EmailService } from "../../../../services";
|
|
3
3
|
import { AuthenticationServicesResolver } from "../../resolver";
|
|
4
4
|
import { JwtProvider } from "../../providers/jwt";
|
|
@@ -11,7 +11,7 @@ export declare class UserRegistrationHandler {
|
|
|
11
11
|
private readonly jwtProvider;
|
|
12
12
|
private readonly logger;
|
|
13
13
|
constructor(services: AuthenticationServicesResolver, passwordHashingProvider: PasswordHashingProvider, emailService: EmailService, jwtProvider: JwtProvider);
|
|
14
|
-
execute<TUserRegistrationInfo, TContext extends
|
|
14
|
+
execute<TUserRegistrationInfo, TContext extends IAuthUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TContext>): Promise<UserRegistrationResult>;
|
|
15
15
|
private createPasswordHash;
|
|
16
16
|
private sendRegistrationEmail;
|
|
17
17
|
private generateEmailVerifyToken;
|
package/dist/esm/types/platforms/nest/extensions/authentication/handlers/user-register/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
2
2
|
import { UserRegistrationError } from "../../types";
|
|
3
3
|
export type UserRegisterCallbackTemplate = {
|
|
4
4
|
urlTemplate: string;
|
|
5
5
|
tokenPlaceholder: string;
|
|
6
6
|
};
|
|
7
|
-
export interface UserRegistrationInput<TUserRegistrationInfo, TUserContext extends
|
|
7
|
+
export interface UserRegistrationInput<TUserRegistrationInfo, TUserContext extends IAuthUserContext> {
|
|
8
8
|
email: string;
|
|
9
9
|
userName: string;
|
|
10
10
|
password: string;
|
|
@@ -16,4 +16,5 @@ export interface UserRegistrationInput<TUserRegistrationInfo, TUserContext exten
|
|
|
16
16
|
export interface UserRegistrationResult {
|
|
17
17
|
success: boolean;
|
|
18
18
|
error?: UserRegistrationError;
|
|
19
|
+
userId?: string;
|
|
19
20
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { JwtProvider } from "../../providers/jwt";
|
|
2
|
-
import {
|
|
2
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
3
3
|
import { UserTokenVerifyInput, UserTokenVerifyResult } from "./types";
|
|
4
4
|
export declare class UserTokenVerifyHandler {
|
|
5
5
|
private readonly jwtProvider;
|
|
6
6
|
constructor(jwtProvider: JwtProvider);
|
|
7
|
-
execute<TUserContext extends
|
|
7
|
+
execute<TUserContext extends IAuthUserContext>(input: UserTokenVerifyInput): Promise<UserTokenVerifyResult<TUserContext>>;
|
|
8
8
|
private decodeUserJwtToken;
|
|
9
9
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UserTokenVerifyResult<TUserContext extends
|
|
1
|
+
import { IAuthUserContext, IAuthUserTokenData } from "../../abstractions";
|
|
2
|
+
export interface UserTokenVerifyResult<TUserContext extends IAuthUserContext> {
|
|
3
3
|
isValid: boolean;
|
|
4
|
-
data:
|
|
4
|
+
data: IAuthUserTokenData<TUserContext>;
|
|
5
5
|
}
|
|
6
6
|
export interface UserTokenVerifyInput {
|
|
7
7
|
token: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
2
2
|
import { EmailService } from "../../../../services";
|
|
3
3
|
import { JwtProvider } from "../../providers/jwt";
|
|
4
4
|
import { AuthenticationServicesResolver } from "../../resolver";
|
|
@@ -8,7 +8,7 @@ export declare class UserVerifyRequestHandler {
|
|
|
8
8
|
private readonly emailService;
|
|
9
9
|
private readonly jwtProvider;
|
|
10
10
|
constructor(services: AuthenticationServicesResolver, emailService: EmailService, jwtProvider: JwtProvider);
|
|
11
|
-
execute<TUserContext extends
|
|
11
|
+
execute<TUserContext extends IAuthUserContext>(input: UserVerifyRequestInput<TUserContext>): Promise<UserVerifyRequestResult>;
|
|
12
12
|
private sendEmailVerifyEmail;
|
|
13
13
|
private generateEmailVerifyToken;
|
|
14
14
|
private resolveUser;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface UserVerifyRequestInput<TUserContext extends
|
|
1
|
+
import { IAuthUserContext } from "../../abstractions";
|
|
2
|
+
export interface UserVerifyRequestInput<TUserContext extends IAuthUserContext> {
|
|
3
3
|
email: string;
|
|
4
4
|
callback: UserVerifyRequestCallbackTemplate;
|
|
5
5
|
languageId: string;
|
|
@@ -8,5 +8,10 @@ export declare class AuthenticationInitializer implements IAppInitializer {
|
|
|
8
8
|
private readonly logger;
|
|
9
9
|
constructor(discover: CustomDiscoveryService, registry: AuthenticationServicesResolver);
|
|
10
10
|
initialize(app: INestApplicationContext): Promise<void>;
|
|
11
|
+
private registerRolesService;
|
|
12
|
+
private registerUsersService;
|
|
13
|
+
private registerUserRolesService;
|
|
11
14
|
private discoverUserService;
|
|
15
|
+
private discoverRolesService;
|
|
16
|
+
private discoverUserRolesService;
|
|
12
17
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestMiddleware } from "@nestjs/common";
|
|
2
|
+
import { AuthenticationService } from "../../services";
|
|
3
|
+
export declare class AuthenticationMiddleware implements NestMiddleware {
|
|
4
|
+
private readonly authService;
|
|
5
|
+
constructor(authService: AuthenticationService);
|
|
6
|
+
use(req: any, res: any, next: (error?: any) => void): Promise<void>;
|
|
7
|
+
private getUserFromToken;
|
|
8
|
+
private getUserRoles;
|
|
9
|
+
private extractTokenFromHeader;
|
|
10
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { DynamicModule } from "@nestjs/common";
|
|
1
|
+
import { DynamicModule, MiddlewareConsumer, NestModule } from "@nestjs/common";
|
|
2
2
|
import { AuthenticationModuleSettings } from "./types";
|
|
3
|
-
export declare class AuthenticationModule {
|
|
3
|
+
export declare class AuthenticationModule implements NestModule {
|
|
4
4
|
static forRoot(input: AuthenticationModuleSettings): DynamicModule;
|
|
5
|
+
configure(consumer: MiddlewareConsumer): void;
|
|
5
6
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuthRole, IAuthRoleService, IAuthUser, IAuthUserRolesService, IAuthUserService } from "../abstractions";
|
|
2
2
|
export declare class AuthenticationServicesResolver {
|
|
3
3
|
private usersService;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
private rolesService;
|
|
5
|
+
private usersRolesService;
|
|
6
|
+
registerUsersService(usersService: IAuthUserService<any, any, any>): void;
|
|
7
|
+
registerRoleService(rolesService: IAuthRoleService<any>): void;
|
|
8
|
+
registerUserRolesService(userRolesService: IAuthUserRolesService<any, any>): void;
|
|
9
|
+
getUsersService<TUser extends IAuthUser, TUserRegistrationInfo>(): IAuthUserService<TUser, any, TUserRegistrationInfo>;
|
|
10
|
+
getRoleService<TRole extends IAuthRole>(): IAuthRoleService<TRole>;
|
|
11
|
+
getUserRoleService<TUser extends IAuthUser, TRole extends IAuthRole>(): IAuthUserRolesService<TUser, TRole>;
|
|
6
12
|
}
|
package/dist/esm/types/platforms/nest/extensions/authentication/services/authentication/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IAuthRole, IAuthRoleService, IAuthService, IAuthUser, IAuthUserContext, IAuthUserRolesService, IAuthUserService } from "../../abstractions";
|
|
2
2
|
import { UserRegistrationHandler } from "../../handlers/user-register";
|
|
3
3
|
import { UserDisableHandler } from "../../handlers/user-disable";
|
|
4
4
|
import { UserEnableHandler } from "../../handlers/user-enable";
|
|
@@ -19,7 +19,8 @@ import { UserRegistrationInput, UserRegistrationResult } from "../../handlers/us
|
|
|
19
19
|
import { UserTokenVerifyInput, UserTokenVerifyResult } from "../../handlers/user-token-verify/types";
|
|
20
20
|
import { UserVerifyCompleteInput } from "../../handlers/user-verify-complete/types";
|
|
21
21
|
import { UserVerifyRequestInput, UserVerifyRequestResult } from "../../handlers/user-verify-request/types";
|
|
22
|
-
|
|
22
|
+
import { AuthenticationServicesResolver } from "../../resolver";
|
|
23
|
+
export declare class AuthenticationService implements IAuthService {
|
|
23
24
|
private readonly userDisableHandler;
|
|
24
25
|
private readonly userEnableHandler;
|
|
25
26
|
private readonly userLoginHandler;
|
|
@@ -30,15 +31,19 @@ export declare class AuthenticationService implements IAuthenticationService {
|
|
|
30
31
|
private readonly userTokenVerifyHandler;
|
|
31
32
|
private readonly userVerifyRequestHandler;
|
|
32
33
|
private readonly userVerifyCompleteHandler;
|
|
33
|
-
|
|
34
|
+
private readonly resolver;
|
|
35
|
+
constructor(userDisableHandler: UserDisableHandler, userEnableHandler: UserEnableHandler, userLoginHandler: UserLoginHandler, userPasswordChangeHandler: UserPasswordChangeHandler, userPasswordResetFinalizeHandler: UserPasswordResetCompleteHandler, userPasswordResetRequestHandler: UserPasswordResetRequestHandler, userRegistrationHandler: UserRegistrationHandler, userTokenVerifyHandler: UserTokenVerifyHandler, userVerifyRequestHandler: UserVerifyRequestHandler, userVerifyCompleteHandler: UserVerifyCompleteHandler, resolver: AuthenticationServicesResolver);
|
|
34
36
|
userDisable(input: UserDisableInput): Promise<void>;
|
|
35
37
|
userEnable(input: UserEnableInput): Promise<void>;
|
|
36
|
-
userLogin<TUserContext extends
|
|
38
|
+
userLogin<TUserContext extends IAuthUserContext>(input: UserLoginInput<TUserContext>): Promise<UserLoginResult>;
|
|
37
39
|
userPasswordChange(input: UserPasswordChangeInput): Promise<void>;
|
|
38
40
|
userPasswordResetFinalize(input: UserPasswordResetCompleteInput): Promise<void>;
|
|
39
|
-
userPasswordResetRequest<TUserContext extends
|
|
40
|
-
userRegister<TUserRegistrationInfo, TUserContext extends
|
|
41
|
-
userVerifyRequest<TUserContext extends
|
|
41
|
+
userPasswordResetRequest<TUserContext extends IAuthUserContext>(input: UserPasswordResetRequestInput<TUserContext>): Promise<UserPasswordResetRequestResult>;
|
|
42
|
+
userRegister<TUserRegistrationInfo, TUserContext extends IAuthUserContext>(input: UserRegistrationInput<TUserRegistrationInfo, TUserContext>): Promise<UserRegistrationResult>;
|
|
43
|
+
userVerifyRequest<TUserContext extends IAuthUserContext>(input: UserVerifyRequestInput<TUserContext>): Promise<UserVerifyRequestResult>;
|
|
42
44
|
userVerifyComplete(input: UserVerifyCompleteInput): Promise<void>;
|
|
43
|
-
userTokenVerify<TUserContext extends
|
|
45
|
+
userTokenVerify<TUserContext extends IAuthUserContext>(input: UserTokenVerifyInput): Promise<UserTokenVerifyResult<TUserContext>>;
|
|
46
|
+
get usersService(): IAuthUserService<IAuthUser, any, unknown>;
|
|
47
|
+
get rolesService(): IAuthRoleService<IAuthRole>;
|
|
48
|
+
get userRolesService(): IAuthUserRolesService<IAuthUser, IAuthRole>;
|
|
44
49
|
}
|
|
@@ -1,39 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
id: string;
|
|
3
|
-
uid: string;
|
|
4
|
-
name: string;
|
|
5
|
-
}
|
|
6
|
-
export interface IDivision {
|
|
7
|
-
id: string;
|
|
8
|
-
uid: string;
|
|
9
|
-
name: string;
|
|
10
|
-
}
|
|
11
|
-
export interface IUser {
|
|
12
|
-
id: string;
|
|
13
|
-
uid: string;
|
|
14
|
-
}
|
|
15
|
-
export interface IModule {
|
|
16
|
-
id: string;
|
|
17
|
-
uid: string;
|
|
18
|
-
name: string;
|
|
19
|
-
}
|
|
20
|
-
export interface IOrganization {
|
|
21
|
-
id: string;
|
|
22
|
-
uid: string;
|
|
23
|
-
name: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ISubscription {
|
|
26
|
-
id: string;
|
|
27
|
-
uid: string;
|
|
28
|
-
name: string;
|
|
29
|
-
}
|
|
30
|
-
export interface ITenant {
|
|
31
|
-
id: string;
|
|
32
|
-
uid: string;
|
|
33
|
-
name: string;
|
|
34
|
-
}
|
|
35
|
-
export interface IUserGroup {
|
|
36
|
-
id: string;
|
|
37
|
-
uid: string;
|
|
38
|
-
name: string;
|
|
39
|
-
}
|
|
1
|
+
export * from "./models";
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export interface IAppTenant {
|
|
2
|
+
id: string;
|
|
3
|
+
uid: string;
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
6
|
+
export interface IAppOrganization {
|
|
7
|
+
id: string;
|
|
8
|
+
uid: string;
|
|
9
|
+
name: string;
|
|
10
|
+
tenant: IAppTenant;
|
|
11
|
+
}
|
|
12
|
+
export interface IAppCompany {
|
|
13
|
+
id: string;
|
|
14
|
+
uid: string;
|
|
15
|
+
name: string;
|
|
16
|
+
organization: IAppOrganization;
|
|
17
|
+
}
|
|
18
|
+
export interface IAppDivision {
|
|
19
|
+
id: string;
|
|
20
|
+
uid: string;
|
|
21
|
+
name: string;
|
|
22
|
+
company: IAppCompany;
|
|
23
|
+
}
|
|
24
|
+
export interface IAppUserProfile {
|
|
25
|
+
firstName: string;
|
|
26
|
+
lastName: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IAppUser {
|
|
29
|
+
id: string;
|
|
30
|
+
uid?: string;
|
|
31
|
+
userName: string;
|
|
32
|
+
email: string;
|
|
33
|
+
verified: boolean;
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
profile: IAppUserProfile;
|
|
36
|
+
tenant: IAppTenant;
|
|
37
|
+
organization?: IAppOrganization;
|
|
38
|
+
}
|
|
39
|
+
export interface IAppUserGroup {
|
|
40
|
+
id: string;
|
|
41
|
+
uid: string;
|
|
42
|
+
name: string;
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
isBuiltIn: boolean;
|
|
45
|
+
organization?: IAppOrganization;
|
|
46
|
+
}
|
|
47
|
+
export interface IAppRole {
|
|
48
|
+
id: string;
|
|
49
|
+
uid: string;
|
|
50
|
+
name: string;
|
|
51
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntityManagerRegistry } from "../../../../ioc";
|
|
2
|
+
export declare abstract class BaseInitializer {
|
|
3
|
+
private readonly registry;
|
|
4
|
+
constructor(registry: EntityManagerRegistry);
|
|
5
|
+
protected get companiesRepo(): import("../../../../../..").IEntityRepository<unknown, unknown, unknown, unknown, unknown, unknown>;
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Providers: never[];
|