MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / storeRefreshedSession

Function storeRefreshedSession

server/src/db/session-refresh-db.ts:20–38  ·  view source on GitHub ↗
(
  oldCookieHash: string,
  newSealedSession: string,
)

Source from the content-addressed store, hash-verified

18 * Store a refreshed session keyed by the hash of the old cookie.
19 */
20export 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.

Callers 2

requireAuthFunction · 0.85
optionalAuthFunction · 0.85

Calls 4

isDatabaseInitializedFunction · 0.85
queryFunction · 0.85
nowMethod · 0.80
warnMethod · 0.80

Tested by

no test coverage detected