@fonderie/auth 5.1.0 → 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 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` |
@@ -118,6 +118,30 @@ interface IUserDTO {
118
118
 
119
119
  function toUserDTO(user: IUser, phoneVerified?: boolean): IUserDTO
120
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
+
121
145
  function validate(schema: IRequestSchema): Middleware
122
146
 
123
147
  namespace schemas — exports: ChangePasswordInput, LoginInput, RegisterInput, ResetPasswordInput, changePasswordSchema, forgotPasswordSchema, loginSchema, mfaTokenSchema, refreshSchema, registerSchema, resetPasswordSchema, updateEmailSchema, updatePhoneSchema, updatePreferencesSchema, updateProfileSchema, verifySchema