( oldCookieHash: string, newSealedSession: string, )
| 18 | * Store a refreshed session keyed by the hash of the old cookie. |
| 19 | */ |
| 20 | export async function storeRefreshedSession( |
| 21 | oldCookieHash: string, |
| 22 | newSealedSession: string, |
| 23 | ): Promise<void> { |
| 24 | if (!isDatabaseInitialized()) return; |
| 25 | const expiresAt = new Date(Date.now() + REFRESH_TTL_MS); |
| 26 | try { |
| 27 | await query( |
| 28 | `INSERT INTO session_refreshes (old_cookie_hash, new_sealed_session, expires_at) |
| 29 | VALUES ($1, $2, $3) |
| 30 | ON CONFLICT (old_cookie_hash) DO UPDATE SET |
| 31 | new_sealed_session = EXCLUDED.new_sealed_session, |
| 32 | expires_at = EXCLUDED.expires_at`, |
| 33 | [oldCookieHash, newSealedSession, expiresAt], |
| 34 | ); |
| 35 | } catch (err) { |
| 36 | logger.warn({ err }, 'Failed to store refreshed session'); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Look up a refreshed session by the hash of the old cookie. |
no test coverage detected