@ackplus/nest-auth 0.0.37 → 0.0.39

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 (178) hide show
  1. package/index.cjs.d.ts +1 -0
  2. package/index.cjs.js +28350 -0
  3. package/package.json +2 -2
  4. package/src/lib/core/entities.d.ts +1 -1
  5. package/README.md +0 -226
  6. package/src/index.js +0 -12
  7. package/src/index.js.map +0 -1
  8. package/src/lib/auth/auth.module.js +0 -52
  9. package/src/lib/auth/auth.module.js.map +0 -1
  10. package/src/lib/auth/controllers/auth.controller.js +0 -189
  11. package/src/lib/auth/controllers/auth.controller.js.map +0 -1
  12. package/src/lib/auth/controllers/mfa.controller.js +0 -130
  13. package/src/lib/auth/controllers/mfa.controller.js.map +0 -1
  14. package/src/lib/auth/dto/index.js +0 -1
  15. package/src/lib/auth/dto/index.js.map +0 -1
  16. package/src/lib/auth/dto/requests/forgot-password.request.dto.js +0 -30
  17. package/src/lib/auth/dto/requests/forgot-password.request.dto.js.map +0 -1
  18. package/src/lib/auth/dto/requests/login.request.dto.js +0 -34
  19. package/src/lib/auth/dto/requests/login.request.dto.js.map +0 -1
  20. package/src/lib/auth/dto/requests/refresh-token.request.dto.js +0 -15
  21. package/src/lib/auth/dto/requests/refresh-token.request.dto.js.map +0 -1
  22. package/src/lib/auth/dto/requests/reset-password.request.dto.js +0 -42
  23. package/src/lib/auth/dto/requests/reset-password.request.dto.js.map +0 -1
  24. package/src/lib/auth/dto/requests/send-mfa-code.request.dto.js +0 -16
  25. package/src/lib/auth/dto/requests/send-mfa-code.request.dto.js.map +0 -1
  26. package/src/lib/auth/dto/requests/signup.request.dto.js +0 -37
  27. package/src/lib/auth/dto/requests/signup.request.dto.js.map +0 -1
  28. package/src/lib/auth/dto/requests/social-login.request.dto.js +0 -16
  29. package/src/lib/auth/dto/requests/social-login.request.dto.js.map +0 -1
  30. package/src/lib/auth/dto/requests/verify-2fa.request.dto.js +0 -21
  31. package/src/lib/auth/dto/requests/verify-2fa.request.dto.js.map +0 -1
  32. package/src/lib/auth/dto/requests/verify-totp-setup.request.dto.js +0 -20
  33. package/src/lib/auth/dto/requests/verify-totp-setup.request.dto.js.map +0 -1
  34. package/src/lib/auth/dto/responses/auth.response.dto.js +0 -50
  35. package/src/lib/auth/dto/responses/auth.response.dto.js.map +0 -1
  36. package/src/lib/auth/entities/mfa-secret.entity.js +0 -50
  37. package/src/lib/auth/entities/mfa-secret.entity.js.map +0 -1
  38. package/src/lib/auth/entities/otp.entity.js +0 -50
  39. package/src/lib/auth/entities/otp.entity.js.map +0 -1
  40. package/src/lib/auth/events/logged-out-all.event.js +0 -10
  41. package/src/lib/auth/events/logged-out-all.event.js.map +0 -1
  42. package/src/lib/auth/events/logged-out.event.js +0 -10
  43. package/src/lib/auth/events/logged-out.event.js.map +0 -1
  44. package/src/lib/auth/events/password-reset-requested.event.js +0 -10
  45. package/src/lib/auth/events/password-reset-requested.event.js.map +0 -1
  46. package/src/lib/auth/events/password-reset.event.js +0 -10
  47. package/src/lib/auth/events/password-reset.event.js.map +0 -1
  48. package/src/lib/auth/events/user-2fa-verified.event.js +0 -10
  49. package/src/lib/auth/events/user-2fa-verified.event.js.map +0 -1
  50. package/src/lib/auth/events/user-logged-in.event.js +0 -10
  51. package/src/lib/auth/events/user-logged-in.event.js.map +0 -1
  52. package/src/lib/auth/events/user-refresh-token.event.js +0 -10
  53. package/src/lib/auth/events/user-refresh-token.event.js.map +0 -1
  54. package/src/lib/auth/index.js +0 -20
  55. package/src/lib/auth/index.js.map +0 -1
  56. package/src/lib/auth/services/auth.service.js +0 -396
  57. package/src/lib/auth/services/auth.service.js.map +0 -1
  58. package/src/lib/auth/services/cookie.service.js +0 -43
  59. package/src/lib/auth/services/cookie.service.js.map +0 -1
  60. package/src/lib/auth/services/mfa.service.js +0 -255
  61. package/src/lib/auth/services/mfa.service.js.map +0 -1
  62. package/src/lib/auth.constants.js +0 -43
  63. package/src/lib/auth.constants.js.map +0 -1
  64. package/src/lib/core/core.module.js +0 -67
  65. package/src/lib/core/core.module.js.map +0 -1
  66. package/src/lib/core/decorators/role.decorator.js +0 -14
  67. package/src/lib/core/decorators/role.decorator.js.map +0 -1
  68. package/src/lib/core/decorators/skip-mfa.decorator.js +0 -8
  69. package/src/lib/core/decorators/skip-mfa.decorator.js.map +0 -1
  70. package/src/lib/core/dto/message.response.dto.js +0 -13
  71. package/src/lib/core/dto/message.response.dto.js.map +0 -1
  72. package/src/lib/core/entities.js +0 -34
  73. package/src/lib/core/entities.js.map +0 -1
  74. package/src/lib/core/guards/auth.guard.js +0 -135
  75. package/src/lib/core/guards/auth.guard.js.map +0 -1
  76. package/src/lib/core/guards/role.guard.js +0 -40
  77. package/src/lib/core/guards/role.guard.js.map +0 -1
  78. package/src/lib/core/index.js +0 -27
  79. package/src/lib/core/index.js.map +0 -1
  80. package/src/lib/core/interfaces/auth-module-options.interface.js +0 -3
  81. package/src/lib/core/interfaces/auth-module-options.interface.js.map +0 -1
  82. package/src/lib/core/interfaces/mfa-options.interface.js +0 -10
  83. package/src/lib/core/interfaces/mfa-options.interface.js.map +0 -1
  84. package/src/lib/core/interfaces/otp.interface.js +0 -10
  85. package/src/lib/core/interfaces/otp.interface.js.map +0 -1
  86. package/src/lib/core/interfaces/session-options.interface.js +0 -9
  87. package/src/lib/core/interfaces/session-options.interface.js.map +0 -1
  88. package/src/lib/core/interfaces/token-payload.interface.js +0 -3
  89. package/src/lib/core/interfaces/token-payload.interface.js.map +0 -1
  90. package/src/lib/core/providers/apple-auth.provider.js +0 -58
  91. package/src/lib/core/providers/apple-auth.provider.js.map +0 -1
  92. package/src/lib/core/providers/base-auth.provider.js +0 -41
  93. package/src/lib/core/providers/base-auth.provider.js.map +0 -1
  94. package/src/lib/core/providers/email-auth.provider.js +0 -42
  95. package/src/lib/core/providers/email-auth.provider.js.map +0 -1
  96. package/src/lib/core/providers/facebook-auth.provider.js +0 -58
  97. package/src/lib/core/providers/facebook-auth.provider.js.map +0 -1
  98. package/src/lib/core/providers/google-auth.provider.js +0 -60
  99. package/src/lib/core/providers/google-auth.provider.js.map +0 -1
  100. package/src/lib/core/providers/jwt-auth.provider.js +0 -51
  101. package/src/lib/core/providers/jwt-auth.provider.js.map +0 -1
  102. package/src/lib/core/providers/phone-auth.provider.js +0 -45
  103. package/src/lib/core/providers/phone-auth.provider.js.map +0 -1
  104. package/src/lib/core/services/auth-provider-registry.service.js +0 -72
  105. package/src/lib/core/services/auth-provider-registry.service.js.map +0 -1
  106. package/src/lib/core/services/jwt.service.js +0 -93
  107. package/src/lib/core/services/jwt.service.js.map +0 -1
  108. package/src/lib/nest-auth.module.js +0 -118
  109. package/src/lib/nest-auth.module.js.map +0 -1
  110. package/src/lib/request-context/request-context.js +0 -108
  111. package/src/lib/request-context/request-context.js.map +0 -1
  112. package/src/lib/request-context/request-context.middleware.js +0 -16
  113. package/src/lib/request-context/request-context.middleware.js.map +0 -1
  114. package/src/lib/role/entities/permission.entity.js +0 -42
  115. package/src/lib/role/entities/permission.entity.js.map +0 -1
  116. package/src/lib/role/entities/role.entity.js +0 -106
  117. package/src/lib/role/entities/role.entity.js.map +0 -1
  118. package/src/lib/role/index.js +0 -6
  119. package/src/lib/role/index.js.map +0 -1
  120. package/src/lib/role/role.module.js +0 -22
  121. package/src/lib/role/role.module.js.map +0 -1
  122. package/src/lib/role/services/role.service.js +0 -220
  123. package/src/lib/role/services/role.service.js.map +0 -1
  124. package/src/lib/session/entities/session.entity.js +0 -63
  125. package/src/lib/session/entities/session.entity.js.map +0 -1
  126. package/src/lib/session/index.js +0 -8
  127. package/src/lib/session/index.js.map +0 -1
  128. package/src/lib/session/services/base-session.service.js +0 -66
  129. package/src/lib/session/services/base-session.service.js.map +0 -1
  130. package/src/lib/session/services/database-session.service.js +0 -55
  131. package/src/lib/session/services/database-session.service.js.map +0 -1
  132. package/src/lib/session/services/redis-session.service.js +0 -120
  133. package/src/lib/session/services/redis-session.service.js.map +0 -1
  134. package/src/lib/session/session.module.js +0 -33
  135. package/src/lib/session/session.module.js.map +0 -1
  136. package/src/lib/tenant/entities/tenant.entity.js +0 -44
  137. package/src/lib/tenant/entities/tenant.entity.js.map +0 -1
  138. package/src/lib/tenant/events/tenant-created.event.js +0 -10
  139. package/src/lib/tenant/events/tenant-created.event.js.map +0 -1
  140. package/src/lib/tenant/events/tenant-deleted.event.js +0 -10
  141. package/src/lib/tenant/events/tenant-deleted.event.js.map +0 -1
  142. package/src/lib/tenant/events/tenant-updated.event.js +0 -10
  143. package/src/lib/tenant/events/tenant-updated.event.js.map +0 -1
  144. package/src/lib/tenant/index.js +0 -7
  145. package/src/lib/tenant/index.js.map +0 -1
  146. package/src/lib/tenant/services/tenant.service.js +0 -136
  147. package/src/lib/tenant/services/tenant.service.js.map +0 -1
  148. package/src/lib/tenant/tenant.module.js +0 -27
  149. package/src/lib/tenant/tenant.module.js.map +0 -1
  150. package/src/lib/user/dto/requests/update-user.dto.js +0 -24
  151. package/src/lib/user/dto/requests/update-user.dto.js.map +0 -1
  152. package/src/lib/user/entities/access-key.entity.js +0 -63
  153. package/src/lib/user/entities/access-key.entity.js.map +0 -1
  154. package/src/lib/user/entities/auth-identity.entity.js +0 -47
  155. package/src/lib/user/entities/auth-identity.entity.js.map +0 -1
  156. package/src/lib/user/entities/user.entity.js +0 -189
  157. package/src/lib/user/entities/user.entity.js.map +0 -1
  158. package/src/lib/user/events/user-created.event.js +0 -10
  159. package/src/lib/user/events/user-created.event.js.map +0 -1
  160. package/src/lib/user/events/user-deleted.event.js +0 -10
  161. package/src/lib/user/events/user-deleted.event.js.map +0 -1
  162. package/src/lib/user/events/user-registered.event.js +0 -10
  163. package/src/lib/user/events/user-registered.event.js.map +0 -1
  164. package/src/lib/user/events/user-updated.event.js +0 -10
  165. package/src/lib/user/events/user-updated.event.js.map +0 -1
  166. package/src/lib/user/index.js +0 -8
  167. package/src/lib/user/index.js.map +0 -1
  168. package/src/lib/user/services/access-key.service.js +0 -119
  169. package/src/lib/user/services/access-key.service.js.map +0 -1
  170. package/src/lib/user/services/user.service.js +0 -217
  171. package/src/lib/user/services/user.service.js.map +0 -1
  172. package/src/lib/user/user.module.js +0 -32
  173. package/src/lib/user/user.module.js.map +0 -1
  174. package/src/lib/utils/database.utils.js +0 -8
  175. package/src/lib/utils/database.utils.js.map +0 -1
  176. package/src/lib/utils/otp.js +0 -7
  177. package/src/lib/utils/otp.js.map +0 -1
  178. package/tsconfig.tsbuildinfo +0 -1
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@ackplus/nest-auth",
3
- "version": "0.0.37",
3
+ "version": "0.0.39",
4
4
  "type": "commonjs",
