@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.
Files changed (237) hide show
  1. package/README.md +68 -1
  2. package/config/auth.constants.d.ts +2 -0
  3. package/config/event-actions.d.ts +2 -0
  4. package/config/index.d.ts +3 -3
  5. package/config/message-keys.d.ts +23 -0
  6. package/controllers/authentication.controller.d.ts +5 -5
  7. package/controllers/branch.controller.d.ts +2 -2
  8. package/controllers/company-selection.controller.d.ts +4 -4
  9. package/controllers/company.controller.d.ts +2 -2
  10. package/controllers/email-verification.controller.d.ts +6 -6
  11. package/controllers/index.d.ts +9 -7
  12. package/controllers/social-auth-config.controller.d.ts +22 -0
  13. package/controllers/social-auth.controller.d.ts +11 -0
  14. package/controllers/user-permission.controller.d.ts +5 -4
  15. package/controllers/user.controller.d.ts +7 -7
  16. package/docs/auth-swagger.config.d.ts +2 -2
  17. package/docs/index.d.ts +1 -1
  18. package/dtos/index.d.ts +6 -5
  19. package/dtos/social-auth.dto.d.ts +42 -0
  20. package/entities/company-branch.entity.d.ts +1 -1
  21. package/entities/company.entity.d.ts +1 -1
  22. package/entities/index.d.ts +15 -13
  23. package/entities/pending-registration.entity.d.ts +1 -1
  24. package/entities/social-auth-config.entity.d.ts +9 -0
  25. package/entities/user-company-permission.entity.d.ts +4 -4
  26. package/enums/index.d.ts +2 -1
  27. package/enums/social-provider-type.enum.d.ts +6 -0
  28. package/fesm/118.js +1230 -0
  29. package/fesm/120.js +2197 -0
  30. package/fesm/24.js +4389 -0
  31. package/fesm/370.js +1163 -0
  32. package/fesm/446.js +877 -0
  33. package/fesm/chunks/117.js +69 -0
  34. package/fesm/config/index.js +244 -3
  35. package/fesm/controllers/index.js +27 -7
  36. package/fesm/docs/index.js +479 -1
  37. package/fesm/dtos/index.js +123 -5
  38. package/fesm/entities/index.js +68 -19
  39. package/fesm/enums/index.js +53 -1
  40. package/fesm/helpers/index.js +115 -2
  41. package/fesm/index.js +1437 -12
  42. package/fesm/interceptors/index.js +508 -2
  43. package/fesm/interfaces/index.js +75 -7
  44. package/fesm/modules/index.js +546 -1
  45. package/fesm/runtime.js +134 -0
  46. package/fesm/services/index.js +67 -9
  47. package/helpers/auth-response.mapper.d.ts +3 -3
  48. package/helpers/index.d.ts +2 -2
  49. package/helpers/token.helper.d.ts +2 -2
  50. package/index.d.ts +13 -12
  51. package/interceptors/clear-token.interceptor.d.ts +2 -2
  52. package/interceptors/index.d.ts +2 -2
  53. package/interceptors/set-token.interceptor.d.ts +2 -2
  54. package/interfaces/auth-module-options.interface.d.ts +3 -3
  55. package/interfaces/authentication.interface.d.ts +3 -3
  56. package/interfaces/company-branch.interface.d.ts +2 -2
  57. package/interfaces/company.interface.d.ts +1 -1
  58. package/interfaces/index.d.ts +8 -7
  59. package/interfaces/social-auth.interface.d.ts +43 -0
  60. package/interfaces/user-enricher.interface.d.ts +3 -3
  61. package/modules/auth.module.d.ts +4 -4
  62. package/modules/index.d.ts +1 -1
  63. package/package.json +32 -39
  64. package/providers/facebook.social-provider.d.ts +10 -0
  65. package/providers/google.social-provider.d.ts +10 -0
  66. package/providers/index.d.ts +1 -0
  67. package/providers/linkedin.social-provider.d.ts +10 -0
  68. package/providers/microsoft.social-provider.d.ts +10 -0
  69. package/providers/oauth-http.util.d.ts +10 -0
  70. package/providers/social-provider.registry.d.ts +3 -0
  71. package/services/auth-config.service.d.ts +4 -3
  72. package/services/auth-datasource.provider.d.ts +4 -3
  73. package/services/auth-email.service.d.ts +3 -3
  74. package/services/authentication.service.d.ts +15 -11
  75. package/services/branch.service.d.ts +7 -7
  76. package/services/company.service.d.ts +6 -6
  77. package/services/index.d.ts +11 -9
  78. package/services/social-auth-config.service.d.ts +21 -0
  79. package/services/social-auth.service.d.ts +24 -0
  80. package/services/user-permission.service.d.ts +8 -4
  81. package/services/user.service.d.ts +7 -7
  82. package/strategies/jwt.strategy.d.ts +4 -4
  83. package/validators/password.validator.d.ts +1 -1
  84. package/cjs/config/auth.constants.js +0 -41
  85. package/cjs/config/event-actions.js +0 -45
  86. package/cjs/config/index.js +0 -20
  87. package/cjs/config/message-keys.js +0 -108
  88. package/cjs/controllers/authentication.controller.js +0 -427
  89. package/cjs/controllers/authentication.controller.spec.js +0 -219
  90. package/cjs/controllers/branch.controller.js +0 -102
  91. package/cjs/controllers/branch.controller.spec.js +0 -134
  92. package/cjs/controllers/company-selection.controller.js +0 -198
  93. package/cjs/controllers/company-selection.controller.spec.js +0 -84
  94. package/cjs/controllers/company.controller.js +0 -102
  95. package/cjs/controllers/company.controller.spec.js +0 -131
  96. package/cjs/controllers/email-verification.controller.js +0 -224
  97. package/cjs/controllers/email-verification.controller.spec.js +0 -142
  98. package/cjs/controllers/index.js +0 -24
  99. package/cjs/controllers/user-permission.controller.js +0 -223
  100. package/cjs/controllers/user-permission.controller.spec.js +0 -138
  101. package/cjs/controllers/user.controller.js +0 -438
  102. package/cjs/controllers/user.controller.spec.js +0 -204
  103. package/cjs/docs/auth-swagger.config.js +0 -453
  104. package/cjs/docs/auth-swagger.config.spec.js +0 -130
  105. package/cjs/docs/index.js +0 -18
  106. package/cjs/dtos/authentication.dto.js +0 -755
  107. package/cjs/dtos/company-branch.dto.js +0 -294
  108. package/cjs/dtos/company.dto.js +0 -298
  109. package/cjs/dtos/index.js +0 -22
  110. package/cjs/dtos/user-permission.dto.js +0 -358
  111. package/cjs/dtos/user.dto.js +0 -413
  112. package/cjs/entities/app-user.entity.js +0 -25
  113. package/cjs/entities/company-branch.entity.js +0 -163
  114. package/cjs/entities/company.entity.js +0 -146
  115. package/cjs/entities/index.js +0 -65
  116. package/cjs/entities/index.spec.js +0 -73
  117. package/cjs/entities/pending-registration.entity.js +0 -135
  118. package/cjs/entities/user-company-permission.entity.js +0 -153
  119. package/cjs/entities/user-token.entity.js +0 -120
  120. package/cjs/enums/index.js +0 -18
  121. package/cjs/enums/user-org-permission-type.enum.js +0 -15
  122. package/cjs/helpers/auth-response.mapper.js +0 -46
  123. package/cjs/helpers/auth-response.mapper.spec.js +0 -139
  124. package/cjs/helpers/index.js +0 -19
  125. package/cjs/helpers/token.helper.js +0 -58
  126. package/cjs/helpers/token.helper.spec.js +0 -86
  127. package/cjs/index.js +0 -29
  128. package/cjs/interceptors/clear-token.interceptor.js +0 -73
  129. package/cjs/interceptors/clear-token.interceptor.spec.js +0 -107
  130. package/cjs/interceptors/index.js +0 -19
  131. package/cjs/interceptors/set-token.interceptor.js +0 -107
  132. package/cjs/interceptors/set-token.interceptor.spec.js +0 -165
  133. package/cjs/interfaces/auth-email-provider.interface.js +0 -45
  134. package/cjs/interfaces/auth-module-options.interface.js +0 -4
  135. package/cjs/interfaces/authentication.interface.js +0 -4
  136. package/cjs/interfaces/company-branch.interface.js +0 -4
  137. package/cjs/interfaces/company.interface.js +0 -4
  138. package/cjs/interfaces/index.js +0 -24
  139. package/cjs/interfaces/user-enricher.interface.js +0 -4
  140. package/cjs/interfaces/user.interface.js +0 -4
  141. package/cjs/modules/auth.module.js +0 -202
  142. package/cjs/modules/auth.module.spec.js +0 -243
  143. package/cjs/modules/index.js +0 -18
  144. package/cjs/services/auth-config.service.js +0 -110
  145. package/cjs/services/auth-config.service.spec.js +0 -97
  146. package/cjs/services/auth-datasource.provider.js +0 -134
  147. package/cjs/services/auth-datasource.provider.spec.js +0 -161
  148. package/cjs/services/auth-email.service.js +0 -539
  149. package/cjs/services/auth-email.service.spec.js +0 -456
  150. package/cjs/services/authentication.service.js +0 -1173
  151. package/cjs/services/authentication.service.spec.js +0 -962
  152. package/cjs/services/branch.service.js +0 -153
  153. package/cjs/services/branch.service.spec.js +0 -169
  154. package/cjs/services/company-selection-session.service.js +0 -121
  155. package/cjs/services/company-selection-session.service.spec.js +0 -90
  156. package/cjs/services/company.service.js +0 -140
  157. package/cjs/services/company.service.spec.js +0 -127
  158. package/cjs/services/index.js +0 -26
  159. package/cjs/services/user-permission.service.js +0 -236
  160. package/cjs/services/user-permission.service.spec.js +0 -254
  161. package/cjs/services/user.service.js +0 -671
  162. package/cjs/services/user.service.spec.js +0 -718
  163. package/cjs/strategies/jwt.strategy.js +0 -140
  164. package/cjs/strategies/jwt.strategy.spec.js +0 -166
  165. package/cjs/validators/password.validator.js +0 -45
  166. package/cjs/validators/password.validator.spec.js +0 -161
  167. package/fesm/config/auth.constants.js +0 -11
  168. package/fesm/config/event-actions.js +0 -24
  169. package/fesm/config/message-keys.js +0 -78
  170. package/fesm/controllers/authentication.controller.js +0 -417
  171. package/fesm/controllers/authentication.controller.spec.js +0 -215
  172. package/fesm/controllers/branch.controller.js +0 -92
  173. package/fesm/controllers/branch.controller.spec.js +0 -130
  174. package/fesm/controllers/company-selection.controller.js +0 -188
  175. package/fesm/controllers/company-selection.controller.spec.js +0 -80
  176. package/fesm/controllers/company.controller.js +0 -92
  177. package/fesm/controllers/company.controller.spec.js +0 -127
  178. package/fesm/controllers/email-verification.controller.js +0 -214
  179. package/fesm/controllers/email-verification.controller.spec.js +0 -138
  180. package/fesm/controllers/user-permission.controller.js +0 -213
  181. package/fesm/controllers/user-permission.controller.spec.js +0 -134
  182. package/fesm/controllers/user.controller.js +0 -428
  183. package/fesm/controllers/user.controller.spec.js +0 -200
  184. package/fesm/docs/auth-swagger.config.js +0 -446
  185. package/fesm/docs/auth-swagger.config.spec.js +0 -126
  186. package/fesm/dtos/authentication.dto.js +0 -683
  187. package/fesm/dtos/company-branch.dto.js +0 -279
  188. package/fesm/dtos/company.dto.js +0 -283
  189. package/fesm/dtos/user-permission.dto.js +0 -339
  190. package/fesm/dtos/user.dto.js +0 -391
  191. package/fesm/entities/app-user.entity.js +0 -15
  192. package/fesm/entities/company-branch.entity.js +0 -153
  193. package/fesm/entities/company.entity.js +0 -136
  194. package/fesm/entities/index.spec.js +0 -69
  195. package/fesm/entities/pending-registration.entity.js +0 -125
  196. package/fesm/entities/user-company-permission.entity.js +0 -136
  197. package/fesm/entities/user-token.entity.js +0 -104
  198. package/fesm/enums/user-org-permission-type.enum.js +0 -5
  199. package/fesm/helpers/auth-response.mapper.js +0 -25
  200. package/fesm/helpers/auth-response.mapper.spec.js +0 -135
  201. package/fesm/helpers/token.helper.js +0 -40
  202. package/fesm/helpers/token.helper.spec.js +0 -82
  203. package/fesm/interceptors/clear-token.interceptor.js +0 -63
  204. package/fesm/interceptors/clear-token.interceptor.spec.js +0 -103
  205. package/fesm/interceptors/set-token.interceptor.js +0 -98
  206. package/fesm/interceptors/set-token.interceptor.spec.js +0 -161
  207. package/fesm/interfaces/auth-email-provider.interface.js +0 -38
  208. package/fesm/interfaces/auth-module-options.interface.js +0 -3
  209. package/fesm/interfaces/authentication.interface.js +0 -1
  210. package/fesm/interfaces/company-branch.interface.js +0 -1
  211. package/fesm/interfaces/company.interface.js +0 -1
  212. package/fesm/interfaces/user-enricher.interface.js +0 -4
  213. package/fesm/interfaces/user.interface.js +0 -1
  214. package/fesm/modules/auth.module.js +0 -192
  215. package/fesm/modules/auth.module.spec.js +0 -239
  216. package/fesm/services/auth-config.service.js +0 -100
  217. package/fesm/services/auth-config.service.spec.js +0 -93
  218. package/fesm/services/auth-datasource.provider.js +0 -83
  219. package/fesm/services/auth-datasource.provider.spec.js +0 -157
  220. package/fesm/services/auth-email.service.js +0 -488
  221. package/fesm/services/auth-email.service.spec.js +0 -411
  222. package/fesm/services/authentication.service.js +0 -1122
  223. package/fesm/services/authentication.service.spec.js +0 -917
  224. package/fesm/services/branch.service.js +0 -143
  225. package/fesm/services/branch.service.spec.js +0 -165
  226. package/fesm/services/company-selection-session.service.js +0 -111
  227. package/fesm/services/company-selection-session.service.spec.js +0 -86
  228. package/fesm/services/company.service.js +0 -130
  229. package/fesm/services/company.service.spec.js +0 -123
  230. package/fesm/services/user-permission.service.js +0 -226
  231. package/fesm/services/user-permission.service.spec.js +0 -250
  232. package/fesm/services/user.service.js +0 -620
  233. package/fesm/services/user.service.spec.js +0 -673
  234. package/fesm/strategies/jwt.strategy.js +0 -130
  235. package/fesm/strategies/jwt.strategy.spec.js +0 -162
  236. package/fesm/validators/password.validator.js +0 -48
  237. package/fesm/validators/password.validator.spec.js +0 -157
