Skip to main content

GetUserSessionsResponseDTO

Package: @nauth-toolkit/core Type: DTO (Response)

Response data transfer object containing all active sessions for a user.

import { GetUserSessionsResponseDTO } from '@nauth-toolkit/nestjs';

Properties

PropertyTypeRequiredDescription
sessionsUserSessionInfo[]YesArray of active sessions. Each session includes device info, location, auth method, and timestamps. Current session marked with isCurrent: true.

UserSessionInfo Properties

PropertyTypeRequiredDescription
sessionIdstringYesUnique session identifier.
deviceIdstringNoDevice identifier. Null if not available.
deviceNamestringNoDevice name (e.g., "iPhone 13", "Chrome on Windows"). Null if not available.
deviceTypestringNoDevice type (e.g., "mobile", "desktop", "tablet"). Null if not available.
platformstringNoPlatform (e.g., "iOS", "Android", "Windows", "macOS"). Null if not available.
browserstringNoBrowser name (e.g., "Chrome", "Safari", "Firefox"). Null if not available.
ipAddressstringNoIP address of the session. Null if not available.
ipCountrystringNoCountry derived from IP address. Null if not available.
ipCitystringNoCity derived from IP address. Null if not available.
lastActivityAtDateYesTimestamp of last activity for this session.
createdAtDateYesTimestamp when session was created.
expiresAtDateYesTimestamp when session expires.
isTrustedDevicebooleanYesWhether session is remembered (trusted device).
isCurrentbooleanYesWhether this is the current session (session making the request).
authMethodstringNoAuthentication method used. Examples: 'password', 'social', 'admin', 'admin-social'. Null if not available.
authProviderstringNoOAuth provider name (only for social logins). Examples: 'google', 'facebook', 'apple'. Null if not a social login or not available.

Example

{
"sessions": [
{
"sessionId": "123",
"deviceId": "device-uuid-123",
"deviceName": "iPhone 13",
"deviceType": "mobile",
"platform": "iOS",
"browser": "Safari",
"ipAddress": "192.168.1.1",
"ipCountry": "US",
"ipCity": "San Francisco",
"lastActivityAt": "2025-01-15T10:30:00.000Z",
"createdAt": "2025-01-10T08:00:00.000Z",
"expiresAt": "2025-01-17T08:00:00.000Z",
"isTrustedDevice": true,
"isCurrent": true,
"authMethod": "password",
"authProvider": null
},
{
"sessionId": "456",
"deviceName": "Chrome on Windows",
"deviceType": "desktop",
"platform": "Windows",
"browser": "Chrome",
"ipAddress": "192.168.1.2",
"ipCountry": "US",
"ipCity": "New York",
"lastActivityAt": "2025-01-14T15:20:00.000Z",
"createdAt": "2025-01-12T09:00:00.000Z",
"expiresAt": "2025-01-19T09:00:00.000Z",
"isTrustedDevice": false,
"deviceId": null,
"isCurrent": false,
"authMethod": "social",
"authProvider": "google"
}
]
}

Used By