This repository has no description
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879// SPDX-License-Identifier: AGPL-3.0-or-later
import type {UserID} from '../BrandedTypes';import type {AuthSessionRow, AuthSessionTombstoneRow} from '../database/types/AuthTypes';
export class AuthSession { readonly userId: UserID; readonly sessionIdHash: Buffer; readonly createdAt: Date; readonly approximateLastUsedAt: Date; readonly clientIp: string; readonly clientUserAgent: string | null; readonly clientIsDesktop: boolean | null; readonly clientOs?: string | null; readonly clientPlatform?: string | null; readonly clientCountry: string | null; readonly version: number;
constructor(row: AuthSessionRow) { this.userId = row.user_id; this.sessionIdHash = row.session_id_hash; this.createdAt = row.created_at; this.approximateLastUsedAt = row.approx_last_used_at; this.clientIp = row.client_ip; this.clientUserAgent = row.client_user_agent ?? null; this.clientIsDesktop = row.client_is_desktop ?? null; this.clientOs = row.client_os ?? null; this.clientPlatform = row.client_platform ?? null; this.clientCountry = row.client_country ?? null; this.version = row.version; }
toRow(): AuthSessionRow { return { user_id: this.userId, session_id_hash: this.sessionIdHash, created_at: this.createdAt, approx_last_used_at: this.approximateLastUsedAt, client_ip: this.clientIp, client_user_agent: this.clientUserAgent, client_is_desktop: this.clientIsDesktop, client_os: this.clientOs, client_platform: this.clientPlatform, client_country: this.clientCountry, version: this.version, }; }}
export class AuthSessionTombstone { readonly userId: UserID; readonly sessionIdHash: Buffer; readonly createdAt: Date; readonly approximateLastUsedAt: Date; readonly clientIp: string; readonly clientUserAgent: string | null; readonly clientIsDesktop: boolean | null; readonly clientOs?: string | null; readonly clientPlatform?: string | null; readonly clientCountry: string | null; readonly deletedAt: Date; readonly version: number;
constructor(row: AuthSessionTombstoneRow) { this.userId = row.user_id; this.sessionIdHash = row.session_id_hash; this.createdAt = row.created_at; this.approximateLastUsedAt = row.approx_last_used_at; this.clientIp = row.client_ip; this.clientUserAgent = row.client_user_agent ?? null; this.clientIsDesktop = row.client_is_desktop ?? null; this.clientOs = row.client_os ?? null; this.clientPlatform = row.client_platform ?? null; this.clientCountry = row.client_country ?? null; this.deletedAt = row.deleted_at; this.version = row.version; }}