@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/README.md CHANGED
@@ -120,7 +120,7 @@ AuthModule.forRootAsync({
120
120
  databaseMode: 'single',
121
121
  enableCompanyFeature: true,
122
122
  enableEmailVerification: true,
123
- },why you cannot fix it,, need to need gap bellow LAB REPORT text
123
+ },
124
124
  useFactory: (cfg: ConfigService) => ({
125
125
  defaultDatabaseConfig: {
126
126
  type: 'mysql',
@@ -266,6 +266,73 @@ export const userEnricherProvider = {
266
266
  AuthModule.forRootAsync({ ..., providers: [userEnricherProvider] });
267
267
  ```
268
268
 
269
+ ## 5. Social Sign-In
270
+
271
+ Google, Facebook, LinkedIn and Microsoft are built in. Nothing is enabled until an
272
+ administrator saves credentials, and no flag gates the feature: the
273
+ `social_auth_config` and `user_social_account` tables are always registered, and
274
+ `SocialAuthController` / `SocialAuthConfigController` are always mounted.
275
+
276
+ ### Credentials
277
+
278
+ `POST /auth/social-config/*` is the usual CRUD surface, guarded by the
279
+ `social-config.create|read|update|delete` permissions. One row per provider is
280
+ enforced, so a provider can be addressed by name from an admin screen.
281
+
282
+ | Column | Purpose |
283
+ | -------------- | ---------------------------------------------------------------- |
284
+ | `provider` | `google` \| `facebook` \| `linkedin` \| `microsoft` (unique) |
285
+ | `isEnabled` | Whether the login page offers it; credentials survive a disable |
286
+ | `clientId` | OAuth client id from the provider's console |
287
+ | `clientSecret` | OAuth client secret |
288
+ | `scopes` | Overrides the provider's defaults when set |
289
+ | `extraConfig` | Provider extras — Microsoft's `tenantId`, for instance |
290
+
291
+ ### Sign-in flow
292
+
293
+ ```
294
+ POST /auth/social/providers { redirectUri } → [{ provider, redirectUri }]
295
+ POST /auth/social/authorize { provider, redirectUri } → { authorizationUrl, state }
296
+ browser → provider consent screen → back to redirectUri?code=…&state=…
297
+ POST /auth/social/callback { code, state, redirectUri } → the same union /auth/login returns
298
+ ```
299
+
300
+ The `state` is a single-use, cache-backed token that also records which provider
301
+ and redirect URI the sign-in started with — providers echo back nothing but
302
+ `code` and `state`, so the callback carries no provider of its own. Redeeming a
303
+ state deletes it, and a redirect URI that does not match the one the sign-in
304
+ started with is rejected.
305
+
306
+ The callback returns exactly what `POST /auth/login` returns, company selection
307
+ included, because both routes finish through `AuthenticationService.issueLoginForUser`.
308
+
309
+ ### How a user is matched
310
+
311
+ 1. The provider's own account id, via `user_social_account` — survives an email change at the provider.
312
+ 2. Otherwise the email, so an existing password account is adopted rather than duplicated.
313
+ 3. Otherwise a new account with no password.
314
+
315
+ Steps 2 and 3 require the provider to have **verified** the address. Matching on an
316
+ unverified email would let anyone who registers someone else's address at the
317
+ provider walk into their FLUSYS account, so an unverified profile is rejected.
318
+ An account already linked at step 1 is unaffected.
319
+
320
+ Step 3 — creating an account — is refused in two cases, each with its own message key:
321
+
322
+ | Condition | Result |
323
+ | ------------------------------------------- | -------------------------------------------- |
324
+ | `bootstrapAppConfig.enableSignUp` is `false` | `auth.social.account.not.linked` |
325
+ | `enableCompanyFeature` is `true` | `auth.social.company.required` |
326
+
327
+ `enableSignUp` is the single switch for social sign-up; there is no per-provider
328
+ override. With the company feature on, a brand-new account could not be given a
329
+ company and would land in a session the route guards reject, so it is refused
330
+ outright: grant the user a company permission first and their social sign-in
331
+ then works. Signing **in** is never affected by either — only account creation is.
332
+
333
+ A cache instance is required: `AuthModule` imports `CacheModule`, so this is
334
+ satisfied by default.
335
+
269
336
  ## License
270
337
 
271
338
  MIT © FLUSYS
@@ -5,3 +5,5 @@ export declare const DEFAULT_COOKIE_NAME = "fsn_refresh_token";
5
5
  export declare const MAX_COOKIE_BYTES = 3500;
6
6
  export declare const SESSION_CACHE_PREFIX = "auth:session";
7
7
  export declare const TOKEN_REVOKED_PREFIX = "auth:revoked";
8
+ export declare const SOCIAL_STATE_PREFIX = "auth:social:state";
9
+ export declare const SOCIAL_STATE_TTL_MS: number;
@@ -10,6 +10,7 @@ export declare const AUTH_EVENT_ACTIONS: {
10
10
  readonly EMAIL_VERIFIED: "email-verified";
11
11
  readonly PERMISSION_GRANTED: "permission-granted";
12
12
  readonly PERMISSION_REVOKED: "permission-revoked";
13
+ readonly SOCIAL_LOGGED_IN: "social-logged-in";
13
14
  };
14
15
  export declare const AUTH_EVENT_ENTITIES: {
15
16
  readonly USER: "appuser";
@@ -17,5 +18,6 @@ export declare const AUTH_EVENT_ENTITIES: {
17
18
  readonly COMPANY_BRANCH: "company_branch";
18
19
  readonly SESSION: "session";
19
20
  readonly USER_PERMISSION: "user_company_permission";
21
+ readonly SOCIAL_AUTH_CONFIG: "social_auth_config";
20
22
  };
21
23
  export declare const AUTH_EVENT_MODULE = "auth";
package/config/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './auth.constants';
2
- export * from './event-actions';
3
- export * from './message-keys';
1
+ export * from './auth.constants.js';
2
+ export * from './event-actions.js';
3
+ export * from './message-keys.js';
@@ -12,7 +12,9 @@ export declare const AUTH_MESSAGES: {
12
12
  readonly SELECT_SUCCESS: "auth.select.success";
13
13
  readonly SWITCH_COMPANY_SUCCESS: "auth.switch.company.success";
14
14
  readonly REGISTER_EMAIL_EXISTS: "auth.register.email.exists";
15
+ readonly REGISTER_ACCOUNT_DELETED: "auth.register.account.deleted";
15
16
  readonly REGISTER_COMPANY_ALREADY_ASSIGNED: "auth.register.company.already.assigned";
17
+ readonly REGISTER_SIGNUP_DISABLED: "auth.register.signup.disabled";
16
18
  readonly PASSWORD_CHANGE_SUCCESS: "auth.password.change.success";
17
19
  readonly PASSWORD_CHANGE_INVALID_CURRENT: "auth.password.change.invalid.current";
18
20
  readonly PASSWORD_CHANGE_CURRENT_REQUIRED: "auth.password.change.current.required";
@@ -49,6 +51,25 @@ export declare const EMAIL_VERIFICATION_MESSAGES: {
49
51
  readonly VERIFICATION_NOT_ENABLED: "email.verification.not.enabled";
50
52
  readonly RESEND_SUCCESS: "email.verification.resend.success";
51
53
  };
54
+ export declare const SOCIAL_AUTH_MESSAGES: {
55
+ readonly PROVIDERS_SUCCESS: "auth.social.providers.success";
56
+ readonly AUTHORIZE_SUCCESS: "auth.social.authorize.success";
57
+ readonly LOGIN_SUCCESS: "auth.social.login.success";
58
+ readonly PROVIDER_DISABLED: "auth.social.provider.disabled";
59
+ readonly PROVIDER_NOT_CONFIGURED: "auth.social.provider.not.configured";
60
+ readonly STATE_INVALID: "auth.social.state.invalid";
61
+ readonly REDIRECT_URI_MISMATCH: "auth.social.redirect.uri.mismatch";
62
+ readonly EXCHANGE_FAILED: "auth.social.exchange.failed";
63
+ readonly PROFILE_INCOMPLETE: "auth.social.profile.incomplete";
64
+ readonly ACCOUNT_NOT_LINKED: "auth.social.account.not.linked";
65
+ readonly COMPANY_REQUIRED: "auth.social.company.required";
66
+ readonly EMAIL_REQUIRED: "auth.social.email.required";
67
+ readonly EMAIL_NOT_VERIFIED: "auth.social.email.not.verified";
68
+ readonly ACCOUNT_DELETED: "auth.social.account.deleted";
69
+ };
70
+ export declare const SOCIAL_AUTH_CONFIG_MESSAGES: {
71
+ readonly PROVIDER_ALREADY_CONFIGURED: "social.config.provider.already.configured";
72
+ };
52
73
  export declare const USER_MESSAGES: {
53
74
  readonly NOT_FOUND: "user.not.found";
54
75
  readonly PROFILE_UPDATE_SUCCESS: "user.profile.update.success";
@@ -74,4 +95,6 @@ export declare const USER_PERMISSION_MESSAGES: {
74
95
  readonly BATCH_SUCCESS: "user.permission.batch.success";
75
96
  readonly ALREADY_ASSIGNED: "user.permission.already.assigned";
76
97
  readonly PERMISSION_NOT_FOUND: "user.permission.not.found";
98
+ readonly COMPANY_NO_ACCESS: "user.permission.company.no.access";
99
+ readonly BRANCH_NO_ACCESS: "user.permission.branch.no.access";
77
100
  };
@@ -1,9 +1,9 @@
1
1
  import { MessageResponseDto, SingleResponseDto } from '@flusys/nestjs-shared/dtos';
2
- import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
3
- import { Request } from 'express';
4
- import { ChangePasswordDto, CompanySelectionResponseDto, LoginDto, LoginResponseDto, LoginResponseRequiresEmailVerificationDto, MeResponseDto, RefreshTokenDto, RegistrationDto, RegistrationResponseDto } from '../dtos/authentication.dto';
5
- import { AuthConfigService } from '../services/auth-config.service';
6
- import { AuthenticationService } from '../services/authentication.service';
2
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
3
+ import { type Request } from 'express';
4
+ import { ChangePasswordDto, CompanySelectionResponseDto, LoginDto, LoginResponseDto, LoginResponseRequiresEmailVerificationDto, MeResponseDto, RefreshTokenDto, RegistrationDto, RegistrationResponseDto } from '../dtos/authentication.dto.js';
5
+ import { AuthConfigService } from '../services/auth-config.service.js';
6
+ import { AuthenticationService } from '../services/authentication.service.js';
7
7
  export declare class AuthenticationController {
8
8
  private readonly authService;
9
9
  private readonly authConfig?;
@@ -1,5 +1,5 @@
1
- import { CompanyBranchResponseDto, CreateCompanyBranchDto, UpdateCompanyBranchDto } from '../dtos/company-branch.dto';
2
- import { BranchService } from '../services/branch.service';
1
+ import { CompanyBranchResponseDto, CreateCompanyBranchDto, UpdateCompanyBranchDto } from '../dtos/company-branch.dto.js';
2
+ import { BranchService } from '../services/branch.service.js';
3
3
  declare const BranchController_base: abstract new (service: BranchService) => {
4
4
  readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
5
5
  service: BranchService;
@@ -1,6 +1,6 @@
1
1
  import { SingleResponseDto } from '@flusys/nestjs-shared/dtos';
2
- import { LoginResponseDto, SelectDto, SwitchCompanyDto } from '../dtos/authentication.dto';
3
- import { AuthenticationService } from '../services/authentication.service';
2
+ import { LoginResponseDto, SelectDto, SwitchCompanyDto } from '../dtos/authentication.dto.js';
3
+ import { AuthenticationService } from '../services/authentication.service.js';
4
4
  export declare class CompanySelectionController {
5
5
  private readonly authService;
6
6
  constructor(authService: AuthenticationService);
@@ -10,12 +10,12 @@ export declare class CompanySelectionController {
10
10
  success: boolean;
11
11
  message: string;
12
12
  messageKey: "auth.company.list.success";
13
- data: import("..").Company[];
13
+ data: import("../index.js").Company[];
14
14
  }>;
15
15
  getUserBranches(userId: string, companyId: string): Promise<{
16
16
  success: boolean;
17
17
  message: string;
18
18
  messageKey: "auth.branch.list.success";
19
- data: import("..").CompanyBranch[];
19
+ data: import("../index.js").CompanyBranch[];
20
20
  }>;
21
21
  }
@@ -1,5 +1,5 @@
1
- import { CompanyResponseDto, CreateCompanyDto, UpdateCompanyDto } from '../dtos/company.dto';
2
- import { CompanyService } from '../services/company.service';
1
+ import { CompanyResponseDto, CreateCompanyDto, UpdateCompanyDto } from '../dtos/company.dto.js';
2
+ import { CompanyService } from '../services/company.service.js';
3
3
  declare const CompanyController_base: abstract new (service: CompanyService) => {
4
4
  readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
5
5
  service: CompanyService;
@@ -1,10 +1,10 @@
1
1
  import { MessageResponseDto } from '@flusys/nestjs-shared/dtos';
2
- import { Request } from 'express';
3
- import { ForgotPasswordDto, RegistrationResponseDto, ResendVerificationDto, ResetPasswordDto, VerifyEmailDto } from '../dtos/authentication.dto';
4
- import { AuthConfigService } from '../services/auth-config.service';
5
- import { AuthDataSourceProvider } from '../services/auth-datasource.provider';
6
- import { AuthEmailService } from '../services/auth-email.service';
7
- import { AuthenticationService } from '../services/authentication.service';
2
+ import { type Request } from 'express';
3
+ import { ForgotPasswordDto, RegistrationResponseDto, ResendVerificationDto, ResetPasswordDto, VerifyEmailDto } from '../dtos/authentication.dto.js';
4
+ import { AuthConfigService } from '../services/auth-config.service.js';
5
+ import { AuthDataSourceProvider } from '../services/auth-datasource.provider.js';
6
+ import { AuthEmailService } from '../services/auth-email.service.js';
7
+ import { AuthenticationService } from '../services/authentication.service.js';
8
8
  export declare class EmailVerificationController {
9
9
  private readonly authService;
10
10
  private readonly authEmailService;
@@ -1,7 +1,9 @@
1
- export * from './authentication.controller';
2
- export * from './company-selection.controller';
3
- export * from './email-verification.controller';
4
- export * from './user.controller';
5
- export * from './company.controller';
6
- export * from './branch.controller';
7
- export * from './user-permission.controller';
1
+ export * from './authentication.controller.js';
2
+ export * from './company-selection.controller.js';
3
+ export * from './email-verification.controller.js';
4
+ export * from './social-auth.controller.js';
5
+ export * from './social-auth-config.controller.js';
6
+ export * from './user.controller.js';
7
+ export * from './company.controller.js';
8
+ export * from './branch.controller.js';
9
+ export * from './user-permission.controller.js';
@@ -0,0 +1,22 @@
1
+ import { CreateSocialAuthConfigDto, SocialAuthConfigResponseDto, UpdateSocialAuthConfigDto } from '../dtos/social-auth.dto.js';
2
+ import { SocialAuthConfigService } from '../services/social-auth-config.service.js';
3
+ declare const SocialAuthConfigController_base: abstract new (service: SocialAuthConfigService) => {
4
+ readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
5
+ service: SocialAuthConfigService;
6
+ isEnabled(endpoint: import("@flusys/nestjs-shared").ApiEndpoint): boolean;
7
+ insert(addDto: CreateSocialAuthConfigDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").SingleResponseDto<SocialAuthConfigResponseDto>>;
8
+ insertMany(addDto: CreateSocialAuthConfigDto[], user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<SocialAuthConfigResponseDto>>;
9
+ getById(id: string, body: import("@flusys/nestjs-shared").GetByIdBodyDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").SingleResponseDto<SocialAuthConfigResponseDto>>;
10
+ getByIds(body: import("@flusys/nestjs-shared").GetByIdsDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").ListResponseDto<SocialAuthConfigResponseDto>>;
11
+ update(updateDto: UpdateSocialAuthConfigDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").SingleResponseDto<SocialAuthConfigResponseDto>>;
12
+ updateMany(updateDtos: UpdateSocialAuthConfigDto[], user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<SocialAuthConfigResponseDto>>;
13
+ bulkUpsert(dtos: (CreateSocialAuthConfigDto | UpdateSocialAuthConfigDto)[], user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<SocialAuthConfigResponseDto>>;
14
+ getByFilter(filter: Record<string, any>, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").SingleResponseDto<SocialAuthConfigResponseDto>>;
15
+ getAll(filterAndPaginationDto: import("@flusys/nestjs-shared").FilterAndPaginationDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null, search?: string): Promise<import("@flusys/nestjs-shared").ListResponseDto<SocialAuthConfigResponseDto>>;
16
+ delete(deleteDto: import("@flusys/nestjs-shared").DeleteDto, user: import("@flusys/nestjs-shared").ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").MessageResponseDto>;
17
+ };
18
+ export declare class SocialAuthConfigController extends SocialAuthConfigController_base {
19
+ socialAuthConfigService: SocialAuthConfigService;
20
+ constructor(socialAuthConfigService: SocialAuthConfigService);
21
+ }
22
+ export {};
@@ -0,0 +1,11 @@
1
+ import { SingleResponseDto } from '@flusys/nestjs-shared/dtos';
2
+ import { CompanySelectionResponseDto, LoginResponseDto } from '../dtos/authentication.dto.js';
3
+ import { SocialAuthorizeDto, SocialAuthorizeResponseDto, SocialCallbackDto, SocialProviderInfoDto, SocialProvidersDto } from '../dtos/social-auth.dto.js';
4
+ import { SocialAuthService } from '../services/social-auth.service.js';
5
+ export declare class SocialAuthController {
6
+ private readonly socialAuthService;
7
+ constructor(socialAuthService: SocialAuthService);
8
+ getProviders(dto: SocialProvidersDto): Promise<SingleResponseDto<SocialProviderInfoDto[]>>;
9
+ authorize(dto: SocialAuthorizeDto): Promise<SingleResponseDto<SocialAuthorizeResponseDto>>;
10
+ callback(dto: SocialCallbackDto): Promise<SingleResponseDto<LoginResponseDto | CompanySelectionResponseDto>>;
11
+ }
@@ -1,16 +1,17 @@
1
- import { AssignUserBranchDto, AssignUserCompanyDto, UserBranchesResponseDto, UserCompaniesResponseDto } from '../dtos/user-permission.dto';
2
- import { UserPermissionService } from '../services/user-permission.service';
1
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
2
+ import { AssignUserBranchDto, AssignUserCompanyDto, UserBranchesResponseDto, UserCompaniesResponseDto } from '../dtos/user-permission.dto.js';
3
+ import { UserPermissionService } from '../services/user-permission.service.js';
3
4
  export declare class UserPermissionController {
4
5
  private readonly permissionService;
5
6
  constructor(permissionService: UserPermissionService);
6
- assignUserCompany(dto: AssignUserCompanyDto): Promise<{
7
+ assignUserCompany(dto: AssignUserCompanyDto, user: ILoggedUserInfo): Promise<{
7
8
  success: boolean;
8
9
  message: string;
9
10
  messageKey: string;
10
11
  messageVariables: Record<string, number>;
11
12
  }>;
12
13
  getUserCompanies(userId: string): Promise<UserCompaniesResponseDto>;
13
- assignUserBranch(dto: AssignUserBranchDto): Promise<{
14
+ assignUserBranch(dto: AssignUserBranchDto, user: ILoggedUserInfo): Promise<{
14
15
  success: boolean;
15
16
  message: string;
16
17
  messageKey: string;
@@ -1,8 +1,8 @@
1
1
  import { FilterAndPaginationDto, ListResponseDto } from '@flusys/nestjs-shared/dtos';
2
- import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
3
- import { CreateUserDto, UpdateUserDto, UserLookupResponseDto, UserResponseDto } from '../dtos/user.dto';
4
- import { IUser } from '../interfaces/user.interface';
5
- import { UserService } from '../services/user.service';
2
+ import { type ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
3
+ import { CreateUserDto, UpdateUserDto, UserLookupResponseDto, UserResponseDto } from '../dtos/user.dto.js';
4
+ import { type IUser } from '../interfaces/user.interface.js';
5
+ import { UserService } from '../services/user.service.js';
6
6
  declare const UserController_base: abstract new (service: UserService) => {
7
7
  readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
8
8
  service: UserService;
@@ -28,7 +28,7 @@ export declare class UserController extends UserController_base {
28
28
  messageKey: "user.profile.extras.success";
29
29
  data: {
30
30
  user: IUser;
31
- extras?: import("..").IProfileExtras;
31
+ extras?: import("../index.js").IProfileExtras;
32
32
  };
33
33
  }>;
34
34
  verifyEmail(id: string): Promise<{
@@ -56,13 +56,13 @@ export declare class UserController extends UserController_base {
56
56
  success: boolean;
57
57
  message: string;
58
58
  messageKey: "user.profile.sections.success";
59
- data: import("..").IProfileSection[];
59
+ data: import("../index.js").IProfileSection[];
60
60
  }>;
61
61
  getProfileSectionData(id: string, sectionId: string, user: ILoggedUserInfo): Promise<{
62
62
  success: boolean;
63
63
  message: string;
64
64
  messageKey: "user.profile.section.data.success";
65
- data: import("..").IProfileSectionData | null;
65
+ data: import("../index.js").IProfileSectionData | null;
66
66
  }>;
67
67
  updateProfileSection(id: string, sectionId: string, data: Record<string, any>, user: ILoggedUserInfo): Promise<{
68
68
  success: boolean;
@@ -1,3 +1,3 @@
1
- import { IBootstrapAppConfig } from '@flusys/nestjs-core';
2
- import { IModuleSwaggerOptions } from '@flusys/nestjs-core/docs';
1
+ import { type IBootstrapAppConfig } from '@flusys/nestjs-core';
2
+ import { type IModuleSwaggerOptions } from '@flusys/nestjs-core/docs';
3
3
  export declare function authSwaggerConfig(bootstrapConfig?: IBootstrapAppConfig): IModuleSwaggerOptions;
package/docs/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from './auth-swagger.config';
1
+ export * from './auth-swagger.config.js';
package/dtos/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from './authentication.dto';
2
- export * from './company-branch.dto';
3
- export * from './company.dto';
4
- export * from './user.dto';
5
- export * from './user-permission.dto';
1
+ export * from './authentication.dto.js';
2
+ export * from './company-branch.dto.js';
3
+ export * from './company.dto.js';
4
+ export * from './social-auth.dto.js';
5
+ export * from './user.dto.js';
6
+ export * from './user-permission.dto.js';
@@ -0,0 +1,42 @@
1
+ import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
2
+ import { SocialProviderTypeEnum } from '../enums/social-provider-type.enum.js';
3
+ export declare class CreateSocialAuthConfigDto {
4
+ provider: SocialProviderTypeEnum;
5
+ isEnabled?: boolean;
6
+ clientId?: string;
7
+ clientSecret?: string;
8
+ scopes?: string[];
9
+ extraConfig?: Record<string, unknown>;
10
+ }
11
+ declare const UpdateSocialAuthConfigDto_base: import("@nestjs/common").Type<Partial<CreateSocialAuthConfigDto>>;
12
+ export declare class UpdateSocialAuthConfigDto extends UpdateSocialAuthConfigDto_base {
13
+ id: string;
14
+ }
15
+ export declare class SocialAuthConfigResponseDto extends IdentityResponseDto {
16
+ provider: SocialProviderTypeEnum;
17
+ isEnabled: boolean;
18
+ clientId: string | null;
19
+ hasClientSecret: boolean;
20
+ scopes: string[] | null;
21
+ extraConfig: Record<string, unknown> | null;
22
+ }
23
+ export declare class SocialProviderInfoDto {
24
+ provider: SocialProviderTypeEnum;
25
+ redirectUri: string;
26
+ }
27
+ export declare class SocialProvidersDto {
28
+ redirectUri: string;
29
+ }
30
+ export declare class SocialAuthorizeDto extends SocialProvidersDto {
31
+ provider: SocialProviderTypeEnum;
32
+ }
33
+ export declare class SocialAuthorizeResponseDto {
34
+ provider: SocialProviderTypeEnum;
35
+ authorizationUrl: string;
36
+ state: string;
37
+ }
38
+ export declare class SocialCallbackDto extends SocialProvidersDto {
39
+ code: string;
40
+ state: string;
41
+ }
42
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { Identity } from '@flusys/nestjs-shared';
2
- import { Company } from './company.entity';
2
+ import { Company } from './company.entity.js';
3
3
  export declare class CompanyBranch extends Identity {
4
4
  readOnly: boolean;
5
5
  name: string;
@@ -1,5 +1,5 @@
1
1
  import { Identity } from '@flusys/nestjs-shared';
2
- import { CompanyBranch } from './company-branch.entity';
2
+ import { CompanyBranch } from './company-branch.entity.js';
3
3
  export declare class Company extends Identity {
4
4
  readOnly: boolean;
5
5
  name: string;
@@ -1,16 +1,18 @@
1
- export * from './app-user.entity';
2
- export * from './company-branch.entity';
3
- export * from './company.entity';
4
- export * from './pending-registration.entity';
5
- export { PermissionType, UserCompanyPermission } from './user-company-permission.entity';
6
- export * from './user-token.entity';
7
- import { AppUser } from './app-user.entity';
8
- import { CompanyBranch } from './company-branch.entity';
9
- import { Company } from './company.entity';
10
- import { PendingRegistration } from './pending-registration.entity';
11
- import { UserCompanyPermission } from './user-company-permission.entity';
12
- import { UserToken } from './user-token.entity';
13
- declare const BaseEntities: (typeof AppUser | typeof UserToken)[];
1
+ export * from './app-user.entity.js';
2
+ export * from './company-branch.entity.js';
3
+ export * from './company.entity.js';
4
+ export * from './pending-registration.entity.js';
5
+ export * from './social-auth-config.entity.js';
6
+ export { PermissionType, UserCompanyPermission } from './user-company-permission.entity.js';
7
+ export * from './user-token.entity.js';
8
+ import { AppUser } from './app-user.entity.js';
9
+ import { CompanyBranch } from './company-branch.entity.js';
10
+ import { Company } from './company.entity.js';
11
+ import { PendingRegistration } from './pending-registration.entity.js';
12
+ import { SocialAuthConfig } from './social-auth-config.entity.js';
13
+ import { UserCompanyPermission } from './user-company-permission.entity.js';
14
+ import { UserToken } from './user-token.entity.js';
15
+ declare const BaseEntities: (typeof AppUser | typeof SocialAuthConfig | typeof UserToken)[];
14
16
  declare const EmailEntities: (typeof PendingRegistration)[];
15
17
  declare const CompanyEntities: (typeof Company | typeof CompanyBranch | typeof UserCompanyPermission)[];
16
18
  export interface IAuthEntitiesConfig {
@@ -1,4 +1,4 @@
1
- import { CompanyRegistrationData } from '../interfaces/authentication.interface';
1
+ import { type CompanyRegistrationData } from '../interfaces/authentication.interface.js';
2
2
  export declare class PendingRegistration {
3
3
  id: string;
4
4
  email: string;
@@ -0,0 +1,9 @@
1
+ import { Identity } from '@flusys/nestjs-shared/entities';
2
+ export declare class SocialAuthConfig extends Identity {
3
+ provider: string;
4
+ isEnabled: boolean;
5
+ clientId: string | null;
6
+ clientSecret: string | null;
7
+ scopes: string[] | null;
8
+ extraConfig: Record<string, unknown> | null;
9
+ }
@@ -1,7 +1,7 @@
1
- import { PermissionType } from '../enums';
2
- import { AppUser } from './app-user.entity';
3
- import { CompanyBranch } from './company-branch.entity';
4
- import { Company } from './company.entity';
1
+ import { PermissionType } from '../enums/index.js';
2
+ import { AppUser } from './app-user.entity.js';
3
+ import { CompanyBranch } from './company-branch.entity.js';
4
+ import { Company } from './company.entity.js';
5
5
  export { PermissionType };
6
6
  export declare class UserCompanyPermission {
7
7
  id: string;
package/enums/index.d.ts CHANGED
@@ -1 +1,2 @@
1
- export * from './user-org-permission-type.enum';
1
+ export * from './social-provider-type.enum.js';
2
+ export * from './user-org-permission-type.enum.js';
@@ -0,0 +1,6 @@
1
+ export declare enum SocialProviderTypeEnum {
2
+ GOOGLE = "google",
3
+ FACEBOOK = "facebook",
4
+ LINKEDIN = "linkedin",
5
+ MICROSOFT = "microsoft"
6
+ }