@fonderie/auth 5.0.4 → 5.2.0
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/brain/outcomes.md +18 -0
- package/brain/signatures.md +26 -0
- package/dist/index.cjs +476 -62
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +71 -3
- package/dist/index.d.ts +71 -3
- package/dist/index.js +426 -13
- package/dist/index.js.map +1 -1
- package/dist/middlewares/index.cjs +50 -5
- package/dist/middlewares/index.cjs.map +1 -1
- package/dist/middlewares/index.d.cts +1 -1
- package/dist/middlewares/index.d.ts +1 -1
- package/dist/middlewares/index.js +50 -5
- package/dist/middlewares/index.js.map +1 -1
- package/dist/migrations/sql/014_login_events.sql +19 -0
- package/dist/{session-CTSCI09F.d.cts → session-DJNd1xp_.d.cts} +1 -1
- package/dist/{session-CTSCI09F.d.ts → session-DJNd1xp_.d.ts} +1 -1
- package/package.json +1 -1
package/brain/outcomes.md
CHANGED
|
@@ -19,6 +19,20 @@ created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
|
19
19
|
PRIMARY KEY (user_id)
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
+
### `fonderie_login_events`
|
|
23
|
+
|
|
24
|
+
```sql
|
|
25
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid()
|
|
26
|
+
user_id UUID REFERENCES fonderie_users(id) ON DELETE CASCADE
|
|
27
|
+
email_attempted TEXT
|
|
28
|
+
method TEXT NOT NULL
|
|
29
|
+
outcome TEXT NOT NULL
|
|
30
|
+
failure_reason TEXT
|
|
31
|
+
ip_address TEXT
|
|
32
|
+
user_agent TEXT
|
|
33
|
+
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
|
34
|
+
```
|
|
35
|
+
|
|
22
36
|
### `fonderie_mfa_backup_codes`
|
|
23
37
|
|
|
24
38
|
```sql
|
|
@@ -119,6 +133,7 @@ Raw SQL ships in `node_modules/@fonderie/auth/dist/migrations/sql/` — read it
|
|
|
119
133
|
| GET | `/auth/google` | `oauth.googleInit` |
|
|
120
134
|
| GET | `/auth/google/callback` | `oauth.googleCallback` |
|
|
121
135
|
| POST | `/auth/login` | `ipLimit('login') → validate(loginSchema) → acctLimit('login') → auth.login` |
|
|
136
|
+
| GET | `/auth/login-history` | `requireAuth → user.loginHistory` |
|
|
122
137
|
| POST | `/auth/logout` | `requireAuth → validate(refreshSchema) → auth.logout` |
|
|
123
138
|
| POST | `/auth/mfa/backup-codes` | `requireAuth → requireEmailLogin → requireVerified → validate(mfaTokenSchema) → mfa.regenerateBackupCodes` |
|
|
124
139
|
| POST | `/auth/mfa/disable` | `requireAuth → requireEmailLogin → requireVerified → validate(mfaTokenSchema) → mfa.disable` |
|
|
@@ -127,6 +142,9 @@ Raw SQL ships in `node_modules/@fonderie/auth/dist/migrations/sql/` — read it
|
|
|
127
142
|
| POST | `/auth/refresh` | `validate(refreshSchema) → auth.refresh` |
|
|
128
143
|
| POST | `/auth/register` | `ipLimit('register') → validate(registerSchema) → auth.register` |
|
|
129
144
|
| GET | `/auth/send-verification` | `requireAuth → auth.sendVerification` |
|
|
145
|
+
| GET | `/auth/sessions` | `requireAuth → user.listSessions` |
|
|
146
|
+
| DELETE | `/auth/sessions/:id` | `requireAuth → user.terminateSession` |
|
|
147
|
+
| DELETE | `/auth/sessions/others` | `requireAuth → user.terminateOtherSessions` |
|
|
130
148
|
| POST | `/auth/verify` | `requireAuth → validate(verifySchema) → auth.verify` |
|
|
131
149
|
| DELETE | `/users` | `requireAuth → verifyGate → user.deleteMe` |
|
|
132
150
|
| GET | `/users` | `requireAuth → user.me` |
|
package/brain/signatures.md
CHANGED
|
@@ -94,6 +94,8 @@ const MESSAGE_KEYS: { readonly emailRegistration: "email-registration"; readonly
|
|
|
94
94
|
|
|
95
95
|
type AuthMessageKey = (typeof MESSAGE_KEYS)[keyof typeof MESSAGE_KEYS];
|
|
96
96
|
|
|
97
|
+
const DEFAULT_TEMPLATES: { "email-registration": { subject: string; html: string; text: string; }; "email-verification": { subject: string; html: string; text: string; }; "password-reset": { subject: string; html: string; text: string; }; "phone-otp": { text: string; }; "mfa-enabled": { subject: string; html: string; text: string; }; "mfa-disabled": { subject: string; html: string; text: string; }; "mfa-backup-codes-regenerated": { subject: string; html: string; text: string; }; "email-changed": { subject: string; html: string; text: string; }; "phone-changed": { subject: string; html: string; text: string; }; }
|
|
98
|
+
|
|
97
99
|
interface IUserDTO {
|
|
98
100
|
id: string;
|
|
99
101
|
email: string;
|
|
@@ -116,6 +118,30 @@ interface IUserDTO {
|
|
|
116
118
|
|
|
117
119
|
function toUserDTO(user: IUser, phoneVerified?: boolean): IUserDTO
|
|
118
120
|
|
|
121
|
+
interface ILoginEventDTO {
|
|
122
|
+
id: string;
|
|
123
|
+
method: string;
|
|
124
|
+
outcome: string;
|
|
125
|
+
failureReason: string | null;
|
|
126
|
+
ipAddress: string | null;
|
|
127
|
+
userAgent: string | null;
|
|
128
|
+
createdAt: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
interface ILoginHistoryPageDTO {
|
|
132
|
+
events: ILoginEventDTO[];
|
|
133
|
+
nextCursor: string | null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
interface ISessionDTO {
|
|
137
|
+
id: string;
|
|
138
|
+
current: boolean;
|
|
139
|
+
ipAddress: string | null;
|
|
140
|
+
userAgent: string | null;
|
|
141
|
+
createdAt: string;
|
|
142
|
+
expiresAt: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
119
145
|
function validate(schema: IRequestSchema): Middleware
|
|
120
146
|
|
|
121
147
|
namespace schemas — exports: ChangePasswordInput, LoginInput, RegisterInput, ResetPasswordInput, changePasswordSchema, forgotPasswordSchema, loginSchema, mfaTokenSchema, refreshSchema, registerSchema, resetPasswordSchema, updateEmailSchema, updatePhoneSchema, updatePreferencesSchema, updateProfileSchema, verifySchema
|