@nauth-toolkit/core 0.1.0 → 0.1.3

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 (184) hide show
  1. package/LICENSE +90 -0
  2. package/README.md +30 -0
  3. package/package.json +7 -2
  4. package/jest.config.js +0 -15
  5. package/jest.setup.ts +0 -6
  6. package/src/adapters/database-columns.ts +0 -165
  7. package/src/adapters/express.adapter.ts +0 -385
  8. package/src/adapters/fastify.adapter.ts +0 -416
  9. package/src/adapters/index.ts +0 -16
  10. package/src/adapters/storage.factory.ts +0 -143
  11. package/src/bootstrap.ts +0 -374
  12. package/src/dto/auth-challenge.dto.ts +0 -231
  13. package/src/dto/auth-response.dto.ts +0 -253
  14. package/src/dto/challenge-response.dto.ts +0 -234
  15. package/src/dto/change-password-request.dto.ts +0 -50
  16. package/src/dto/change-password-response.dto.ts +0 -29
  17. package/src/dto/change-password.dto.ts +0 -57
  18. package/src/dto/error-response.dto.ts +0 -136
  19. package/src/dto/get-available-methods.dto.ts +0 -55
  20. package/src/dto/get-challenge-data-response.dto.ts +0 -28
  21. package/src/dto/get-challenge-data.dto.ts +0 -69
  22. package/src/dto/get-client-info.dto.ts +0 -104
  23. package/src/dto/get-device-token-response.dto.ts +0 -25
  24. package/src/dto/get-events-by-type.dto.ts +0 -76
  25. package/src/dto/get-ip-address-response.dto.ts +0 -24
  26. package/src/dto/get-mfa-status.dto.ts +0 -94
  27. package/src/dto/get-risk-assessment-history.dto.ts +0 -39
  28. package/src/dto/get-session-id-response.dto.ts +0 -25
  29. package/src/dto/get-setup-data-response.dto.ts +0 -31
  30. package/src/dto/get-setup-data.dto.ts +0 -75
  31. package/src/dto/get-suspicious-activity.dto.ts +0 -42
  32. package/src/dto/get-user-agent-response.dto.ts +0 -23
  33. package/src/dto/get-user-auth-history.dto.ts +0 -95
  34. package/src/dto/get-user-by-email.dto.ts +0 -61
  35. package/src/dto/get-user-by-id.dto.ts +0 -46
  36. package/src/dto/get-user-devices.dto.ts +0 -53
  37. package/src/dto/get-user-response.dto.ts +0 -17
  38. package/src/dto/has-provider.dto.ts +0 -56
  39. package/src/dto/index.ts +0 -57
  40. package/src/dto/is-trusted-device-response.dto.ts +0 -34
  41. package/src/dto/list-providers-response.dto.ts +0 -23
  42. package/src/dto/login.dto.ts +0 -95
  43. package/src/dto/logout-all-response.dto.ts +0 -24
  44. package/src/dto/logout-all.dto.ts +0 -65
  45. package/src/dto/logout-response.dto.ts +0 -25
  46. package/src/dto/logout.dto.ts +0 -64
  47. package/src/dto/refresh-token.dto.ts +0 -36
  48. package/src/dto/remove-devices.dto.ts +0 -85
  49. package/src/dto/resend-code-response.dto.ts +0 -32
  50. package/src/dto/resend-code.dto.ts +0 -51
  51. package/src/dto/reset-password.dto.ts +0 -115
  52. package/src/dto/respond-challenge.dto.ts +0 -272
  53. package/src/dto/set-mfa-exemption.dto.ts +0 -112
  54. package/src/dto/set-must-change-password-response.dto.ts +0 -27
  55. package/src/dto/set-must-change-password.dto.ts +0 -46
  56. package/src/dto/set-preferred-method.dto.ts +0 -80
  57. package/src/dto/setup-mfa.dto.ts +0 -98
  58. package/src/dto/signup.dto.ts +0 -174
  59. package/src/dto/social-auth.dto.ts +0 -422
  60. package/src/dto/trust-device-response.dto.ts +0 -30
  61. package/src/dto/trust-device.dto.ts +0 -9
  62. package/src/dto/update-user-attributes-request.dto.ts +0 -51
  63. package/src/dto/user-response.dto.ts +0 -138
  64. package/src/dto/user-update.dto.ts +0 -222
  65. package/src/dto/verify-email.dto.ts +0 -313
  66. package/src/dto/verify-mfa-code.dto.ts +0 -103
  67. package/src/dto/verify-phone-by-sub.dto.ts +0 -78
  68. package/src/dto/verify-phone.dto.ts +0 -245
  69. package/src/entities/auth-audit.entity.ts +0 -232
  70. package/src/entities/challenge-session.entity.ts +0 -116
  71. package/src/entities/index.ts +0 -29
  72. package/src/entities/login-attempt.entity.ts +0 -64
  73. package/src/entities/mfa-device.entity.ts +0 -151
  74. package/src/entities/rate-limit.entity.ts +0 -44
  75. package/src/entities/session.entity.ts +0 -180
  76. package/src/entities/social-account.entity.ts +0 -96
  77. package/src/entities/storage-lock.entity.ts +0 -39
  78. package/src/entities/trusted-device.entity.ts +0 -112
  79. package/src/entities/user.entity.ts +0 -243
  80. package/src/entities/verification-token.entity.ts +0 -141
  81. package/src/enums/auth-audit-event-type.enum.ts +0 -360
  82. package/src/enums/error-codes.enum.ts +0 -420
  83. package/src/enums/mfa-method.enum.ts +0 -97
  84. package/src/enums/risk-factor.enum.ts +0 -111
  85. package/src/exceptions/nauth.exception.ts +0 -231
  86. package/src/handlers/auth.handler.ts +0 -260
  87. package/src/handlers/client-info.handler.ts +0 -101
  88. package/src/handlers/csrf.handler.ts +0 -156
  89. package/src/handlers/token-delivery.handler.ts +0 -118
  90. package/src/index.ts +0 -118
  91. package/src/interfaces/client-info.interface.ts +0 -85
  92. package/src/interfaces/config.interface.ts +0 -2135
  93. package/src/interfaces/entities.interface.ts +0 -226
  94. package/src/interfaces/index.ts +0 -15
  95. package/src/interfaces/logger.interface.ts +0 -283
  96. package/src/interfaces/mfa-provider.interface.ts +0 -154
  97. package/src/interfaces/oauth.interface.ts +0 -148
  98. package/src/interfaces/provider.interface.ts +0 -47
  99. package/src/interfaces/social-auth-provider.interface.ts +0 -131
  100. package/src/interfaces/storage-adapter.interface.ts +0 -82
  101. package/src/interfaces/template.interface.ts +0 -510
  102. package/src/interfaces/token-verifier.interface.ts +0 -110
  103. package/src/internal.ts +0 -178
  104. package/src/platform/interfaces.ts +0 -299
  105. package/src/schemas/auth-config.schema.ts +0 -646
  106. package/src/services/adaptive-mfa-decision.service.spec.ts +0 -1058
  107. package/src/services/adaptive-mfa-decision.service.ts +0 -457
  108. package/src/services/auth-audit.service.spec.ts +0 -675
  109. package/src/services/auth-audit.service.ts +0 -558
  110. package/src/services/auth-challenge-helper.service.spec.ts +0 -3227
  111. package/src/services/auth-challenge-helper.service.ts +0 -825
  112. package/src/services/auth-flow-context-builder.service.ts +0 -520
  113. package/src/services/auth-flow-rules.ts +0 -202
  114. package/src/services/auth-flow-state-definitions.ts +0 -190
  115. package/src/services/auth-flow-state-machine.service.ts +0 -207
  116. package/src/services/auth-flow-state-machine.types.ts +0 -316
  117. package/src/services/auth.service.spec.ts +0 -4195
  118. package/src/services/auth.service.ts +0 -3727
  119. package/src/services/challenge.service.spec.ts +0 -1363
  120. package/src/services/challenge.service.ts +0 -696
  121. package/src/services/client-info.service.spec.ts +0 -572
  122. package/src/services/client-info.service.ts +0 -374
  123. package/src/services/csrf.service.ts +0 -54
  124. package/src/services/email-verification.service.spec.ts +0 -1229
  125. package/src/services/email-verification.service.ts +0 -578
  126. package/src/services/geo-location.service.spec.ts +0 -603
  127. package/src/services/geo-location.service.ts +0 -599
  128. package/src/services/index.ts +0 -13
  129. package/src/services/jwt.service.spec.ts +0 -882
  130. package/src/services/jwt.service.ts +0 -621
  131. package/src/services/mfa-base.service.spec.ts +0 -246
  132. package/src/services/mfa-base.service.ts +0 -611
  133. package/src/services/mfa.service.spec.ts +0 -693
  134. package/src/services/mfa.service.ts +0 -960
  135. package/src/services/password.service.spec.ts +0 -166
  136. package/src/services/password.service.ts +0 -309
  137. package/src/services/phone-verification.service.spec.ts +0 -1120
  138. package/src/services/phone-verification.service.ts +0 -751
  139. package/src/services/risk-detection.service.spec.ts +0 -1292
  140. package/src/services/risk-detection.service.ts +0 -1012
  141. package/src/services/risk-scoring.service.spec.ts +0 -204
  142. package/src/services/risk-scoring.service.ts +0 -131
  143. package/src/services/session.service.spec.ts +0 -1293
  144. package/src/services/session.service.ts +0 -803
  145. package/src/services/social-account.service.spec.ts +0 -725
  146. package/src/services/social-auth-base.service.spec.ts +0 -418
  147. package/src/services/social-auth-base.service.ts +0 -581
  148. package/src/services/social-auth.service.spec.ts +0 -238
  149. package/src/services/social-auth.service.ts +0 -436
  150. package/src/services/social-provider-registry.service.spec.ts +0 -238
  151. package/src/services/social-provider-registry.service.ts +0 -122
  152. package/src/services/trusted-device.service.spec.ts +0 -505
  153. package/src/services/trusted-device.service.ts +0 -339
  154. package/src/storage/account-lockout-storage.service.spec.ts +0 -310
  155. package/src/storage/account-lockout-storage.service.ts +0 -89
  156. package/src/storage/index.ts +0 -3
  157. package/src/storage/memory-storage.adapter.ts +0 -443
  158. package/src/storage/rate-limit-storage.service.spec.ts +0 -247
  159. package/src/storage/rate-limit-storage.service.ts +0 -38
  160. package/src/templates/html-template.engine.spec.ts +0 -161
  161. package/src/templates/html-template.engine.ts +0 -688
  162. package/src/templates/index.ts +0 -7
  163. package/src/utils/common-passwords.spec.ts +0 -230
  164. package/src/utils/common-passwords.ts +0 -170
  165. package/src/utils/context-storage.ts +0 -188
  166. package/src/utils/cookie-names.util.ts +0 -67
  167. package/src/utils/cookies.util.ts +0 -94
  168. package/src/utils/index.ts +0 -12
  169. package/src/utils/ip-extractor.spec.ts +0 -330
  170. package/src/utils/ip-extractor.ts +0 -220
  171. package/src/utils/nauth-logger.spec.ts +0 -388
  172. package/src/utils/nauth-logger.ts +0 -215
  173. package/src/utils/pii-redactor.spec.ts +0 -130
  174. package/src/utils/pii-redactor.ts +0 -288
  175. package/src/utils/setup/get-repositories.ts +0 -140
  176. package/src/utils/setup/init-services.ts +0 -422
  177. package/src/utils/setup/init-social.ts +0 -189
  178. package/src/utils/setup/init-storage.ts +0 -94
  179. package/src/utils/setup/register-mfa.ts +0 -165
  180. package/src/utils/setup/run-nauth-migrations.ts +0 -61
  181. package/src/utils/token-delivery-policy.ts +0 -38
  182. package/src/validators/template.validator.ts +0 -219
  183. package/tsconfig.json +0 -37
  184. package/tsconfig.lint.json +0 -6
