@flusys/nestjs-auth 7.0.2 → 8.0.0-beta.1
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 +68 -1
- package/config/auth.constants.d.ts +2 -0
- package/config/event-actions.d.ts +2 -0
- package/config/index.d.ts +3 -3
- package/config/message-keys.d.ts +23 -0
- package/controllers/authentication.controller.d.ts +5 -5
- package/controllers/branch.controller.d.ts +2 -2
- package/controllers/company-selection.controller.d.ts +4 -4
- package/controllers/company.controller.d.ts +2 -2
- package/controllers/email-verification.controller.d.ts +6 -6
- package/controllers/index.d.ts +9 -7
- package/controllers/social-auth-config.controller.d.ts +22 -0
- package/controllers/social-auth.controller.d.ts +11 -0
- package/controllers/user-permission.controller.d.ts +5 -4
- package/controllers/user.controller.d.ts +7 -7
- package/docs/auth-swagger.config.d.ts +2 -2
- package/docs/index.d.ts +1 -1
- package/dtos/index.d.ts +6 -5
- package/dtos/social-auth.dto.d.ts +42 -0
- package/entities/company-branch.entity.d.ts +1 -1
- package/entities/company.entity.d.ts +1 -1
- package/entities/index.d.ts +15 -13
- package/entities/pending-registration.entity.d.ts +1 -1
- package/entities/social-auth-config.entity.d.ts +9 -0
- package/entities/user-company-permission.entity.d.ts +4 -4
- package/enums/index.d.ts +2 -1
- package/enums/social-provider-type.enum.d.ts +6 -0
- package/fesm/118.js +1230 -0
- package/fesm/120.js +2197 -0
- package/fesm/24.js +4389 -0
- package/fesm/370.js +1163 -0
- package/fesm/446.js +877 -0
- package/fesm/chunks/117.js +69 -0
- package/fesm/config/index.js +244 -3
- package/fesm/controllers/index.js +27 -7
- package/fesm/docs/index.js +479 -1
- package/fesm/dtos/index.js +123 -5
- package/fesm/entities/index.js +68 -19
- package/fesm/enums/index.js +53 -1
- package/fesm/helpers/index.js +115 -2
- package/fesm/index.js +1437 -12
- package/fesm/interceptors/index.js +508 -2
- package/fesm/interfaces/index.js +75 -7
- package/fesm/modules/index.js +546 -1
- package/fesm/runtime.js +134 -0
- package/fesm/services/index.js +67 -9
- package/helpers/auth-response.mapper.d.ts +3 -3
- package/helpers/index.d.ts +2 -2
- package/helpers/token.helper.d.ts +2 -2
- package/index.d.ts +13 -12
- package/interceptors/clear-token.interceptor.d.ts +2 -2
- package/interceptors/index.d.ts +2 -2
- package/interceptors/set-token.interceptor.d.ts +2 -2
- package/interfaces/auth-module-options.interface.d.ts +3 -3
- package/interfaces/authentication.interface.d.ts +3 -3
- package/interfaces/company-branch.interface.d.ts +2 -2
- package/interfaces/company.interface.d.ts +1 -1
- package/interfaces/index.d.ts +8 -7
- package/interfaces/social-auth.interface.d.ts +43 -0
- package/interfaces/user-enricher.interface.d.ts +3 -3
- package/modules/auth.module.d.ts +4 -4
- package/modules/index.d.ts +1 -1
- package/package.json +32 -39
- package/providers/facebook.social-provider.d.ts +10 -0
- package/providers/google.social-provider.d.ts +10 -0
- package/providers/index.d.ts +1 -0
- package/providers/linkedin.social-provider.d.ts +10 -0
- package/providers/microsoft.social-provider.d.ts +10 -0
- package/providers/oauth-http.util.d.ts +10 -0
- package/providers/social-provider.registry.d.ts +3 -0
- package/services/auth-config.service.d.ts +4 -3
- package/services/auth-datasource.provider.d.ts +4 -3
- package/services/auth-email.service.d.ts +3 -3
- package/services/authentication.service.d.ts +15 -11
- package/services/branch.service.d.ts +7 -7
- package/services/company.service.d.ts +6 -6
- package/services/index.d.ts +11 -9
- package/services/social-auth-config.service.d.ts +21 -0
- package/services/social-auth.service.d.ts +24 -0
- package/services/user-permission.service.d.ts +8 -4
- package/services/user.service.d.ts +7 -7
- package/strategies/jwt.strategy.d.ts +4 -4
- package/validators/password.validator.d.ts +1 -1
- package/cjs/config/auth.constants.js +0 -41
- package/cjs/config/event-actions.js +0 -45
- package/cjs/config/index.js +0 -20
- package/cjs/config/message-keys.js +0 -108
- package/cjs/controllers/authentication.controller.js +0 -427
- package/cjs/controllers/authentication.controller.spec.js +0 -219
- package/cjs/controllers/branch.controller.js +0 -102
- package/cjs/controllers/branch.controller.spec.js +0 -134
- package/cjs/controllers/company-selection.controller.js +0 -198
- package/cjs/controllers/company-selection.controller.spec.js +0 -84
- package/cjs/controllers/company.controller.js +0 -102
- package/cjs/controllers/company.controller.spec.js +0 -131
- package/cjs/controllers/email-verification.controller.js +0 -224
- package/cjs/controllers/email-verification.controller.spec.js +0 -142
- package/cjs/controllers/index.js +0 -24
- package/cjs/controllers/user-permission.controller.js +0 -223
- package/cjs/controllers/user-permission.controller.spec.js +0 -138
- package/cjs/controllers/user.controller.js +0 -438
- package/cjs/controllers/user.controller.spec.js +0 -204
- package/cjs/docs/auth-swagger.config.js +0 -453
- package/cjs/docs/auth-swagger.config.spec.js +0 -130
- package/cjs/docs/index.js +0 -18
- package/cjs/dtos/authentication.dto.js +0 -755
- package/cjs/dtos/company-branch.dto.js +0 -294
- package/cjs/dtos/company.dto.js +0 -298
- package/cjs/dtos/index.js +0 -22
- package/cjs/dtos/user-permission.dto.js +0 -358
- package/cjs/dtos/user.dto.js +0 -413
- package/cjs/entities/app-user.entity.js +0 -25
- package/cjs/entities/company-branch.entity.js +0 -163
- package/cjs/entities/company.entity.js +0 -146
- package/cjs/entities/index.js +0 -65
- package/cjs/entities/index.spec.js +0 -73
- package/cjs/entities/pending-registration.entity.js +0 -135
- package/cjs/entities/user-company-permission.entity.js +0 -153
- package/cjs/entities/user-token.entity.js +0 -120
- package/cjs/enums/index.js +0 -18
- package/cjs/enums/user-org-permission-type.enum.js +0 -15
- package/cjs/helpers/auth-response.mapper.js +0 -46
- package/cjs/helpers/auth-response.mapper.spec.js +0 -139
- package/cjs/helpers/index.js +0 -19
- package/cjs/helpers/token.helper.js +0 -58
- package/cjs/helpers/token.helper.spec.js +0 -86
- package/cjs/index.js +0 -29
- package/cjs/interceptors/clear-token.interceptor.js +0 -73
- package/cjs/interceptors/clear-token.interceptor.spec.js +0 -107
- package/cjs/interceptors/index.js +0 -19
- package/cjs/interceptors/set-token.interceptor.js +0 -107
- package/cjs/interceptors/set-token.interceptor.spec.js +0 -165
- package/cjs/interfaces/auth-email-provider.interface.js +0 -45
- package/cjs/interfaces/auth-module-options.interface.js +0 -4
- package/cjs/interfaces/authentication.interface.js +0 -4
- package/cjs/interfaces/company-branch.interface.js +0 -4
- package/cjs/interfaces/company.interface.js +0 -4
- package/cjs/interfaces/index.js +0 -24
- package/cjs/interfaces/user-enricher.interface.js +0 -4
- package/cjs/interfaces/user.interface.js +0 -4
- package/cjs/modules/auth.module.js +0 -202
- package/cjs/modules/auth.module.spec.js +0 -243
- package/cjs/modules/index.js +0 -18
- package/cjs/services/auth-config.service.js +0 -110
- package/cjs/services/auth-config.service.spec.js +0 -97
- package/cjs/services/auth-datasource.provider.js +0 -134
- package/cjs/services/auth-datasource.provider.spec.js +0 -161
- package/cjs/services/auth-email.service.js +0 -539
- package/cjs/services/auth-email.service.spec.js +0 -456
- package/cjs/services/authentication.service.js +0 -1173
- package/cjs/services/authentication.service.spec.js +0 -962
- package/cjs/services/branch.service.js +0 -153
- package/cjs/services/branch.service.spec.js +0 -169
- package/cjs/services/company-selection-session.service.js +0 -121
- package/cjs/services/company-selection-session.service.spec.js +0 -90
- package/cjs/services/company.service.js +0 -140
- package/cjs/services/company.service.spec.js +0 -127
- package/cjs/services/index.js +0 -26
- package/cjs/services/user-permission.service.js +0 -236
- package/cjs/services/user-permission.service.spec.js +0 -254
- package/cjs/services/user.service.js +0 -671
- package/cjs/services/user.service.spec.js +0 -718
- package/cjs/strategies/jwt.strategy.js +0 -140
- package/cjs/strategies/jwt.strategy.spec.js +0 -166
- package/cjs/validators/password.validator.js +0 -45
- package/cjs/validators/password.validator.spec.js +0 -161
- package/fesm/config/auth.constants.js +0 -11
- package/fesm/config/event-actions.js +0 -24
- package/fesm/config/message-keys.js +0 -78
- package/fesm/controllers/authentication.controller.js +0 -417
- package/fesm/controllers/authentication.controller.spec.js +0 -215
- package/fesm/controllers/branch.controller.js +0 -92
- package/fesm/controllers/branch.controller.spec.js +0 -130
- package/fesm/controllers/company-selection.controller.js +0 -188
- package/fesm/controllers/company-selection.controller.spec.js +0 -80
- package/fesm/controllers/company.controller.js +0 -92
- package/fesm/controllers/company.controller.spec.js +0 -127
- package/fesm/controllers/email-verification.controller.js +0 -214
- package/fesm/controllers/email-verification.controller.spec.js +0 -138
- package/fesm/controllers/user-permission.controller.js +0 -213
- package/fesm/controllers/user-permission.controller.spec.js +0 -134
- package/fesm/controllers/user.controller.js +0 -428
- package/fesm/controllers/user.controller.spec.js +0 -200
- package/fesm/docs/auth-swagger.config.js +0 -446
- package/fesm/docs/auth-swagger.config.spec.js +0 -126
- package/fesm/dtos/authentication.dto.js +0 -683
- package/fesm/dtos/company-branch.dto.js +0 -279
- package/fesm/dtos/company.dto.js +0 -283
- package/fesm/dtos/user-permission.dto.js +0 -339
- package/fesm/dtos/user.dto.js +0 -391
- package/fesm/entities/app-user.entity.js +0 -15
- package/fesm/entities/company-branch.entity.js +0 -153
- package/fesm/entities/company.entity.js +0 -136
- package/fesm/entities/index.spec.js +0 -69
- package/fesm/entities/pending-registration.entity.js +0 -125
- package/fesm/entities/user-company-permission.entity.js +0 -136
- package/fesm/entities/user-token.entity.js +0 -104
- package/fesm/enums/user-org-permission-type.enum.js +0 -5
- package/fesm/helpers/auth-response.mapper.js +0 -25
- package/fesm/helpers/auth-response.mapper.spec.js +0 -135
- package/fesm/helpers/token.helper.js +0 -40
- package/fesm/helpers/token.helper.spec.js +0 -82
- package/fesm/interceptors/clear-token.interceptor.js +0 -63
- package/fesm/interceptors/clear-token.interceptor.spec.js +0 -103
- package/fesm/interceptors/set-token.interceptor.js +0 -98
- package/fesm/interceptors/set-token.interceptor.spec.js +0 -161
- package/fesm/interfaces/auth-email-provider.interface.js +0 -38
- package/fesm/interfaces/auth-module-options.interface.js +0 -3
- package/fesm/interfaces/authentication.interface.js +0 -1
- package/fesm/interfaces/company-branch.interface.js +0 -1
- package/fesm/interfaces/company.interface.js +0 -1
- package/fesm/interfaces/user-enricher.interface.js +0 -4
- package/fesm/interfaces/user.interface.js +0 -1
- package/fesm/modules/auth.module.js +0 -192
- package/fesm/modules/auth.module.spec.js +0 -239
- package/fesm/services/auth-config.service.js +0 -100
- package/fesm/services/auth-config.service.spec.js +0 -93
- package/fesm/services/auth-datasource.provider.js +0 -83
- package/fesm/services/auth-datasource.provider.spec.js +0 -157
- package/fesm/services/auth-email.service.js +0 -488
- package/fesm/services/auth-email.service.spec.js +0 -411
- package/fesm/services/authentication.service.js +0 -1122
- package/fesm/services/authentication.service.spec.js +0 -917
- package/fesm/services/branch.service.js +0 -143
- package/fesm/services/branch.service.spec.js +0 -165
- package/fesm/services/company-selection-session.service.js +0 -111
- package/fesm/services/company-selection-session.service.spec.js +0 -86
- package/fesm/services/company.service.js +0 -130
- package/fesm/services/company.service.spec.js +0 -123
- package/fesm/services/user-permission.service.js +0 -226
- package/fesm/services/user-permission.service.spec.js +0 -250
- package/fesm/services/user.service.js +0 -620
- package/fesm/services/user.service.spec.js +0 -673
- package/fesm/strategies/jwt.strategy.js +0 -130
- package/fesm/strategies/jwt.strategy.spec.js +0 -162
- package/fesm/validators/password.validator.js +0 -48
- package/fesm/validators/password.validator.spec.js +0 -157
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
const _nestjsshared = require("@flusys/nestjs-shared");
|
|
6
|
-
const _authdatasourceprovider = require("./auth-datasource.provider");
|
|
7
|
-
function buildOptions(overrides = {}) {
|
|
8
|
-
return {
|
|
9
|
-
global: false,
|
|
10
|
-
includeController: true,
|
|
11
|
-
bootstrapAppConfig: {
|
|
12
|
-
databaseMode: 'single',
|
|
13
|
-
enableCompanyFeature: false,
|
|
14
|
-
enableEmailVerification: true
|
|
15
|
-
},
|
|
16
|
-
...overrides
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
describe('AuthDataSourceProvider', ()=>{
|
|
20
|
-
afterEach(()=>{
|
|
21
|
-
jest.restoreAllMocks();
|
|
22
|
-
});
|
|
23
|
-
describe('isCompanyFeatureEnabled', ()=>{
|
|
24
|
-
it('returns false by default when bootstrap config disables it', ()=>{
|
|
25
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions());
|
|
26
|
-
expect(provider.isCompanyFeatureEnabled()).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
it('returns true when bootstrap config enables it', ()=>{
|
|
29
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
30
|
-
bootstrapAppConfig: {
|
|
31
|
-
databaseMode: 'single',
|
|
32
|
-
enableCompanyFeature: true
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
expect(provider.isCompanyFeatureEnabled()).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
it('prefers the tenant override over bootstrap config', ()=>{
|
|
38
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
39
|
-
bootstrapAppConfig: {
|
|
40
|
-
databaseMode: 'multi-tenant',
|
|
41
|
-
enableCompanyFeature: false
|
|
42
|
-
}
|
|
43
|
-
}));
|
|
44
|
-
expect(provider.isCompanyFeatureEnabled({
|
|
45
|
-
enableCompanyFeature: true
|
|
46
|
-
})).toBe(true);
|
|
47
|
-
});
|
|
48
|
-
it('defaults to false when no bootstrap config and no tenant override is present', ()=>{
|
|
49
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
50
|
-
bootstrapAppConfig: undefined
|
|
51
|
-
}));
|
|
52
|
-
expect(provider.isCompanyFeatureEnabled()).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
describe('isEmailVerificationEnabled', ()=>{
|
|
56
|
-
it('returns true by default (feature defaults to enabled)', ()=>{
|
|
57
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
58
|
-
bootstrapAppConfig: undefined
|
|
59
|
-
}));
|
|
60
|
-
expect(provider.isEmailVerificationEnabled()).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
it('returns false when bootstrap config disables it', ()=>{
|
|
63
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
64
|
-
bootstrapAppConfig: {
|
|
65
|
-
databaseMode: 'single',
|
|
66
|
-
enableCompanyFeature: false,
|
|
67
|
-
enableEmailVerification: false
|
|
68
|
-
}
|
|
69
|
-
}));
|
|
70
|
-
expect(provider.isEmailVerificationEnabled()).toBe(false);
|
|
71
|
-
});
|
|
72
|
-
it('prefers the tenant override over bootstrap config', ()=>{
|
|
73
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
74
|
-
bootstrapAppConfig: {
|
|
75
|
-
databaseMode: 'multi-tenant',
|
|
76
|
-
enableCompanyFeature: true,
|
|
77
|
-
enableEmailVerification: true
|
|
78
|
-
}
|
|
79
|
-
}));
|
|
80
|
-
expect(provider.isEmailVerificationEnabled({
|
|
81
|
-
enableEmailVerification: false
|
|
82
|
-
})).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('getAuthEntities', ()=>{
|
|
86
|
-
it('returns only base entities when company feature and email verification are disabled', async ()=>{
|
|
87
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
88
|
-
bootstrapAppConfig: {
|
|
89
|
-
databaseMode: 'single',
|
|
90
|
-
enableCompanyFeature: false,
|
|
91
|
-
enableEmailVerification: false
|
|
92
|
-
}
|
|
93
|
-
}));
|
|
94
|
-
const entities = await provider.getAuthEntities();
|
|
95
|
-
const names = entities.map((e)=>e.name);
|
|
96
|
-
expect(names).toEqual(expect.arrayContaining([
|
|
97
|
-
'AppUser',
|
|
98
|
-
'UserToken'
|
|
99
|
-
]));
|
|
100
|
-
expect(names).not.toContain('Company');
|
|
101
|
-
expect(names).not.toContain('PendingRegistration');
|
|
102
|
-
});
|
|
103
|
-
it('includes company entities when company feature is enabled', async ()=>{
|
|
104
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
105
|
-
bootstrapAppConfig: {
|
|
106
|
-
databaseMode: 'single',
|
|
107
|
-
enableCompanyFeature: true,
|
|
108
|
-
enableEmailVerification: false
|
|
109
|
-
}
|
|
110
|
-
}));
|
|
111
|
-
const entities = await provider.getAuthEntities();
|
|
112
|
-
const names = entities.map((e)=>e.name);
|
|
113
|
-
expect(names).toEqual(expect.arrayContaining([
|
|
114
|
-
'AppUser',
|
|
115
|
-
'UserToken',
|
|
116
|
-
'Company',
|
|
117
|
-
'CompanyBranch',
|
|
118
|
-
'UserCompanyPermission'
|
|
119
|
-
]));
|
|
120
|
-
});
|
|
121
|
-
it('includes pending registration entity when email verification is enabled', async ()=>{
|
|
122
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
123
|
-
bootstrapAppConfig: {
|
|
124
|
-
databaseMode: 'single',
|
|
125
|
-
enableCompanyFeature: false,
|
|
126
|
-
enableEmailVerification: true
|
|
127
|
-
}
|
|
128
|
-
}));
|
|
129
|
-
const entities = await provider.getAuthEntities();
|
|
130
|
-
const names = entities.map((e)=>e.name);
|
|
131
|
-
expect(names).toContain('PendingRegistration');
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
describe('createDataSourceFromConfig', ()=>{
|
|
135
|
-
it('forwards the config and resolved auth entities to the parent implementation', async ()=>{
|
|
136
|
-
const fakeDataSource = {
|
|
137
|
-
isInitialized: true
|
|
138
|
-
};
|
|
139
|
-
const parentSpy = jest.spyOn(_nestjsshared.MultiTenantDataSourceService.prototype, 'createDataSourceFromConfig').mockResolvedValue(fakeDataSource);
|
|
140
|
-
const provider = new _authdatasourceprovider.AuthDataSourceProvider(buildOptions({
|
|
141
|
-
bootstrapAppConfig: {
|
|
142
|
-
databaseMode: 'single',
|
|
143
|
-
enableCompanyFeature: true,
|
|
144
|
-
enableEmailVerification: true
|
|
145
|
-
}
|
|
146
|
-
}));
|
|
147
|
-
const config = {
|
|
148
|
-
type: 'postgres',
|
|
149
|
-
host: 'localhost'
|
|
150
|
-
};
|
|
151
|
-
const result = await provider.createDataSourceFromConfig(config);
|
|
152
|
-
expect(result).toBe(fakeDataSource);
|
|
153
|
-
expect(parentSpy).toHaveBeenCalledWith(config, expect.any(Array));
|
|
154
|
-
const forwardedEntityNames = parentSpy.mock.calls[0][1].map((e)=>e.name);
|
|
155
|
-
expect(forwardedEntityNames).toEqual(expect.arrayContaining([
|
|
156
|
-
'AppUser',
|
|
157
|
-
'Company'
|
|
158
|
-
]));
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
});
|
|
@@ -1,539 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "AuthEmailService", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return AuthEmailService;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
const _nestjsshared = require("@flusys/nestjs-shared");
|
|
12
|
-
const _classes = require("@flusys/nestjs-shared/classes");
|
|
13
|
-
const _constants = require("@flusys/nestjs-shared/constants");
|
|
14
|
-
const _common = require("@nestjs/common");
|
|
15
|
-
const _bcrypt = /*#__PURE__*/ _interop_require_wildcard(require("bcrypt"));
|
|
16
|
-
const _crypto = /*#__PURE__*/ _interop_require_wildcard(require("crypto"));
|
|
17
|
-
const _config = require("../config");
|
|
18
|
-
const _appuserentity = require("../entities/app-user.entity");
|
|
19
|
-
const _pendingregistrationentity = require("../entities/pending-registration.entity");
|
|
20
|
-
const _usertokenentity = require("../entities/user-token.entity");
|
|
21
|
-
const _interfaces = require("../interfaces");
|
|
22
|
-
const _authdatasourceprovider = require("./auth-datasource.provider");
|
|
23
|
-
function _define_property(obj, key, value) {
|
|
24
|
-
if (key in obj) {
|
|
25
|
-
Object.defineProperty(obj, key, {
|
|
26
|
-
value: value,
|
|
27
|
-
enumerable: true,
|
|
28
|
-
configurable: true,
|
|
29
|
-
writable: true
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
obj[key] = value;
|
|
33
|
-
}
|
|
34
|
-
return obj;
|
|
35
|
-
}
|
|
36
|
-
function _getRequireWildcardCache(nodeInterop) {
|
|
37
|
-
if (typeof WeakMap !== "function") return null;
|
|
38
|
-
var cacheBabelInterop = new WeakMap();
|
|
39
|
-
var cacheNodeInterop = new WeakMap();
|
|
40
|
-
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
41
|
-
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
42
|
-
})(nodeInterop);
|
|
43
|
-
}
|
|
44
|
-
function _interop_require_wildcard(obj, nodeInterop) {
|
|
45
|
-
if (!nodeInterop && obj && obj.__esModule) {
|
|
46
|
-
return obj;
|
|
47
|
-
}
|
|
48
|
-
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
49
|
-
return {
|
|
50
|
-
default: obj
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
var cache = _getRequireWildcardCache(nodeInterop);
|
|
54
|
-
if (cache && cache.has(obj)) {
|
|
55
|
-
return cache.get(obj);
|
|
56
|
-
}
|
|
57
|
-
var newObj = {
|
|
58
|
-
__proto__: null
|
|
59
|
-
};
|
|
60
|
-
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
61
|
-
for(var key in obj){
|
|
62
|
-
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
63
|
-
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
64
|
-
if (desc && (desc.get || desc.set)) {
|
|
65
|
-
Object.defineProperty(newObj, key, desc);
|
|
66
|
-
} else {
|
|
67
|
-
newObj[key] = obj[key];
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
newObj.default = obj;
|
|
72
|
-
if (cache) {
|
|
73
|
-
cache.set(obj, newObj);
|
|
74
|
-
}
|
|
75
|
-
return newObj;
|
|
76
|
-
}
|
|
77
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
78
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
79
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
80
|
-
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;
|
|
81
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
82
|
-
}
|
|
83
|
-
function _ts_metadata(k, v) {
|
|
84
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
85
|
-
}
|
|
86
|
-
function _ts_param(paramIndex, decorator) {
|
|
87
|
-
return function(target, key) {
|
|
88
|
-
decorator(target, key, paramIndex);
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
let AuthEmailService = class AuthEmailService {
|
|
92
|
-
isEmailEnabled() {
|
|
93
|
-
return !!this.emailProvider;
|
|
94
|
-
}
|
|
95
|
-
async getRepository(entity) {
|
|
96
|
-
if (!this.dataSourceProvider) {
|
|
97
|
-
throw new _common.InternalServerErrorException({
|
|
98
|
-
message: `${String(entity)} repository not available`,
|
|
99
|
-
messageKey: _constants.SYSTEM_MESSAGES.REPOSITORY_NOT_AVAILABLE,
|
|
100
|
-
messageVariables: {
|
|
101
|
-
entity: String(entity)
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return this.dataSourceProvider.getRepository(entity);
|
|
106
|
-
}
|
|
107
|
-
generateToken() {
|
|
108
|
-
return _crypto.randomBytes(32).toString('hex');
|
|
109
|
-
}
|
|
110
|
-
hashToken(token) {
|
|
111
|
-
return _crypto.createHash('sha256').update(token).digest('hex');
|
|
112
|
-
}
|
|
113
|
-
assertEmailEnabled() {
|
|
114
|
-
if (!this.emailProvider) {
|
|
115
|
-
throw new _common.BadRequestException({
|
|
116
|
-
message: 'Email service is not configured',
|
|
117
|
-
messageKey: _config.AUTH_MESSAGES.EMAIL_NOT_CONFIGURED
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async sendVerificationEmailSafe(email, token, verifyUrl) {
|
|
122
|
-
try {
|
|
123
|
-
await this.emailProvider.sendVerificationEmail(email, token, verifyUrl);
|
|
124
|
-
} catch {
|
|
125
|
-
throw new _common.BadRequestException({
|
|
126
|
-
message: 'Failed to send verification email. Please try again.',
|
|
127
|
-
messageKey: _config.AUTH_MESSAGES.EMAIL_SEND_FAILED
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
validateTokenNotExpiredOrUsed(token, expiredMessage, expiredMessageKey, usedMessage, usedMessageKey) {
|
|
132
|
-
if (token.expiresAt < new Date()) {
|
|
133
|
-
throw new _common.BadRequestException({
|
|
134
|
-
message: expiredMessage,
|
|
135
|
-
messageKey: expiredMessageKey
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
if (usedMessage && usedMessageKey && token.usedAt) {
|
|
139
|
-
throw new _common.BadRequestException({
|
|
140
|
-
message: usedMessage,
|
|
141
|
-
messageKey: usedMessageKey
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
async hasPendingRegistration(email) {
|
|
146
|
-
if (!this.isEmailEnabled()) return false;
|
|
147
|
-
const pendingRepository = await this.getRepository(_pendingregistrationentity.PendingRegistration);
|
|
148
|
-
const pending = await pendingRepository.findOne({
|
|
149
|
-
where: {
|
|
150
|
-
email
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
return !!pending && pending.expiresAt > new Date();
|
|
154
|
-
}
|
|
155
|
-
async createPendingRegistration(data) {
|
|
156
|
-
this.assertEmailEnabled();
|
|
157
|
-
const userRepository = await this.getRepository(_appuserentity.AppUser);
|
|
158
|
-
const pendingRepository = await this.getRepository(_pendingregistrationentity.PendingRegistration);
|
|
159
|
-
// Check if user already exists
|
|
160
|
-
const existingUser = await userRepository.findOne({
|
|
161
|
-
where: {
|
|
162
|
-
email: data.email
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
if (existingUser) {
|
|
166
|
-
throw new _common.BadRequestException({
|
|
167
|
-
message: 'Registration failed. Please try again or contact support.',
|
|
168
|
-
messageKey: _config.AUTH_MESSAGES.REGISTER_FAILED
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
// Delete any existing pending registration for this email
|
|
172
|
-
await pendingRepository.delete({
|
|
173
|
-
email: data.email
|
|
174
|
-
});
|
|
175
|
-
// Create pending registration with hashed token for secure storage
|
|
176
|
-
const token = this.generateToken();
|
|
177
|
-
const tokenHash = this.hashToken(token);
|
|
178
|
-
const passwordHash = await _bcrypt.hash(data.password, _config.BCRYPT_SALT_ROUNDS);
|
|
179
|
-
const expiresAt = new Date(Date.now() + this.EMAIL_VERIFICATION_EXPIRY);
|
|
180
|
-
const pending = pendingRepository.create({
|
|
181
|
-
email: data.email,
|
|
182
|
-
name: data.name ?? null,
|
|
183
|
-
phone: data.phone ?? null,
|
|
184
|
-
passwordHash,
|
|
185
|
-
token: tokenHash,
|
|
186
|
-
expiresAt,
|
|
187
|
-
companyData: data.companyData ?? null,
|
|
188
|
-
additionalFields: data.additionalFields ?? null
|
|
189
|
-
});
|
|
190
|
-
await pendingRepository.save(pending);
|
|
191
|
-
// Send verification email with raw token (user receives this)
|
|
192
|
-
const verifyUrl = `${data.verifyUrlBase}?token=${token}`;
|
|
193
|
-
await this.sendVerificationEmailSafe(data.email, token, verifyUrl);
|
|
194
|
-
return {
|
|
195
|
-
success: true,
|
|
196
|
-
message: 'Please check your email to verify your registration.',
|
|
197
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_SENT
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
async forgotPassword(email, resetUrlBase) {
|
|
201
|
-
this.assertEmailEnabled();
|
|
202
|
-
const userRepository = await this.getRepository(_appuserentity.AppUser);
|
|
203
|
-
const tokenRepository = await this.getRepository(_usertokenentity.UserToken);
|
|
204
|
-
const user = await userRepository.findOne({
|
|
205
|
-
where: {
|
|
206
|
-
email
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
// Always return success to prevent email enumeration
|
|
210
|
-
if (!user || !user.isActive) {
|
|
211
|
-
return {
|
|
212
|
-
success: true,
|
|
213
|
-
message: 'If the email exists, a password reset link has been sent.',
|
|
214
|
-
messageKey: _config.AUTH_MESSAGES.PASSWORD_RESET_EMAIL_SENT
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
// Invalidate existing password reset tokens for this user
|
|
218
|
-
await tokenRepository.delete({
|
|
219
|
-
userId: user.id,
|
|
220
|
-
type: _usertokenentity.TokenType.PASSWORD_RESET
|
|
221
|
-
});
|
|
222
|
-
// Create new token with hashed storage
|
|
223
|
-
const token = this.generateToken();
|
|
224
|
-
const tokenHash = this.hashToken(token);
|
|
225
|
-
const userToken = tokenRepository.create({
|
|
226
|
-
userId: user.id,
|
|
227
|
-
type: _usertokenentity.TokenType.PASSWORD_RESET,
|
|
228
|
-
token: tokenHash,
|
|
229
|
-
expiresAt: new Date(Date.now() + this.PASSWORD_RESET_EXPIRY)
|
|
230
|
-
});
|
|
231
|
-
await tokenRepository.save(userToken);
|
|
232
|
-
// Send email with raw token
|
|
233
|
-
const resetUrl = `${resetUrlBase}?token=${token}`;
|
|
234
|
-
try {
|
|
235
|
-
await this.emailProvider.sendPasswordResetEmail(email, token, resetUrl);
|
|
236
|
-
} catch {
|
|
237
|
-
throw new _common.BadRequestException({
|
|
238
|
-
message: 'Failed to process request. Please try again later.',
|
|
239
|
-
messageKey: _constants.SYSTEM_MESSAGES.INTERNAL_ERROR,
|
|
240
|
-
messageVariables: {
|
|
241
|
-
provider: 'EmailProvider',
|
|
242
|
-
error: 'Send email failed'
|
|
243
|
-
}
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
await this.publishUserEvent(_config.AUTH_EVENT_ACTIONS.PASSWORD_RESET_REQUESTED, user.id, {
|
|
247
|
-
email: user.email
|
|
248
|
-
});
|
|
249
|
-
return {
|
|
250
|
-
success: true,
|
|
251
|
-
message: 'If the email exists, a password reset link has been sent.',
|
|
252
|
-
messageKey: _config.AUTH_MESSAGES.PASSWORD_RESET_EMAIL_SENT
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
async resetPassword(token, newPassword) {
|
|
256
|
-
const userRepository = await this.getRepository(_appuserentity.AppUser);
|
|
257
|
-
const tokenRepository = await this.getRepository(_usertokenentity.UserToken);
|
|
258
|
-
// Hash the incoming token to compare with stored hash
|
|
259
|
-
const tokenHash = this.hashToken(token);
|
|
260
|
-
const userToken = await tokenRepository.findOne({
|
|
261
|
-
where: {
|
|
262
|
-
token: tokenHash,
|
|
263
|
-
type: _usertokenentity.TokenType.PASSWORD_RESET
|
|
264
|
-
}
|
|
265
|
-
});
|
|
266
|
-
if (!userToken) {
|
|
267
|
-
throw new _common.BadRequestException({
|
|
268
|
-
message: 'Invalid or expired reset token',
|
|
269
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_INVALID
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
this.validateTokenNotExpiredOrUsed(userToken, 'Reset token has expired. Please request a new one.', _config.AUTH_MESSAGES.PASSWORD_RESET_TOKEN_EXPIRED, 'This reset token has already been used.', _config.AUTH_MESSAGES.PASSWORD_RESET_TOKEN_USED);
|
|
273
|
-
const user = await userRepository.findOne({
|
|
274
|
-
where: {
|
|
275
|
-
id: userToken.userId
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
if (!user) {
|
|
279
|
-
throw new _common.BadRequestException({
|
|
280
|
-
message: 'User not found',
|
|
281
|
-
messageKey: _config.USER_MESSAGES.NOT_FOUND
|
|
282
|
-
});
|
|
283
|
-
}
|
|
284
|
-
// Update password
|
|
285
|
-
user.password = await _bcrypt.hash(newPassword, _config.BCRYPT_SALT_ROUNDS);
|
|
286
|
-
await userRepository.save(user);
|
|
287
|
-
// Mark token as used
|
|
288
|
-
userToken.usedAt = new Date();
|
|
289
|
-
await tokenRepository.save(userToken);
|
|
290
|
-
await this.publishUserEvent(_config.AUTH_EVENT_ACTIONS.PASSWORD_RESET, user.id, {
|
|
291
|
-
email: user.email
|
|
292
|
-
});
|
|
293
|
-
return {
|
|
294
|
-
success: true,
|
|
295
|
-
message: 'Password has been reset successfully.',
|
|
296
|
-
messageKey: _config.AUTH_MESSAGES.PASSWORD_RESET_SUCCESS
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
async verifyEmail(token) {
|
|
300
|
-
const pendingRepository = await this.getRepository(_pendingregistrationentity.PendingRegistration);
|
|
301
|
-
const userRepository = await this.getRepository(_appuserentity.AppUser);
|
|
302
|
-
const tokenRepository = await this.getRepository(_usertokenentity.UserToken);
|
|
303
|
-
// Hash the incoming token to compare with stored hash
|
|
304
|
-
const tokenHash = this.hashToken(token);
|
|
305
|
-
// Check for pending registration first
|
|
306
|
-
const pending = await pendingRepository.findOne({
|
|
307
|
-
where: {
|
|
308
|
-
token: tokenHash
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
if (pending) {
|
|
312
|
-
if (pending.expiresAt < new Date()) {
|
|
313
|
-
await pendingRepository.delete({
|
|
314
|
-
id: pending.id
|
|
315
|
-
});
|
|
316
|
-
throw new _common.BadRequestException({
|
|
317
|
-
message: 'Verification token has expired. Please register again.',
|
|
318
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_EXPIRED
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
// Delete pending registration (will be consumed by caller to create user)
|
|
322
|
-
await pendingRepository.delete({
|
|
323
|
-
id: pending.id
|
|
324
|
-
});
|
|
325
|
-
return {
|
|
326
|
-
type: 'pending',
|
|
327
|
-
pending
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
// Check for existing user email verification token
|
|
331
|
-
const userToken = await tokenRepository.findOne({
|
|
332
|
-
where: {
|
|
333
|
-
token: tokenHash,
|
|
334
|
-
type: _usertokenentity.TokenType.EMAIL_VERIFICATION
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
if (!userToken) {
|
|
338
|
-
throw new _common.BadRequestException({
|
|
339
|
-
message: 'Invalid or expired verification token',
|
|
340
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_INVALID
|
|
341
|
-
});
|
|
342
|
-
}
|
|
343
|
-
if (userToken.expiresAt < new Date()) {
|
|
344
|
-
await tokenRepository.delete({
|
|
345
|
-
id: userToken.id
|
|
346
|
-
});
|
|
347
|
-
throw new _common.BadRequestException({
|
|
348
|
-
message: 'Verification token has expired. Please request a new one.',
|
|
349
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_TOKEN_EXPIRED
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
if (userToken.usedAt) {
|
|
353
|
-
return {
|
|
354
|
-
type: 'verified',
|
|
355
|
-
message: 'Email has already been verified.',
|
|
356
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_SUCCESS
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
const user = await userRepository.findOne({
|
|
360
|
-
where: {
|
|
361
|
-
id: userToken.userId
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
if (!user) {
|
|
365
|
-
throw new _common.BadRequestException({
|
|
366
|
-
message: 'User not found',
|
|
367
|
-
messageKey: _config.USER_MESSAGES.NOT_FOUND
|
|
368
|
-
});
|
|
369
|
-
}
|
|
370
|
-
// Mark email as verified
|
|
371
|
-
user.emailVerified = true;
|
|
372
|
-
await userRepository.save(user);
|
|
373
|
-
// Mark token as used
|
|
374
|
-
userToken.usedAt = new Date();
|
|
375
|
-
await tokenRepository.save(userToken);
|
|
376
|
-
await this.publishUserEvent(_config.AUTH_EVENT_ACTIONS.EMAIL_VERIFIED, user.id, {
|
|
377
|
-
email: user.email
|
|
378
|
-
});
|
|
379
|
-
return {
|
|
380
|
-
type: 'verified',
|
|
381
|
-
message: 'Email has been verified successfully.',
|
|
382
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.VERIFICATION_SUCCESS
|
|
383
|
-
};
|
|
384
|
-
}
|
|
385
|
-
async publishUserEvent(action, userId, metadata) {
|
|
386
|
-
await (0, _classes.publishDomainEvent)({
|
|
387
|
-
module: _config.AUTH_EVENT_MODULE,
|
|
388
|
-
entity: _config.AUTH_EVENT_ENTITIES.USER,
|
|
389
|
-
action,
|
|
390
|
-
ids: [
|
|
391
|
-
userId
|
|
392
|
-
],
|
|
393
|
-
metadata
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
async resendVerificationEmail(email, verifyUrlBase) {
|
|
397
|
-
this.assertEmailEnabled();
|
|
398
|
-
const pendingRepository = await this.getRepository(_pendingregistrationentity.PendingRegistration);
|
|
399
|
-
const userRepository = await this.getRepository(_appuserentity.AppUser);
|
|
400
|
-
const tokenRepository = await this.getRepository(_usertokenentity.UserToken);
|
|
401
|
-
// Check pending registration first
|
|
402
|
-
const pending = await pendingRepository.findOne({
|
|
403
|
-
where: {
|
|
404
|
-
email
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
if (pending) {
|
|
408
|
-
const token = this.generateToken();
|
|
409
|
-
pending.token = this.hashToken(token);
|
|
410
|
-
pending.expiresAt = new Date(Date.now() + this.EMAIL_VERIFICATION_EXPIRY);
|
|
411
|
-
await pendingRepository.save(pending);
|
|
412
|
-
const verifyUrl = `${verifyUrlBase}?token=${token}`;
|
|
413
|
-
await this.sendVerificationEmailSafe(email, token, verifyUrl);
|
|
414
|
-
return {
|
|
415
|
-
success: true,
|
|
416
|
-
message: 'If the email requires verification, a link has been sent.',
|
|
417
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.RESEND_SUCCESS
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
// Check existing user
|
|
421
|
-
const user = await userRepository.findOne({
|
|
422
|
-
where: {
|
|
423
|
-
email
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
if (!user || user.emailVerified) {
|
|
427
|
-
return {
|
|
428
|
-
success: true,
|
|
429
|
-
message: 'If the email requires verification, a link has been sent.',
|
|
430
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.RESEND_SUCCESS
|
|
431
|
-
};
|
|
432
|
-
}
|
|
433
|
-
// Invalidate existing tokens and create new one
|
|
434
|
-
await tokenRepository.delete({
|
|
435
|
-
userId: user.id,
|
|
436
|
-
type: _usertokenentity.TokenType.EMAIL_VERIFICATION
|
|
437
|
-
});
|
|
438
|
-
const token = this.generateToken();
|
|
439
|
-
const userToken = tokenRepository.create({
|
|
440
|
-
userId: user.id,
|
|
441
|
-
type: _usertokenentity.TokenType.EMAIL_VERIFICATION,
|
|
442
|
-
token: this.hashToken(token),
|
|
443
|
-
expiresAt: new Date(Date.now() + this.EMAIL_VERIFICATION_EXPIRY)
|
|
444
|
-
});
|
|
445
|
-
await tokenRepository.save(userToken);
|
|
446
|
-
const verifyUrl = `${verifyUrlBase}?token=${token}`;
|
|
447
|
-
await this.sendVerificationEmailSafe(user.email, token, verifyUrl);
|
|
448
|
-
return {
|
|
449
|
-
success: true,
|
|
450
|
-
message: 'If the email requires verification, a link has been sent.',
|
|
451
|
-
messageKey: _config.EMAIL_VERIFICATION_MESSAGES.RESEND_SUCCESS
|
|
452
|
-
};
|
|
453
|
-
}
|
|
454
|
-
constructor(dataSourceProvider, emailProvider){
|
|
455
|
-
_define_property(this, "dataSourceProvider", void 0);
|
|
456
|
-
_define_property(this, "emailProvider", void 0);
|
|
457
|
-
_define_property(this, "PASSWORD_RESET_EXPIRY", void 0); // 1 hour
|
|
458
|
-
_define_property(this, "EMAIL_VERIFICATION_EXPIRY", void 0); // 24 hours
|
|
459
|
-
this.dataSourceProvider = dataSourceProvider;
|
|
460
|
-
this.emailProvider = emailProvider;
|
|
461
|
-
this.PASSWORD_RESET_EXPIRY = 60 * 60 * 1000;
|
|
462
|
-
this.EMAIL_VERIFICATION_EXPIRY = 24 * 60 * 60 * 1000;
|
|
463
|
-
}
|
|
464
|
-
};
|
|
465
|
-
_ts_decorate([
|
|
466
|
-
(0, _nestjsshared.LogAction)({
|
|
467
|
-
action: 'auth.createPendingRegistration',
|
|
468
|
-
module: 'auth',
|
|
469
|
-
includeParams: false
|
|
470
|
-
}),
|
|
471
|
-
_ts_metadata("design:type", Function),
|
|
472
|
-
_ts_metadata("design:paramtypes", [
|
|
473
|
-
Object
|
|
474
|
-
]),
|
|
475
|
-
_ts_metadata("design:returntype", Promise)
|
|
476
|
-
], AuthEmailService.prototype, "createPendingRegistration", null);
|
|
477
|
-
_ts_decorate([
|
|
478
|
-
(0, _nestjsshared.LogAction)({
|
|
479
|
-
action: 'auth.forgotPassword',
|
|
480
|
-
module: 'auth',
|
|
481
|
-
includeParams: false
|
|
482
|
-
}),
|
|
483
|
-
_ts_metadata("design:type", Function),
|
|
484
|
-
_ts_metadata("design:paramtypes", [
|
|
485
|
-
String,
|
|
486
|
-
String
|
|
487
|
-
]),
|
|
488
|
-
_ts_metadata("design:returntype", Promise)
|
|
489
|
-
], AuthEmailService.prototype, "forgotPassword", null);
|
|
490
|
-
_ts_decorate([
|
|
491
|
-
(0, _nestjsshared.LogAction)({
|
|
492
|
-
action: 'auth.resetPassword',
|
|
493
|
-
module: 'auth',
|
|
494
|
-
includeParams: false
|
|
495
|
-
}),
|
|
496
|
-
_ts_metadata("design:type", Function),
|
|
497
|
-
_ts_metadata("design:paramtypes", [
|
|
498
|
-
String,
|
|
499
|
-
String
|
|
500
|
-
]),
|
|
501
|
-
_ts_metadata("design:returntype", Promise)
|
|
502
|
-
], AuthEmailService.prototype, "resetPassword", null);
|
|
503
|
-
_ts_decorate([
|
|
504
|
-
(0, _nestjsshared.LogAction)({
|
|
505
|
-
action: 'auth.verifyEmailToken',
|
|
506
|
-
module: 'auth'
|
|
507
|
-
}),
|
|
508
|
-
_ts_metadata("design:type", Function),
|
|
509
|
-
_ts_metadata("design:paramtypes", [
|
|
510
|
-
String
|
|
511
|
-
]),
|
|
512
|
-
_ts_metadata("design:returntype", Promise)
|
|
513
|
-
], AuthEmailService.prototype, "verifyEmail", null);
|
|
514
|
-
_ts_decorate([
|
|
515
|
-
(0, _nestjsshared.LogAction)({
|
|
516
|
-
action: 'auth.sendVerificationEmail',
|
|
517
|
-
module: 'auth'
|
|
518
|
-
}),
|
|
519
|
-
_ts_metadata("design:type", Function),
|
|
520
|
-
_ts_metadata("design:paramtypes", [
|
|
521
|
-
String,
|
|
522
|
-
String
|
|
523
|
-
]),
|
|
524
|
-
_ts_metadata("design:returntype", Promise)
|
|
525
|
-
], AuthEmailService.prototype, "resendVerificationEmail", null);
|
|
526
|
-
AuthEmailService = _ts_decorate([
|
|
527
|
-
(0, _common.Injectable)({
|
|
528
|
-
scope: _common.Scope.REQUEST
|
|
529
|
-
}),
|
|
530
|
-
_ts_param(0, (0, _common.Optional)()),
|
|
531
|
-
_ts_param(0, (0, _common.Inject)(_authdatasourceprovider.AuthDataSourceProvider)),
|
|
532
|
-
_ts_param(1, (0, _common.Optional)()),
|
|
533
|
-
_ts_param(1, (0, _common.Inject)(_interfaces.AUTH_EMAIL_PROVIDER)),
|
|
534
|
-
_ts_metadata("design:type", Function),
|
|
535
|
-
_ts_metadata("design:paramtypes", [
|
|
536
|
-
typeof _authdatasourceprovider.AuthDataSourceProvider === "undefined" ? Object : _authdatasourceprovider.AuthDataSourceProvider,
|
|
537
|
-
typeof _interfaces.IAuthEmailProvider === "undefined" ? Object : _interfaces.IAuthEmailProvider
|
|
538
|
-
])
|
|
539
|
-
], AuthEmailService);
|