Changeset View
Changeset View
Standalone View
Standalone View
keyserver/src/session/cookies.js
Show First 20 Lines • Show All 817 Lines • ▼ Show 20 Lines | const query = SQL` | ||||
WHERE id = ${cookieID} | WHERE id = ${cookieID} | ||||
`; | `; | ||||
const [queryResult] = await dbQuery(query); | const [queryResult] = await dbQuery(query); | ||||
return ( | return ( | ||||
queryResult.length === 1 && queryResult[0].signed_identity_keys === null | queryResult.length === 1 && queryResult[0].signed_identity_keys === null | ||||
); | ); | ||||
} | } | ||||
async function isCookieMissingOlmNotificationsSession( | |||||
viewer: Viewer, | |||||
): Promise<boolean> { | |||||
if ( | |||||
!viewer.platformDetails || | |||||
viewer.platformDetails.platform !== 'ios' || | |||||
!viewer.platformDetails.codeVersion || | |||||
viewer.platformDetails.codeVersion < 1000 | |||||
) { | |||||
return false; | |||||
} | |||||
const query = SQL` | |||||
SELECT * | |||||
FROM olm_sessions | |||||
WHERE cookie_id = ${viewer.cookieID} AND is_content = FALSE; | |||||
`; | |||||
const [queryResult] = await dbQuery(query); | |||||
return queryResult.length === 0; | |||||
} | |||||
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 35 Lines | export { | ||||
setNewSession, | setNewSession, | ||||
extendCookieLifespan, | extendCookieLifespan, | ||||
addCookieToJSONResponse, | addCookieToJSONResponse, | ||||
addCookieToHomeResponse, | addCookieToHomeResponse, | ||||
setCookieSignedIdentityKeysBlob, | setCookieSignedIdentityKeysBlob, | ||||
isCookieMissingSignedIdentityKeysBlob, | isCookieMissingSignedIdentityKeysBlob, | ||||
setCookiePlatform, | setCookiePlatform, | ||||
setCookiePlatformDetails, | setCookiePlatformDetails, | ||||
isCookieMissingOlmNotificationsSession, | |||||
}; | }; |