5
- "main": "./src/index.js",
5
+ "main": "./index.cjs.js",
6
6
  "types": "./src/index.d.ts",
7
7
  "license": "MIT",
8
8
  "repository": {
@@ -16,4 +16,4 @@ export * from '../role/entities/permission.entity';
16
16
  export * from '../auth/entities/mfa-secret.entity';
17
17
  export * from '../auth/entities/otp.entity';
18
18
  export * from '../session/entities/session.entity';
19
- export declare const NestAuthEntities: (typeof Tenant | typeof AuthIdentity | typeof User | typeof Session | typeof OTP | typeof MFASecret | typeof Permission | typeof Role | typeof AccessKey)[];
19
+ export declare const NestAuthEntities: (typeof User | typeof AuthIdentity | typeof Role | typeof Permission | typeof Tenant | typeof MFASecret | typeof Session | typeof OTP | typeof AccessKey)[];
package/README.md DELETED
@@ -1,226 +0,0 @@
1
- # Nest Auth
2
-
3
- A comprehensive authentication module for NestJS applications.
4
-
5
- ## Table of Contents
6
-
7
- - [Installation](#installation)
8
- - [Quick Start](#quick-start)
9
- - [Configuration](#configuration)
10
- - [Database Setup](#database-setup)
11
- - [Testing](#testing)
12
- - [Authentication Providers](#authentication-providers)
13
- - [API Documentation](#api-documentation)
14
- - [Contributing](#contributing)
15
- - [License](#license)
16
-
17
- ## Installation
18
-
19
- ```bash
20
- yarn add @ackplus/nest-auth
21
- ```
22
-
23
- ## Quick Start
24
-
25
- ```typescript
26
- import { NestAuthModule } from '@ackplus/nest-auth';
27
-
28
- @Module({
29
- imports: [
30
- NestAuthModule.forRoot({
31
- jwt: {
32
- secret: 'your-secret-key',
33
- },
34
- emailAuth: {
35
- enabled: true,
36
- },
37
- // ... other options
38
- }),
39
- ],
40
- })
41
- export class AppModule {}
42
- ```
43
-
44
- ## Configuration
45
-
46
- ### Database Configuration
47
-
48
- The module supports both PostgreSQL and SQLite databases. Configure your database connection using the `DATABASE_URL` environment variable:
49
-
50
- ```bash
51
- # For PostgreSQL
52
- DATABASE_URL=postgresql://user:password@localhost:5432/dbname
53
-
54
- # For SQLite
55
- DATABASE_URL=:memory: # For in-memory database
56
- DATABASE_URL=./database.sqlite # For file-based database
57
- ```
58
-
59
- ### Environment Variables
60
-
61
- | Variable | Description | Default |
62
- |----------|-------------|---------|
63
- | `DATABASE_URL` | Database connection URL | `:memory:` |
64
- | `NODE_ENV` | Application environment | `development` |
65
-
66
- ### Module Options
67
-
68
- ```typescript
69
- interface AuthModuleOptions {
70
- jwt: {
71
- secret: string;
72
- expiresIn?: string;
73
- };
74
- emailAuth?: {
75
- enabled: boolean;
76
- // ... other email auth options
77
- };
78
- phoneAuth?: {
79
- enabled: boolean;
80
- // ... other phone auth options
81
- };
82
- // ... other options
83
- }
84
- ```
85
-
86
- ## Database Setup
87
-
88
- ### PostgreSQL
89
-
90
- 1. Create a new database:
91
- ```sql
92
- CREATE DATABASE your_database;
93
- ```
94
-
95
- 2. Run migrations:
96
- ```bash
97
- yarn typeorm migration:run -d src/typeorm.config.ts
98
- ```
99
-
100
- ### SQLite
101
-
102
- No setup required. The database will be created automatically.
103
-
104
- ## Testing
105
-
106
- ### Local Development
107
-
108
- 1. For PostgreSQL:
109
- ```bash
110
- DATABASE_URL=postgresql://user:password@localhost:5432/testdb yarn test
111
- ```
112
-
113
- 2. For SQLite:
114
- ```bash
115
- DATABASE_URL=:memory: yarn test
116
- ```
117
-
118
- ### CI/CD (GitHub Actions)
119
-
120
- The tests run automatically in GitHub Actions using SQLite for faster execution. No additional setup required.
121
-
122
- ## Authentication Providers
123
-
124
- ### Email Authentication
125
-
126
- ```typescript
127
- @Post('login')
128
- async login(@Body() loginDto: LoginRequestDto) {
129
- return this.authService.login({
130
- providerId: 'email',
131
- credentials: {
132
- email: loginDto.email,
133
- password: loginDto.password,
134
- },
135
- });
136
- }
137
- ```
138
-
139
- ### Phone Authentication
140
-
141
- ```typescript
142
- @Post('login')
143
- async login(@Body() loginDto: LoginRequestDto) {
144
- return this.authService.login({
145
- providerId: 'phone',
146
- credentials: {
147
- phone: loginDto.phone,
148
- password: loginDto.password,
149
- },
150
- });
151
- }
152
- ```
153
-
154
- ## API Documentation
155
-
156
- ### Authentication Endpoints
157
-
158
- | Endpoint | Method | Description |
159
- |----------|--------|-------------|
160
- | `/auth/login` | POST | Login with credentials |
161
- | `/auth/register` | POST | Register new user |
162
- | `/auth/refresh` | POST | Refresh access token |
163
- | `/auth/logout` | POST | Logout user |
164
-
165
- ### Request/Response Examples
166
-
167
- #### Login Request
168
- ```json
169
- {
170
- "providerId": "email",
171
- "credentials": {
172
- "email": "user@example.com",
173
- "password": "password123"
174
- }
175
- }
176
- ```
177
-
178
- #### Login Response
179
- ```json
180
- {
181
- "accessToken": "eyJhbGciOiJIUzI1NiIs...",
182
- "refreshToken": "eyJhbGciOiJIUzI1NiIs...",
183
- "isRequiresMfa": false
184
- }
185
- ```
186
-
187
- ## Contributing
188
-
189
- 1. Fork the repository
190
- 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
191
- 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
192
- 4. Push to the branch (`git push origin feature/amazing-feature`)
193
- 5. Open a Pull Request
194
-
195
- ### Development Setup
196
-
197
- 1. Clone the repository
198
- 2. Install dependencies:
199
- ```bash
200
- yarn install
201
- ```
202
-
203
- 3. Set up the database:
204
- ```bash
205
- # For PostgreSQL
206
- DATABASE_URL=postgresql://user:password@localhost:5432/testdb
207
-
208
- # For SQLite
209
- DATABASE_URL=:memory:
210
- ```
211
-
212
- 4. Run tests:
213
- ```bash
214
- yarn test
215
- ```
216
-
217
- ### Testing Guidelines
218
-
219
- - Write tests for all new features
220
- - Ensure tests pass in both PostgreSQL and SQLite
221
- - Follow the existing test patterns
222
- - Use appropriate test fixtures
223
-
224
- ## License
225
-
226
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
package/src/index.js DELETED
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/nest-auth.module"), exports);
5
- tslib_1.__exportStar(require("./lib/auth.constants"), exports);
6
- tslib_1.__exportStar(require("./lib/auth"), exports);
7
- tslib_1.__exportStar(require("./lib/session"), exports);
8
- tslib_1.__exportStar(require("./lib/user"), exports);
9
- tslib_1.__exportStar(require("./lib/role"), exports);
10
- tslib_1.__exportStar(require("./lib/tenant"), exports);
11
- tslib_1.__exportStar(require("./lib/core"), exports);
12
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nest-auth/src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAuC;AAEvC,+DAAqC;AAGrC,qDAA2B;AAC3B,wDAA8B;AAC9B,qDAA2B;AAC3B,qDAA2B;AAC3B,uDAA6B;AAC7B,qDAA2B"}
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthModule = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const auth_service_1 = require("./services/auth.service");
7
- const cookie_service_1 = require("./services/cookie.service");
8
- const mfa_service_1 = require("./services/mfa.service");
9
- const auth_controller_1 = require("./controllers/auth.controller");
10
- const mfa_controller_1 = require("./controllers/mfa.controller");
11
- const auth_identity_entity_1 = require("../user/entities/auth-identity.entity");
12
- const typeorm_1 = require("@nestjs/typeorm");
13
- const user_entity_1 = require("../user/entities/user.entity");
14
- const otp_entity_1 = require("./entities/otp.entity");
15
- const mfa_secret_entity_1 = require("./entities/mfa-secret.entity");
16
- const access_key_entity_1 = require("../user/entities/access-key.entity");
17
- const event_emitter_1 = require("@nestjs/event-emitter");
18
- const user_module_1 = require("../user/user.module");
19
- const core_module_1 = require("../core/core.module");
20
- const session_module_1 = require("../session/session.module");
21
- let AuthModule = class AuthModule {
22
- };
23
- exports.AuthModule = AuthModule;
24
- exports.AuthModule = AuthModule = tslib_1.__decorate([
25
- (0, common_1.Module)({
26
- imports: [
27
- event_emitter_1.EventEmitterModule,
28
- typeorm_1.TypeOrmModule.forFeature([
29
- user_entity_1.User,
30
- otp_entity_1.OTP,
31
- mfa_secret_entity_1.MFASecret,
32
- access_key_entity_1.AccessKey,
33
- auth_identity_entity_1.AuthIdentity,
34
- ]),
35
- (0, common_1.forwardRef)(() => core_module_1.CoreModule),
36
- (0, common_1.forwardRef)(() => user_module_1.UserModule),
37
- (0, common_1.forwardRef)(() => session_module_1.SessionModule),
38
- ],
39
- providers: [
40
- auth_service_1.AuthService,
41
- cookie_service_1.CookieService,
42
- mfa_service_1.MfaService,
43
- ],
44
- controllers: [auth_controller_1.AuthController, mfa_controller_1.MfaController],
45
- exports: [
46
- auth_service_1.AuthService,
47
- cookie_service_1.CookieService,
48
- mfa_service_1.MfaService,
49
- ],
50
- })
51
- ], AuthModule);
52
- //# sourceMappingURL=auth.module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.module.js","sourceRoot":"","sources":["../../../../../../packages/nest-auth/src/lib/auth/auth.module.ts"],"names":[],"mappings":";;;;AAAA,2CAAoD;AACpD,0DAAsD;AACtD,8DAA0D;AAC1D,wDAAoD;AACpD,mEAA+D;AAC/D,iEAA6D;AAC7D,gFAAqE;AACrE,6CAAgD;AAChD,8DAAoD;AACpD,sDAA4C;AAC5C,oEAAyD;AACzD,0EAA+D;AAC/D,yDAA2D;AAC3D,qDAAiD;AACjD,qDAAiD;AACjD,8DAA0D;AA4BnD,IAAM,UAAU,GAAhB,MAAM,UAAU;CACtB,CAAA;AADY,gCAAU;qBAAV,UAAU;IA1BtB,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YACL,kCAAkB;YAClB,uBAAa,CAAC,UAAU,CAAC;gBACrB,kBAAI;gBACJ,gBAAG;gBACH,6BAAS;gBACT,6BAAS;gBACT,mCAAY;aACf,CAAC;YACF,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,wBAAU,CAAC;YAC5B,IAAA,mBAAU,EAAC,GAAG,EAAE,CAAC,8BAAa,CAAC;SAClC;QACD,SAAS,EAAE;YACP,0BAAW;YACX,8BAAa;YACb,wBAAU;SACb;QACD,WAAW,EAAE,CAAC,gCAAc,EAAE,8BAAa,CAAC;QAC5C,OAAO,EAAE;YACL,0BAAW;YACX,8BAAa;YACb,wBAAU;SACb;KACJ,CAAC;GACW,UAAU,CACtB"}
@@ -1,189 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AuthController = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const auth_service_1 = require("../services/auth.service");
7
- const verify_2fa_request_dto_1 = require("../dto/requests/verify-2fa.request.dto");
8
- const refresh_token_request_dto_1 = require("../dto/requests/refresh-token.request.dto");
9
- const swagger_1 = require("@nestjs/swagger");
10
- const swagger_2 = require("@nestjs/swagger");
11
- const cookie_service_1 = require("../services/cookie.service");
12
- const auth_response_dto_1 = require("../dto/responses/auth.response.dto");
13
- const signup_request_dto_1 = require("../dto/requests/signup.request.dto");
14
- const login_request_dto_1 = require("../dto/requests/login.request.dto");
15
- const request_context_1 = require("../../request-context/request-context");
16
- const core_1 = require("../../core");
17
- const forgot_password_request_dto_1 = require("../dto/requests/forgot-password.request.dto");
18
- const reset_password_request_dto_1 = require("../dto/requests/reset-password.request.dto");
19
- let AuthController = class AuthController {
20
- constructor(authService, cookieService) {
21
- this.authService = authService;
22
- this.cookieService = cookieService;
23
- }
24
- async signup(input, res) {
25
- const response = await this.authService.signup(input);
26
- this.cookieService.setTokens(res, response.accessToken, response.refreshToken);
27
- res.status(200).json(response);
28
- }
29
- async login(input, res) {
30
- const response = await this.authService.login(input);
31
- this.cookieService.setTokens(res, response.accessToken, response.refreshToken);
32
- res.status(200).json(response);
33
- }
34
- async refreshToken(input, res) {
35
- const response = await this.authService.refreshToken(input.refreshToken);
36
- this.cookieService.setTokens(res, response.accessToken, response.refreshToken);
37
- res.status(200).json(response);
38
- }
39
- async send2faCode(method) {
40
- const user = request_context_1.RequestContext.currentUser();
41
- await this.authService.send2faCode(user.id, method);
42
- return { message: '2FA code sent successfully' };
43
- }
44
- async verify2fa(input, res) {
45
- const response = await this.authService.verify2fa(input);
46
- this.cookieService.setTokens(res, response.accessToken, response.refreshToken);
47
- res.status(200).json(response);
48
- }
49
- async logout(res) {
50
- await this.authService.logout();
51
- this.cookieService.clearCookies(res);
52
- res.status(200).json({ message: 'Logged out successfully' });
53
- }
54
- async logoutAll() {
55
- const user = request_context_1.RequestContext.currentUser();
56
- await this.authService.logoutAll(user.id);
57
- return { message: 'Logged out from all devices successfully' };
58
- }
59
- async forgotPassword(input) {
60
- await this.authService.forgotPassword(input);
61
- return { message: 'If the account exists, a password reset code has been sent' };
62
- }
63
- async resetPassword(input) {
64
- await this.authService.resetPassword(input);
65
- return { message: 'Password reset successfully' };
66
- }
67
- async getUser() {
68
- return await this.authService.getUser();
69
- }
70
- };
71
- exports.AuthController = AuthController;
72
- tslib_1.__decorate([
73
- (0, swagger_2.ApiOperation)({ summary: 'Signup' }),
74
- (0, swagger_1.ApiResponse)({ status: 200, type: auth_response_dto_1.AuthResponseDto }),
75
- (0, common_1.HttpCode)(200),
76
- (0, common_1.Post)('signup'),
77
- tslib_1.__param(0, (0, common_1.Body)()),
78
- tslib_1.__param(1, (0, common_1.Res)()),
79
- tslib_1.__metadata("design:type", Function),
80
- tslib_1.__metadata("design:paramtypes", [signup_request_dto_1.SignupRequestDto, Object]),
81
- tslib_1.__metadata("design:returntype", Promise)
82
- ], AuthController.prototype, "signup", null);
83
- tslib_1.__decorate([
84
- (0, swagger_2.ApiOperation)({ summary: 'Login' }),
85
- (0, swagger_1.ApiResponse)({ status: 200, type: auth_response_dto_1.AuthResponseDto }),
86
- (0, common_1.HttpCode)(200),
87
- (0, common_1.Post)('login'),
88
- tslib_1.__param(0, (0, common_1.Body)()),
89
- tslib_1.__param(1, (0, common_1.Res)()),
90
- tslib_1.__metadata("design:type", Function),
91
- tslib_1.__metadata("design:paramtypes", [login_request_dto_1.LoginRequestDto, Object]),
92
- tslib_1.__metadata("design:returntype", Promise)
93
- ], AuthController.prototype, "login", null);
94
- tslib_1.__decorate([
95
- (0, swagger_2.ApiOperation)({ summary: 'Refresh Token' }),
96
- (0, swagger_1.ApiResponse)({ status: 200, type: auth_response_dto_1.AuthResponseDto }),
97
- (0, common_1.HttpCode)(200),
98
- (0, common_1.Post)('refresh-token'),
99
- tslib_1.__param(0, (0, common_1.Body)()),
100
- tslib_1.__param(1, (0, common_1.Res)()),
101
- tslib_1.__metadata("design:type", Function),
102
- tslib_1.__metadata("design:paramtypes", [refresh_token_request_dto_1.RefreshTokenRequestDto, Object]),
103
- tslib_1.__metadata("design:returntype", Promise)
104
- ], AuthController.prototype, "refreshToken", null);
105
- tslib_1.__decorate([
106
- (0, swagger_2.ApiOperation)({ summary: 'Send 2FA Code' }),
107
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
108
- (0, common_1.HttpCode)(200),
109
- (0, common_1.Post)('send-2fa-code'),
110
- (0, core_1.SkipMfa)(),
111
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
112
- tslib_1.__param(0, (0, common_1.Body)('method')),
113
- tslib_1.__metadata("design:type", Function),
114
- tslib_1.__metadata("design:paramtypes", [String]),
115
- tslib_1.__metadata("design:returntype", Promise)
116
- ], AuthController.prototype, "send2faCode", null);
117
- tslib_1.__decorate([
118
- (0, swagger_2.ApiOperation)({ summary: 'Verify 2FA' }),
119
- (0, swagger_1.ApiResponse)({ status: 200, type: auth_response_dto_1.Verify2faResponseDto }),
120
- (0, common_1.HttpCode)(200),
121
- (0, common_1.Post)('verify-2fa'),
122
- (0, core_1.SkipMfa)(),
123
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
124
- tslib_1.__param(0, (0, common_1.Body)()),
125
- tslib_1.__param(1, (0, common_1.Res)()),
126
- tslib_1.__metadata("design:type", Function),
127
- tslib_1.__metadata("design:paramtypes", [verify_2fa_request_dto_1.Verify2faRequestDto, Object]),
128
- tslib_1.__metadata("design:returntype", Promise)
129
- ], AuthController.prototype, "verify2fa", null);
130
- tslib_1.__decorate([
131
- (0, swagger_2.ApiOperation)({ summary: 'Logout' }),
132
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
133
- (0, common_1.HttpCode)(200),
134
- (0, common_1.Post)('logout'),
135
- (0, core_1.SkipMfa)(),
136
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
137
- tslib_1.__param(0, (0, common_1.Res)()),
138
- tslib_1.__metadata("design:type", Function),
139
- tslib_1.__metadata("design:paramtypes", [Object]),
140
- tslib_1.__metadata("design:returntype", Promise)
141
- ], AuthController.prototype, "logout", null);
142
- tslib_1.__decorate([
143
- (0, swagger_2.ApiOperation)({ summary: 'Logout All' }),
144
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
145
- (0, common_1.HttpCode)(200),
146
- (0, common_1.Post)('logout-all'),
147
- (0, core_1.SkipMfa)(),
148
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
149
- tslib_1.__metadata("design:type", Function),
150
- tslib_1.__metadata("design:paramtypes", []),
151
- tslib_1.__metadata("design:returntype", Promise)
152
- ], AuthController.prototype, "logoutAll", null);
153
- tslib_1.__decorate([
154
- (0, swagger_2.ApiOperation)({ summary: 'Forgot Password' }),
155
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
156
- (0, common_1.HttpCode)(200),
157
- (0, common_1.Post)('forgot-password'),
158
- (0, core_1.SkipMfa)(),
159
- tslib_1.__param(0, (0, common_1.Body)()),
160
- tslib_1.__metadata("design:type", Function),
161
- tslib_1.__metadata("design:paramtypes", [forgot_password_request_dto_1.ForgotPasswordRequestDto]),
162
- tslib_1.__metadata("design:returntype", Promise)
163
- ], AuthController.prototype, "forgotPassword", null);
164
- tslib_1.__decorate([
165
- (0, swagger_2.ApiOperation)({ summary: 'Reset Password' }),
166
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
167
- (0, common_1.HttpCode)(200),
168
- (0, common_1.Post)('reset-password'),
169
- (0, core_1.SkipMfa)(),
170
- tslib_1.__param(0, (0, common_1.Body)()),
171
- tslib_1.__metadata("design:type", Function),
172
- tslib_1.__metadata("design:paramtypes", [reset_password_request_dto_1.ResetPasswordRequestDto]),
173
- tslib_1.__metadata("design:returntype", Promise)
174
- ], AuthController.prototype, "resetPassword", null);
175
- tslib_1.__decorate([
176
- (0, swagger_2.ApiOperation)({ summary: 'Get Logged In User' }),
177
- (0, swagger_1.ApiResponse)({ status: 200, type: auth_response_dto_1.UserResponseDto }),
178
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
179
- (0, common_1.Get)('user'),
180
- tslib_1.__metadata("design:type", Function),
181
- tslib_1.__metadata("design:paramtypes", []),
182
- tslib_1.__metadata("design:returntype", Promise)
183
- ], AuthController.prototype, "getUser", null);
184
- exports.AuthController = AuthController = tslib_1.__decorate([
185
- (0, common_1.Controller)('auth'),
186
- tslib_1.__metadata("design:paramtypes", [auth_service_1.AuthService,
187
- cookie_service_1.CookieService])
188
- ], AuthController);
189
- //# sourceMappingURL=auth.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.controller.js","sourceRoot":"","sources":["../../../../../../../packages/nest-au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AE,GAAG,EAAE,IAAI,EAAE,mCAAe,EAAE,CAAC;IACnD,IAAA,kBAAS,EAAC,wBAAiB,CAAC;IAC5B,IAAA,YAAG,EAAC,MAAM,CAAC;;;;6CAGX;yBA/GQ,cAAc;IAD1B,IAAA,mBAAU,EAAC,MAAM,CAAC;6CAGmB,0BAAW;QACT,8BAAa;GAHxC,cAAc,CAiH1B"}
@@ -1,130 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MfaController = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const core_1 = require("../../core");
7
- const mfa_service_1 = require("../services/mfa.service");
8
- const request_context_1 = require("../../request-context/request-context");
9
- const send_mfa_code_request_dto_1 = require("../dto/requests/send-mfa-code.request.dto");
10
- const verify_totp_setup_request_dto_1 = require("../dto/requests/verify-totp-setup.request.dto");
11
- const swagger_1 = require("@nestjs/swagger");
12
- const auth_constants_1 = require("../../auth.constants");
13
- let MfaController = class MfaController {
14
- constructor(mfaService) {
15
- this.mfaService = mfaService;
16
- }
17
- async sendMfaCode(input) {
18
- const user = request_context_1.RequestContext.currentUser();
19
- if (!user) {
20
- throw new common_1.UnauthorizedException('User not found');
21
- }
22
- await this.mfaService.sendMfaCode(user.id, input.method);
23
- return { message: 'MFA code sent' };
24
- }
25
- async setupTotp() {
26
- const user = request_context_1.RequestContext.currentUser();
27
- if (!user) {
28
- throw new common_1.UnauthorizedException('User not found');
29
- }
30
- const { secret, qrCode } = await this.mfaService.setupTotpDevice(user.id);
31
- return { secret, qrCode };
32
- }
33
- async verifyTotpSetup(input) {
34
- const user = request_context_1.RequestContext.currentUser();
35
- if (!user) {
36
- throw new common_1.UnauthorizedException({
37
- message: 'User not found',
38
- code: auth_constants_1.USER_NOT_FOUND_EXCEPTION_CODE
39
- });
40
- }
41
- const isVerified = await this.mfaService.verifyTotpSetup(user.id, input.secret, input.otp);
42
- if (!isVerified) {
43
- throw new common_1.UnauthorizedException({
44
- message: 'Invalid OTP',
45
- code: auth_constants_1.INVALID_MFA_EXCEPTION_CODE
46
- });
47
- }
48
- return { message: 'Device setup successfully' };
49
- }
50
- async generateRecoveryCodes() {
51
- const user = request_context_1.RequestContext.currentUser();
52
- if (!user) {
53
- throw new common_1.UnauthorizedException('User not found');
54
- }
55
- const code = await this.mfaService.generateRecoveryCode(user.id);
56
- return { code };
57
- }
58
- async resetTotp(code) {
59
- const user = request_context_1.RequestContext.currentUser();
60
- if (!user) {
61
- throw new common_1.UnauthorizedException('User not found');
62
- }
63
- await this.mfaService.resetMfa(user.id, code);
64
- return { message: 'MFA reset successfully' };
65
- }
66
- };
67
- exports.MfaController = MfaController;
68
- tslib_1.__decorate([
69
- (0, swagger_1.ApiOperation)({ summary: 'Send MFA Code' }),
70
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
71
- (0, common_1.HttpCode)(200),
72
- (0, common_1.Post)('send-mfa-code'),
73
- (0, core_1.SkipMfa)(),
74
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
75
- tslib_1.__param(0, (0, common_1.Body)()),
76
- tslib_1.__metadata("design:type", Function),
77
- tslib_1.__metadata("design:paramtypes", [send_mfa_code_request_dto_1.SendMfaCodeRequestDto]),
78
- tslib_1.__metadata("design:returntype", Promise)
79
- ], MfaController.prototype, "sendMfaCode", null);
80
- tslib_1.__decorate([
81
- (0, swagger_1.ApiOperation)({ summary: 'Setup TOTP Device' }),
82
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
83
- (0, common_1.HttpCode)(200),
84
- (0, common_1.Post)('setup-totp'),
85
- (0, core_1.SkipMfa)(),
86
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
87
- tslib_1.__metadata("design:type", Function),
88
- tslib_1.__metadata("design:paramtypes", []),
89
- tslib_1.__metadata("design:returntype", Promise)
90
- ], MfaController.prototype, "setupTotp", null);
91
- tslib_1.__decorate([
92
- (0, swagger_1.ApiOperation)({ summary: 'Verify TOTP Setup' }),
93
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
94
- (0, common_1.HttpCode)(200),
95
- (0, common_1.Post)('verify-totp-setup'),
96
- (0, core_1.SkipMfa)(),
97
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
98
- tslib_1.__param(0, (0, common_1.Body)()),
99
- tslib_1.__metadata("design:type", Function),
100
- tslib_1.__metadata("design:paramtypes", [verify_totp_setup_request_dto_1.VerifyTotpSetupRequestDto]),
101
- tslib_1.__metadata("design:returntype", Promise)
102
- ], MfaController.prototype, "verifyTotpSetup", null);
103
- tslib_1.__decorate([
104
- (0, swagger_1.ApiOperation)({ summary: 'Generate Recovery Codes' }),
105
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
106
- (0, common_1.HttpCode)(200),
107
- (0, common_1.Post)('generate-recovery-code'),
108
- (0, core_1.SkipMfa)(),
109
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
110
- tslib_1.__metadata("design:type", Function),
111
- tslib_1.__metadata("design:paramtypes", []),
112
- tslib_1.__metadata("design:returntype", Promise)
113
- ], MfaController.prototype, "generateRecoveryCodes", null);
114
- tslib_1.__decorate([
115
- (0, swagger_1.ApiOperation)({ summary: 'Reset TOTP Device' }),
116
- (0, swagger_1.ApiResponse)({ status: 200, type: core_1.MessageResponseDto }),
117
- (0, common_1.HttpCode)(200),
118
- (0, common_1.Post)('reset-totp'),
119
- (0, core_1.SkipMfa)(),
120
- (0, common_1.UseGuards)(core_1.NestAuthAuthGuard),
121
- tslib_1.__param(0, (0, common_1.Body)('code')),
122
- tslib_1.__metadata("design:type", Function),
123
- tslib_1.__metadata("design:paramtypes", [String]),
124
- tslib_1.__metadata("design:returntype", Promise)
125
- ], MfaController.prototype, "resetTotp", null);
126
- exports.MfaController = MfaController = tslib_1.__decorate([
127
- (0, common_1.Controller)('auth/mfa'),
128
- tslib_1.__metadata("design:paramtypes", [mfa_service_1.MfaService])
129
- ], MfaController);
130
- //# sourceMappingURL=mfa.controller.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mfa.controller.js","sourceRoot":"","sources":["../../../../../../../packages/nest-auth/src/lib/auth/controllers/mfa.controller.ts"],"names":[],"mappings":";;;;AAAA,2CAAoG;AACpG,qCAA4E;AAC5E,yDAAqD;AACrD,2EAAuE;AACvE,yFAAkF;AAClF,iGAA0F;AAC1F,6CAA4D;AAC5D,yDAAiG;AAG1F,IAAM,aAAa,GAAnB,MAAM,aAAa;IACtB,YACqB,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IACvC,CAAC;IAQC,AAAN,KAAK,CAAC,WAAW,CAAS,KAA4B;QAClD,MAAM,IAAI,GAAG,gCAAc,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,CAAC,gBAAgB,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAEzD,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IACxC,CAAC;IASK,AAAN,KAAK,CAAC,SAAS;QACX,MAAM,IAAI,GAAG,gCAAc,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;YACR,MAAM,IAAI,8BAAqB,CAAC,gBAAgB,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC9B,CAAC;IAQK,AAAN,KAAK,CAAC,eAAe,CAAS,KAAgC;QAC1D,MAAM,IAAI,GAAG,gCAAc,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI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;IAC9B,IAAA,cAAO,GAAE;IACT,IAAA,kBAAS,EAAC,wBAAiB,CAAC;;;;0DAU5B;AAQK;IANL,IAAA,sBAAY,EAAC,EAAE,OAAO,EAAE,mBAAmB,EAAE,CAAC;IAC9C,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,yBAAkB,EAAE,CAAC;IACtD,IAAA,iBAAQ,EAAC,GAAG,CAAC;IACb,IAAA,aAAI,EAAC,YAAY,CAAC;IAClB,IAAA,cAAO,GAAE;IACT,IAAA,kBAAS,EAAC,wBAAiB,CAAC;IACZ,mBAAA,IAAA,aAAI,EAAC,MAAM,CAAC,CAAA;;;;8CAO5B;wBA9FQ,aAAa;IADzB,IAAA,mBAAU,EAAC,UAAU,CAAC;6CAGc,wBAAU;GAFlC,aAAa,CA+FzB"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../packages/nest-auth/src/lib/auth/dto/index.ts"],"names":[],"mappings":""}