package/LICENSE ADDED
@@ -0,0 +1,90 @@
1
+ NAUTH TOOLKIT EARLY ACCESS LICENSE
2
+ Version 1.0 (December 2025)
3
+
4
+ ================================================================================
5
+ FUTURE OPEN SOURCE NOTICE
6
+ ================================================================================
7
+ NAuth Toolkit will transition to an open-source license (MIT or Apache 2.0) for
8
+ core authentication features once the project reaches production readiness.
9
+
10
+ This Early Access License is temporary and designed to:
11
+ • Allow developers to build with nauth-toolkit during preview/beta
12
+ • Provide clear expectations during the pre-release phase
13
+ • Enable feedback and real-world testing before GA
14
+
15
+ We're committed to keeping core auth free and open source. Premium features
16
+ (enterprise SSO, advanced compliance, hosted options) will be offered separately
17
+ under fair commercial terms.
18
+
19
+ ================================================================================
20
+ EARLY ACCESS LICENSE TERMS
21
+ ================================================================================
22
+
23
+ 1. Grant of Use
24
+ You are granted a free, non-exclusive, non-transferable license to:
25
+ - Install and use nauth-toolkit packages in development, testing, staging,
26
+ and production environments
27
+ - Modify the code for your own internal use
28
+ - Deploy applications using nauth-toolkit to serve your users
29
+
30
+ You may NOT:
31
+ - Redistribute NAuth Toolkit as a standalone product or service
32
+ - Sell, sublicense, or offer NAuth Toolkit as part of a competing auth
33
+ platform or toolkit
34
+ - Remove or alter copyright notices
35
+
36
+ 2. No Fees During Early Access
37
+ There are no license fees, subscription costs, or usage charges during the
38
+ Early Access period. You may use nauth-toolkit freely for commercial and
39
+ non-commercial purposes within the terms of this license.
40
+
41
+ 3. Production Use
42
+ Production use is permitted but comes with standard early-access caveats:
43
+ - Features and APIs may change between preview releases
44
+ - Support is community-based (GitHub issues/discussions)
45
+ - No SLA or guaranteed uptime (you run it on your infrastructure)
46
+
47
+ We recommend thorough testing and having rollback plans for critical systems.
48
+
49
+ 4. Future Transition
50
+ When nauth-toolkit releases v1.0 GA:
51
+ - Core packages will adopt an open-source license (MIT or Apache 2.0)
52
+ - Your existing deployments will continue to work
53
+ - Premium features (if any) will be clearly documented with separate licensing
54
+ - No forced upgrades or surprise fees
55
+
56
+ 5. Ownership
57
+ NAuth Toolkit is developed and maintained by Noorix Digital Solutions.
58
+ You retain full ownership of your applications and data.
59
+
60
+ 6. Data and Privacy
61
+ NAuth Toolkit runs in YOUR infrastructure and database. You control all data.
62
+ You are responsible for compliance with applicable data protection laws.
63
+
64
+ 7. Disclaimer of Warranty
65
+ THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
66
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
67
+ FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
68
+
69
+ 8. Limitation of Liability
70
+ IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY INDIRECT, INCIDENTAL,
71
+ SPECIAL, CONSEQUENTIAL, OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO LOSS
72
+ OF PROFITS, REVENUE, DATA, OR USE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
73
+ DAMAGES.
74
+
75
+ 9. Termination
76
+ This license remains in effect until:
77
+ - You stop using nauth-toolkit, or
78
+ - The project transitions to open source (at which point the new license applies)
79
+
80
+ If you breach these terms, your license terminates and you must stop using the
81
+ software.
82
+
83
+ 10. Contact and Support
84
+ - Documentation: https://nauth.dev
85
+ - Issues/Discussions: GitHub (when public repository launches)
86
+ - Commercial inquiries: Contact admin@noorix.com
87
+
88
+ ================================================================================
89
+ Thank you for being an early adopter. Your feedback shapes the future of NAuth.
90
+ ================================================================================
package/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # @nauth-toolkit/core
2
+
3
+ Core authentication toolkit for NestJS
4
+
5
+ ## ⚠️ Preview Release Notice
6
+
7
+ **This is a preview release for internal testing. Do not use in production yet.**
8
+
9
+ This package is part of nauth-toolkit and is currently in early access/preview. Features and APIs may change between releases. For production use, please wait for the stable v1.0 release.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @nauth-toolkit/core@preview
15
+ # or
16
+ yarn add @nauth-toolkit/core@preview
17
+ ```
18
+
19
+ ## License
20
+
21
+ See LICENSE file in the package root for full license terms.
22
+
23
+ ## Documentation
24
+
25
+ Full documentation: https://nauth.dev
26
+
27
+ ## Support
28
+
29
+ - Issues/Discussions: GitHub (when repository is public)
30
+ - Documentation: https://nauth.dev
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nauth-toolkit/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.3",
4
4
  "description": "Core authentication toolkit for NestJS",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,11 +63,16 @@
63
63
  "access": "public",
64
64
  "tag": "preview"
65
65
  },
66
- "license": "SEE LICENSE IN LICENSE",
66
+ "license": "UNLICENSED",
67
67
  "keywords": [
68
68
  "nestjs",
69
69
  "authentication",
70
70
  "jwt",
71
71
  "typeorm"
72
+ ],
73
+ "files": [
74
+ "dist",
75
+ "LICENSE",
76
+ "README.md"
72
77
  ]
73
78
  }
package/jest.config.js DELETED
@@ -1,15 +0,0 @@
1
- module.exports = {
2
- moduleFileExtensions: ['js', 'json', 'ts'],
3
- rootDir: 'src',
4
- testRegex: '.*\\.spec\\.ts$',
5
- transform: {
6
- '^.+\\.(t|j)s$': 'ts-jest',
7
- },
8
- collectCoverageFrom: ['**/*.(t|j)s'],
9
- coverageDirectory: '../coverage',
10
- testEnvironment: 'node',
11
- // Transform ESM modules like jose
12
- transformIgnorePatterns: ['node_modules/(?!(jose)/)'],
13
- // Setup reflect-metadata for TypeORM
14
- setupFilesAfterEnv: ['<rootDir>/../jest.setup.ts'],
15
- };
package/jest.setup.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Jest setup file for reflect-metadata support
3
- * Required for TypeORM decorators to work in tests
4
- */
5
- import 'reflect-metadata';
6
-
@@ -1,165 +0,0 @@
1
- import { Column, ColumnOptions } from 'typeorm';
2
-
3
- /**
4
- * Database-Agnostic Column Decorators
5
- *
6
- * Provides column decorators that automatically adapt to different database types.
7
- * Uses the database adapter to determine appropriate column types.
8
- *
9
- * @example
10
- * ```typescript
11
- * @Entity()
12
- * export class User {
13
- * @UuidColumn()
14
- * id!: string;
15
- *
16
- * @JsonColumn()
17
- * metadata?: Record<string, any>;
18
- *
19
- * @ArrayColumn()
20
- * tags?: string[];
21
- * }
22
- * ```
23
- */
24
-
25
- /**
26
- * Create UUID column with database-appropriate type
27
- *
28
- * @param options - Additional column options
29
- * @returns Column decorator
30
- */
31
- export function UuidColumn(options?: Partial<ColumnOptions>) {
32
- return function (target: Record<string, unknown>, propertyKey: string) {
33
- // This would be replaced with actual adapter-based logic
34
- // For now, use PostgreSQL default
35
- const columnOptions: ColumnOptions = {
36
- type: 'uuid',
37
- ...options,
38
- };
39
-
40
- // In a real implementation, this would use the injected adapter
41
- // to determine the correct column type
42
- return Column(columnOptions)(target, propertyKey);
43
- };
44
- }
45
-
46
- /**
47
- * Create JSON column with database-appropriate type
48
- *
49
- * @param options - Additional column options
50
- * @returns Column decorator
51
- */
52
- export function JsonColumn(options?: Partial<ColumnOptions>) {
53
- return function (target: Record<string, unknown>, propertyKey: string) {
54
- const columnOptions: ColumnOptions = {
55
- type: 'jsonb', // PostgreSQL default
56
- ...options,
57
- };
58
-
59
- return Column(columnOptions)(target, propertyKey);
60
- };
61
- }
62
-
63
- /**
64
- * Create array column with database-appropriate type
65
- *
66
- * @param options - Additional column options
67
- * @returns Column decorator
68
- */
69
- export function ArrayColumn(options?: Partial<ColumnOptions>) {
70
- return function (target: Record<string, unknown>, propertyKey: string) {
71
- const columnOptions: ColumnOptions = {
72
- type: 'simple-array', // TypeORM handles this
73
- ...options,
74
- };
75
-
76
- return Column(columnOptions)(target, propertyKey);
77
- };
78
- }
79
-
80
- /**
81
- * Create timestamp column with database-appropriate type
82
- *
83
- * @param options - Additional column options
84
- * @returns Column decorator
85
- */
86
- export function TimestampColumn(options?: Partial<ColumnOptions>) {
87
- return function (target: Record<string, unknown>, propertyKey: string) {
88
- const columnOptions: ColumnOptions = {
89
- type: 'timestamp',
90
- ...options,
91
- };
92
-
93
- return Column(columnOptions)(target, propertyKey);
94
- };
95
- }
96
-
97
- /**
98
- * Create boolean column with database-appropriate type
99
- *
100
- * @param options - Additional column options
101
- * @returns Column decorator
102
- */
103
- export function BooleanColumn(options?: Partial<ColumnOptions>) {
104
- return function (target: Record<string, unknown>, propertyKey: string) {
105
- const columnOptions: ColumnOptions = {
106
- type: 'boolean',
107
- ...options,
108
- };
109
-
110
- return Column(columnOptions)(target, propertyKey);
111
- };
112
- }
113
-
114
- /**
115
- * Create integer column with database-appropriate type
116
- *
117
- * @param options - Additional column options
118
- * @returns Column decorator
119
- */
120
- export function IntegerColumn(options?: Partial<ColumnOptions>) {
121
- return function (target: Record<string, unknown>, propertyKey: string) {
122
- const columnOptions: ColumnOptions = {
123
- type: 'int',
124
- ...options,
125
- };
126
-
127
- return Column(columnOptions)(target, propertyKey);
128
- };
129
- }
130
-
131
- /**
132
- * Create varchar column with database-appropriate type
133
- *
134
- * @param length - Maximum length
135
- * @param options - Additional column options
136
- * @returns Column decorator
137
- */
138
- export function VarcharColumn(length: number, options?: Partial<ColumnOptions>) {
139
- return function (target: Record<string, unknown>, propertyKey: string) {
140
- const columnOptions: ColumnOptions = {
141
- type: 'varchar',
142
- length,
143
- ...options,
144
- };
145
-
146
- return Column(columnOptions)(target, propertyKey);
147
- };
148
- }
149
-
150
- /**
151
- * Create text column with database-appropriate type
152
- *
153
- * @param options - Additional column options
154
- * @returns Column decorator
155
- */
156
- export function TextColumn(options?: Partial<ColumnOptions>) {
157
- return function (target: Record<string, unknown>, propertyKey: string) {
158
- const columnOptions: ColumnOptions = {
159
- type: 'text',
160
- ...options,
161
- };
162
-
163
- return Column(columnOptions)(target, propertyKey);
164
- };
165
- }