@flusys/nestjs-auth 0.1.0-beta.3 → 1.0.0-rc
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/README.md +274 -301
- package/cjs/config/auth.constants.js +22 -4
- package/cjs/controllers/authentication.controller.js +222 -38
- package/cjs/controllers/branch.controller.js +46 -4
- package/cjs/controllers/company-selection.controller.js +27 -20
- package/cjs/controllers/company.controller.js +46 -4
- package/cjs/controllers/user-permission.controller.js +40 -37
- package/cjs/controllers/user.controller.js +222 -23
- package/cjs/dtos/authentication.dto.js +119 -13
- package/cjs/dtos/user-permission.dto.js +28 -0
- package/cjs/dtos/user.dto.js +19 -4
- package/cjs/entities/index.js +5 -1
- package/cjs/entities/pending-registration.entity.js +125 -0
- package/cjs/entities/user-company-permission.entity.js +0 -6
- package/cjs/entities/user-token.entity.js +129 -0
- package/cjs/guards/auth-throttler.guard.js +53 -0
- package/cjs/interceptors/clear-token.interceptor.js +3 -6
- package/cjs/interceptors/set-token.interceptor.js +38 -31
- package/cjs/interfaces/auth-email-provider.interface.js +45 -0
- package/cjs/interfaces/authentication.interface.js +0 -3
- package/cjs/interfaces/index.js +2 -0
- package/cjs/interfaces/user-enricher.interface.js +4 -0
- package/cjs/modules/auth.module.js +8 -20
- package/cjs/services/auth-config.service.js +42 -47
- package/cjs/services/auth-datasource.provider.js +18 -34
- package/cjs/services/auth-email.service.js +471 -0
- package/cjs/services/authentication.service.js +240 -153
- package/cjs/services/branch.service.js +15 -48
- package/cjs/services/company-selection-session.service.js +1 -1
- package/cjs/services/company.service.js +7 -36
- package/cjs/services/index.js +1 -0
- package/cjs/services/user-permission.service.js +9 -29
- package/cjs/services/user.service.js +228 -107
- package/cjs/strategies/jwt.strategy.js +14 -1
- package/cjs/validators/password.validator.js +45 -0
- package/config/auth.constants.d.ts +5 -0
- package/controllers/authentication.controller.d.ts +13 -9
- package/controllers/company-selection.controller.d.ts +6 -2
- package/controllers/user.controller.d.ts +33 -0
- package/dtos/authentication.dto.d.ts +21 -3
- package/dtos/company-branch.dto.d.ts +0 -1
- package/dtos/company.dto.d.ts +0 -1
- package/dtos/user-permission.dto.d.ts +4 -0
- package/dtos/user.dto.d.ts +1 -2
- package/entities/index.d.ts +7 -3
- package/entities/pending-registration.entity.d.ts +17 -0
- package/entities/user-company-permission.entity.d.ts +0 -2
- package/entities/user-token.entity.d.ts +15 -0
- package/fesm/config/auth.constants.js +11 -8
- package/fesm/controllers/authentication.controller.js +224 -40
- package/fesm/controllers/branch.controller.js +49 -7
- package/fesm/controllers/company-selection.controller.js +28 -21
- package/fesm/controllers/company.controller.js +49 -7
- package/fesm/controllers/user-permission.controller.js +41 -38
- package/fesm/controllers/user.controller.js +225 -26
- package/fesm/dtos/authentication.dto.js +123 -111
- package/fesm/dtos/user-permission.dto.js +28 -0
- package/fesm/dtos/user.dto.js +20 -5
- package/fesm/entities/index.js +7 -1
- package/fesm/entities/pending-registration.entity.js +115 -0
- package/fesm/entities/user-company-permission.entity.js +0 -6
- package/fesm/entities/user-token.entity.js +113 -0
- package/fesm/guards/auth-throttler.guard.js +43 -0
- package/fesm/interceptors/clear-token.interceptor.js +2 -5
- package/fesm/interceptors/set-token.interceptor.js +37 -30
- package/fesm/interfaces/auth-email-provider.interface.js +38 -0
- package/fesm/interfaces/authentication.interface.js +1 -7
- package/fesm/interfaces/index.js +2 -0
- package/fesm/interfaces/user-enricher.interface.js +26 -0
- package/fesm/modules/auth.module.js +10 -22
- package/fesm/services/auth-config.service.js +42 -47
- package/fesm/services/auth-datasource.provider.js +19 -35
- package/fesm/services/auth-email.service.js +420 -0
- package/fesm/services/authentication.service.js +238 -151
- package/fesm/services/branch.service.js +16 -49
- package/fesm/services/company-selection-session.service.js +1 -1
- package/fesm/services/company.service.js +8 -37
- package/fesm/services/index.js +1 -0
- package/fesm/services/user-permission.service.js +10 -30
- package/fesm/services/user.service.js +229 -108
- package/fesm/strategies/jwt.strategy.js +14 -1
- package/fesm/validators/password.validator.js +48 -0
- package/guards/auth-throttler.guard.d.ts +7 -0
- package/interceptors/set-token.interceptor.d.ts +1 -0
- package/interfaces/auth-email-provider.interface.d.ts +6 -0
- package/interfaces/auth-module-options.interface.d.ts +4 -1
- package/interfaces/authentication.interface.d.ts +14 -0
- package/interfaces/index.d.ts +2 -0
- package/interfaces/user-enricher.interface.d.ts +64 -0
- package/interfaces/user.interface.d.ts +1 -0
- package/modules/auth.module.d.ts +0 -1
- package/package.json +4 -4
- package/services/auth-config.service.d.ts +5 -1
- package/services/auth-email.service.d.ts +51 -0
- package/services/authentication.service.d.ts +21 -12
- package/services/branch.service.d.ts +2 -5
- package/services/company-selection-session.service.d.ts +1 -1
- package/services/company.service.d.ts +1 -4
- package/services/index.d.ts +1 -0
- package/services/user-permission.service.d.ts +0 -1
- package/services/user.service.d.ts +20 -6
- package/validators/password.validator.d.ts +10 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
2
|
+
import { QueryRunner, SelectQueryBuilder } from 'typeorm';
|
|
3
|
+
import { User } from '../entities/user.entity';
|
|
4
|
+
import { IUser } from './user.interface';
|
|
5
|
+
export interface IProfileSection {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
order: number;
|
|
9
|
+
icon?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
hasFileUpload?: boolean;
|
|
12
|
+
editPermission?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface IProfileSectionData {
|
|
15
|
+
sectionId: string;
|
|
16
|
+
data: Record<string, any>;
|
|
17
|
+
isComplete: boolean;
|
|
18
|
+
files?: IProfileFile[];
|
|
19
|
+
}
|
|
20
|
+
export interface IProfileFile {
|
|
21
|
+
field: string;
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
type?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IProfileExtras {
|
|
28
|
+
roles?: IProfileRole[];
|
|
29
|
+
actions?: IProfileAction[];
|
|
30
|
+
sections?: IProfileSectionData[];
|
|
31
|
+
completionPercentage?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface IProfileRole {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string | null;
|
|
37
|
+
}
|
|
38
|
+
export interface IProfileAction {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
code: string;
|
|
42
|
+
description?: string | null;
|
|
43
|
+
}
|
|
44
|
+
export type IEnrichedUser = IUser & IProfileExtras;
|
|
45
|
+
export interface IUserEnricher {
|
|
46
|
+
enrichListQuery?(query: SelectQueryBuilder<User>, user: ILoggedUserInfo | null): Promise<{
|
|
47
|
+
extraFields: string[];
|
|
48
|
+
}>;
|
|
49
|
+
enrichListItems?(users: IUser[], user: ILoggedUserInfo | null): Promise<IEnrichedUser[]>;
|
|
50
|
+
getProfileExtras?(userId: string, user: ILoggedUserInfo): Promise<IProfileExtras>;
|
|
51
|
+
updateProfileExtras?(userId: string, extras: Record<string, any>, queryRunner: QueryRunner): Promise<void>;
|
|
52
|
+
validateProfileExtras?(userId: string, extras: Record<string, any>, user: ILoggedUserInfo): Promise<void>;
|
|
53
|
+
getProfileSections?(): IProfileSection[];
|
|
54
|
+
getProfileSectionData?(userId: string, sectionId: string, user: ILoggedUserInfo): Promise<IProfileSectionData>;
|
|
55
|
+
updateProfileSection?(userId: string, sectionId: string, data: Record<string, any>, queryRunner: QueryRunner): Promise<void>;
|
|
56
|
+
handleSectionFileUpload?(userId: string, sectionId: string, field: string, fileInfo: {
|
|
57
|
+
name: string;
|
|
58
|
+
url: string;
|
|
59
|
+
size: number;
|
|
60
|
+
type: string;
|
|
61
|
+
}, queryRunner: QueryRunner): Promise<IProfileFile>;
|
|
62
|
+
handleSectionFileDelete?(userId: string, sectionId: string, field: string, fileId: string, queryRunner: QueryRunner): Promise<void>;
|
|
63
|
+
calculateProfileCompletion?(userId: string, user: ILoggedUserInfo): Promise<number>;
|
|
64
|
+
}
|
package/modules/auth.module.d.ts
CHANGED
|
@@ -5,6 +5,5 @@ export declare class AuthModule {
|
|
|
5
5
|
static forRootAsync(asyncOptions: AuthModuleAsyncOptions): DynamicModule;
|
|
6
6
|
private static buildDynamicModule;
|
|
7
7
|
private static createAsyncProviders;
|
|
8
|
-
private static getRepositoryProviders;
|
|
9
8
|
static getEntities(enableCompanyFeature?: boolean): any[];
|
|
10
9
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0-rc",
|
|
4
4
|
"description": "Authentication and authorization infrastructure for NestJS applications",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -84,14 +84,14 @@
|
|
|
84
84
|
"bcrypt": "^5.0.0 || ^6.0.0",
|
|
85
85
|
"class-transformer": "^0.5.0",
|
|
86
86
|
"class-validator": "^0.14.0",
|
|
87
|
-
"nodemailer": "^
|
|
87
|
+
"nodemailer": "^7.0.0",
|
|
88
88
|
"passport": "^0.7.0",
|
|
89
89
|
"passport-jwt": "^4.0.0",
|
|
90
90
|
"passport-local": "^1.0.0",
|
|
91
91
|
"typeorm": "^0.3.0"
|
|
92
92
|
},
|
|
93
93
|
"dependencies": {
|
|
94
|
-
"@flusys/nestjs-core": "
|
|
95
|
-
"@flusys/nestjs-shared": "
|
|
94
|
+
"@flusys/nestjs-core": "1.0.0-rc",
|
|
95
|
+
"@flusys/nestjs-shared": "1.0.0-rc"
|
|
96
96
|
}
|
|
97
97
|
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { DatabaseMode, IDatabaseConfig, ITenantDatabaseConfig } from '@flusys/nestjs-core';
|
|
2
|
+
import { IModuleConfigService } from '@flusys/nestjs-shared/interfaces';
|
|
2
3
|
import { AuthModuleOptions, IAuthModuleConfig } from '../interfaces/auth-module-options.interface';
|
|
3
|
-
export declare class AuthConfigService {
|
|
4
|
+
export declare class AuthConfigService implements IModuleConfigService {
|
|
5
|
+
private readonly logger;
|
|
4
6
|
private readonly options;
|
|
5
7
|
private readonly config;
|
|
8
|
+
private refreshTokenSecretWarned;
|
|
6
9
|
constructor(injectedOptions?: AuthModuleOptions);
|
|
7
10
|
getDatabaseMode(): DatabaseMode;
|
|
8
11
|
isMultiTenant(): boolean;
|
|
@@ -12,6 +15,7 @@ export declare class AuthConfigService {
|
|
|
12
15
|
getRefreshTokenSecret(): string;
|
|
13
16
|
getRefreshTokenExpiration(): string;
|
|
14
17
|
getRefreshTokenCookieName(): string;
|
|
18
|
+
getFrontendUrl(): string | undefined;
|
|
15
19
|
getDefaultDatabaseConfig(): IDatabaseConfig | undefined;
|
|
16
20
|
getTenantDefaultDatabaseConfig(): IDatabaseConfig | undefined;
|
|
17
21
|
getTenants(): ITenantDatabaseConfig[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
2
|
+
import { PendingRegistration } from '../entities/pending-registration.entity';
|
|
3
|
+
import { IAuthEmailProvider } from '../interfaces';
|
|
4
|
+
export declare class AuthEmailService {
|
|
5
|
+
private readonly dataSourceProvider?;
|
|
6
|
+
private readonly emailProvider?;
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private readonly PASSWORD_RESET_EXPIRY;
|
|
9
|
+
private readonly EMAIL_VERIFICATION_EXPIRY;
|
|
10
|
+
constructor(dataSourceProvider?: AuthDataSourceProvider, emailProvider?: IAuthEmailProvider);
|
|
11
|
+
private getUserRepository;
|
|
12
|
+
private getUserTokenRepository;
|
|
13
|
+
private getPendingRegistrationRepository;
|
|
14
|
+
isEmailEnabled(): boolean;
|
|
15
|
+
private generateToken;
|
|
16
|
+
private hashToken;
|
|
17
|
+
createPendingRegistration(data: {
|
|
18
|
+
email: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
phone?: string;
|
|
21
|
+
password: string;
|
|
22
|
+
companyData?: PendingRegistration['companyData'];
|
|
23
|
+
verifyUrlBase: string;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
success: boolean;
|
|
26
|
+
message: string;
|
|
27
|
+
}>;
|
|
28
|
+
forgotPassword(email: string, resetUrlBase: string): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
message: string;
|
|
31
|
+
}>;
|
|
32
|
+
resetPassword(token: string, newPassword: string): Promise<{
|
|
33
|
+
success: boolean;
|
|
34
|
+
message: string;
|
|
35
|
+
}>;
|
|
36
|
+
verifyEmail(token: string): Promise<{
|
|
37
|
+
type: 'pending';
|
|
38
|
+
pending: PendingRegistration;
|
|
39
|
+
} | {
|
|
40
|
+
type: 'verified';
|
|
41
|
+
message: string;
|
|
42
|
+
}>;
|
|
43
|
+
resendVerificationEmail(email: string, verifyUrlBase: string): Promise<{
|
|
44
|
+
success: boolean;
|
|
45
|
+
message: string;
|
|
46
|
+
}>;
|
|
47
|
+
cleanupExpired(): Promise<{
|
|
48
|
+
deletedTokens: number;
|
|
49
|
+
deletedPending: number;
|
|
50
|
+
}>;
|
|
51
|
+
}
|
|
@@ -1,33 +1,38 @@
|
|
|
1
1
|
import { JwtService } from '@nestjs/jwt';
|
|
2
|
-
import { Repository } from 'typeorm';
|
|
3
2
|
import { AuthConfigService } from './auth-config.service';
|
|
4
3
|
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
5
4
|
import { RegistrationDto } from '../dtos/authentication.dto';
|
|
6
|
-
import {
|
|
5
|
+
import { HybridCache } from '@flusys/nestjs-shared/classes';
|
|
6
|
+
import { LoginResponse, LoginResponseRequiresEmailVerification, LoginResponseRequiresSelection, MeResponse, RegistrationResponse } from '../interfaces/authentication.interface';
|
|
7
|
+
import { AuthEmailService } from './auth-email.service';
|
|
7
8
|
import { CompanyBranch } from '../entities/company-branch.entity';
|
|
8
9
|
import { Company } from '../entities/company.entity';
|
|
9
|
-
import {
|
|
10
|
-
import { User } from '../entities/user.entity';
|
|
10
|
+
import { PendingRegistration } from '../entities/pending-registration.entity';
|
|
11
11
|
import { CompanySelectionSessionService } from './company-selection-session.service';
|
|
12
12
|
export declare class AuthenticationService {
|
|
13
13
|
private readonly jwtService;
|
|
14
14
|
private readonly authConfig;
|
|
15
|
+
private readonly cacheManager?;
|
|
15
16
|
private readonly dataSourceProvider?;
|
|
16
17
|
private readonly sessionService?;
|
|
17
|
-
private readonly
|
|
18
|
-
private readonly injectedPermissionRepository?;
|
|
19
|
-
private readonly injectedCompanyRepository?;
|
|
20
|
-
private readonly injectedBranchRepository?;
|
|
18
|
+
private readonly authEmailService?;
|
|
21
19
|
private readonly logger;
|
|
22
|
-
constructor(jwtService: JwtService, authConfig: AuthConfigService, dataSourceProvider?: AuthDataSourceProvider, sessionService?: CompanySelectionSessionService,
|
|
20
|
+
constructor(jwtService: JwtService, authConfig: AuthConfigService, cacheManager?: HybridCache, dataSourceProvider?: AuthDataSourceProvider, sessionService?: CompanySelectionSessionService, authEmailService?: AuthEmailService);
|
|
23
21
|
private getUserRepository;
|
|
24
22
|
private getPermissionRepository;
|
|
25
23
|
private getCompanyRepository;
|
|
26
24
|
private getBranchRepository;
|
|
27
|
-
login(email: string, password: string): Promise<LoginResponse | LoginResponseRequiresSelection>;
|
|
25
|
+
login(email: string, password: string): Promise<LoginResponse | LoginResponseRequiresSelection | LoginResponseRequiresEmailVerification>;
|
|
28
26
|
private handleCompanyBasedLogin;
|
|
29
|
-
register(dto: RegistrationDto): Promise<
|
|
27
|
+
register(dto: RegistrationDto, verifyUrlBase?: string): Promise<RegistrationResponse | {
|
|
28
|
+
requiresEmailVerification: true;
|
|
29
|
+
message: string;
|
|
30
|
+
}>;
|
|
31
|
+
private createUserDirectly;
|
|
32
|
+
createUserFromPendingRegistration(pending: PendingRegistration): Promise<RegistrationResponse>;
|
|
33
|
+
private handleCompanyRegistrationFromPending;
|
|
30
34
|
private handleCompanyRegistration;
|
|
35
|
+
private processCompanyRegistration;
|
|
31
36
|
private generateSlug;
|
|
32
37
|
select(sessionId: string, companyId: string, branchId: string): Promise<LoginResponse>;
|
|
33
38
|
switchCompany(userId: string, companyId: string, branchId: string): Promise<LoginResponse>;
|
|
@@ -36,7 +41,9 @@ export declare class AuthenticationService {
|
|
|
36
41
|
refreshToken: string;
|
|
37
42
|
}>;
|
|
38
43
|
changePassword(userId: string, currentPassword: string, newPassword: string): Promise<void>;
|
|
39
|
-
logout(
|
|
44
|
+
logout(userId: string): Promise<void>;
|
|
45
|
+
isTokenRevoked(userId: string, tokenIssuedAt?: number): Promise<boolean>;
|
|
46
|
+
private parseExpiryToMs;
|
|
40
47
|
getUserCompanies(userId: string): Promise<Company[]>;
|
|
41
48
|
getUserBranches(userId: string, companyId: string): Promise<CompanyBranch[]>;
|
|
42
49
|
getCompanyById(companyId: string): Promise<Company | null>;
|
|
@@ -47,4 +54,6 @@ export declare class AuthenticationService {
|
|
|
47
54
|
private generateLoginResponse;
|
|
48
55
|
private generateLoginResponseWithCompany;
|
|
49
56
|
private generateCompanySelectionResponse;
|
|
57
|
+
private generateRegistrationResponse;
|
|
58
|
+
private generateRegistrationResponseWithCompany;
|
|
50
59
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RequestScopedApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
4
|
-
import { Logger } from '@nestjs/common';
|
|
5
4
|
import { EntityTarget, Repository, SelectQueryBuilder } from 'typeorm';
|
|
6
5
|
import { CreateCompanyBranchDto, UpdateCompanyBranchDto } from '../dtos/company-branch.dto';
|
|
7
6
|
import { ICompanyBranch } from '../interfaces/company-branch.interface';
|
|
@@ -13,20 +12,18 @@ export declare class BranchService extends RequestScopedApiService<CreateCompany
|
|
|
13
12
|
protected utilsService: UtilsService;
|
|
14
13
|
private readonly dataSourceProvider;
|
|
15
14
|
private readonly authConfig;
|
|
16
|
-
protected logger: Logger;
|
|
17
15
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: AuthDataSourceProvider, authConfig: AuthConfigService);
|
|
18
16
|
protected resolveEntity(): EntityTarget<CompanyBranch>;
|
|
19
17
|
protected getDataSourceProvider(): AuthDataSourceProvider;
|
|
20
|
-
convertSingleDtoToEntity(dto: CreateCompanyBranchDto | UpdateCompanyBranchDto, _user: ILoggedUserInfo): Promise<CompanyBranch>;
|
|
21
18
|
getSelectQuery(query: SelectQueryBuilder<CompanyBranch>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
22
19
|
query: SelectQueryBuilder<CompanyBranch>;
|
|
23
20
|
isRaw: boolean;
|
|
24
21
|
}>;
|
|
25
|
-
protected getGlobalSearchQuery(query: SelectQueryBuilder<CompanyBranch>, search: string
|
|
22
|
+
protected getGlobalSearchQuery(query: SelectQueryBuilder<CompanyBranch>, search: string): Promise<{
|
|
26
23
|
query: SelectQueryBuilder<CompanyBranch>;
|
|
27
24
|
isRaw: boolean;
|
|
28
25
|
}>;
|
|
29
|
-
protected getExtraManipulateQuery(query: SelectQueryBuilder<CompanyBranch>,
|
|
26
|
+
protected getExtraManipulateQuery(query: SelectQueryBuilder<CompanyBranch>, filterDto: any, user: ILoggedUserInfo | null): Promise<{
|
|
30
27
|
query: SelectQueryBuilder<CompanyBranch>;
|
|
31
28
|
isRaw: boolean;
|
|
32
29
|
}>;
|
|
@@ -8,7 +8,7 @@ interface StoredSession {
|
|
|
8
8
|
export declare class CompanySelectionSessionService {
|
|
9
9
|
protected cacheManager: HybridCache;
|
|
10
10
|
constructor(cacheManager: HybridCache);
|
|
11
|
-
createSession(userId: string
|
|
11
|
+
createSession(userId: string): Promise<string>;
|
|
12
12
|
getSession(sessionId: string): Promise<StoredSession | null>;
|
|
13
13
|
consumeSession(sessionId: string): Promise<StoredSession | null>;
|
|
14
14
|
deleteSession(sessionId: string): Promise<void>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { RequestScopedApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
4
|
-
import { Logger } from '@nestjs/common';
|
|
5
4
|
import { EntityTarget, Repository, SelectQueryBuilder } from 'typeorm';
|
|
6
5
|
import { CreateCompanyDto, UpdateCompanyDto } from '../dtos/company.dto';
|
|
7
6
|
import { Company } from '../entities/company.entity';
|
|
@@ -11,16 +10,14 @@ export declare class CompanyService extends RequestScopedApiService<CreateCompan
|
|
|
11
10
|
protected cacheManager: HybridCache;
|
|
12
11
|
protected utilsService: UtilsService;
|
|
13
12
|
private readonly dataSourceProvider;
|
|
14
|
-
protected logger: Logger;
|
|
15
13
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: AuthDataSourceProvider);
|
|
16
14
|
protected resolveEntity(): EntityTarget<Company>;
|
|
17
15
|
protected getDataSourceProvider(): AuthDataSourceProvider;
|
|
18
|
-
convertSingleDtoToEntity(dto: CreateCompanyDto | UpdateCompanyDto, _user: ILoggedUserInfo): Promise<Company>;
|
|
19
16
|
getSelectQuery(query: SelectQueryBuilder<Company>, _user: ILoggedUserInfo | null, select?: string[]): Promise<{
|
|
20
17
|
query: SelectQueryBuilder<Company>;
|
|
21
18
|
isRaw: boolean;
|
|
22
19
|
}>;
|
|
23
|
-
protected getGlobalSearchQuery(query: SelectQueryBuilder<Company>, search: string
|
|
20
|
+
protected getGlobalSearchQuery(query: SelectQueryBuilder<Company>, search: string): Promise<{
|
|
24
21
|
query: SelectQueryBuilder<Company>;
|
|
25
22
|
isRaw: boolean;
|
|
26
23
|
}>;
|
package/services/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { UserCompanyPermission } from '../entities/user-company-permission.entit
|
|
|
3
3
|
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
4
4
|
export declare class UserPermissionService {
|
|
5
5
|
private readonly dataSourceProvider;
|
|
6
|
-
private readonly logger;
|
|
7
6
|
private _repository;
|
|
8
7
|
constructor(dataSourceProvider: AuthDataSourceProvider);
|
|
9
8
|
private getRepository;
|
|
@@ -1,31 +1,34 @@
|
|
|
1
1
|
import { RequestScopedApiService, HybridCache } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
4
|
-
import { Logger } from '@nestjs/common';
|
|
5
4
|
import { EntityTarget, Repository } from 'typeorm';
|
|
6
5
|
import { AuthConfigService } from './auth-config.service';
|
|
7
6
|
import { AuthDataSourceProvider } from './auth-datasource.provider';
|
|
8
7
|
import { CreateUserDto, UpdateUserDto } from '../dtos/user.dto';
|
|
9
8
|
import { IUser } from '../interfaces/user.interface';
|
|
9
|
+
import { IEnrichedUser, IProfileExtras, IProfileSection, IProfileSectionData, IUserEnricher } from '../interfaces/user-enricher.interface';
|
|
10
10
|
import { User } from '../entities/user.entity';
|
|
11
11
|
export declare class UserService extends RequestScopedApiService<CreateUserDto, UpdateUserDto, IUser, User, Repository<User>> {
|
|
12
12
|
protected cacheManager: HybridCache;
|
|
13
13
|
protected utilsService: UtilsService;
|
|
14
14
|
private readonly dataSourceProvider;
|
|
15
15
|
private readonly authConfig;
|
|
16
|
-
|
|
16
|
+
private readonly userEnricher?;
|
|
17
17
|
private permissionRepository?;
|
|
18
18
|
private dataSource?;
|
|
19
|
-
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: AuthDataSourceProvider, authConfig: AuthConfigService);
|
|
19
|
+
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: AuthDataSourceProvider, authConfig: AuthConfigService, userEnricher?: IUserEnricher);
|
|
20
20
|
protected resolveEntity(): EntityTarget<User>;
|
|
21
21
|
protected getDataSourceProvider(): AuthDataSourceProvider;
|
|
22
22
|
protected ensureRepositoryInitialized(): Promise<void>;
|
|
23
|
-
|
|
23
|
+
private validateProfileOwnership;
|
|
24
24
|
verifyEmail(id: string): Promise<void>;
|
|
25
25
|
verifyPhone(id: string): Promise<void>;
|
|
26
26
|
updateStatus(id: string, isActive: boolean, user?: ILoggedUserInfo | null): Promise<void>;
|
|
27
|
-
protected convertSingleDtoToEntity(dto: CreateUserDto | UpdateUserDto, user:
|
|
27
|
+
protected convertSingleDtoToEntity(dto: CreateUserDto | UpdateUserDto, user: ILoggedUserInfo | null): Promise<User>;
|
|
28
28
|
protected convertEntityToResponseDto(entity: User, isRaw: boolean): IUser;
|
|
29
|
+
private convertRawToResponseDto;
|
|
30
|
+
private convertEntityToDto;
|
|
31
|
+
protected convertEntityListToResponseListDto(entities: User[], isRaw: boolean): IUser[];
|
|
29
32
|
protected getGlobalSearchQuery(query: any, search: string, _user: any): Promise<{
|
|
30
33
|
query: any;
|
|
31
34
|
isRaw: boolean;
|
|
@@ -35,5 +38,16 @@ export declare class UserService extends RequestScopedApiService<CreateUserDto,
|
|
|
35
38
|
isRaw: boolean;
|
|
36
39
|
}>;
|
|
37
40
|
insert(dto: CreateUserDto, user: ILoggedUserInfo | null): Promise<IUser>;
|
|
38
|
-
|
|
41
|
+
getProfileWithExtras(userId: string, user: ILoggedUserInfo): Promise<{
|
|
42
|
+
user: IUser;
|
|
43
|
+
extras?: IProfileExtras;
|
|
44
|
+
}>;
|
|
45
|
+
getEnrichedList(users: IUser[], user: ILoggedUserInfo | null): Promise<IEnrichedUser[]>;
|
|
46
|
+
getProfileSections(): Promise<IProfileSection[]>;
|
|
47
|
+
getProfileSectionData(userId: string, sectionId: string, user: ILoggedUserInfo): Promise<IProfileSectionData | null>;
|
|
48
|
+
updateProfileSection(userId: string, sectionId: string, data: Record<string, any>, user: ILoggedUserInfo): Promise<void>;
|
|
49
|
+
getProfileCompletion(userId: string, user: ILoggedUserInfo): Promise<number>;
|
|
50
|
+
profile(dto: UpdateUserDto & {
|
|
51
|
+
extras?: Record<string, any>;
|
|
52
|
+
}, user: ILoggedUserInfo): Promise<string>;
|
|
39
53
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValidationOptions } from 'class-validator';
|
|
2
|
+
export interface PasswordComplexityOptions {
|
|
3
|
+
minLength?: number;
|
|
4
|
+
maxLength?: number;
|
|
5
|
+
requireUppercase?: boolean;
|
|
6
|
+
requireLowercase?: boolean;
|
|
7
|
+
requireNumber?: boolean;
|
|
8
|
+
requireSpecialChar?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare function IsStrongPassword(options?: PasswordComplexityOptions, validationOptions?: ValidationOptions): (object: object, propertyName: string) => void;
|