Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/session/cookies.js
Show First 20 Lines • Show All 801 Lines • ▼ Show 20 Lines | ) { | ||||
const query = SQL` | const query = SQL` | ||||
UPDATE cookies | UPDATE cookies | ||||
SET signed_identity_keys = ${signedIdentityKeysStr} | SET signed_identity_keys = ${signedIdentityKeysStr} | ||||
WHERE id = ${cookieID} | WHERE id = ${cookieID} | ||||
`; | `; | ||||
await dbQuery(query); | 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<boolean> { | |||||
const query = SQL` | |||||
SELECT signed_identity_keys | |||||
FROM cookies | |||||
WHERE id = ${cookieID} | |||||
`; | |||||
const [queryResult] = await dbQuery(query); | |||||
return ( | |||||
queryResult.length === 1 && queryResult[0].signed_identity_keys === null | |||||
); | |||||
} | |||||
async function setCookiePlatform( | async function setCookiePlatform( | ||||
viewer: Viewer, | viewer: Viewer, | ||||
platform: Platform, | platform: Platform, | ||||
): Promise<void> { | ): Promise<void> { | ||||
const newPlatformDetails = { ...viewer.platformDetails, platform }; | const newPlatformDetails = { ...viewer.platformDetails, platform }; | ||||
viewer.setPlatformDetails(newPlatformDetails); | viewer.setPlatformDetails(newPlatformDetails); | ||||
const query = SQL` | const query = SQL` | ||||
UPDATE cookies | UPDATE cookies | ||||
Show All 32 Lines | export { | ||||
fetchViewerForSocket, | fetchViewerForSocket, | ||||
createNewAnonymousCookie, | createNewAnonymousCookie, | ||||
createNewUserCookie, | createNewUserCookie, | ||||
setNewSession, | setNewSession, | ||||
extendCookieLifespan, | extendCookieLifespan, | ||||
addCookieToJSONResponse, | addCookieToJSONResponse, | ||||
addCookieToHomeResponse, | addCookieToHomeResponse, | ||||
setCookieSignedIdentityKeysBlob, | setCookieSignedIdentityKeysBlob, | ||||
isCookieMissingSignedIdentityKeysBlob, | |||||
setCookiePlatform, | setCookiePlatform, | ||||
setCookiePlatformDetails, | setCookiePlatformDetails, | ||||
}; | }; |