@rineex/auth-core 0.0.6 → 0.1.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.
- package/package.json +8 -4
- package/Architecture.md +0 -257
- package/CHANGELOG.md +0 -49
- package/Definition.md +0 -1490
- package/Develop.md +0 -0
- package/RULES.md +0 -1470
- package/eslint.config.mjs +0 -59
- package/src/application/mfa/events/challenge-issue-observability.event.ts +0 -18
- package/src/application/mfa/events/session-started-observability.event.ts +0 -18
- package/src/application/mfa/events/verification-failed-observability.event.ts +0 -14
- package/src/application/mfa/events/verification-succeeded-observibility.event.ts +0 -12
- package/src/application/mfa/issue-mfa-challenge.application-service.ts +0 -75
- package/src/application/mfa/start-mfa-session.application-service.ts +0 -90
- package/src/application/mfa/verify-mfa.application-service.ts +0 -61
- package/src/application/services/auth-orchestrator.service.ts +0 -77
- package/src/application/services/oauth-authorize.service.ts +0 -12
- package/src/domain/identity/aggregates/authentication-attempt.aggregate.ts +0 -136
- package/src/domain/identity/aggregates/index.ts +0 -1
- package/src/domain/identity/entities/identity.entity.ts +0 -126
- package/src/domain/identity/entities/index.ts +0 -1
- package/src/domain/identity/events/authentication-failed.event.ts +0 -24
- package/src/domain/identity/events/authentication-started.event.ts +0 -29
- package/src/domain/identity/events/authentication-succeeded.event.ts +0 -24
- package/src/domain/identity/events/index.ts +0 -3
- package/src/domain/identity/index.ts +0 -4
- package/src/domain/identity/value-objects/__tests__/auth-attempt-id.vo.spec.ts +0 -42
- package/src/domain/identity/value-objects/__tests__/auth-factor.vo.spec.ts +0 -39
- package/src/domain/identity/value-objects/__tests__/auth-method.vo.spec.ts +0 -0
- package/src/domain/identity/value-objects/auth-attempt-id.vo.ts +0 -23
- package/src/domain/identity/value-objects/auth-factor.vo.ts +0 -17
- package/src/domain/identity/value-objects/auth-method.vo.ts +0 -34
- package/src/domain/identity/value-objects/auth-policy.vo.ts +0 -19
- package/src/domain/identity/value-objects/auth-status.vo.ts +0 -38
- package/src/domain/identity/value-objects/identity-id.vo.ts +0 -26
- package/src/domain/identity/value-objects/identity-provider.vo.ts +0 -13
- package/src/domain/identity/value-objects/index.ts +0 -8
- package/src/domain/identity/value-objects/risk-signal.vo.ts +0 -17
- package/src/domain/index.ts +0 -5
- package/src/domain/mfa/aggregates/mfa-session.aggregate.ts +0 -84
- package/src/domain/mfa/entities/mfa-challenge.entity.ts +0 -70
- package/src/domain/mfa/types/mfa-challenge-registry.ts +0 -21
- package/src/domain/mfa/value-objects/mfa-challenge-id.vo.ts +0 -19
- package/src/domain/mfa/value-objects/mfa-challenge-status.vo.ts +0 -31
- package/src/domain/mfa/value-objects/mfa-session-id.vo.ts +0 -19
- package/src/domain/mfa/violations/mfa-active-challenge-exists.violation.ts +0 -10
- package/src/domain/mfa/violations/mfa-already-verified.violation.ts +0 -10
- package/src/domain/mfa/violations/mfa-attempts-exceeded.violation.ts +0 -17
- package/src/domain/mfa/violations/mfa-expired.violation.ts +0 -10
- package/src/domain/oauth/aggregates/oauth-authorization.aggregate.ts +0 -106
- package/src/domain/oauth/aggregates/oauth-authorize.service.ts +0 -0
- package/src/domain/oauth/entities/oauth-authorization.entity.ts +0 -50
- package/src/domain/oauth/value-objects/authorization-code-id.vo.ts +0 -9
- package/src/domain/oauth/value-objects/authorization-code.vo.ts +0 -18
- package/src/domain/oauth/value-objects/client-id.vo.ts +0 -9
- package/src/domain/oauth/value-objects/code-challenge-method.vo.ts +0 -15
- package/src/domain/oauth/value-objects/code-challenge.vo.ts +0 -24
- package/src/domain/oauth/value-objects/oauth-authorization-id.vo.ts +0 -19
- package/src/domain/oauth/value-objects/oauth-provider.vo.ts +0 -15
- package/src/domain/oauth/value-objects/pkce.vo.ts +0 -29
- package/src/domain/oauth/value-objects/redirect-uri.vo.ts +0 -19
- package/src/domain/oauth/value-objects/scope-set.vo.ts +0 -37
- package/src/domain/oauth/violations/authorization-already-used.violation.ts +0 -10
- package/src/domain/oauth/violations/authorization-expired.violation.ts +0 -10
- package/src/domain/oauth/violations/consent-required.violation.ts +0 -10
- package/src/domain/oauth/violations/invalid-authorization-code.violation.ts +0 -12
- package/src/domain/oauth/violations/invalid-oauth-provider.violation.ts +0 -13
- package/src/domain/oauth/violations/invalid-pkce.violation.ts +0 -12
- package/src/domain/oauth/violations/invalid-redirect-uri.violation.ts +0 -10
- package/src/domain/policy/contracts/auth-policy-context.ts +0 -27
- package/src/domain/policy/contracts/auth-policy-decision.ts +0 -7
- package/src/domain/policy/contracts/auth-policy.ts +0 -17
- package/src/domain/policy/contracts/index.ts +0 -3
- package/src/domain/policy/engine/auth-policy-engine.ts +0 -41
- package/src/domain/policy/index.ts +0 -2
- package/src/domain/session/entities/session.entity.ts +0 -82
- package/src/domain/session/value-objects/session-id.vo.ts +0 -10
- package/src/domain/token/aggregates/token.aggregate.ts +0 -34
- package/src/domain/token/value-objects/auth-token.vo.ts +0 -29
- package/src/domain/token/value-objects/session-token.vo.ts +0 -14
- package/src/domain/violations/auth-domain.violation.ts +0 -9
- package/src/domain/violations/invalid-auth-token.violation.ts +0 -13
- package/src/domain/violations/invalid-scope.violation.ts +0 -10
- package/src/domain/violations/invalid-session.violation.ts +0 -13
- package/src/index.ts +0 -3
- package/src/ports/inbound/auth-method.port.ts +0 -18
- package/src/ports/inbound/index.ts +0 -2
- package/src/ports/inbound/start-auth.command.ts +0 -28
- package/src/ports/index.ts +0 -2
- package/src/ports/log/log.port.ts +0 -25
- package/src/ports/mfa/mfa-clock.port.ts +0 -11
- package/src/ports/mfa/mfa-session-id-generator.port.ts +0 -15
- package/src/ports/mfa/mfa-session-repository.port.ts +0 -31
- package/src/ports/observability/observability-event.port.ts +0 -16
- package/src/ports/outbound/authentication-attempt.repository.port.ts +0 -11
- package/src/ports/outbound/domain-event-publisher.port.ts +0 -13
- package/src/ports/outbound/index.ts +0 -2
- package/src/ports/outbound/session.repository.port.ts +0 -9
- package/src/ports/repositories/oauth-authorization.repository.ts +0 -21
- package/src/ports/repositories/token.repository.ts +0 -11
- package/src/types/auth-context.type.ts +0 -11
- package/src/types/auth-factor.type.ts +0 -10
- package/src/types/auth-method.type.ts +0 -20
- package/src/types/auth-policy.type.ts +0 -16
- package/src/types/identity-provider.type.ts +0 -8
- package/src/types/index.ts +0 -6
- package/src/types/observability-event.ts +0 -33
- package/src/types/risk-signal.type.ts +0 -11
- package/src/utils/default-if-blank.util.ts +0 -46
- package/tsconfig.build.json +0 -6
- package/tsconfig.json +0 -28
- package/tsup.config.ts +0 -13
- package/vitest.config.ts +0 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rineex/auth-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Authentication Core package for Rineex core modules",
|
|
5
5
|
"author": "Rineex Team",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"passwordless",
|
|
16
16
|
"sso"
|
|
17
17
|
],
|
|
18
|
+
"files": [
|
|
19
|
+
"dist/**"
|
|
20
|
+
],
|
|
18
21
|
"publishConfig": {
|
|
19
22
|
"provenance": true,
|
|
20
23
|
"access": "public",
|
|
@@ -32,19 +35,20 @@
|
|
|
32
35
|
"typescript": "5.9.3",
|
|
33
36
|
"vite-tsconfig-paths": "6.0.2",
|
|
34
37
|
"vitest": "4.0.16",
|
|
35
|
-
"@rineex/eslint-config": "0.0.
|
|
36
|
-
"@rineex/typescript-config": "0.0.
|
|
38
|
+
"@rineex/eslint-config": "0.0.1",
|
|
39
|
+
"@rineex/typescript-config": "0.0.1"
|
|
37
40
|
},
|
|
38
41
|
"repository": {
|
|
39
42
|
"type": "git",
|
|
40
43
|
"url": "https://github.com/rineex/core.git",
|
|
41
44
|
"directory": "packages/authentication/core"
|
|
42
45
|
},
|
|
46
|
+
"homepage": "https://github.com/rineex/core/tree/main/packages/authentication/core",
|
|
43
47
|
"license": "Apache-2.0",
|
|
44
48
|
"dependencies": {
|
|
45
49
|
"lodash.isempty": "4.4.0",
|
|
46
50
|
"lodash.isnil": "4.0.0",
|
|
47
|
-
"@rineex/ddd": "2.
|
|
51
|
+
"@rineex/ddd": "2.1.0"
|
|
48
52
|
},
|
|
49
53
|
"scripts": {
|
|
50
54
|
"test": "vitest run --passWithNoTests",
|
package/Architecture.md
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
# Auth Core — Domain Foundations (DDD + Hexagonal)
|
|
2
|
-
|
|
3
|
-
## 1. Purpose
|
|
4
|
-
|
|
5
|
-
Design a **framework-agnostic, storage-agnostic authentication core** that:
|
|
6
|
-
|
|
7
|
-
- Works with **zero customization**
|
|
8
|
-
- Supports **incremental auth methods**
|
|
9
|
-
- Is suitable for **enterprise and simple products**
|
|
10
|
-
- Is extensible without modifying existing domain code
|
|
11
|
-
- Is independent of HTTP, DB, tokens, providers, or frameworks
|
|
12
|
-
|
|
13
|
-
This module defines **what authentication is**, not **how it is transported or
|
|
14
|
-
stored**.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## 2. Architectural Constraints (Hard Rules)
|
|
19
|
-
|
|
20
|
-
These rules must never be violated:
|
|
21
|
-
|
|
22
|
-
1. Authentication is **not identity**
|
|
23
|
-
2. Authentication methods are **plugins**
|
|
24
|
-
3. Authentication flows are **data-driven**
|
|
25
|
-
4. Infrastructure choices are **external**
|
|
26
|
-
5. Domain owns **rules and invariants only**
|
|
27
|
-
6. No provider, protocol, or framework knowledge in domain
|
|
28
|
-
7. No auth method may require changing existing aggregates
|
|
29
|
-
|
|
30
|
-
If a new auth method breaks a rule → architecture is wrong.
|
|
31
|
-
|
|
32
|
-
---
|
|
33
|
-
|
|
34
|
-
## 3. Bounded Context
|
|
35
|
-
|
|
36
|
-
### Authentication Context (this module)
|
|
37
|
-
|
|
38
|
-
Responsibilities:
|
|
39
|
-
|
|
40
|
-
- Verifying proof of access
|
|
41
|
-
- Orchestrating authentication flows
|
|
42
|
-
- Enforcing policies
|
|
43
|
-
- Producing authenticated sessions
|
|
44
|
-
|
|
45
|
-
Non-responsibilities:
|
|
46
|
-
|
|
47
|
-
- User profile management
|
|
48
|
-
- Authorization / permissions
|
|
49
|
-
- HTTP handling
|
|
50
|
-
- UI flows
|
|
51
|
-
- Token formats
|
|
52
|
-
- Database schemas
|
|
53
|
-
|
|
54
|
-
---
|
|
55
|
-
|
|
56
|
-
## 4. Ubiquitous Language (Canonical)
|
|
57
|
-
|
|
58
|
-
These terms have **single meanings** and must not be overloaded:
|
|
59
|
-
|
|
60
|
-
| Term | Meaning |
|
|
61
|
-
| ------------ | ----------------------------------------------- |
|
|
62
|
-
| Principal | Any actor that can authenticate |
|
|
63
|
-
| Credential | Authentication material owned by a principal |
|
|
64
|
-
| Auth Factor | Category of proof (knowledge, possession, etc.) |
|
|
65
|
-
| Auth Method | Concrete mechanism (password, otp, oauth, …) |
|
|
66
|
-
| Auth Attempt | One authentication execution |
|
|
67
|
-
| Auth Flow | Orchestration rules |
|
|
68
|
-
| Auth Policy | Constraints and conditions |
|
|
69
|
-
| Auth Proof | Verifiable evidence |
|
|
70
|
-
| Auth Result | Outcome of authentication |
|
|
71
|
-
| Session | Post-auth continuity |
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## 5. Core Domain Aggregates
|
|
76
|
-
|
|
77
|
-
### 5.1 Principal (Aggregate Root)
|
|
78
|
-
|
|
79
|
-
Represents **who or what** is authenticating.
|
|
80
|
-
|
|
81
|
-
**Key rules**
|
|
82
|
-
|
|
83
|
-
- Can exist without credentials
|
|
84
|
-
- Can represent humans, services, or devices
|
|
85
|
-
- Is auth-method agnostic
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
### 5.2 Credential (Entity)
|
|
90
|
-
|
|
91
|
-
Represents **what the principal owns** to authenticate.
|
|
92
|
-
|
|
93
|
-
**Key rules**
|
|
94
|
-
|
|
95
|
-
- Domain never stores secrets
|
|
96
|
-
- Lifecycle is domain-controlled
|
|
97
|
-
- Verification is delegated to infrastructure
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
### 5.3 AuthenticationAttempt (Aggregate Root)
|
|
102
|
-
|
|
103
|
-
Represents **one authentication process**.
|
|
104
|
-
|
|
105
|
-
**Why it exists**
|
|
106
|
-
|
|
107
|
-
- Prevents replay
|
|
108
|
-
- Supports MFA and step-up
|
|
109
|
-
- Enables audit and risk evaluation
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
### 5.4 AuthenticationSession (Aggregate Root)
|
|
114
|
-
|
|
115
|
-
Represents **authenticated continuity**.
|
|
116
|
-
|
|
117
|
-
**Key rules**
|
|
118
|
-
|
|
119
|
-
- Created only after successful authentication
|
|
120
|
-
- Stateless vs stateful is infrastructure choice
|
|
121
|
-
- Trust level is domain-owned
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## 6. Value Objects (Core Concepts)
|
|
126
|
-
|
|
127
|
-
Value Objects define meaning, not storage:
|
|
128
|
-
|
|
129
|
-
- AuthMethodType
|
|
130
|
-
- AuthFactorType
|
|
131
|
-
- AuthProof
|
|
132
|
-
- TrustLevel
|
|
133
|
-
- RiskScore
|
|
134
|
-
- Challenge
|
|
135
|
-
- ContextSnapshot
|
|
136
|
-
|
|
137
|
-
Auth factors are **categories**, not implementations:
|
|
138
|
-
|
|
139
|
-
- Knowledge
|
|
140
|
-
- Possession
|
|
141
|
-
- Inherence
|
|
142
|
-
- Delegated
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
## 7. Authentication Methods (Extensibility Model)
|
|
147
|
-
|
|
148
|
-
Authentication methods are **not services** and **not branches**.
|
|
149
|
-
|
|
150
|
-
They are **capabilities described by data**.
|
|
151
|
-
|
|
152
|
-
An Auth Method defines:
|
|
153
|
-
|
|
154
|
-
- Its identifier
|
|
155
|
-
- Supported factors
|
|
156
|
-
- Required inputs
|
|
157
|
-
- Output proof type
|
|
158
|
-
|
|
159
|
-
The domain:
|
|
160
|
-
|
|
161
|
-
- Does not know _how_ a method works
|
|
162
|
-
- Does not know _who_ provides it
|
|
163
|
-
- Does not change when a method is added
|
|
164
|
-
|
|
165
|
-
---
|
|
166
|
-
|
|
167
|
-
## 8. Domain Services (Pure Logic)
|
|
168
|
-
|
|
169
|
-
### Authentication Orchestrator
|
|
170
|
-
|
|
171
|
-
Coordinates attempts, proofs, and policies.
|
|
172
|
-
|
|
173
|
-
### Policy Evaluator
|
|
174
|
-
|
|
175
|
-
Decides:
|
|
176
|
-
|
|
177
|
-
- Whether authentication is allowed
|
|
178
|
-
- Whether step-up is required
|
|
179
|
-
- Which flow applies
|
|
180
|
-
|
|
181
|
-
No domain service:
|
|
182
|
-
|
|
183
|
-
- Talks to HTTP
|
|
184
|
-
- Knows about tokens
|
|
185
|
-
- Knows about databases
|
|
186
|
-
|
|
187
|
-
---
|
|
188
|
-
|
|
189
|
-
## 9. Hexagonal Ports (Boundaries)
|
|
190
|
-
|
|
191
|
-
### Persistence Ports
|
|
192
|
-
|
|
193
|
-
- PrincipalRepository
|
|
194
|
-
- CredentialRepository
|
|
195
|
-
- AuthenticationAttemptRepository
|
|
196
|
-
- AuthenticationSessionRepository
|
|
197
|
-
|
|
198
|
-
### Capability Ports
|
|
199
|
-
|
|
200
|
-
- AuthProofVerifier
|
|
201
|
-
- ChallengeIssuer
|
|
202
|
-
- RiskEvaluator
|
|
203
|
-
- TokenIssuer
|
|
204
|
-
|
|
205
|
-
Infrastructure implements ports. Domain only defines **contracts**.
|
|
206
|
-
|
|
207
|
-
---
|
|
208
|
-
|
|
209
|
-
## 10. Phase 1 Auth Methods (Initial Scope)
|
|
210
|
-
|
|
211
|
-
Start small, cover most use cases:
|
|
212
|
-
|
|
213
|
-
1. Password (compatibility)
|
|
214
|
-
2. Passwordless (email magic)
|
|
215
|
-
3. OTP (TOTP + Email)
|
|
216
|
-
4. OAuth2 / OIDC
|
|
217
|
-
5. Social Login
|
|
218
|
-
6. API Tokens (M2M)
|
|
219
|
-
|
|
220
|
-
Everything else is additive.
|
|
221
|
-
|
|
222
|
-
---
|
|
223
|
-
|
|
224
|
-
## 11. Explicit Non-Goals (For Now)
|
|
225
|
-
|
|
226
|
-
These are **intentionally excluded**:
|
|
227
|
-
|
|
228
|
-
- HTTP redirects
|
|
229
|
-
- Cookies and headers
|
|
230
|
-
- JWT structure
|
|
231
|
-
- OAuth provider SDKs
|
|
232
|
-
- UI workflows
|
|
233
|
-
- Database schemas
|
|
234
|
-
|
|
235
|
-
They belong to adapters, not the core.
|
|
236
|
-
|
|
237
|
-
---
|
|
238
|
-
|
|
239
|
-
## 12. Extensibility Guarantees
|
|
240
|
-
|
|
241
|
-
Before adding any auth feature, verify:
|
|
242
|
-
|
|
243
|
-
- No existing aggregate changes
|
|
244
|
-
- No domain branching
|
|
245
|
-
- No infrastructure assumptions
|
|
246
|
-
- No HTTP dependency
|
|
247
|
-
- Enabled via configuration or policy
|
|
248
|
-
|
|
249
|
-
Failing any → redesign first.
|
|
250
|
-
|
|
251
|
-
---
|
|
252
|
-
|
|
253
|
-
## 13. Document Status
|
|
254
|
-
|
|
255
|
-
- This document is **authoritative**
|
|
256
|
-
- Any implementation must conform to it
|
|
257
|
-
- Changes require architectural justification
|
package/CHANGELOG.md
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
# @rineex/auth-core
|
|
2
|
-
|
|
3
|
-
## 0.0.6
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- Updated dependencies
|
|
8
|
-
[[`200f30a`](https://github.com/rineex/core/commit/200f30aa61b341774f93c8ce0910be0c53f5e7f2),
|
|
9
|
-
[`54d43d0`](https://github.com/rineex/core/commit/54d43d0bda3d9ce13146eaaaf1b1aa21314823de)]:
|
|
10
|
-
- @rineex/ddd@2.0.0
|
|
11
|
-
|
|
12
|
-
## 0.0.5
|
|
13
|
-
|
|
14
|
-
### Patch Changes
|
|
15
|
-
|
|
16
|
-
- Updated dependencies
|
|
17
|
-
[[`94c732f`](https://github.com/rineex/core/commit/94c732fc529d269886216e63ac9d47605036fae4)]:
|
|
18
|
-
- @rineex/ddd@1.6.1
|
|
19
|
-
|
|
20
|
-
## 0.0.4
|
|
21
|
-
|
|
22
|
-
### Patch Changes
|
|
23
|
-
|
|
24
|
-
- Updated dependencies
|
|
25
|
-
[[`0fab4a2`](https://github.com/rineex/core/commit/0fab4a28f4b5b8af947f587448804115a2fd509c)]:
|
|
26
|
-
- @rineex/ddd@1.6.0
|
|
27
|
-
|
|
28
|
-
## 0.0.3
|
|
29
|
-
|
|
30
|
-
### Patch Changes
|
|
31
|
-
|
|
32
|
-
- Updated dependencies
|
|
33
|
-
[[`b1e8e3a`](https://github.com/rineex/core/commit/b1e8e3a4e02644118af82b8f068259d3e5bb2f24)]:
|
|
34
|
-
- @rineex/ddd@1.5.2
|
|
35
|
-
|
|
36
|
-
## 0.0.2
|
|
37
|
-
|
|
38
|
-
### Patch Changes
|
|
39
|
-
|
|
40
|
-
- Updated dependencies
|
|
41
|
-
[[`a347a2f`](https://github.com/rineex/core/commit/a347a2fbe9b1136c811f89a8ee4335bad13ca2ba)]:
|
|
42
|
-
- @rineex/ddd@1.5.2
|
|
43
|
-
|
|
44
|
-
## 0.0.1
|
|
45
|
-
|
|
46
|
-
### Patch Changes
|
|
47
|
-
|
|
48
|
-
- add initial documentation and modular structure for auth-core package
|
|
49
|
-
([`bc6f1fc`](https://github.com/rineex/core/commit/bc6f1fce44cf9138ae417eb3463d1748b433d65c))
|