package/fesm/120.js ADDED
@@ -0,0 +1,2197 @@
1
+ import * as __rspack_external__flusys_nestjs_shared_guards_3f79ddd1 from "@flusys/nestjs-shared/guards";
2
+ import * as __rspack_external_rxjs from "rxjs";
3
+ import * as __rspack_external__flusys_nestjs_shared_decorators_c129b601 from "@flusys/nestjs-shared/decorators";
4
+ import * as __rspack_external__nestjs_throttler_68da00c9 from "@nestjs/throttler";
5
+ import * as __rspack_external_buffer from "buffer";
6
+ export const __rspack_esm_id = 120;
7
+ export const __rspack_esm_ids = [120];
8
+ export const __webpack_modules__ = {
9
+ 1003(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
10
+
11
+ // EXPORTS
12
+ __webpack_require__.d(__webpack_exports__, {
13
+ $3: () => (/* reexport */ AuthenticationController),
14
+ zF: () => (/* reexport */ BranchController),
15
+ wD: () => (/* reexport */ CompanyController),
16
+ Qg: () => (/* reexport */ CompanySelectionController),
17
+ Q1: () => (/* reexport */ EmailVerificationController),
18
+ O3: () => (/* reexport */ SocialAuthConfigController),
19
+ eA: () => (/* reexport */ SocialAuthController),
20
+ SZ: () => (/* reexport */ UserController),
21
+ rl: () => (/* reexport */ UserPermissionController)
22
+ });
23
+
24
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared"
25
+ var nestjs_shared_ = __webpack_require__(3422);
26
+ ;// CONCATENATED MODULE: external "@flusys/nestjs-shared/decorators"
27
+
28
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared/dtos"
29
+ var dtos_ = __webpack_require__(6873);
30
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared/guards"
31
+ var guards_ = __webpack_require__(3513);
32
+ // EXTERNAL MODULE: external "@nestjs/common"
33
+ var common_ = __webpack_require__(6157);
34
+ // EXTERNAL MODULE: external "@nestjs/swagger"
35
+ var swagger_ = __webpack_require__(6176);
36
+ ;// CONCATENATED MODULE: external "@nestjs/throttler"
37
+
38
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/config/message-keys.ts
39
+ var message_keys = __webpack_require__(5363);
40
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/config/auth.constants.ts
41
+ var auth_constants = __webpack_require__(5588);
42
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/authentication.dto.ts
43
+ var authentication_dto = __webpack_require__(8978);
44
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/interceptors/clear-token.interceptor.ts
45
+ var clear_token_interceptor = __webpack_require__(5207);
46
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/interceptors/set-token.interceptor.ts + 1 modules
47
+ var set_token_interceptor = __webpack_require__(8359);
48
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-config.service.ts + 1 modules
49
+ var auth_config_service = __webpack_require__(6514);
50
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/authentication.service.ts + 1 modules
51
+ var authentication_service = __webpack_require__(4722);
52
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/authentication.controller.ts
53
+ function _ts_decorate(decorators, target, key, desc) {
54
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
55
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
56
+ r = Reflect.decorate(decorators, target, key, desc);
57
+ } else {
58
+ for(var i = decorators.length - 1; i >= 0; i--){
59
+ if (d = decorators[i]) {
60
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
61
+ }
62
+ }
63
+ }
64
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
65
+ }
66
+ function _ts_metadata(metadataKey, metadataValue) {
67
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
68
+ return Reflect.metadata(metadataKey, metadataValue);
69
+ }
70
+ }
71
+ function _ts_param(paramIndex, decorator) {
72
+ return function(target, key) {
73
+ decorator(target, key, paramIndex);
74
+ };
75
+ }
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+
89
+ class AuthenticationController {
90
+ authService;
91
+ authConfig;
92
+ constructor(authService, authConfig){
93
+ this.authService = authService;
94
+ this.authConfig = authConfig;
95
+ }
96
+ async login(loginDto) {
97
+ const result = await this.authService.login(loginDto.email, loginDto.password);
98
+ if ('requiresEmailVerification' in result) {
99
+ return {
100
+ success: true,
101
+ message: 'Email verification required',
102
+ messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_EMAIL_NOT_VERIFIED */.mK.LOGIN_EMAIL_NOT_VERIFIED,
103
+ data: result
104
+ };
105
+ }
106
+ if ('requiresSelection' in result) {
107
+ return {
108
+ success: true,
109
+ message: 'Company selection required',
110
+ messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_REQUIRES_SELECTION */.mK.LOGIN_REQUIRES_SELECTION,
111
+ data: result
112
+ };
113
+ }
114
+ return {
115
+ success: true,
116
+ message: 'Login successful',
117
+ messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_SUCCESS */.mK.LOGIN_SUCCESS,
118
+ data: result
119
+ };
120
+ }
121
+ /** Register new user. If company feature enabled, can join/create company. */ async register(req, registrationDto) {
122
+ const verifyUrlBase = (0,nestjs_shared_.buildFrontendUrl)(req, '/auth/verify-email');
123
+ const result = await this.authService.register(registrationDto, verifyUrlBase);
124
+ return {
125
+ success: true,
126
+ message: result.requiresEmailVerification ? 'Verification email sent' : 'Registration successful',
127
+ messageKey: result.requiresEmailVerification ? message_keys/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_SENT */.sv.VERIFICATION_SENT : message_keys/* .AUTH_MESSAGES.REGISTER_SUCCESS */.mK.REGISTER_SUCCESS,
128
+ data: result
129
+ };
130
+ }
131
+ /**
132
+ * Refresh access token.
133
+ * - **Browser**: Prefers HTTP-only cookie, falls back to body if cookie missing.
134
+ * - **API/Mobile**: Must send `refreshToken` in request body. Set header `x-client-type: mobile` or `x-client-type: api`.
135
+ */ async refreshToken(req, refreshTokenDto) {
136
+ const cookieName = this.authConfig?.getRefreshTokenCookieName() ?? auth_constants/* .DEFAULT_COOKIE_NAME */.rv;
137
+ // Always check cookie first, then body - handles Browser, SSR, and Mobile/API
138
+ const refreshToken = req.cookies?.[cookieName] || refreshTokenDto.refreshToken;
139
+ if (!refreshToken) {
140
+ throw new common_.UnauthorizedException({
141
+ message: 'Refresh token is required',
142
+ messageKey: message_keys/* .AUTH_MESSAGES.TOKEN_REQUIRED */.mK.TOKEN_REQUIRED
143
+ });
144
+ }
145
+ const data = await this.authService.refreshToken(refreshToken);
146
+ return {
147
+ success: true,
148
+ message: 'Token refreshed successfully',
149
+ messageKey: message_keys/* .AUTH_MESSAGES.REFRESH_SUCCESS */.mK.REFRESH_SUCCESS,
150
+ data
151
+ };
152
+ }
153
+ /** Get current user info. Returns user, company, and branch data (no tokens). */ async getCurrentUser(user) {
154
+ const data = await this.authService.getUserInfo(user.id, user.companyId, user.branchId);
155
+ return {
156
+ success: true,
157
+ message: 'User info retrieved successfully',
158
+ messageKey: message_keys/* .AUTH_MESSAGES.ME_SUCCESS */.mK.ME_SUCCESS,
159
+ data
160
+ };
161
+ }
162
+ /** Logout - Clears refresh token cookie for browsers */ async logout(userId) {
163
+ await this.authService.logout(userId);
164
+ return {
165
+ success: true,
166
+ message: 'Logged out successfully',
167
+ messageKey: message_keys/* .AUTH_MESSAGES.LOGOUT_SUCCESS */.mK.LOGOUT_SUCCESS
168
+ };
169
+ }
170
+ async changePassword(userId, dto) {
171
+ await this.authService.changePassword(userId, dto.currentPassword, dto.newPassword);
172
+ return {
173
+ success: true,
174
+ message: 'Password changed successfully',
175
+ messageKey: message_keys/* .AUTH_MESSAGES.PASSWORD_CHANGE_SUCCESS */.mK.PASSWORD_CHANGE_SUCCESS
176
+ };
177
+ }
178
+ }
179
+ _ts_decorate([
180
+ (0,common_.Post)('login'),
181
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
182
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
183
+ default: {
184
+ limit: 5,
185
+ ttl: 60000
186
+ }
187
+ }),
188
+ (0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
189
+ (0,swagger_.ApiOperation)({
190
+ summary: 'User login'
191
+ }),
192
+ (0,swagger_.ApiBody)({
193
+ type: authentication_dto/* .LoginDto */.pb
194
+ }),
195
+ (0,swagger_.ApiResponse)({
196
+ status: 200,
197
+ description: 'Login successful, requires company selection, or requires email verification',
198
+ content: {
199
+ 'application/json': {
200
+ examples: {
201
+ loginSuccess: {
202
+ summary: 'Login Success',
203
+ value: {
204
+ success: true,
205
+ message: 'Login successful',
206
+ messageKey: 'auth.login.success',
207
+ data: {
208
+ accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
209
+ user: {
210
+ id: '550e8400-e29b-41d4-a716-446655440000',
211
+ email: 'john@example.com',
212
+ name: 'John Doe'
213
+ }
214
+ }
215
+ }
216
+ },
217
+ loginSuccessWithCompany: {
218
+ summary: 'Login Success (with company/branch)',
219
+ value: {
220
+ success: true,
221
+ message: 'Login successful',
222
+ messageKey: 'auth.login.success',
223
+ data: {
224
+ accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
225
+ user: {
226
+ id: '550e8400-e29b-41d4-a716-446655440000',
227
+ email: 'john@example.com',
228
+ name: 'John Doe'
229
+ },
230
+ company: {
231
+ id: 'company-id',
232
+ name: 'Acme Corp'
233
+ },
234
+ branch: {
235
+ id: 'branch-id',
236
+ name: 'Main Branch'
237
+ }
238
+ }
239
+ }
240
+ },
241
+ companySelection: {
242
+ summary: 'Company Selection Required',
243
+ value: {
244
+ success: true,
245
+ message: 'Company selection required',
246
+ messageKey: 'auth.login.requires.selection',
247
+ data: {
248
+ requiresSelection: true,
249
+ sessionId: 'sess_abc123def456',
250
+ expiresAt: '2024-12-18T15:30:00.000Z',
251
+ user: {
252
+ id: '550e8400-e29b-41d4-a716-446655440000',
253
+ email: 'john@example.com'
254
+ },
255
+ companies: [
256
+ {
257
+ id: 'company-id',
258
+ name: 'Acme Corp',
259
+ slug: 'acme-corp',
260
+ branches: [
261
+ {
262
+ id: 'branch-id',
263
+ name: 'Main Branch',
264
+ slug: 'main-branch'
265
+ }
266
+ ]
267
+ }
268
+ ]
269
+ }
270
+ }
271
+ },
272
+ emailVerification: {
273
+ summary: 'Email Verification Required',
274
+ value: {
275
+ success: true,
276
+ message: 'Email verification required',
277
+ messageKey: 'auth.login.email.not.verified',
278
+ data: {
279
+ requiresEmailVerification: true,
280
+ email: 'john@example.com'
281
+ }
282
+ }
283
+ }
284
+ }
285
+ }
286
+ }
287
+ }),
288
+ _ts_param(0, (0,common_.Body)()),
289
+ _ts_metadata("design:type", Function),
290
+ _ts_metadata("design:paramtypes", [
291
+ typeof authentication_dto/* .LoginDto */.pb === "undefined" ? Object : authentication_dto/* .LoginDto */.pb
292
+ ]),
293
+ _ts_metadata("design:returntype", Promise)
294
+ ], AuthenticationController.prototype, "login", null);
295
+ _ts_decorate([
296
+ (0,common_.Post)('register'),
297
+ (0,common_.HttpCode)(common_.HttpStatus.CREATED),
298
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
299
+ default: {
300
+ limit: 3,
301
+ ttl: 60000
302
+ }
303
+ }),
304
+ (0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
305
+ (0,swagger_.ApiOperation)({
306
+ summary: 'Register new user'
307
+ }),
308
+ (0,swagger_.ApiBody)({
309
+ type: authentication_dto/* .RegistrationDto */.xG
310
+ }),
311
+ (0,swagger_.ApiResponse)({
312
+ status: 201,
313
+ description: 'Registration successful or email verification required'
314
+ }),
315
+ _ts_param(0, (0,common_.Req)()),
316
+ _ts_param(1, (0,common_.Body)()),
317
+ _ts_metadata("design:type", Function),
318
+ _ts_metadata("design:paramtypes", [
319
+ typeof Request === "undefined" ? Object : Request,
320
+ typeof authentication_dto/* .RegistrationDto */.xG === "undefined" ? Object : authentication_dto/* .RegistrationDto */.xG
321
+ ]),
322
+ _ts_metadata("design:returntype", Promise)
323
+ ], AuthenticationController.prototype, "register", null);
324
+ _ts_decorate([
325
+ (0,common_.Post)('refresh'),
326
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
327
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
328
+ default: {
329
+ limit: 30,
330
+ ttl: 60000
331
+ }
332
+ }),
333
+ (0,swagger_.ApiOperation)({
334
+ summary: 'Refresh access token',
335
+ description: `
336
+ **Browser clients**: Refresh token is read from HTTP-only cookie (automatically set on login/register).
337
+ Falls back to request body if cookie is not available.
338
+
339
+ **API/Mobile clients**: Must send \`refreshToken\` in request body.
340
+ Set header \`x-client-type: mobile\` or \`x-client-type: api\` to identify as non-browser client.
341
+
342
+ **Client detection**: Uses \`x-client-type\` header first, then falls back to User-Agent detection.
343
+ `
344
+ }),
345
+ (0,swagger_.ApiHeader)({
346
+ name: 'x-client-type',
347
+ required: false,
348
+ description: 'Client type: "browser"/"web" for cookie-based auth, "mobile"/"api" for body-based auth',
349
+ example: 'mobile'
350
+ }),
351
+ (0,swagger_.ApiBody)({
352
+ type: authentication_dto/* .RefreshTokenDto */.k2,
353
+ description: 'Required for API/Mobile clients. Browser clients prefer HTTP-only cookie with body fallback.'
354
+ }),
355
+ (0,swagger_.ApiResponse)({
356
+ status: 200,
357
+ description: 'Token refreshed successfully',
358
+ schema: {
359
+ example: {
360
+ success: true,
361
+ message: 'Token refreshed successfully',
362
+ messageKey: 'auth.refresh.success',
363
+ data: {
364
+ accessToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
365
+ }
366
+ }
367
+ }
368
+ }),
369
+ (0,swagger_.ApiResponse)({
370
+ status: 401,
371
+ description: 'Invalid or missing refresh token'
372
+ }),
373
+ _ts_param(0, (0,common_.Req)()),
374
+ _ts_param(1, (0,common_.Body)()),
375
+ _ts_metadata("design:type", Function),
376
+ _ts_metadata("design:paramtypes", [
377
+ typeof Request === "undefined" ? Object : Request,
378
+ typeof authentication_dto/* .RefreshTokenDto */.k2 === "undefined" ? Object : authentication_dto/* .RefreshTokenDto */.k2
379
+ ]),
380
+ _ts_metadata("design:returntype", Promise)
381
+ ], AuthenticationController.prototype, "refreshToken", null);
382
+ _ts_decorate([
383
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
384
+ (0,common_.Post)('me'),
385
+ (0,__rspack_external__nestjs_throttler_68da00c9.SkipThrottle)(),
386
+ (0,swagger_.ApiBearerAuth)(),
387
+ (0,swagger_.ApiOperation)({
388
+ summary: 'Get current user info'
389
+ }),
390
+ (0,swagger_.ApiResponse)({
391
+ status: 200,
392
+ description: 'Current user info retrieved successfully'
393
+ }),
394
+ _ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
395
+ _ts_metadata("design:type", Function),
396
+ _ts_metadata("design:paramtypes", [
397
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
398
+ ]),
399
+ _ts_metadata("design:returntype", Promise)
400
+ ], AuthenticationController.prototype, "getCurrentUser", null);
401
+ _ts_decorate([
402
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
403
+ (0,common_.Post)('logout'),
404
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
405
+ (0,__rspack_external__nestjs_throttler_68da00c9.SkipThrottle)(),
406
+ (0,common_.UseInterceptors)(clear_token_interceptor/* .ClearToken */.t),
407
+ (0,swagger_.ApiBearerAuth)(),
408
+ (0,swagger_.ApiOperation)({
409
+ summary: 'Logout user'
410
+ }),
411
+ (0,swagger_.ApiResponse)({
412
+ status: 200,
413
+ type: dtos_.MessageResponseDto
414
+ }),
415
+ _ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
416
+ _ts_metadata("design:type", Function),
417
+ _ts_metadata("design:paramtypes", [
418
+ String
419
+ ]),
420
+ _ts_metadata("design:returntype", Promise)
421
+ ], AuthenticationController.prototype, "logout", null);
422
+ _ts_decorate([
423
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
424
+ (0,common_.Post)('change-password'),
425
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
426
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
427
+ default: {
428
+ limit: 5,
429
+ ttl: 60000
430
+ }
431
+ }),
432
+ (0,swagger_.ApiBearerAuth)(),
433
+ (0,swagger_.ApiOperation)({
434
+ summary: 'Change password'
435
+ }),
436
+ (0,swagger_.ApiBody)({
437
+ type: authentication_dto/* .ChangePasswordDto */.$h
438
+ }),
439
+ (0,swagger_.ApiResponse)({
440
+ status: 200,
441
+ type: dtos_.MessageResponseDto
442
+ }),
443
+ _ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
444
+ _ts_param(1, (0,common_.Body)()),
445
+ _ts_metadata("design:type", Function),
446
+ _ts_metadata("design:paramtypes", [
447
+ String,
448
+ typeof authentication_dto/* .ChangePasswordDto */.$h === "undefined" ? Object : authentication_dto/* .ChangePasswordDto */.$h
449
+ ]),
450
+ _ts_metadata("design:returntype", Promise)
451
+ ], AuthenticationController.prototype, "changePassword", null);
452
+ AuthenticationController = _ts_decorate([
453
+ (0,swagger_.ApiTags)('Authentication'),
454
+ (0,common_.Controller)('auth'),
455
+ _ts_param(0, (0,common_.Inject)(authentication_service/* .AuthenticationService */.k)),
456
+ _ts_param(1, (0,common_.Optional)()),
457
+ _ts_param(1, (0,common_.Inject)(auth_config_service/* .AuthConfigService */.W)),
458
+ _ts_metadata("design:type", Function),
459
+ _ts_metadata("design:paramtypes", [
460
+ typeof authentication_service/* .AuthenticationService */.k === "undefined" ? Object : authentication_service/* .AuthenticationService */.k,
461
+ typeof auth_config_service/* .AuthConfigService */.W === "undefined" ? Object : auth_config_service/* .AuthConfigService */.W
462
+ ])
463
+ ], AuthenticationController);
464
+
465
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/company-selection.controller.ts
466
+ function company_selection_controller_ts_decorate(decorators, target, key, desc) {
467
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
468
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
469
+ r = Reflect.decorate(decorators, target, key, desc);
470
+ } else {
471
+ for(var i = decorators.length - 1; i >= 0; i--){
472
+ if (d = decorators[i]) {
473
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
474
+ }
475
+ }
476
+ }
477
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
478
+ }
479
+ function company_selection_controller_ts_metadata(metadataKey, metadataValue) {
480
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
481
+ return Reflect.metadata(metadataKey, metadataValue);
482
+ }
483
+ }
484
+ function company_selection_controller_ts_param(paramIndex, decorator) {
485
+ return function(target, key) {
486
+ decorator(target, key, paramIndex);
487
+ };
488
+ }
489
+
490
+
491
+
492
+
493
+
494
+
495
+
496
+
497
+ class CompanySelectionController {
498
+ authService;
499
+ constructor(authService){
500
+ this.authService = authService;
501
+ }
502
+ async select(dto) {
503
+ const data = await this.authService.select(dto.sessionId, dto.companyId, dto.branchId);
504
+ return {
505
+ success: true,
506
+ message: 'Company selected successfully',
507
+ messageKey: message_keys/* .AUTH_MESSAGES.SELECT_SUCCESS */.mK.SELECT_SUCCESS,
508
+ data
509
+ };
510
+ }
511
+ async switchCompany(userId, dto) {
512
+ const data = await this.authService.switchCompany(userId, dto.companyId, dto.branchId);
513
+ return {
514
+ success: true,
515
+ message: 'Company switched successfully',
516
+ messageKey: message_keys/* .AUTH_MESSAGES.SWITCH_COMPANY_SUCCESS */.mK.SWITCH_COMPANY_SUCCESS,
517
+ data
518
+ };
519
+ }
520
+ async getUserCompanies(userId) {
521
+ const companies = await this.authService.getUserCompanies(userId);
522
+ return {
523
+ success: true,
524
+ message: 'User companies retrieved successfully',
525
+ messageKey: message_keys/* .AUTH_MESSAGES.COMPANY_LIST_SUCCESS */.mK.COMPANY_LIST_SUCCESS,
526
+ data: companies
527
+ };
528
+ }
529
+ async getUserBranches(userId, companyId) {
530
+ const branches = await this.authService.getUserBranches(userId, companyId);
531
+ return {
532
+ success: true,
533
+ message: 'Company branches retrieved successfully',
534
+ messageKey: message_keys/* .AUTH_MESSAGES.BRANCH_LIST_SUCCESS */.mK.BRANCH_LIST_SUCCESS,
535
+ data: branches
536
+ };
537
+ }
538
+ }
539
+ company_selection_controller_ts_decorate([
540
+ (0,common_.Post)('select'),
541
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
542
+ (0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
543
+ (0,swagger_.ApiOperation)({
544
+ summary: 'Select company and branch after login',
545
+ description: 'Complete login by selecting company and branch when multiple options are available'
546
+ }),
547
+ (0,swagger_.ApiBody)({
548
+ type: authentication_dto/* .SelectDto */.aZ
549
+ }),
550
+ (0,swagger_.ApiResponse)({
551
+ status: 200,
552
+ description: 'Company selected, tokens returned'
553
+ }),
554
+ company_selection_controller_ts_param(0, (0,common_.Body)()),
555
+ company_selection_controller_ts_metadata("design:type", Function),
556
+ company_selection_controller_ts_metadata("design:paramtypes", [
557
+ typeof authentication_dto/* .SelectDto */.aZ === "undefined" ? Object : authentication_dto/* .SelectDto */.aZ
558
+ ]),
559
+ company_selection_controller_ts_metadata("design:returntype", Promise)
560
+ ], CompanySelectionController.prototype, "select", null);
561
+ company_selection_controller_ts_decorate([
562
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
563
+ (0,common_.Post)('switch-company'),
564
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
565
+ (0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
566
+ (0,swagger_.ApiBearerAuth)(),
567
+ (0,swagger_.ApiOperation)({
568
+ summary: 'Switch to different company/branch',
569
+ description: 'Switch to a different company and branch while already authenticated'
570
+ }),
571
+ (0,swagger_.ApiBody)({
572
+ type: authentication_dto/* .SwitchCompanyDto */.RQ
573
+ }),
574
+ (0,swagger_.ApiResponse)({
575
+ status: 200,
576
+ description: 'Company switched, new tokens returned'
577
+ }),
578
+ company_selection_controller_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
579
+ company_selection_controller_ts_param(1, (0,common_.Body)()),
580
+ company_selection_controller_ts_metadata("design:type", Function),
581
+ company_selection_controller_ts_metadata("design:paramtypes", [
582
+ String,
583
+ typeof authentication_dto/* .SwitchCompanyDto */.RQ === "undefined" ? Object : authentication_dto/* .SwitchCompanyDto */.RQ
584
+ ]),
585
+ company_selection_controller_ts_metadata("design:returntype", Promise)
586
+ ], CompanySelectionController.prototype, "switchCompany", null);
587
+ company_selection_controller_ts_decorate([
588
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
589
+ (0,common_.Post)('get-companies'),
590
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
591
+ (0,swagger_.ApiBearerAuth)(),
592
+ (0,swagger_.ApiOperation)({
593
+ summary: "Get user's available companies",
594
+ description: 'Get list of companies the current user has access to'
595
+ }),
596
+ (0,swagger_.ApiResponse)({
597
+ status: 200,
598
+ description: 'User companies retrieved successfully'
599
+ }),
600
+ company_selection_controller_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
601
+ company_selection_controller_ts_metadata("design:type", Function),
602
+ company_selection_controller_ts_metadata("design:paramtypes", [
603
+ String
604
+ ]),
605
+ company_selection_controller_ts_metadata("design:returntype", Promise)
606
+ ], CompanySelectionController.prototype, "getUserCompanies", null);
607
+ company_selection_controller_ts_decorate([
608
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
609
+ (0,common_.Post)('get-company-branches'),
610
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
611
+ (0,swagger_.ApiBearerAuth)(),
612
+ (0,swagger_.ApiOperation)({
613
+ summary: 'Get branches for a company',
614
+ description: 'Get list of branches for a specific company that the user has access to'
615
+ }),
616
+ (0,swagger_.ApiBody)({
617
+ schema: {
618
+ properties: {
619
+ companyId: {
620
+ type: 'string'
621
+ }
622
+ },
623
+ required: [
624
+ 'companyId'
625
+ ]
626
+ }
627
+ }),
628
+ (0,swagger_.ApiResponse)({
629
+ status: 200,
630
+ description: 'Company branches retrieved successfully'
631
+ }),
632
+ company_selection_controller_ts_param(0, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)('id')),
633
+ company_selection_controller_ts_param(1, (0,common_.Body)('companyId')),
634
+ company_selection_controller_ts_metadata("design:type", Function),
635
+ company_selection_controller_ts_metadata("design:paramtypes", [
636
+ String,
637
+ String
638
+ ]),
639
+ company_selection_controller_ts_metadata("design:returntype", Promise)
640
+ ], CompanySelectionController.prototype, "getUserBranches", null);
641
+ CompanySelectionController = company_selection_controller_ts_decorate([
642
+ (0,swagger_.ApiTags)('Company Selection'),
643
+ (0,common_.Controller)('auth'),
644
+ company_selection_controller_ts_param(0, (0,common_.Inject)(authentication_service/* .AuthenticationService */.k)),
645
+ company_selection_controller_ts_metadata("design:type", Function),
646
+ company_selection_controller_ts_metadata("design:paramtypes", [
647
+ typeof authentication_service/* .AuthenticationService */.k === "undefined" ? Object : authentication_service/* .AuthenticationService */.k
648
+ ])
649
+ ], CompanySelectionController);
650
+
651
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-datasource.provider.ts
652
+ var auth_datasource_provider = __webpack_require__(2732);
653
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-email.service.ts
654
+ var auth_email_service = __webpack_require__(3221);
655
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/email-verification.controller.ts
656
+ function email_verification_controller_ts_decorate(decorators, target, key, desc) {
657
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
658
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
659
+ r = Reflect.decorate(decorators, target, key, desc);
660
+ } else {
661
+ for(var i = decorators.length - 1; i >= 0; i--){
662
+ if (d = decorators[i]) {
663
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
664
+ }
665
+ }
666
+ }
667
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
668
+ }
669
+ function email_verification_controller_ts_metadata(metadataKey, metadataValue) {
670
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
671
+ return Reflect.metadata(metadataKey, metadataValue);
672
+ }
673
+ }
674
+ function email_verification_controller_ts_param(paramIndex, decorator) {
675
+ return function(target, key) {
676
+ decorator(target, key, paramIndex);
677
+ };
678
+ }
679
+
680
+
681
+
682
+
683
+
684
+
685
+
686
+
687
+
688
+
689
+
690
+
691
+ class EmailVerificationController {
692
+ authService;
693
+ authEmailService;
694
+ authConfig;
695
+ dataSourceProvider;
696
+ constructor(authService, authEmailService, authConfig, dataSourceProvider){
697
+ this.authService = authService;
698
+ this.authEmailService = authEmailService;
699
+ this.authConfig = authConfig;
700
+ this.dataSourceProvider = dataSourceProvider;
701
+ }
702
+ ensureEmailVerificationEnabled() {
703
+ if (!this.dataSourceProvider.isEmailVerificationEnabled()) {
704
+ throw new common_.BadRequestException({
705
+ message: 'Email verification is not enabled for this tenant',
706
+ messageKey: message_keys/* .EMAIL_VERIFICATION_MESSAGES.VERIFICATION_NOT_ENABLED */.sv.VERIFICATION_NOT_ENABLED
707
+ });
708
+ }
709
+ }
710
+ async forgotPassword(req, dto) {
711
+ this.ensureEmailVerificationEnabled();
712
+ return this.authEmailService.forgotPassword(dto.email, (0,nestjs_shared_.buildFrontendUrl)(req, '/auth/reset-password'));
713
+ }
714
+ async resetPassword(dto) {
715
+ this.ensureEmailVerificationEnabled();
716
+ return this.authEmailService.resetPassword(dto.token, dto.newPassword);
717
+ }
718
+ async resendVerification(req, dto) {
719
+ this.ensureEmailVerificationEnabled();
720
+ return this.authEmailService.resendVerificationEmail(dto.email, (0,nestjs_shared_.buildFrontendUrl)(req, '/auth/verify-email'));
721
+ }
722
+ async verifyEmail(dto) {
723
+ this.ensureEmailVerificationEnabled();
724
+ const result = await this.authEmailService.verifyEmail(dto.token);
725
+ if (result.type === 'pending') {
726
+ const data = await this.authService.createUserFromPendingRegistration(result.pending);
727
+ return {
728
+ success: true,
729
+ message: 'Registration completed successfully',
730
+ messageKey: message_keys/* .AUTH_MESSAGES.REGISTER_SUCCESS */.mK.REGISTER_SUCCESS,
731
+ data
732
+ };
733
+ }
734
+ return {
735
+ success: true,
736
+ message: result.message,
737
+ messageKey: result.messageKey
738
+ };
739
+ }
740
+ }
741
+ email_verification_controller_ts_decorate([
742
+ (0,common_.Post)('forgot-password'),
743
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
744
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
745
+ default: {
746
+ limit: 3,
747
+ ttl: 300000
748
+ }
749
+ }),
750
+ (0,swagger_.ApiOperation)({
751
+ summary: 'Request password reset email'
752
+ }),
753
+ (0,swagger_.ApiBody)({
754
+ type: authentication_dto/* .ForgotPasswordDto */.mG
755
+ }),
756
+ (0,swagger_.ApiResponse)({
757
+ status: 200,
758
+ type: dtos_.MessageResponseDto
759
+ }),
760
+ email_verification_controller_ts_param(0, (0,common_.Req)()),
761
+ email_verification_controller_ts_param(1, (0,common_.Body)()),
762
+ email_verification_controller_ts_metadata("design:type", Function),
763
+ email_verification_controller_ts_metadata("design:paramtypes", [
764
+ typeof Request === "undefined" ? Object : Request,
765
+ typeof authentication_dto/* .ForgotPasswordDto */.mG === "undefined" ? Object : authentication_dto/* .ForgotPasswordDto */.mG
766
+ ]),
767
+ email_verification_controller_ts_metadata("design:returntype", Promise)
768
+ ], EmailVerificationController.prototype, "forgotPassword", null);
769
+ email_verification_controller_ts_decorate([
770
+ (0,common_.Post)('reset-password'),
771
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
772
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
773
+ default: {
774
+ limit: 5,
775
+ ttl: 900000
776
+ }
777
+ }),
778
+ (0,swagger_.ApiOperation)({
779
+ summary: 'Reset password using token'
780
+ }),
781
+ (0,swagger_.ApiBody)({
782
+ type: authentication_dto/* .ResetPasswordDto */.US
783
+ }),
784
+ (0,swagger_.ApiResponse)({
785
+ status: 200,
786
+ type: dtos_.MessageResponseDto
787
+ }),
788
+ email_verification_controller_ts_param(0, (0,common_.Body)()),
789
+ email_verification_controller_ts_metadata("design:type", Function),
790
+ email_verification_controller_ts_metadata("design:paramtypes", [
791
+ typeof authentication_dto/* .ResetPasswordDto */.US === "undefined" ? Object : authentication_dto/* .ResetPasswordDto */.US
792
+ ]),
793
+ email_verification_controller_ts_metadata("design:returntype", Promise)
794
+ ], EmailVerificationController.prototype, "resetPassword", null);
795
+ email_verification_controller_ts_decorate([
796
+ (0,common_.Post)('resend-verification'),
797
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
798
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
799
+ default: {
800
+ limit: 3,
801
+ ttl: 300000
802
+ }
803
+ }),
804
+ (0,swagger_.ApiOperation)({
805
+ summary: 'Resend email verification link'
806
+ }),
807
+ (0,swagger_.ApiBody)({
808
+ type: authentication_dto/* .ResendVerificationDto */.Oz
809
+ }),
810
+ (0,swagger_.ApiResponse)({
811
+ status: 200,
812
+ type: dtos_.MessageResponseDto
813
+ }),
814
+ email_verification_controller_ts_param(0, (0,common_.Req)()),
815
+ email_verification_controller_ts_param(1, (0,common_.Body)()),
816
+ email_verification_controller_ts_metadata("design:type", Function),
817
+ email_verification_controller_ts_metadata("design:paramtypes", [
818
+ typeof Request === "undefined" ? Object : Request,
819
+ typeof authentication_dto/* .ResendVerificationDto */.Oz === "undefined" ? Object : authentication_dto/* .ResendVerificationDto */.Oz
820
+ ]),
821
+ email_verification_controller_ts_metadata("design:returntype", Promise)
822
+ ], EmailVerificationController.prototype, "resendVerification", null);
823
+ email_verification_controller_ts_decorate([
824
+ (0,common_.Post)('verify-email'),
825
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
826
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
827
+ default: {
828
+ limit: 10,
829
+ ttl: 60000
830
+ }
831
+ }),
832
+ (0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
833
+ (0,swagger_.ApiOperation)({
834
+ summary: 'Verify email using token'
835
+ }),
836
+ (0,swagger_.ApiBody)({
837
+ type: authentication_dto/* .VerifyEmailDto */.rl
838
+ }),
839
+ (0,swagger_.ApiResponse)({
840
+ status: 200,
841
+ description: 'Email verified or registration completed'
842
+ }),
843
+ email_verification_controller_ts_param(0, (0,common_.Body)()),
844
+ email_verification_controller_ts_metadata("design:type", Function),
845
+ email_verification_controller_ts_metadata("design:paramtypes", [
846
+ typeof authentication_dto/* .VerifyEmailDto */.rl === "undefined" ? Object : authentication_dto/* .VerifyEmailDto */.rl
847
+ ]),
848
+ email_verification_controller_ts_metadata("design:returntype", Promise)
849
+ ], EmailVerificationController.prototype, "verifyEmail", null);
850
+ EmailVerificationController = email_verification_controller_ts_decorate([
851
+ (0,swagger_.ApiTags)('Authentication'),
852
+ (0,common_.Controller)('auth'),
853
+ email_verification_controller_ts_param(0, (0,common_.Inject)(authentication_service/* .AuthenticationService */.k)),
854
+ email_verification_controller_ts_param(1, (0,common_.Inject)(auth_email_service/* .AuthEmailService */.G)),
855
+ email_verification_controller_ts_param(2, (0,common_.Inject)(auth_config_service/* .AuthConfigService */.W)),
856
+ email_verification_controller_ts_param(3, (0,common_.Inject)(auth_datasource_provider/* .AuthDataSourceProvider */.v)),
857
+ email_verification_controller_ts_metadata("design:type", Function),
858
+ email_verification_controller_ts_metadata("design:paramtypes", [
859
+ typeof authentication_service/* .AuthenticationService */.k === "undefined" ? Object : authentication_service/* .AuthenticationService */.k,
860
+ typeof auth_email_service/* .AuthEmailService */.G === "undefined" ? Object : auth_email_service/* .AuthEmailService */.G,
861
+ typeof auth_config_service/* .AuthConfigService */.W === "undefined" ? Object : auth_config_service/* .AuthConfigService */.W,
862
+ typeof auth_datasource_provider/* .AuthDataSourceProvider */.v === "undefined" ? Object : auth_datasource_provider/* .AuthDataSourceProvider */.v
863
+ ])
864
+ ], EmailVerificationController);
865
+
866
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/social-auth.dto.ts
867
+ var social_auth_dto = __webpack_require__(430);
868
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/social-auth.service.ts
869
+ var social_auth_service = __webpack_require__(2786);
870
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/social-auth.controller.ts
871
+ function social_auth_controller_ts_decorate(decorators, target, key, desc) {
872
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
873
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
874
+ r = Reflect.decorate(decorators, target, key, desc);
875
+ } else {
876
+ for(var i = decorators.length - 1; i >= 0; i--){
877
+ if (d = decorators[i]) {
878
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
879
+ }
880
+ }
881
+ }
882
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
883
+ }
884
+ function social_auth_controller_ts_metadata(metadataKey, metadataValue) {
885
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
886
+ return Reflect.metadata(metadataKey, metadataValue);
887
+ }
888
+ }
889
+ function social_auth_controller_ts_param(paramIndex, decorator) {
890
+ return function(target, key) {
891
+ decorator(target, key, paramIndex);
892
+ };
893
+ }
894
+
895
+
896
+
897
+
898
+
899
+
900
+
901
+ class SocialAuthController {
902
+ socialAuthService;
903
+ constructor(socialAuthService){
904
+ this.socialAuthService = socialAuthService;
905
+ }
906
+ async getProviders(dto) {
907
+ const data = await this.socialAuthService.listEnabledProviders(dto.redirectUri);
908
+ return {
909
+ success: true,
910
+ message: 'Social providers retrieved successfully',
911
+ messageKey: message_keys/* .SOCIAL_AUTH_MESSAGES.PROVIDERS_SUCCESS */.OF.PROVIDERS_SUCCESS,
912
+ data
913
+ };
914
+ }
915
+ async authorize(dto) {
916
+ const data = await this.socialAuthService.createAuthorization(dto.provider, dto.redirectUri);
917
+ return {
918
+ success: true,
919
+ message: 'Authorization URL generated successfully',
920
+ messageKey: message_keys/* .SOCIAL_AUTH_MESSAGES.AUTHORIZE_SUCCESS */.OF.AUTHORIZE_SUCCESS,
921
+ data
922
+ };
923
+ }
924
+ async callback(dto) {
925
+ const result = await this.socialAuthService.completeLogin(dto.code, dto.state, dto.redirectUri);
926
+ if ('requiresSelection' in result) {
927
+ return {
928
+ success: true,
929
+ message: 'Company selection required',
930
+ messageKey: message_keys/* .AUTH_MESSAGES.LOGIN_REQUIRES_SELECTION */.mK.LOGIN_REQUIRES_SELECTION,
931
+ data: result
932
+ };
933
+ }
934
+ return {
935
+ success: true,
936
+ message: 'Login successful',
937
+ messageKey: message_keys/* .SOCIAL_AUTH_MESSAGES.LOGIN_SUCCESS */.OF.LOGIN_SUCCESS,
938
+ data: result
939
+ };
940
+ }
941
+ }
942
+ social_auth_controller_ts_decorate([
943
+ (0,common_.Post)('providers'),
944
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
945
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
946
+ default: {
947
+ limit: 30,
948
+ ttl: 60000
949
+ }
950
+ }),
951
+ (0,swagger_.ApiOperation)({
952
+ summary: 'List enabled social sign-in providers'
953
+ }),
954
+ (0,swagger_.ApiBody)({
955
+ type: social_auth_dto/* .SocialProvidersDto */.fP
956
+ }),
957
+ (0,swagger_.ApiResponse)({
958
+ status: 200,
959
+ type: [
960
+ social_auth_dto/* .SocialProviderInfoDto */.a2
961
+ ]
962
+ }),
963
+ social_auth_controller_ts_param(0, (0,common_.Body)()),
964
+ social_auth_controller_ts_metadata("design:type", Function),
965
+ social_auth_controller_ts_metadata("design:paramtypes", [
966
+ typeof social_auth_dto/* .SocialProvidersDto */.fP === "undefined" ? Object : social_auth_dto/* .SocialProvidersDto */.fP
967
+ ]),
968
+ social_auth_controller_ts_metadata("design:returntype", Promise)
969
+ ], SocialAuthController.prototype, "getProviders", null);
970
+ social_auth_controller_ts_decorate([
971
+ (0,common_.Post)('authorize'),
972
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
973
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
974
+ default: {
975
+ limit: 10,
976
+ ttl: 60000
977
+ }
978
+ }),
979
+ (0,swagger_.ApiOperation)({
980
+ summary: "Start a sign-in and get the provider's consent URL"
981
+ }),
982
+ (0,swagger_.ApiBody)({
983
+ type: social_auth_dto/* .SocialAuthorizeDto */.s4
984
+ }),
985
+ (0,swagger_.ApiResponse)({
986
+ status: 200,
987
+ type: social_auth_dto/* .SocialAuthorizeResponseDto */.pd
988
+ }),
989
+ social_auth_controller_ts_param(0, (0,common_.Body)()),
990
+ social_auth_controller_ts_metadata("design:type", Function),
991
+ social_auth_controller_ts_metadata("design:paramtypes", [
992
+ typeof social_auth_dto/* .SocialAuthorizeDto */.s4 === "undefined" ? Object : social_auth_dto/* .SocialAuthorizeDto */.s4
993
+ ]),
994
+ social_auth_controller_ts_metadata("design:returntype", Promise)
995
+ ], SocialAuthController.prototype, "authorize", null);
996
+ social_auth_controller_ts_decorate([
997
+ (0,common_.Post)('callback'),
998
+ (0,common_.HttpCode)(common_.HttpStatus.OK),
999
+ (0,__rspack_external__nestjs_throttler_68da00c9.Throttle)({
1000
+ default: {
1001
+ limit: 10,
1002
+ ttl: 60000
1003
+ }
1004
+ }),
1005
+ (0,common_.UseInterceptors)(set_token_interceptor/* .SetToken */.A),
1006
+ (0,swagger_.ApiOperation)({
1007
+ summary: 'Complete a social sign-in'
1008
+ }),
1009
+ (0,swagger_.ApiBody)({
1010
+ type: social_auth_dto/* .SocialCallbackDto */.QW
1011
+ }),
1012
+ (0,swagger_.ApiResponse)({
1013
+ status: 200,
1014
+ description: 'Sign-in successful, or company selection is still required'
1015
+ }),
1016
+ social_auth_controller_ts_param(0, (0,common_.Body)()),
1017
+ social_auth_controller_ts_metadata("design:type", Function),
1018
+ social_auth_controller_ts_metadata("design:paramtypes", [
1019
+ typeof social_auth_dto/* .SocialCallbackDto */.QW === "undefined" ? Object : social_auth_dto/* .SocialCallbackDto */.QW
1020
+ ]),
1021
+ social_auth_controller_ts_metadata("design:returntype", Promise)
1022
+ ], SocialAuthController.prototype, "callback", null);
1023
+ SocialAuthController = social_auth_controller_ts_decorate([
1024
+ (0,swagger_.ApiTags)('Social Authentication'),
1025
+ (0,common_.Controller)('auth/social'),
1026
+ social_auth_controller_ts_param(0, (0,common_.Inject)(social_auth_service/* .SocialAuthService */.J)),
1027
+ social_auth_controller_ts_metadata("design:type", Function),
1028
+ social_auth_controller_ts_metadata("design:paramtypes", [
1029
+ typeof social_auth_service/* .SocialAuthService */.J === "undefined" ? Object : social_auth_service/* .SocialAuthService */.J
1030
+ ])
1031
+ ], SocialAuthController);
1032
+
1033
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared/classes"
1034
+ var classes_ = __webpack_require__(6937);
1035
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared/constants"
1036
+ var constants_ = __webpack_require__(9140);
1037
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/social-auth-config.service.ts
1038
+ var social_auth_config_service = __webpack_require__(8275);
1039
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/social-auth-config.controller.ts
1040
+ function social_auth_config_controller_ts_decorate(decorators, target, key, desc) {
1041
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1042
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1043
+ r = Reflect.decorate(decorators, target, key, desc);
1044
+ } else {
1045
+ for(var i = decorators.length - 1; i >= 0; i--){
1046
+ if (d = decorators[i]) {
1047
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1048
+ }
1049
+ }
1050
+ }
1051
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1052
+ }
1053
+ function social_auth_config_controller_ts_metadata(metadataKey, metadataValue) {
1054
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1055
+ return Reflect.metadata(metadataKey, metadataValue);
1056
+ }
1057
+ }
1058
+ function social_auth_config_controller_ts_param(paramIndex, decorator) {
1059
+ return function(target, key) {
1060
+ decorator(target, key, paramIndex);
1061
+ };
1062
+ }
1063
+
1064
+
1065
+
1066
+
1067
+
1068
+
1069
+ class SocialAuthConfigController extends (0,classes_.createApiController)(social_auth_dto/* .CreateSocialAuthConfigDto */.X8, social_auth_dto/* .UpdateSocialAuthConfigDto */.kd, social_auth_dto/* .SocialAuthConfigResponseDto */.SN, {
1070
+ entityName: 'social.config',
1071
+ security: {
1072
+ insert: {
1073
+ level: 'permission',
1074
+ permissions: [
1075
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.CREATE
1076
+ ]
1077
+ },
1078
+ bulkUpsert: {
1079
+ level: 'permission',
1080
+ permissions: [
1081
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.CREATE,
1082
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.UPDATE
1083
+ ],
1084
+ operator: 'AND'
1085
+ },
1086
+ getById: {
1087
+ level: 'permission',
1088
+ permissions: [
1089
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.READ
1090
+ ]
1091
+ },
1092
+ getAll: {
1093
+ level: 'permission',
1094
+ permissions: [
1095
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.READ
1096
+ ]
1097
+ },
1098
+ update: {
1099
+ level: 'permission',
1100
+ permissions: [
1101
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.UPDATE
1102
+ ]
1103
+ },
1104
+ delete: {
1105
+ level: 'permission',
1106
+ permissions: [
1107
+ constants_.SOCIAL_AUTH_CONFIG_PERMISSIONS.DELETE
1108
+ ]
1109
+ }
1110
+ },
1111
+ enabledEndpoints: [
1112
+ 'insert',
1113
+ 'bulkUpsert',
1114
+ 'getById',
1115
+ 'getAll',
1116
+ 'update',
1117
+ 'delete'
1118
+ ]
1119
+ }) {
1120
+ socialAuthConfigService;
1121
+ constructor(socialAuthConfigService){
1122
+ super(socialAuthConfigService), this.socialAuthConfigService = socialAuthConfigService;
1123
+ }
1124
+ }
1125
+ SocialAuthConfigController = social_auth_config_controller_ts_decorate([
1126
+ (0,swagger_.ApiTags)('Social Auth Config'),
1127
+ (0,common_.Controller)('auth/social-config'),
1128
+ social_auth_config_controller_ts_param(0, (0,common_.Inject)(social_auth_config_service/* .SocialAuthConfigService */.t)),
1129
+ social_auth_config_controller_ts_metadata("design:type", Function),
1130
+ social_auth_config_controller_ts_metadata("design:paramtypes", [
1131
+ typeof social_auth_config_service/* .SocialAuthConfigService */.t === "undefined" ? Object : social_auth_config_service/* .SocialAuthConfigService */.t
1132
+ ])
1133
+ ], SocialAuthConfigController);
1134
+
1135
+ // EXTERNAL MODULE: external "class-transformer"
1136
+ var external_class_transformer_ = __webpack_require__(5812);
1137
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/user.dto.ts
1138
+ var user_dto = __webpack_require__(7265);
1139
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/user.service.ts
1140
+ var user_service = __webpack_require__(7229);
1141
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/user.controller.ts
1142
+ function user_controller_ts_decorate(decorators, target, key, desc) {
1143
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1144
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1145
+ r = Reflect.decorate(decorators, target, key, desc);
1146
+ } else {
1147
+ for(var i = decorators.length - 1; i >= 0; i--){
1148
+ if (d = decorators[i]) {
1149
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1150
+ }
1151
+ }
1152
+ }
1153
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1154
+ }
1155
+ function user_controller_ts_metadata(metadataKey, metadataValue) {
1156
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1157
+ return Reflect.metadata(metadataKey, metadataValue);
1158
+ }
1159
+ }
1160
+ function user_controller_ts_param(paramIndex, decorator) {
1161
+ return function(target, key) {
1162
+ decorator(target, key, paramIndex);
1163
+ };
1164
+ }
1165
+
1166
+
1167
+
1168
+
1169
+
1170
+
1171
+
1172
+
1173
+
1174
+
1175
+ class UserController extends (0,classes_.createApiController)(user_dto/* .CreateUserDto */.TG, user_dto/* .UpdateUserDto */.Qf, user_dto/* .UserResponseDto */.kq, {
1176
+ entityName: 'user',
1177
+ security: {
1178
+ insert: {
1179
+ level: 'permission',
1180
+ permissions: [
1181
+ classes_.USER_PERMISSIONS.CREATE
1182
+ ]
1183
+ },
1184
+ insertMany: {
1185
+ level: 'permission',
1186
+ permissions: [
1187
+ classes_.USER_PERMISSIONS.CREATE
1188
+ ]
1189
+ },
1190
+ getById: {
1191
+ level: 'permission',
1192
+ permissions: [
1193
+ classes_.USER_PERMISSIONS.READ
1194
+ ]
1195
+ },
1196
+ getAll: {
1197
+ level: 'permission',
1198
+ permissions: [
1199
+ classes_.USER_PERMISSIONS.READ
1200
+ ]
1201
+ },
1202
+ update: {
1203
+ level: 'permission',
1204
+ permissions: [
1205
+ classes_.USER_PERMISSIONS.UPDATE
1206
+ ]
1207
+ },
1208
+ updateMany: {
1209
+ level: 'permission',
1210
+ permissions: [
1211
+ classes_.USER_PERMISSIONS.UPDATE
1212
+ ]
1213
+ },
1214
+ delete: {
1215
+ level: 'permission',
1216
+ permissions: [
1217
+ classes_.USER_PERMISSIONS.DELETE
1218
+ ]
1219
+ }
1220
+ }
1221
+ }) {
1222
+ service;
1223
+ constructor(service){
1224
+ super(service), this.service = service;
1225
+ }
1226
+ async lookup(filterAndPaginationDto, user, search) {
1227
+ const result = await this.service.getAll(search ?? '', filterAndPaginationDto, user);
1228
+ const data = result.data.map((item)=>(0,external_class_transformer_.plainToInstance)(user_dto/* .UserLookupResponseDto */.sx, item, {
1229
+ excludeExtraneousValues: true
1230
+ }));
1231
+ const page = filterAndPaginationDto.pagination?.currentPage ?? 0;
1232
+ const pageSize = filterAndPaginationDto.pagination?.pageSize ?? data.length;
1233
+ const totalPages = pageSize > 0 ? Math.ceil(result.total / pageSize) : 1;
1234
+ return {
1235
+ success: true,
1236
+ message: 'Users retrieved successfully',
1237
+ messageKey: message_keys/* .USER_MESSAGES.LOOKUP_SUCCESS */.ny.LOOKUP_SUCCESS,
1238
+ data,
1239
+ meta: {
1240
+ total: result.total,
1241
+ page,
1242
+ pageSize,
1243
+ count: data.length,
1244
+ hasMore: page < totalPages - 1,
1245
+ totalPages
1246
+ }
1247
+ };
1248
+ }
1249
+ async getProfileWithExtras(id, user) {
1250
+ const data = await this.service.getProfileWithExtras(id, user);
1251
+ return {
1252
+ success: true,
1253
+ message: 'Profile extras retrieved successfully',
1254
+ messageKey: message_keys/* .USER_MESSAGES.PROFILE_EXTRAS_SUCCESS */.ny.PROFILE_EXTRAS_SUCCESS,
1255
+ data
1256
+ };
1257
+ }
1258
+ async verifyEmail(id) {
1259
+ await this.service.verifyEmail(id);
1260
+ return {
1261
+ success: true,
1262
+ message: 'Email verified successfully',
1263
+ messageKey: message_keys/* .USER_MESSAGES.EMAIL_VERIFY_SUCCESS */.ny.EMAIL_VERIFY_SUCCESS
1264
+ };
1265
+ }
1266
+ async verifyPhone(id) {
1267
+ await this.service.verifyPhone(id);
1268
+ return {
1269
+ success: true,
1270
+ message: 'Phone verified successfully',
1271
+ messageKey: message_keys/* .USER_MESSAGES.PHONE_VERIFY_SUCCESS */.ny.PHONE_VERIFY_SUCCESS
1272
+ };
1273
+ }
1274
+ async updateStatus(id, isActive, user) {
1275
+ await this.service.updateStatus(id, isActive, user);
1276
+ return {
1277
+ success: true,
1278
+ message: 'Status updated successfully',
1279
+ messageKey: message_keys/* .USER_MESSAGES.STATUS_UPDATE_SUCCESS */.ny.STATUS_UPDATE_SUCCESS
1280
+ };
1281
+ }
1282
+ async profile(dto, user) {
1283
+ const data = await this.service.profile(dto, user);
1284
+ return {
1285
+ success: true,
1286
+ message: 'Profile updated successfully',
1287
+ messageKey: message_keys/* .USER_MESSAGES.PROFILE_UPDATE_SUCCESS */.ny.PROFILE_UPDATE_SUCCESS,
1288
+ data
1289
+ };
1290
+ }
1291
+ async getProfileSections() {
1292
+ const sections = await this.service.getProfileSections();
1293
+ return {
1294
+ success: true,
1295
+ message: 'Profile sections retrieved successfully',
1296
+ messageKey: message_keys/* .USER_MESSAGES.PROFILE_SECTIONS_SUCCESS */.ny.PROFILE_SECTIONS_SUCCESS,
1297
+ data: sections
1298
+ };
1299
+ }
1300
+ async getProfileSectionData(id, sectionId, user) {
1301
+ const data = await this.service.getProfileSectionData(id, sectionId, user);
1302
+ return {
1303
+ success: true,
1304
+ message: 'Profile section data retrieved successfully',
1305
+ messageKey: message_keys/* .USER_MESSAGES.PROFILE_SECTION_DATA_SUCCESS */.ny.PROFILE_SECTION_DATA_SUCCESS,
1306
+ data
1307
+ };
1308
+ }
1309
+ async updateProfileSection(id, sectionId, data, user) {
1310
+ await this.service.updateProfileSection(id, sectionId, data, user);
1311
+ return {
1312
+ success: true,
1313
+ message: 'Section updated successfully',
1314
+ messageKey: message_keys/* .USER_MESSAGES.PROFILE_SECTION_UPDATE_SUCCESS */.ny.PROFILE_SECTION_UPDATE_SUCCESS
1315
+ };
1316
+ }
1317
+ async getProfileCompletion(id, user) {
1318
+ const percentage = await this.service.getProfileCompletion(id, user);
1319
+ return {
1320
+ success: true,
1321
+ message: 'Profile completion retrieved successfully',
1322
+ messageKey: message_keys/* .USER_MESSAGES.PROFILE_COMPLETION_SUCCESS */.ny.PROFILE_COMPLETION_SUCCESS,
1323
+ data: {
1324
+ completionPercentage: percentage
1325
+ }
1326
+ };
1327
+ }
1328
+ }
1329
+ user_controller_ts_decorate([
1330
+ (0,common_.Post)('lookup'),
1331
+ (0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
1332
+ (0,swagger_.ApiBearerAuth)(),
1333
+ (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequireAnyPermission)(classes_.USER_PERMISSIONS.READ, classes_.USER_PERMISSIONS.LOOKUP),
1334
+ (0,swagger_.ApiOperation)({
1335
+ summary: 'Lookup users for pickers/directory',
1336
+ description: 'Lightweight user directory search for selection widgets (event participants, assignees, etc.). ' + 'Returns only id/name/email. Accessible with USER_PERMISSIONS.READ or the narrower USER_PERMISSIONS.LOOKUP, ' + 'so panels that only need to pick a user do not require full user-management access.'
1337
+ }),
1338
+ (0,swagger_.ApiQuery)({
1339
+ name: 'q',
1340
+ required: false,
1341
+ description: 'Global text search across searchable fields'
1342
+ }),
1343
+ (0,swagger_.ApiBody)({
1344
+ type: dtos_.FilterAndPaginationDto
1345
+ }),
1346
+ user_controller_ts_param(0, (0,common_.Body)()),
1347
+ user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1348
+ user_controller_ts_param(2, (0,common_.Query)('q')),
1349
+ user_controller_ts_metadata("design:type", Function),
1350
+ user_controller_ts_metadata("design:paramtypes", [
1351
+ typeof dtos_.FilterAndPaginationDto === "undefined" ? Object : dtos_.FilterAndPaginationDto,
1352
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo,
1353
+ String
1354
+ ]),
1355
+ user_controller_ts_metadata("design:returntype", Promise)
1356
+ ], UserController.prototype, "lookup", null);
1357
+ user_controller_ts_decorate([
1358
+ (0,common_.Post)(':id/profile-extras'),
1359
+ (0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
1360
+ (0,swagger_.ApiBearerAuth)(),
1361
+ (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.READ),
1362
+ (0,swagger_.ApiOperation)({
1363
+ summary: 'Get user profile with extras',
1364
+ description: 'Returns user profile along with extra data (roles, permissions, etc.) if UserEnricher is provided.'
1365
+ }),
1366
+ (0,swagger_.ApiParam)({
1367
+ name: 'id',
1368
+ description: 'User ID'
1369
+ }),
1370
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1371
+ user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1372
+ user_controller_ts_metadata("design:type", Function),
1373
+ user_controller_ts_metadata("design:paramtypes", [
1374
+ String,
1375
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1376
+ ]),
1377
+ user_controller_ts_metadata("design:returntype", Promise)
1378
+ ], UserController.prototype, "getProfileWithExtras", null);
1379
+ user_controller_ts_decorate([
1380
+ (0,common_.Post)(':id/verify-email'),
1381
+ (0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
1382
+ (0,swagger_.ApiBearerAuth)(),
1383
+ (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.UPDATE),
1384
+ (0,swagger_.ApiOperation)({
1385
+ summary: 'Verify user email'
1386
+ }),
1387
+ (0,swagger_.ApiParam)({
1388
+ name: 'id',
1389
+ description: 'User ID'
1390
+ }),
1391
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1392
+ user_controller_ts_metadata("design:type", Function),
1393
+ user_controller_ts_metadata("design:paramtypes", [
1394
+ String
1395
+ ]),
1396
+ user_controller_ts_metadata("design:returntype", Promise)
1397
+ ], UserController.prototype, "verifyEmail", null);
1398
+ user_controller_ts_decorate([
1399
+ (0,common_.Post)(':id/verify-phone'),
1400
+ (0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
1401
+ (0,swagger_.ApiBearerAuth)(),
1402
+ (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.UPDATE),
1403
+ (0,swagger_.ApiOperation)({
1404
+ summary: 'Verify user phone'
1405
+ }),
1406
+ (0,swagger_.ApiParam)({
1407
+ name: 'id',
1408
+ description: 'User ID'
1409
+ }),
1410
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1411
+ user_controller_ts_metadata("design:type", Function),
1412
+ user_controller_ts_metadata("design:paramtypes", [
1413
+ String
1414
+ ]),
1415
+ user_controller_ts_metadata("design:returntype", Promise)
1416
+ ], UserController.prototype, "verifyPhone", null);
1417
+ user_controller_ts_decorate([
1418
+ (0,common_.Post)(':id/status'),
1419
+ (0,common_.UseGuards)(guards_.JwtAuthGuard, guards_.PermissionGuard),
1420
+ (0,swagger_.ApiBearerAuth)(),
1421
+ (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.UPDATE),
1422
+ (0,swagger_.ApiOperation)({
1423
+ summary: 'Update user active status',
1424
+ description: 'Updates user active status. When company feature is enabled, updates the status for the current company context.'
1425
+ }),
1426
+ (0,swagger_.ApiParam)({
1427
+ name: 'id',
1428
+ description: 'User ID'
1429
+ }),
1430
+ (0,swagger_.ApiBody)({
1431
+ schema: {
1432
+ example: {
1433
+ isActive: true
1434
+ }
1435
+ }
1436
+ }),
1437
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1438
+ user_controller_ts_param(1, (0,common_.Body)('isActive')),
1439
+ user_controller_ts_param(2, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1440
+ user_controller_ts_metadata("design:type", Function),
1441
+ user_controller_ts_metadata("design:paramtypes", [
1442
+ String,
1443
+ Boolean,
1444
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1445
+ ]),
1446
+ user_controller_ts_metadata("design:returntype", Promise)
1447
+ ], UserController.prototype, "updateStatus", null);
1448
+ user_controller_ts_decorate([
1449
+ (0,common_.Post)('profile'),
1450
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
1451
+ (0,swagger_.ApiBearerAuth)(),
1452
+ (0,swagger_.ApiOperation)({
1453
+ summary: 'Update user profile'
1454
+ }),
1455
+ (0,swagger_.ApiBody)({
1456
+ type: user_dto/* .UpdateUserDto */.Qf
1457
+ }),
1458
+ user_controller_ts_param(0, (0,common_.Body)()),
1459
+ user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1460
+ user_controller_ts_metadata("design:type", Function),
1461
+ user_controller_ts_metadata("design:paramtypes", [
1462
+ typeof user_dto/* .UpdateUserDto */.Qf === "undefined" ? Object : user_dto/* .UpdateUserDto */.Qf,
1463
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1464
+ ]),
1465
+ user_controller_ts_metadata("design:returntype", Promise)
1466
+ ], UserController.prototype, "profile", null);
1467
+ user_controller_ts_decorate([
1468
+ (0,common_.Post)('profile-sections'),
1469
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
1470
+ (0,swagger_.ApiBearerAuth)(),
1471
+ (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.RequirePermission)(classes_.USER_PERMISSIONS.READ),
1472
+ (0,swagger_.ApiOperation)({
1473
+ summary: 'Get profile section definitions',
1474
+ description: 'Returns available profile sections for multi-step profile (if enricher configured).'
1475
+ }),
1476
+ user_controller_ts_metadata("design:type", Function),
1477
+ user_controller_ts_metadata("design:paramtypes", []),
1478
+ user_controller_ts_metadata("design:returntype", Promise)
1479
+ ], UserController.prototype, "getProfileSections", null);
1480
+ user_controller_ts_decorate([
1481
+ (0,common_.Post)(':id/profile-section/:sectionId'),
1482
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
1483
+ (0,swagger_.ApiBearerAuth)(),
1484
+ (0,swagger_.ApiOperation)({
1485
+ summary: 'Get profile section data',
1486
+ description: 'Returns data for a specific profile section.'
1487
+ }),
1488
+ (0,swagger_.ApiParam)({
1489
+ name: 'id',
1490
+ description: 'User ID'
1491
+ }),
1492
+ (0,swagger_.ApiParam)({
1493
+ name: 'sectionId',
1494
+ description: 'Section identifier'
1495
+ }),
1496
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1497
+ user_controller_ts_param(1, (0,common_.Param)('sectionId')),
1498
+ user_controller_ts_param(2, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1499
+ user_controller_ts_metadata("design:type", Function),
1500
+ user_controller_ts_metadata("design:paramtypes", [
1501
+ String,
1502
+ String,
1503
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1504
+ ]),
1505
+ user_controller_ts_metadata("design:returntype", Promise)
1506
+ ], UserController.prototype, "getProfileSectionData", null);
1507
+ user_controller_ts_decorate([
1508
+ (0,common_.Post)(':id/profile-section/:sectionId/update'),
1509
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
1510
+ (0,swagger_.ApiBearerAuth)(),
1511
+ (0,swagger_.ApiOperation)({
1512
+ summary: 'Update profile section',
1513
+ description: 'Updates a specific profile section data.'
1514
+ }),
1515
+ (0,swagger_.ApiParam)({
1516
+ name: 'id',
1517
+ description: 'User ID'
1518
+ }),
1519
+ (0,swagger_.ApiParam)({
1520
+ name: 'sectionId',
1521
+ description: 'Section identifier'
1522
+ }),
1523
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1524
+ user_controller_ts_param(1, (0,common_.Param)('sectionId')),
1525
+ user_controller_ts_param(2, (0,common_.Body)()),
1526
+ user_controller_ts_param(3, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1527
+ user_controller_ts_metadata("design:type", Function),
1528
+ user_controller_ts_metadata("design:paramtypes", [
1529
+ String,
1530
+ String,
1531
+ typeof Record === "undefined" ? Object : Record,
1532
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1533
+ ]),
1534
+ user_controller_ts_metadata("design:returntype", Promise)
1535
+ ], UserController.prototype, "updateProfileSection", null);
1536
+ user_controller_ts_decorate([
1537
+ (0,common_.Post)(':id/profile-completion'),
1538
+ (0,common_.UseGuards)(guards_.JwtAuthGuard),
1539
+ (0,swagger_.ApiBearerAuth)(),
1540
+ (0,swagger_.ApiOperation)({
1541
+ summary: 'Get profile completion percentage',
1542
+ description: 'Returns overall profile completion percentage.'
1543
+ }),
1544
+ (0,swagger_.ApiParam)({
1545
+ name: 'id',
1546
+ description: 'User ID'
1547
+ }),
1548
+ user_controller_ts_param(0, (0,common_.Param)('id')),
1549
+ user_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1550
+ user_controller_ts_metadata("design:type", Function),
1551
+ user_controller_ts_metadata("design:paramtypes", [
1552
+ String,
1553
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1554
+ ]),
1555
+ user_controller_ts_metadata("design:returntype", Promise)
1556
+ ], UserController.prototype, "getProfileCompletion", null);
1557
+ UserController = user_controller_ts_decorate([
1558
+ (0,swagger_.ApiTags)('Users'),
1559
+ (0,common_.Controller)('administration/users'),
1560
+ user_controller_ts_param(0, (0,common_.Inject)(user_service/* .UserService */.D)),
1561
+ user_controller_ts_metadata("design:type", Function),
1562
+ user_controller_ts_metadata("design:paramtypes", [
1563
+ typeof user_service/* .UserService */.D === "undefined" ? Object : user_service/* .UserService */.D
1564
+ ])
1565
+ ], UserController);
1566
+
1567
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/company.dto.ts
1568
+ var company_dto = __webpack_require__(1845);
1569
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/company.service.ts
1570
+ var company_service = __webpack_require__(9201);
1571
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/company.controller.ts
1572
+ function company_controller_ts_decorate(decorators, target, key, desc) {
1573
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1574
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1575
+ r = Reflect.decorate(decorators, target, key, desc);
1576
+ } else {
1577
+ for(var i = decorators.length - 1; i >= 0; i--){
1578
+ if (d = decorators[i]) {
1579
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1580
+ }
1581
+ }
1582
+ }
1583
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1584
+ }
1585
+ function company_controller_ts_metadata(metadataKey, metadataValue) {
1586
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1587
+ return Reflect.metadata(metadataKey, metadataValue);
1588
+ }
1589
+ }
1590
+ function company_controller_ts_param(paramIndex, decorator) {
1591
+ return function(target, key) {
1592
+ decorator(target, key, paramIndex);
1593
+ };
1594
+ }
1595
+
1596
+
1597
+
1598
+
1599
+
1600
+ class CompanyController extends (0,classes_.createApiController)(company_dto/* .CreateCompanyDto */.l4, company_dto/* .UpdateCompanyDto */.Ky, company_dto/* .CompanyResponseDto */.cd, {
1601
+ entityName: 'company',
1602
+ security: {
1603
+ insert: {
1604
+ level: 'permission',
1605
+ permissions: [
1606
+ classes_.COMPANY_PERMISSIONS.CREATE
1607
+ ]
1608
+ },
1609
+ insertMany: {
1610
+ level: 'permission',
1611
+ permissions: [
1612
+ classes_.COMPANY_PERMISSIONS.CREATE
1613
+ ]
1614
+ },
1615
+ getById: {
1616
+ level: 'permission',
1617
+ permissions: [
1618
+ classes_.COMPANY_PERMISSIONS.READ
1619
+ ]
1620
+ },
1621
+ getAll: {
1622
+ level: 'permission',
1623
+ permissions: [
1624
+ classes_.COMPANY_PERMISSIONS.READ
1625
+ ]
1626
+ },
1627
+ update: {
1628
+ level: 'permission',
1629
+ permissions: [
1630
+ classes_.COMPANY_PERMISSIONS.UPDATE
1631
+ ]
1632
+ },
1633
+ updateMany: {
1634
+ level: 'permission',
1635
+ permissions: [
1636
+ classes_.COMPANY_PERMISSIONS.UPDATE
1637
+ ]
1638
+ },
1639
+ delete: {
1640
+ level: 'permission',
1641
+ permissions: [
1642
+ classes_.COMPANY_PERMISSIONS.DELETE
1643
+ ]
1644
+ }
1645
+ }
1646
+ }) {
1647
+ companyService;
1648
+ constructor(companyService){
1649
+ super(companyService), this.companyService = companyService;
1650
+ }
1651
+ }
1652
+ CompanyController = company_controller_ts_decorate([
1653
+ (0,swagger_.ApiTags)('Companies'),
1654
+ (0,common_.Controller)('administration/company'),
1655
+ company_controller_ts_param(0, (0,common_.Inject)(company_service/* .CompanyService */.B)),
1656
+ company_controller_ts_metadata("design:type", Function),
1657
+ company_controller_ts_metadata("design:paramtypes", [
1658
+ typeof company_service/* .CompanyService */.B === "undefined" ? Object : company_service/* .CompanyService */.B
1659
+ ])
1660
+ ], CompanyController);
1661
+
1662
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/company-branch.dto.ts
1663
+ var company_branch_dto = __webpack_require__(9556);
1664
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/branch.service.ts
1665
+ var branch_service = __webpack_require__(5402);
1666
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/branch.controller.ts
1667
+ function branch_controller_ts_decorate(decorators, target, key, desc) {
1668
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1669
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1670
+ r = Reflect.decorate(decorators, target, key, desc);
1671
+ } else {
1672
+ for(var i = decorators.length - 1; i >= 0; i--){
1673
+ if (d = decorators[i]) {
1674
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1675
+ }
1676
+ }
1677
+ }
1678
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1679
+ }
1680
+ function branch_controller_ts_metadata(metadataKey, metadataValue) {
1681
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1682
+ return Reflect.metadata(metadataKey, metadataValue);
1683
+ }
1684
+ }
1685
+ function branch_controller_ts_param(paramIndex, decorator) {
1686
+ return function(target, key) {
1687
+ decorator(target, key, paramIndex);
1688
+ };
1689
+ }
1690
+
1691
+
1692
+
1693
+
1694
+
1695
+ class BranchController extends (0,classes_.createApiController)(company_branch_dto/* .CreateCompanyBranchDto */.Vw, company_branch_dto/* .UpdateCompanyBranchDto */.Oo, company_branch_dto/* .CompanyBranchResponseDto */.ET, {
1696
+ entityName: 'branch',
1697
+ security: {
1698
+ insert: {
1699
+ level: 'permission',
1700
+ permissions: [
1701
+ classes_.BRANCH_PERMISSIONS.CREATE
1702
+ ]
1703
+ },
1704
+ insertMany: {
1705
+ level: 'permission',
1706
+ permissions: [
1707
+ classes_.BRANCH_PERMISSIONS.CREATE
1708
+ ]
1709
+ },
1710
+ getById: {
1711
+ level: 'permission',
1712
+ permissions: [
1713
+ classes_.BRANCH_PERMISSIONS.READ
1714
+ ]
1715
+ },
1716
+ getAll: {
1717
+ level: 'permission',
1718
+ permissions: [
1719
+ classes_.BRANCH_PERMISSIONS.READ
1720
+ ]
1721
+ },
1722
+ update: {
1723
+ level: 'permission',
1724
+ permissions: [
1725
+ classes_.BRANCH_PERMISSIONS.UPDATE
1726
+ ]
1727
+ },
1728
+ updateMany: {
1729
+ level: 'permission',
1730
+ permissions: [
1731
+ classes_.BRANCH_PERMISSIONS.UPDATE
1732
+ ]
1733
+ },
1734
+ delete: {
1735
+ level: 'permission',
1736
+ permissions: [
1737
+ classes_.BRANCH_PERMISSIONS.DELETE
1738
+ ]
1739
+ }
1740
+ }
1741
+ }) {
1742
+ branchService;
1743
+ constructor(branchService){
1744
+ super(branchService), this.branchService = branchService;
1745
+ }
1746
+ }
1747
+ BranchController = branch_controller_ts_decorate([
1748
+ (0,swagger_.ApiTags)('Branches'),
1749
+ (0,common_.Controller)('administration/branch'),
1750
+ branch_controller_ts_param(0, (0,common_.Inject)(branch_service/* .BranchService */.O)),
1751
+ branch_controller_ts_metadata("design:type", Function),
1752
+ branch_controller_ts_metadata("design:paramtypes", [
1753
+ typeof branch_service/* .BranchService */.O === "undefined" ? Object : branch_service/* .BranchService */.O
1754
+ ])
1755
+ ], BranchController);
1756
+
1757
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/dtos/user-permission.dto.ts
1758
+ var user_permission_dto = __webpack_require__(3939);
1759
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/entities/user-company-permission.entity.ts
1760
+ var user_company_permission_entity = __webpack_require__(2377);
1761
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/user-permission.service.ts
1762
+ var user_permission_service = __webpack_require__(5291);
1763
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/user-permission.controller.ts
1764
+ function user_permission_controller_ts_decorate(decorators, target, key, desc) {
1765
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1766
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
1767
+ r = Reflect.decorate(decorators, target, key, desc);
1768
+ } else {
1769
+ for(var i = decorators.length - 1; i >= 0; i--){
1770
+ if (d = decorators[i]) {
1771
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1772
+ }
1773
+ }
1774
+ }
1775
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1776
+ }
1777
+ function user_permission_controller_ts_metadata(metadataKey, metadataValue) {
1778
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
1779
+ return Reflect.metadata(metadataKey, metadataValue);
1780
+ }
1781
+ }
1782
+ function user_permission_controller_ts_param(paramIndex, decorator) {
1783
+ return function(target, key) {
1784
+ decorator(target, key, paramIndex);
1785
+ };
1786
+ }
1787
+
1788
+
1789
+
1790
+
1791
+
1792
+
1793
+
1794
+
1795
+ class UserPermissionController {
1796
+ permissionService;
1797
+ constructor(permissionService){
1798
+ this.permissionService = permissionService;
1799
+ }
1800
+ async assignUserCompany(dto, user) {
1801
+ return this.processBatchPermissions(dto.userId, dto.items, user_company_permission_entity/* .PermissionType.COMPANY */.e.COMPANY, user);
1802
+ }
1803
+ async getUserCompanies(userId) {
1804
+ const permissions = await this.permissionService.findUserCompanies(userId);
1805
+ return {
1806
+ success: true,
1807
+ message: 'User companies retrieved successfully',
1808
+ messageKey: message_keys/* .USER_PERMISSION_MESSAGES.COMPANY_LIST_SUCCESS */.jz.COMPANY_LIST_SUCCESS,
1809
+ data: permissions.map((p)=>({
1810
+ id: p.id,
1811
+ userId: p.userId,
1812
+ companyId: p.company?.id || p.targetId,
1813
+ companyName: p.company?.name || '',
1814
+ companySlug: p.company?.slug || ''
1815
+ }))
1816
+ };
1817
+ }
1818
+ async assignUserBranch(dto, user) {
1819
+ return this.processBatchPermissions(dto.userId, dto.items, user_company_permission_entity/* .PermissionType.BRANCH */.e.BRANCH, user);
1820
+ }
1821
+ async getUserBranches(userId, companyId) {
1822
+ const permissions = await this.permissionService.findUserBranches(userId, companyId);
1823
+ return {
1824
+ success: true,
1825
+ message: 'User branches retrieved successfully',
1826
+ messageKey: message_keys/* .USER_PERMISSION_MESSAGES.BRANCH_LIST_SUCCESS */.jz.BRANCH_LIST_SUCCESS,
1827
+ data: permissions.map((p)=>({
1828
+ id: p.id,
1829
+ userId: p.userId,
1830
+ branchId: p.branch?.id || p.targetId,
1831
+ branchName: p.branch?.name || '',
1832
+ branchSlug: p.branch?.slug || '',
1833
+ companyId: p.branch?.companyId || ''
1834
+ }))
1835
+ };
1836
+ }
1837
+ /** Process batch permission assignments/revocations */ async processBatchPermissions(userId, items, type, user) {
1838
+ let added = 0, removed = 0;
1839
+ for (const item of items){
1840
+ await this.permissionService.validateTenantScope(type, item.targetId, user);
1841
+ if (item.isAdd) {
1842
+ await this.permissionService.assignPermission(userId, item.targetId, type);
1843
+ added++;
1844
+ } else {
1845
+ await this.permissionService.revokePermission(userId, item.targetId, type);
1846
+ removed++;
1847
+ }
1848
+ }
1849
+ return {
1850
+ success: true,
1851
+ message: `Processed ${added} additions and ${removed} removals`,
1852
+ messageKey: message_keys/* .USER_PERMISSION_MESSAGES.BATCH_SUCCESS */.jz.BATCH_SUCCESS,
1853
+ messageVariables: {
1854
+ added,
1855
+ removed
1856
+ }
1857
+ };
1858
+ }
1859
+ }
1860
+ user_permission_controller_ts_decorate([
1861
+ (0,common_.Post)('user-company/assign'),
1862
+ (0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.UPDATE),
1863
+ (0,swagger_.ApiOperation)({
1864
+ summary: 'Batch assign/revoke user-company permissions'
1865
+ }),
1866
+ (0,swagger_.ApiResponse)({
1867
+ status: 200,
1868
+ description: 'Company permissions updated successfully'
1869
+ }),
1870
+ (0,swagger_.ApiBody)({
1871
+ type: user_permission_dto/* .AssignUserCompanyDto */.DU
1872
+ }),
1873
+ user_permission_controller_ts_param(0, (0,common_.Body)()),
1874
+ user_permission_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1875
+ user_permission_controller_ts_metadata("design:type", Function),
1876
+ user_permission_controller_ts_metadata("design:paramtypes", [
1877
+ typeof user_permission_dto/* .AssignUserCompanyDto */.DU === "undefined" ? Object : user_permission_dto/* .AssignUserCompanyDto */.DU,
1878
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1879
+ ]),
1880
+ user_permission_controller_ts_metadata("design:returntype", Promise)
1881
+ ], UserPermissionController.prototype, "assignUserCompany", null);
1882
+ user_permission_controller_ts_decorate([
1883
+ (0,common_.Post)('get-user-company'),
1884
+ (0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.READ),
1885
+ (0,swagger_.ApiOperation)({
1886
+ summary: 'Get user companies'
1887
+ }),
1888
+ (0,swagger_.ApiBody)({
1889
+ schema: {
1890
+ properties: {
1891
+ userId: {
1892
+ type: 'string'
1893
+ }
1894
+ },
1895
+ required: [
1896
+ 'userId'
1897
+ ]
1898
+ }
1899
+ }),
1900
+ (0,swagger_.ApiResponse)({
1901
+ status: 200,
1902
+ type: user_permission_dto/* .UserCompaniesResponseDto */.LU
1903
+ }),
1904
+ user_permission_controller_ts_param(0, (0,common_.Body)('userId')),
1905
+ user_permission_controller_ts_metadata("design:type", Function),
1906
+ user_permission_controller_ts_metadata("design:paramtypes", [
1907
+ String
1908
+ ]),
1909
+ user_permission_controller_ts_metadata("design:returntype", Promise)
1910
+ ], UserPermissionController.prototype, "getUserCompanies", null);
1911
+ user_permission_controller_ts_decorate([
1912
+ (0,common_.Post)('user-branch/assign'),
1913
+ (0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.UPDATE),
1914
+ (0,swagger_.ApiOperation)({
1915
+ summary: 'Batch assign/revoke user-branch permissions'
1916
+ }),
1917
+ (0,swagger_.ApiResponse)({
1918
+ status: 200,
1919
+ description: 'Branch permissions updated successfully'
1920
+ }),
1921
+ (0,swagger_.ApiBody)({
1922
+ type: user_permission_dto/* .AssignUserBranchDto */.qW
1923
+ }),
1924
+ user_permission_controller_ts_param(0, (0,common_.Body)()),
1925
+ user_permission_controller_ts_param(1, (0,__rspack_external__flusys_nestjs_shared_decorators_c129b601.CurrentUser)()),
1926
+ user_permission_controller_ts_metadata("design:type", Function),
1927
+ user_permission_controller_ts_metadata("design:paramtypes", [
1928
+ typeof user_permission_dto/* .AssignUserBranchDto */.qW === "undefined" ? Object : user_permission_dto/* .AssignUserBranchDto */.qW,
1929
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
1930
+ ]),
1931
+ user_permission_controller_ts_metadata("design:returntype", Promise)
1932
+ ], UserPermissionController.prototype, "assignUserBranch", null);
1933
+ user_permission_controller_ts_decorate([
1934
+ (0,common_.Post)('get-user-branch'),
1935
+ (0,nestjs_shared_.RequirePermission)(nestjs_shared_.USER_PERMISSIONS.READ),
1936
+ (0,swagger_.ApiOperation)({
1937
+ summary: 'Get user branches'
1938
+ }),
1939
+ (0,swagger_.ApiBody)({
1940
+ schema: {
1941
+ properties: {
1942
+ userId: {
1943
+ type: 'string'
1944
+ },
1945
+ companyId: {
1946
+ type: 'string',
1947
+ description: 'Optional company ID to filter branches'
1948
+ }
1949
+ },
1950
+ required: [
1951
+ 'userId'
1952
+ ]
1953
+ }
1954
+ }),
1955
+ (0,swagger_.ApiResponse)({
1956
+ status: 200,
1957
+ type: user_permission_dto/* .UserBranchesResponseDto */.wc
1958
+ }),
1959
+ user_permission_controller_ts_param(0, (0,common_.Body)('userId')),
1960
+ user_permission_controller_ts_param(1, (0,common_.Body)('companyId')),
1961
+ user_permission_controller_ts_metadata("design:type", Function),
1962
+ user_permission_controller_ts_metadata("design:paramtypes", [
1963
+ String,
1964
+ String
1965
+ ]),
1966
+ user_permission_controller_ts_metadata("design:returntype", Promise)
1967
+ ], UserPermissionController.prototype, "getUserBranches", null);
1968
+ UserPermissionController = user_permission_controller_ts_decorate([
1969
+ (0,swagger_.ApiTags)('User Permissions'),
1970
+ (0,swagger_.ApiBearerAuth)(),
1971
+ (0,common_.Controller)('administration/permissions'),
1972
+ (0,common_.UseGuards)(nestjs_shared_.JwtAuthGuard, nestjs_shared_.PermissionGuard),
1973
+ user_permission_controller_ts_param(0, (0,common_.Inject)(user_permission_service/* .UserPermissionService */.O)),
1974
+ user_permission_controller_ts_metadata("design:type", Function),
1975
+ user_permission_controller_ts_metadata("design:paramtypes", [
1976
+ typeof user_permission_service/* .UserPermissionService */.O === "undefined" ? Object : user_permission_service/* .UserPermissionService */.O
1977
+ ])
1978
+ ], UserPermissionController);
1979
+
1980
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/controllers/index.ts
1981
+
1982
+
1983
+
1984
+
1985
+
1986
+
1987
+
1988
+
1989
+
1990
+
1991
+
1992
+ },
1993
+ 5207(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
1994
+ /* import */ var _flusys_nestjs_shared_utils__rspack_import_0 = __webpack_require__(9216);
1995
+ /* import */ var _nestjs_common__rspack_import_1 = __webpack_require__(6157);
1996
+ /* import */ var rxjs__rspack_import_2 = __webpack_require__(7271);
1997
+ /* import */ var _config_index_js__rspack_import_4 = __webpack_require__(5588);
1998
+ /* import */ var _services_auth_config_service_js__rspack_import_3 = __webpack_require__(6514);
1999
+ function _ts_decorate(decorators, target, key, desc) {
2000
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2001
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2002
+ r = Reflect.decorate(decorators, target, key, desc);
2003
+ } else {
2004
+ for(var i = decorators.length - 1; i >= 0; i--){
2005
+ if (d = decorators[i]) {
2006
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2007
+ }
2008
+ }
2009
+ }
2010
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2011
+ }
2012
+ function _ts_metadata(metadataKey, metadataValue) {
2013
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2014
+ return Reflect.metadata(metadataKey, metadataValue);
2015
+ }
2016
+ }
2017
+ function _ts_param(paramIndex, decorator) {
2018
+ return function(target, key) {
2019
+ decorator(target, key, paramIndex);
2020
+ };
2021
+ }
2022
+
2023
+
2024
+
2025
+
2026
+
2027
+ class ClearToken {
2028
+ authConfig;
2029
+ constructor(authConfig){
2030
+ this.authConfig = authConfig;
2031
+ }
2032
+ get cookieName() {
2033
+ return this.authConfig?.getRefreshTokenCookieName() ?? _config_index_js__rspack_import_4/* .DEFAULT_COOKIE_NAME */.rv;
2034
+ }
2035
+ intercept(context, next) {
2036
+ const req = context.switchToHttp().getRequest();
2037
+ const res = context.switchToHttp().getResponse();
2038
+ return next.handle().pipe((0,rxjs__rspack_import_2.map)((value)=>{
2039
+ if ((0,_flusys_nestjs_shared_utils__rspack_import_0.isBrowserRequest)(req)) {
2040
+ res.clearCookie(this.cookieName, {
2041
+ httpOnly: true,
2042
+ path: '/',
2043
+ ...(0,_flusys_nestjs_shared_utils__rspack_import_0.buildCookieOptions)(req)
2044
+ });
2045
+ }
2046
+ return value;
2047
+ }));
2048
+ }
2049
+ }
2050
+ ClearToken = _ts_decorate([
2051
+ (0,_nestjs_common__rspack_import_1.Injectable)(),
2052
+ _ts_param(0, (0,_nestjs_common__rspack_import_1.Optional)()),
2053
+ _ts_metadata("design:type", Function),
2054
+ _ts_metadata("design:paramtypes", [
2055
+ typeof _services_auth_config_service_js__rspack_import_3/* .AuthConfigService */.W === "undefined" ? Object : _services_auth_config_service_js__rspack_import_3/* .AuthConfigService */.W
2056
+ ])
2057
+ ], ClearToken);
2058
+
2059
+ __webpack_require__.d(__webpack_exports__, {
2060
+ t: () => (ClearToken)
2061
+ });
2062
+
2063
+
2064
+ },
2065
+ 8359(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2066
+
2067
+ // EXPORTS
2068
+ __webpack_require__.d(__webpack_exports__, {
2069
+ A: () => (/* binding */ SetToken)
2070
+ });
2071
+
2072
+ // EXTERNAL MODULE: external "@flusys/nestjs-shared/utils"
2073
+ var utils_ = __webpack_require__(9216);
2074
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/config/message-keys.ts
2075
+ var message_keys = __webpack_require__(5363);
2076
+ // EXTERNAL MODULE: external "@nestjs/common"
2077
+ var common_ = __webpack_require__(6157);
2078
+ ;// CONCATENATED MODULE: external "buffer"
2079
+
2080
+ // EXTERNAL MODULE: external "rxjs"
2081
+ var external_rxjs_ = __webpack_require__(7271);
2082
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/config/auth.constants.ts
2083
+ var auth_constants = __webpack_require__(5588);
2084
+ // EXTERNAL MODULE: ./projects/nestjs-auth/src/services/auth-config.service.ts + 1 modules
2085
+ var auth_config_service = __webpack_require__(6514);
2086
+ ;// CONCATENATED MODULE: ./projects/nestjs-auth/src/interceptors/set-token.interceptor.ts
2087
+ function _ts_decorate(decorators, target, key, desc) {
2088
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2089
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") {
2090
+ r = Reflect.decorate(decorators, target, key, desc);
2091
+ } else {
2092
+ for(var i = decorators.length - 1; i >= 0; i--){
2093
+ if (d = decorators[i]) {
2094
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
2095
+ }
2096
+ }
2097
+ }
2098
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
2099
+ }
2100
+ function _ts_metadata(metadataKey, metadataValue) {
2101
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") {
2102
+ return Reflect.metadata(metadataKey, metadataValue);
2103
+ }
2104
+ }
2105
+ function _ts_param(paramIndex, decorator) {
2106
+ return function(target, key) {
2107
+ decorator(target, key, paramIndex);
2108
+ };
2109
+ }
2110
+
2111
+
2112
+
2113
+
2114
+
2115
+
2116
+
2117
+ class SetToken {
2118
+ authConfig;
2119
+ constructor(authConfig){
2120
+ this.authConfig = authConfig;
2121
+ }
2122
+ get cookieName() {
2123
+ return this.authConfig?.getRefreshTokenCookieName() ?? auth_constants/* .DEFAULT_COOKIE_NAME */.rv;
2124
+ }
2125
+ get maxAgeMs() {
2126
+ return (0,utils_.parseDurationToMs)(this.authConfig?.getRefreshTokenExpiration() ?? '7d');
2127
+ }
2128
+ intercept(context, next) {
2129
+ const req = context.switchToHttp().getRequest();
2130
+ const res = context.switchToHttp().getResponse();
2131
+ return next.handle().pipe((0,external_rxjs_.map)((value)=>{
2132
+ if (typeof value !== 'object' || value === null) {
2133
+ return value;
2134
+ }
2135
+ const response = value;
2136
+ const data = typeof response['data'] === 'object' && response['data'] !== null ? response['data'] : null;
2137
+ const tokenInData = data && typeof data['refreshToken'] === 'string';
2138
+ if (!tokenInData) {
2139
+ return value;
2140
+ }
2141
+ if (!(0,utils_.isBrowserRequest)(req)) {
2142
+ return value;
2143
+ }
2144
+ this.setRefreshTokenCookie(req, res, data['refreshToken']);
2145
+ const { refreshToken: _, ...dataWithoutToken } = data;
2146
+ return {
2147
+ ...response,
2148
+ data: dataWithoutToken
2149
+ };
2150
+ }), (0,external_rxjs_.catchError)((err)=>(0,external_rxjs_.throwError)(()=>err)));
2151
+ }
2152
+ setRefreshTokenCookie(req, res, tokenValue) {
2153
+ const rawCookieString = `${this.cookieName}=${tokenValue}; HttpOnly`;
2154
+ const estimatedBytes = __rspack_external_buffer.Buffer.byteLength(rawCookieString, 'utf8');
2155
+ if (estimatedBytes > (/* inlined export .MAX_COOKIE_BYTES */3500)) {
2156
+ throw new common_.PayloadTooLargeException({
2157
+ message: `Refresh token too large (≈${estimatedBytes} bytes)`,
2158
+ messageKey: message_keys/* .AUTH_MESSAGES.TOKEN_TOO_LARGE */.mK.TOKEN_TOO_LARGE,
2159
+ messageVariables: {
2160
+ size: estimatedBytes
2161
+ }
2162
+ });
2163
+ }
2164
+ res.cookie(this.cookieName, tokenValue, {
2165
+ httpOnly: true,
2166
+ path: '/',
2167
+ maxAge: this.maxAgeMs,
2168
+ ...(0,utils_.buildCookieOptions)(req)
2169
+ });
2170
+ }
2171
+ }
2172
+ SetToken = _ts_decorate([
2173
+ (0,common_.Injectable)(),
2174
+ _ts_param(0, (0,common_.Optional)()),
2175
+ _ts_param(0, (0,common_.Inject)(auth_config_service/* .AuthConfigService */.W)),
2176
+ _ts_metadata("design:type", Function),
2177
+ _ts_metadata("design:paramtypes", [
2178
+ typeof auth_config_service/* .AuthConfigService */.W === "undefined" ? Object : auth_config_service/* .AuthConfigService */.W
2179
+ ])
2180
+ ], SetToken);
2181
+
2182
+
2183
+ },
2184
+ 3513(module) {
2185
+
2186
+ module.exports = __rspack_external__flusys_nestjs_shared_guards_3f79ddd1;
2187
+
2188
+
2189
+ },
2190
+ 7271(module) {
2191
+
2192
+ module.exports = __rspack_external_rxjs;
2193
+
2194
+
2195
+ },
2196
+
2197
+ };