(
sessionPath: string,
email: string,
isMobile: boolean,
maxAgeMs?: number
)
| 51 | } |
| 52 | |
| 53 | export function loadSession( |
| 54 | sessionPath: string, |
| 55 | email: string, |
| 56 | isMobile: boolean, |
| 57 | maxAgeMs?: number |
| 58 | ): LoadedSession | null { |
| 59 | const row = getDb(sessionPath) |
| 60 | .prepare('SELECT storage_state, fingerprint, updated_at FROM sessions WHERE email = ? AND platform = ?') |
| 61 | .get(email, platformOf(isMobile)) as SessionRow | undefined |
| 62 | |
| 63 | if (!row) return null |
| 64 | |
| 65 | if (maxAgeMs && Date.now() - row.updated_at > maxAgeMs) { |
| 66 | return null |
| 67 | } |
| 68 | |
| 69 | return { |
| 70 | storageState: row.storage_state ? (JSON.parse(row.storage_state) as StorageState) : null, |
| 71 | fingerprint: row.fingerprint ? (JSON.parse(row.fingerprint) as BrowserFingerprintWithHeaders) : null, |
| 72 | updatedAt: row.updated_at |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | export function saveStorageState( |
| 77 | sessionPath: string, |
no test coverage detected