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

Function getRefreshedSession

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

Source from the content-addressed store, hash-verified

42 * Returns the new sealed session if found and not expired, undefined otherwise.
43 */
44export async function getRefreshedSession(
45 oldCookieHash: string,
46): Promise<string | undefined> {
47 if (!isDatabaseInitialized()) return undefined;
48 try {
49 const result = await query(
50 `SELECT new_sealed_session FROM session_refreshes
51 WHERE old_cookie_hash = $1 AND expires_at > NOW()`,
52 [oldCookieHash],
53 );
54 if (result.rows.length > 0) {
55 return result.rows[0].new_sealed_session;
56 }
57 } catch (err) {
58 logger.warn({ err }, 'Failed to look up refreshed session');
59 }
60 return undefined;
61}
62
63/**
64 * Clean up expired entries. Called periodically.

Callers 2

requireAuthFunction · 0.85
optionalAuthFunction · 0.85

Calls 3

isDatabaseInitializedFunction · 0.85
queryFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected