@flusys/nestjs-auth 7.1.0 → 8.0.0
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 +1 -1
- package/config/index.d.ts +3 -3
- package/config/message-keys.d.ts +4 -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 -9
- package/controllers/social-auth-config.controller.d.ts +2 -2
- package/controllers/social-auth.controller.d.ts +3 -3
- package/controllers/user-permission.controller.d.ts +7 -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 -6
- package/dtos/social-auth.dto.d.ts +1 -1
- package/dtos/user-permission.dto.d.ts +30 -0
- package/entities/company-branch.entity.d.ts +1 -1
- package/entities/company.entity.d.ts +1 -1
- package/entities/index.d.ts +14 -14
- package/entities/pending-registration.entity.d.ts +1 -1
- package/entities/user-company-permission.entity.d.ts +4 -4
- package/enums/index.d.ts +2 -2
- package/fesm/118.js +1404 -0
- package/fesm/120.js +2265 -0
- package/fesm/24.js +4422 -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 +246 -3
- package/fesm/controllers/index.js +27 -9
- package/fesm/docs/index.js +479 -1
- package/fesm/dtos/index.js +135 -6
- package/fesm/entities/index.js +68 -22
- package/fesm/enums/index.js +53 -2
- package/fesm/helpers/index.js +115 -2
- package/fesm/index.js +1455 -13
- package/fesm/interceptors/index.js +510 -2
- package/fesm/interfaces/index.js +75 -8
- package/fesm/modules/index.js +546 -1
- package/fesm/runtime.js +134 -0
- package/fesm/services/index.js +67 -11
- 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 -13
- 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 -8
- package/interfaces/social-auth.interface.d.ts +2 -2
- 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 +2 -2
- package/providers/google.social-provider.d.ts +2 -2
- package/providers/index.d.ts +1 -1
- package/providers/linkedin.social-provider.d.ts +2 -2
- package/providers/microsoft.social-provider.d.ts +2 -2
- package/providers/social-provider.registry.d.ts +2 -2
- package/services/auth-config.service.d.ts +3 -3
- package/services/auth-datasource.provider.d.ts +3 -3
- package/services/auth-email.service.d.ts +3 -3
- package/services/authentication.service.d.ts +12 -12
- package/services/branch.service.d.ts +7 -7
- package/services/company.service.d.ts +6 -6
- package/services/index.d.ts +11 -11
- package/services/social-auth-config.service.d.ts +6 -6
- package/services/social-auth.service.d.ts +5 -5
- package/services/user-permission.service.d.ts +10 -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 -49
- package/cjs/config/event-actions.js +0 -47
- package/cjs/config/index.js +0 -20
- package/cjs/config/message-keys.js +0 -135
- 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 -26
- package/cjs/controllers/social-auth-config.controller.js +0 -107
- package/cjs/controllers/social-auth.controller.js +0 -175
- package/cjs/controllers/social-auth.controller.spec.js +0 -79
- 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 -461
- 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 -23
- package/cjs/dtos/social-auth.dto.js +0 -318
- 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 -67
- package/cjs/entities/index.spec.js +0 -84
- package/cjs/entities/pending-registration.entity.js +0 -135
- package/cjs/entities/social-auth-config.entity.js +0 -102
- 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 -19
- package/cjs/enums/social-provider-type.enum.js +0 -17
- 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 -30
- 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 -25
- package/cjs/interfaces/social-auth.interface.js +0 -4
- package/cjs/interfaces/user-enricher.interface.js +0 -4
- package/cjs/interfaces/user.interface.js +0 -4
- package/cjs/modules/auth.module.js +0 -208
- package/cjs/modules/auth.module.spec.js +0 -258
- package/cjs/modules/index.js +0 -18
- package/cjs/providers/facebook.social-provider.js +0 -73
- package/cjs/providers/google.social-provider.js +0 -68
- package/cjs/providers/index.js +0 -18
- package/cjs/providers/linkedin.social-provider.js +0 -66
- package/cjs/providers/microsoft.social-provider.js +0 -78
- package/cjs/providers/oauth-http.util.js +0 -107
- package/cjs/providers/social-provider.registry.js +0 -24
- package/cjs/providers/social-provider.registry.spec.js +0 -135
- package/cjs/services/auth-config.service.js +0 -113
- package/cjs/services/auth-config.service.spec.js +0 -100
- package/cjs/services/auth-datasource.provider.js +0 -138
- package/cjs/services/auth-datasource.provider.spec.js +0 -191
- 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 -1203
- package/cjs/services/authentication.service.spec.js +0 -1020
- 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 -28
- package/cjs/services/social-auth-config.service.js +0 -103
- package/cjs/services/social-auth-config.service.spec.js +0 -71
- package/cjs/services/social-auth.service.js +0 -310
- package/cjs/services/social-auth.service.spec.js +0 -310
- 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 -14
- package/fesm/config/event-actions.js +0 -26
- package/fesm/config/message-keys.js +0 -99
- 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/social-auth-config.controller.js +0 -97
- package/fesm/controllers/social-auth.controller.js +0 -165
- package/fesm/controllers/social-auth.controller.spec.js +0 -75
- 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 -454
- 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/social-auth.dto.js +0 -282
- 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 -80
- package/fesm/entities/pending-registration.entity.js +0 -125
- package/fesm/entities/social-auth-config.entity.js +0 -92
- package/fesm/entities/user-company-permission.entity.js +0 -136
- package/fesm/entities/user-token.entity.js +0 -104
- package/fesm/enums/social-provider-type.enum.js +0 -7
- 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/social-auth.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 -198
- package/fesm/modules/auth.module.spec.js +0 -254
- package/fesm/providers/facebook.social-provider.js +0 -63
- package/fesm/providers/google.social-provider.js +0 -58
- package/fesm/providers/index.js +0 -1
- package/fesm/providers/linkedin.social-provider.js +0 -56
- package/fesm/providers/microsoft.social-provider.js +0 -68
- package/fesm/providers/oauth-http.util.js +0 -77
- package/fesm/providers/social-provider.registry.js +0 -14
- package/fesm/providers/social-provider.registry.spec.js +0 -131
- package/fesm/services/auth-config.service.js +0 -103
- package/fesm/services/auth-config.service.spec.js +0 -96
- package/fesm/services/auth-datasource.provider.js +0 -87
- package/fesm/services/auth-datasource.provider.spec.js +0 -187
- 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 -1152
- package/fesm/services/authentication.service.spec.js +0 -975
- 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/social-auth-config.service.js +0 -93
- package/fesm/services/social-auth-config.service.spec.js +0 -67
- package/fesm/services/social-auth.service.js +0 -300
- package/fesm/services/social-auth.service.spec.js +0 -265
- 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,454 +0,0 @@
|
|
|
1
|
-
// ============================================================================
|
|
2
|
-
// Company feature exclusions
|
|
3
|
-
// ============================================================================
|
|
4
|
-
const COMPANY_RELATED_TAGS = [
|
|
5
|
-
'Companies',
|
|
6
|
-
'Branches',
|
|
7
|
-
'User Permissions',
|
|
8
|
-
'Company Selection'
|
|
9
|
-
];
|
|
10
|
-
const COMPANY_SCHEMA_EXCLUSIONS = [
|
|
11
|
-
// Request DTOs
|
|
12
|
-
{
|
|
13
|
-
schemaName: 'RegistrationDto',
|
|
14
|
-
properties: [
|
|
15
|
-
'companySlug',
|
|
16
|
-
'branchSlug',
|
|
17
|
-
'newCompanyName',
|
|
18
|
-
'newCompanyPhone',
|
|
19
|
-
'newCompanyAddress'
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
schemaName: 'SelectDto',
|
|
24
|
-
properties: [
|
|
25
|
-
'sessionId',
|
|
26
|
-
'companyId',
|
|
27
|
-
'branchId'
|
|
28
|
-
]
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
schemaName: 'SwitchCompanyDto',
|
|
32
|
-
properties: [
|
|
33
|
-
'companyId',
|
|
34
|
-
'branchId'
|
|
35
|
-
]
|
|
36
|
-
},
|
|
37
|
-
// Response DTOs
|
|
38
|
-
{
|
|
39
|
-
schemaName: 'RegistrationResponseDto',
|
|
40
|
-
properties: [
|
|
41
|
-
'company',
|
|
42
|
-
'branch'
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
schemaName: 'LoginResponseDto',
|
|
47
|
-
properties: [
|
|
48
|
-
'company',
|
|
49
|
-
'branch'
|
|
50
|
-
]
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
schemaName: 'MeResponseDto',
|
|
54
|
-
properties: [
|
|
55
|
-
'company',
|
|
56
|
-
'branch'
|
|
57
|
-
]
|
|
58
|
-
},
|
|
59
|
-
// Nested helper DTOs
|
|
60
|
-
{
|
|
61
|
-
schemaName: 'CompanyInfoDto',
|
|
62
|
-
properties: [
|
|
63
|
-
'id',
|
|
64
|
-
'name',
|
|
65
|
-
'slug',
|
|
66
|
-
'logoId'
|
|
67
|
-
]
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
schemaName: 'BranchInfoDto',
|
|
71
|
-
properties: [
|
|
72
|
-
'id',
|
|
73
|
-
'name',
|
|
74
|
-
'slug',
|
|
75
|
-
'logoId'
|
|
76
|
-
]
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
schemaName: 'BranchSelectionInfoDto',
|
|
80
|
-
properties: [
|
|
81
|
-
'id',
|
|
82
|
-
'name',
|
|
83
|
-
'slug',
|
|
84
|
-
'logoId'
|
|
85
|
-
]
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
schemaName: 'CompanyWithBranchesDto',
|
|
89
|
-
properties: [
|
|
90
|
-
'id',
|
|
91
|
-
'name',
|
|
92
|
-
'slug',
|
|
93
|
-
'logoId',
|
|
94
|
-
'branches'
|
|
95
|
-
]
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
schemaName: 'CompanySelectionResponseDto',
|
|
99
|
-
properties: [
|
|
100
|
-
'requiresSelection',
|
|
101
|
-
'sessionId',
|
|
102
|
-
'expiresAt',
|
|
103
|
-
'user',
|
|
104
|
-
'companies'
|
|
105
|
-
]
|
|
106
|
-
},
|
|
107
|
-
// Company management DTOs
|
|
108
|
-
{
|
|
109
|
-
schemaName: 'CreateCompanyDto',
|
|
110
|
-
properties: [
|
|
111
|
-
'name',
|
|
112
|
-
'slug',
|
|
113
|
-
'logoId',
|
|
114
|
-
'address',
|
|
115
|
-
'phone',
|
|
116
|
-
'email',
|
|
117
|
-
'website',
|
|
118
|
-
'serial',
|
|
119
|
-
'isActive',
|
|
120
|
-
'settings',
|
|
121
|
-
'additionalFields'
|
|
122
|
-
]
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
schemaName: 'UpdateCompanyDto',
|
|
126
|
-
properties: [
|
|
127
|
-
'id',
|
|
128
|
-
'name',
|
|
129
|
-
'slug',
|
|
130
|
-
'logoId',
|
|
131
|
-
'address',
|
|
132
|
-
'phone',
|
|
133
|
-
'email',
|
|
134
|
-
'website',
|
|
135
|
-
'serial',
|
|
136
|
-
'isActive',
|
|
137
|
-
'settings',
|
|
138
|
-
'additionalFields'
|
|
139
|
-
]
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
schemaName: 'CompanyResponseDto',
|
|
143
|
-
properties: [
|
|
144
|
-
'id',
|
|
145
|
-
'name',
|
|
146
|
-
'slug',
|
|
147
|
-
'logoId',
|
|
148
|
-
'address',
|
|
149
|
-
'phone',
|
|
150
|
-
'email',
|
|
151
|
-
'website',
|
|
152
|
-
'serial',
|
|
153
|
-
'isActive',
|
|
154
|
-
'settings',
|
|
155
|
-
'additionalFields',
|
|
156
|
-
'readOnly',
|
|
157
|
-
'createdAt',
|
|
158
|
-
'updatedAt'
|
|
159
|
-
]
|
|
160
|
-
},
|
|
161
|
-
// Branch management DTOs
|
|
162
|
-
{
|
|
163
|
-
schemaName: 'CreateCompanyBranchDto',
|
|
164
|
-
properties: [
|
|
165
|
-
'name',
|
|
166
|
-
'slug',
|
|
167
|
-
'companyId',
|
|
168
|
-
'parentId',
|
|
169
|
-
'logoId',
|
|
170
|
-
'address',
|
|
171
|
-
'phone',
|
|
172
|
-
'email',
|
|
173
|
-
'serial',
|
|
174
|
-
'isActive',
|
|
175
|
-
'additionalFields'
|
|
176
|
-
]
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
schemaName: 'UpdateCompanyBranchDto',
|
|
180
|
-
properties: [
|
|
181
|
-
'id',
|
|
182
|
-
'name',
|
|
183
|
-
'slug',
|
|
184
|
-
'companyId',
|
|
185
|
-
'parentId',
|
|
186
|
-
'logoId',
|
|
187
|
-
'address',
|
|
188
|
-
'phone',
|
|
189
|
-
'email',
|
|
190
|
-
'serial',
|
|
191
|
-
'isActive',
|
|
192
|
-
'additionalFields'
|
|
193
|
-
]
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
schemaName: 'CompanyBranchResponseDto',
|
|
197
|
-
properties: [
|
|
198
|
-
'id',
|
|
199
|
-
'name',
|
|
200
|
-
'slug',
|
|
201
|
-
'companyId',
|
|
202
|
-
'parentId',
|
|
203
|
-
'logoId',
|
|
204
|
-
'address',
|
|
205
|
-
'phone',
|
|
206
|
-
'email',
|
|
207
|
-
'serial',
|
|
208
|
-
'isActive',
|
|
209
|
-
'additionalFields',
|
|
210
|
-
'readOnly',
|
|
211
|
-
'createdAt',
|
|
212
|
-
'updatedAt'
|
|
213
|
-
]
|
|
214
|
-
},
|
|
215
|
-
// User permission DTOs
|
|
216
|
-
{
|
|
217
|
-
schemaName: 'UserCompanyPermissionDto',
|
|
218
|
-
properties: [
|
|
219
|
-
'id',
|
|
220
|
-
'userId',
|
|
221
|
-
'companyId',
|
|
222
|
-
'companyName',
|
|
223
|
-
'companySlug'
|
|
224
|
-
]
|
|
225
|
-
},
|
|
226
|
-
{
|
|
227
|
-
schemaName: 'UserBranchPermissionDto',
|
|
228
|
-
properties: [
|
|
229
|
-
'id',
|
|
230
|
-
'userId',
|
|
231
|
-
'branchId',
|
|
232
|
-
'branchName',
|
|
233
|
-
'branchSlug',
|
|
234
|
-
'companyId'
|
|
235
|
-
]
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
schemaName: 'AssignUserCompanyDto',
|
|
239
|
-
properties: [
|
|
240
|
-
'userId',
|
|
241
|
-
'items'
|
|
242
|
-
]
|
|
243
|
-
},
|
|
244
|
-
{
|
|
245
|
-
schemaName: 'AssignUserBranchDto',
|
|
246
|
-
properties: [
|
|
247
|
-
'userId',
|
|
248
|
-
'items'
|
|
249
|
-
]
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
schemaName: 'PermissionItemDto',
|
|
253
|
-
properties: [
|
|
254
|
-
'targetId',
|
|
255
|
-
'isAdd'
|
|
256
|
-
]
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
schemaName: 'UserCompaniesResponseDto',
|
|
260
|
-
properties: [
|
|
261
|
-
'data'
|
|
262
|
-
]
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
schemaName: 'UserBranchesResponseDto',
|
|
266
|
-
properties: [
|
|
267
|
-
'data'
|
|
268
|
-
]
|
|
269
|
-
}
|
|
270
|
-
];
|
|
271
|
-
const COMPANY_EXAMPLE_EXCLUSIONS = [
|
|
272
|
-
{
|
|
273
|
-
pathPattern: '/auth/login',
|
|
274
|
-
method: 'post',
|
|
275
|
-
examples: [
|
|
276
|
-
'loginSuccessWithCompany',
|
|
277
|
-
'companySelection'
|
|
278
|
-
]
|
|
279
|
-
}
|
|
280
|
-
];
|
|
281
|
-
// ============================================================================
|
|
282
|
-
// Email verification exclusions
|
|
283
|
-
// ============================================================================
|
|
284
|
-
const EMAIL_VERIFICATION_PATHS = [
|
|
285
|
-
'/auth/forgot-password',
|
|
286
|
-
'/auth/reset-password',
|
|
287
|
-
'/auth/resend-verification',
|
|
288
|
-
'/auth/verify-email'
|
|
289
|
-
];
|
|
290
|
-
const EMAIL_VERIFICATION_SCHEMA_EXCLUSIONS = [
|
|
291
|
-
{
|
|
292
|
-
schemaName: 'RegistrationResponseDto',
|
|
293
|
-
properties: [
|
|
294
|
-
'requiresEmailVerification'
|
|
295
|
-
]
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
schemaName: 'LoginResponseRequiresEmailVerificationDto',
|
|
299
|
-
properties: [
|
|
300
|
-
'requiresEmailVerification',
|
|
301
|
-
'email'
|
|
302
|
-
]
|
|
303
|
-
}
|
|
304
|
-
];
|
|
305
|
-
const EMAIL_VERIFICATION_EXAMPLE_EXCLUSIONS = [
|
|
306
|
-
{
|
|
307
|
-
pathPattern: '/auth/login',
|
|
308
|
-
method: 'post',
|
|
309
|
-
examples: [
|
|
310
|
-
'emailVerification'
|
|
311
|
-
]
|
|
312
|
-
}
|
|
313
|
-
];
|
|
314
|
-
// ============================================================================
|
|
315
|
-
// Description builder
|
|
316
|
-
// ============================================================================
|
|
317
|
-
function buildDescription(enableCompanyFeature, enableEmailVerification, isMultiTenant) {
|
|
318
|
-
const multiTenantNote = isMultiTenant ? `\n> **Multi-Tenant Mode**: Include \`x-tenant-id\` header to target a specific tenant database.\n` : '';
|
|
319
|
-
const features = [
|
|
320
|
-
'- User registration',
|
|
321
|
-
'- Login with email/password',
|
|
322
|
-
'- Social sign-in (Google, Facebook, LinkedIn, Microsoft)',
|
|
323
|
-
'- JWT token-based authentication',
|
|
324
|
-
...enableEmailVerification ? [
|
|
325
|
-
'- Email verification',
|
|
326
|
-
'- Forgot/reset password'
|
|
327
|
-
] : [],
|
|
328
|
-
...enableCompanyFeature ? [
|
|
329
|
-
'- Company/Branch selection flow (multi-company enabled)'
|
|
330
|
-
] : [],
|
|
331
|
-
'- Token refresh',
|
|
332
|
-
'- Password change'
|
|
333
|
-
].join('\n');
|
|
334
|
-
const loginFlowSection = enableCompanyFeature ? `
|
|
335
|
-
### Authentication Flow
|
|
336
|
-
|
|
337
|
-
#### Simple Login (single company/branch)
|
|
338
|
-
\`\`\`
|
|
339
|
-
POST /auth/login → { accessToken, refreshToken, user, company, branch }
|
|
340
|
-
\`\`\`
|
|
341
|
-
|
|
342
|
-
#### Multi-Company Login (multiple companies or branches)
|
|
343
|
-
\`\`\`
|
|
344
|
-
POST /auth/login → { requiresSelection: true, sessionId, companies }
|
|
345
|
-
POST /auth/select → { accessToken, refreshToken, user, company, branch }
|
|
346
|
-
\`\`\`
|
|
347
|
-
${enableEmailVerification ? `
|
|
348
|
-
#### Email Verification Required
|
|
349
|
-
\`\`\`
|
|
350
|
-
POST /auth/login → { requiresEmailVerification: true, email }
|
|
351
|
-
POST /auth/verify-email → { accessToken, refreshToken, user }
|
|
352
|
-
\`\`\`
|
|
353
|
-
` : ''}
|
|
354
|
-
### Company/Branch Selection Endpoints
|
|
355
|
-
- \`POST /auth/select\` - Complete login by selecting company and branch
|
|
356
|
-
- \`POST /auth/switch-company\` - Switch to different company/branch while logged in
|
|
357
|
-
` : `
|
|
358
|
-
### Authentication Flow
|
|
359
|
-
\`\`\`
|
|
360
|
-
POST /auth/login → { accessToken, refreshToken, user }
|
|
361
|
-
\`\`\`
|
|
362
|
-
${enableEmailVerification ? `
|
|
363
|
-
#### Email Verification Required
|
|
364
|
-
\`\`\`
|
|
365
|
-
POST /auth/login → { requiresEmailVerification: true, email }
|
|
366
|
-
POST /auth/verify-email → { accessToken, refreshToken, user }
|
|
367
|
-
\`\`\`
|
|
368
|
-
` : ''}`;
|
|
369
|
-
const emailVerificationSection = enableEmailVerification ? `
|
|
370
|
-
### Email Verification Endpoints
|
|
371
|
-
- \`POST /auth/forgot-password\` - Request password reset email
|
|
372
|
-
- \`POST /auth/reset-password\` - Reset password using token
|
|
373
|
-
- \`POST /auth/resend-verification\` - Resend verification email
|
|
374
|
-
- \`POST /auth/verify-email\` - Verify email using token
|
|
375
|
-
` : '';
|
|
376
|
-
const socialSection = `
|
|
377
|
-
### Social Sign-In Endpoints
|
|
378
|
-
- \`POST /auth/social/providers\` - List the providers an administrator enabled
|
|
379
|
-
- \`POST /auth/social/authorize\` - Start a sign-in and get the provider's consent URL
|
|
380
|
-
- \`POST /auth/social/callback\` - Exchange the provider's code for a session
|
|
381
|
-
- \`POST /auth/social-config/*\` - Manage provider credentials
|
|
382
|
-
`;
|
|
383
|
-
const administrationSection = enableCompanyFeature ? `
|
|
384
|
-
### Administration Endpoints
|
|
385
|
-
- \`POST /administration/users/*\` - User management
|
|
386
|
-
- \`POST /administration/company/*\` - Company management
|
|
387
|
-
- \`POST /administration/branch/*\` - Branch management
|
|
388
|
-
- \`POST /administration/user-permissions/*\` - User permission management
|
|
389
|
-
` : `
|
|
390
|
-
### Administration Endpoints
|
|
391
|
-
- \`POST /administration/users/*\` - User management
|
|
392
|
-
`;
|
|
393
|
-
const registrationSection = enableCompanyFeature ? `
|
|
394
|
-
### Registration Flow
|
|
395
|
-
|
|
396
|
-
**Simple registration:**
|
|
397
|
-
\`\`\`json
|
|
398
|
-
{ "name": "John Doe", "email": "john@example.com", "password": "password123" }
|
|
399
|
-
\`\`\`
|
|
400
|
-
|
|
401
|
-
**Join existing company:**
|
|
402
|
-
\`\`\`json
|
|
403
|
-
{ "name": "John Doe", "email": "john@example.com", "password": "password123", "companySlug": "acme-corp", "branchSlug": "main-branch" }
|
|
404
|
-
\`\`\`
|
|
405
|
-
|
|
406
|
-
**Create new company:**
|
|
407
|
-
\`\`\`json
|
|
408
|
-
{ "name": "John Doe", "email": "john@example.com", "password": "password123", "newCompanyName": "My New Company" }
|
|
409
|
-
\`\`\`
|
|
410
|
-
` : `
|
|
411
|
-
### Registration Flow
|
|
412
|
-
\`\`\`json
|
|
413
|
-
{ "name": "John Doe", "email": "john@example.com", "password": "password123" }
|
|
414
|
-
\`\`\`
|
|
415
|
-
`;
|
|
416
|
-
return `
|
|
417
|
-
## Authentication API
|
|
418
|
-
${multiTenantNote}
|
|
419
|
-
Handles user authentication${enableCompanyFeature ? ', company/branch management' : ''}, and registration.
|
|
420
|
-
|
|
421
|
-
### Features
|
|
422
|
-
${features}
|
|
423
|
-
${loginFlowSection}${emailVerificationSection}${socialSection}${administrationSection}${registrationSection}`;
|
|
424
|
-
}
|
|
425
|
-
// ============================================================================
|
|
426
|
-
// Config factory
|
|
427
|
-
// ============================================================================
|
|
428
|
-
export function authSwaggerConfig(bootstrapConfig) {
|
|
429
|
-
const enableCompanyFeature = bootstrapConfig?.enableCompanyFeature ?? true;
|
|
430
|
-
const enableEmailVerification = bootstrapConfig?.enableEmailVerification ?? true;
|
|
431
|
-
const isMultiTenant = bootstrapConfig?.databaseMode === 'multi-tenant';
|
|
432
|
-
const excludeTags = enableCompanyFeature ? [] : COMPANY_RELATED_TAGS;
|
|
433
|
-
const excludeSchemaProperties = [
|
|
434
|
-
...enableCompanyFeature ? [] : COMPANY_SCHEMA_EXCLUSIONS,
|
|
435
|
-
...enableEmailVerification ? [] : EMAIL_VERIFICATION_SCHEMA_EXCLUSIONS
|
|
436
|
-
];
|
|
437
|
-
// Merge example exclusions — both may target /auth/login with different example names
|
|
438
|
-
const excludeExamples = [
|
|
439
|
-
...enableCompanyFeature ? [] : COMPANY_EXAMPLE_EXCLUSIONS,
|
|
440
|
-
...enableEmailVerification ? [] : EMAIL_VERIFICATION_EXAMPLE_EXCLUSIONS
|
|
441
|
-
];
|
|
442
|
-
const excludePaths = enableEmailVerification ? undefined : EMAIL_VERIFICATION_PATHS;
|
|
443
|
-
return {
|
|
444
|
-
title: 'Auth API',
|
|
445
|
-
description: buildDescription(enableCompanyFeature, enableEmailVerification, isMultiTenant),
|
|
446
|
-
version: '1.0',
|
|
447
|
-
path: 'api/docs/auth',
|
|
448
|
-
bearerAuth: true,
|
|
449
|
-
excludeTags,
|
|
450
|
-
excludeSchemaProperties: excludeSchemaProperties.length ? excludeSchemaProperties : undefined,
|
|
451
|
-
excludeExamples: excludeExamples.length ? excludeExamples : undefined,
|
|
452
|
-
excludePaths
|
|
453
|
-
};
|
|
454
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { authSwaggerConfig } from './auth-swagger.config';
|
|
2
|
-
describe('authSwaggerConfig', ()=>{
|
|
3
|
-
it('should default to both features enabled and single-database mode when no config is given', ()=>{
|
|
4
|
-
const config = authSwaggerConfig();
|
|
5
|
-
expect(config.title).toBe('Auth API');
|
|
6
|
-
expect(config.path).toBe('api/docs/auth');
|
|
7
|
-
expect(config.bearerAuth).toBe(true);
|
|
8
|
-
expect(config.excludeTags).toEqual([]);
|
|
9
|
-
expect(config.excludeSchemaProperties).toBeUndefined();
|
|
10
|
-
expect(config.excludeExamples).toBeUndefined();
|
|
11
|
-
expect(config.excludePaths).toBeUndefined();
|
|
12
|
-
expect(config.description).not.toContain('Multi-Tenant Mode');
|
|
13
|
-
});
|
|
14
|
-
it('should exclude company-related tags, schema properties, and examples when the company feature is off', ()=>{
|
|
15
|
-
const config = authSwaggerConfig({
|
|
16
|
-
enableCompanyFeature: false,
|
|
17
|
-
databaseMode: 'single'
|
|
18
|
-
});
|
|
19
|
-
expect(config.excludeTags).toEqual(expect.arrayContaining([
|
|
20
|
-
'Companies',
|
|
21
|
-
'Branches',
|
|
22
|
-
'User Permissions',
|
|
23
|
-
'Company Selection'
|
|
24
|
-
]));
|
|
25
|
-
expect(config.excludeSchemaProperties).toEqual(expect.arrayContaining([
|
|
26
|
-
expect.objectContaining({
|
|
27
|
-
schemaName: 'RegistrationDto'
|
|
28
|
-
})
|
|
29
|
-
]));
|
|
30
|
-
expect(config.excludeExamples).toEqual(expect.arrayContaining([
|
|
31
|
-
expect.objectContaining({
|
|
32
|
-
pathPattern: '/auth/login',
|
|
33
|
-
examples: [
|
|
34
|
-
'loginSuccessWithCompany',
|
|
35
|
-
'companySelection'
|
|
36
|
-
]
|
|
37
|
-
})
|
|
38
|
-
]));
|
|
39
|
-
// Email verification is still enabled by default, so its paths must not be excluded
|
|
40
|
-
expect(config.excludePaths).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
it('should exclude email-verification paths, schema properties, and examples when disabled', ()=>{
|
|
43
|
-
const config = authSwaggerConfig({
|
|
44
|
-
enableEmailVerification: false
|
|
45
|
-
});
|
|
46
|
-
expect(config.excludePaths).toEqual([
|
|
47
|
-
'/auth/forgot-password',
|
|
48
|
-
'/auth/reset-password',
|
|
49
|
-
'/auth/resend-verification',
|
|
50
|
-
'/auth/verify-email'
|
|
51
|
-
]);
|
|
52
|
-
expect(config.excludeSchemaProperties).toEqual(expect.arrayContaining([
|
|
53
|
-
expect.objectContaining({
|
|
54
|
-
schemaName: 'LoginResponseRequiresEmailVerificationDto'
|
|
55
|
-
})
|
|
56
|
-
]));
|
|
57
|
-
expect(config.excludeExamples).toEqual(expect.arrayContaining([
|
|
58
|
-
expect.objectContaining({
|
|
59
|
-
pathPattern: '/auth/login',
|
|
60
|
-
examples: [
|
|
61
|
-
'emailVerification'
|
|
62
|
-
]
|
|
63
|
-
})
|
|
64
|
-
]));
|
|
65
|
-
// Company feature is still enabled by default, so its tags must not be excluded
|
|
66
|
-
expect(config.excludeTags).toEqual([]);
|
|
67
|
-
});
|
|
68
|
-
it('should merge exclusions from both features when both are disabled', ()=>{
|
|
69
|
-
const config = authSwaggerConfig({
|
|
70
|
-
enableCompanyFeature: false,
|
|
71
|
-
enableEmailVerification: false
|
|
72
|
-
});
|
|
73
|
-
expect(config.excludeTags?.length).toBeGreaterThan(0);
|
|
74
|
-
expect(config.excludePaths?.length).toBeGreaterThan(0);
|
|
75
|
-
// Both feature's schema exclusions should be present together
|
|
76
|
-
const schemaNames = config.excludeSchemaProperties?.map((e)=>e.schemaName) ?? [];
|
|
77
|
-
expect(schemaNames).toContain('RegistrationDto');
|
|
78
|
-
expect(schemaNames).toContain('LoginResponseRequiresEmailVerificationDto');
|
|
79
|
-
// Both feature's example exclusions merge onto the same /auth/login path
|
|
80
|
-
const loginExclusions = config.excludeExamples?.filter((e)=>e.pathPattern === '/auth/login');
|
|
81
|
-
expect(loginExclusions).toHaveLength(2);
|
|
82
|
-
});
|
|
83
|
-
it('should mention multi-tenant mode in the description only for multi-tenant database mode', ()=>{
|
|
84
|
-
const multiTenant = authSwaggerConfig({
|
|
85
|
-
databaseMode: 'multi-tenant'
|
|
86
|
-
});
|
|
87
|
-
const single = authSwaggerConfig({
|
|
88
|
-
databaseMode: 'single'
|
|
89
|
-
});
|
|
90
|
-
expect(multiTenant.description).toContain('Multi-Tenant Mode');
|
|
91
|
-
expect(single.description).not.toContain('Multi-Tenant Mode');
|
|
92
|
-
});
|
|
93
|
-
it('should describe the multi-company login flow only when the company feature is enabled', ()=>{
|
|
94
|
-
const withCompany = authSwaggerConfig({
|
|
95
|
-
enableCompanyFeature: true
|
|
96
|
-
});
|
|
97
|
-
const withoutCompany = authSwaggerConfig({
|
|
98
|
-
enableCompanyFeature: false
|
|
99
|
-
});
|
|
100
|
-
expect(withCompany.description).toContain('Multi-Company Login');
|
|
101
|
-
expect(withCompany.description).toContain('/auth/switch-company');
|
|
102
|
-
expect(withoutCompany.description).not.toContain('Multi-Company Login');
|
|
103
|
-
expect(withoutCompany.description).not.toContain('/auth/switch-company');
|
|
104
|
-
});
|
|
105
|
-
it('should describe email verification endpoints only when enabled', ()=>{
|
|
106
|
-
const withVerification = authSwaggerConfig({
|
|
107
|
-
enableEmailVerification: true
|
|
108
|
-
});
|
|
109
|
-
const withoutVerification = authSwaggerConfig({
|
|
110
|
-
enableEmailVerification: false
|
|
111
|
-
});
|
|
112
|
-
expect(withVerification.description).toContain('/auth/forgot-password');
|
|
113
|
-
expect(withoutVerification.description).not.toContain('### Email Verification Endpoints');
|
|
114
|
-
});
|
|
115
|
-
it('should list company administration endpoints only when the company feature is enabled', ()=>{
|
|
116
|
-
const withCompany = authSwaggerConfig({
|
|
117
|
-
enableCompanyFeature: true
|
|
118
|
-
});
|
|
119
|
-
const withoutCompany = authSwaggerConfig({
|
|
120
|
-
enableCompanyFeature: false
|
|
121
|
-
});
|
|
122
|
-
expect(withCompany.description).toContain('/administration/company/*');
|
|
123
|
-
expect(withoutCompany.description).not.toContain('/administration/company/*');
|
|
124
|
-
expect(withoutCompany.description).toContain('/administration/users/*');
|
|
125
|
-
});
|
|
126
|
-
});
|