feat: add security activity and trusted devices management to settings page

This commit is contained in:
Usman Baig
2026-02-28 19:58:49 +01:00
parent c4e95268fe
commit 7053cf5d5e
5 changed files with 507 additions and 6 deletions

28
lib/api/activity.ts Normal file
View File

@@ -0,0 +1,28 @@
import apiRequest from './client'
export interface AuditLogEntry {
id: string
created_at: string
event_type: string
outcome: string
ip_address?: string
user_agent?: string
metadata?: Record<string, string>
}
export interface ActivityResponse {
entries: AuditLogEntry[] | null
total_count: number
has_more: boolean
limit: number
offset: number
}
export async function getUserActivity(
limit = 20,
offset = 0
): Promise<ActivityResponse> {
return apiRequest<ActivityResponse>(
`/auth/user/activity?limit=${limit}&offset=${offset}`
)
}

19
lib/api/devices.ts Normal file
View File

@@ -0,0 +1,19 @@
import apiRequest from './client'
export interface TrustedDevice {
id: string
display_hint: string
first_seen_at: string
last_seen_at: string
is_current: boolean
}
export async function getUserDevices(): Promise<{ devices: TrustedDevice[] }> {
return apiRequest<{ devices: TrustedDevice[] }>('/auth/user/devices')
}
export async function removeDevice(deviceId: string): Promise<void> {
return apiRequest<void>(`/auth/user/devices/${deviceId}`, {
method: 'DELETE',
})
}