diff --git a/keyserver/src/session/cookies.js b/keyserver/src/session/cookies.js --- a/keyserver/src/session/cookies.js +++ b/keyserver/src/session/cookies.js @@ -806,6 +806,26 @@ await dbQuery(query); } +// Returns `true` if row with `id = cookieID` exists AND +// `signed_identity_keys` is `NULL`. Otherwise, returns `false`. +async function isCookieMissingSignedIdentityKeysBlob( + cookieID: string, +): Promise { + const query = SQL` + SELECT signed_identity_keys + FROM cookies + WHERE id = ${cookieID} + `; + const [queryResult] = await dbQuery(query); + if ( + queryResult.length === 1 && + queryResult[0].signed_identity_keys === null + ) { + return true; + } + return false; +} + async function setCookiePlatform( viewer: Viewer, platform: Platform, @@ -854,6 +874,7 @@ addCookieToJSONResponse, addCookieToHomeResponse, setCookieSignedIdentityKeysBlob, + isCookieMissingSignedIdentityKeysBlob, setCookiePlatform, setCookiePlatformDetails, };