diff --git a/keyserver/src/socket/socket.js b/keyserver/src/socket/socket.js --- a/keyserver/src/socket/socket.js +++ b/keyserver/src/socket/socket.js @@ -17,10 +17,7 @@ import { mostRecentUpdateTimestamp } from 'lib/shared/update-utils.js'; import { hasMinCodeVersion } from 'lib/shared/version-utils.js'; import { endpointIsSocketSafe } from 'lib/types/endpoints.js'; -import { - type RawEntryInfo, - calendarQueryValidator, -} from 'lib/types/entry-types.js'; +import type { RawEntryInfo } from 'lib/types/entry-types.js'; import { defaultNumberPerThread } from 'lib/types/message-types.js'; import { redisMessageTypes, type RedisMessage } from 'lib/types/redis-types.js'; import { @@ -30,6 +27,7 @@ import { sessionCheckFrequency, stateCheckInactivityActivationInterval, + sessionStateValidator, } from 'lib/types/session-types.js'; import { type ClientSocketMessage, @@ -106,12 +104,7 @@ cookie: t.maybe(tCookie), sessionID: t.maybe(t.String), }), - sessionState: tShape({ - calendarQuery: calendarQueryValidator, - messagesCurrentAsOf: t.Number, - updatesCurrentAsOf: t.Number, - watchedIDs: t.list(t.String), - }), + sessionState: sessionStateValidator, clientResponses: t.list(clientResponseInputValidator), }), }), diff --git a/lib/types/session-types.js b/lib/types/session-types.js --- a/lib/types/session-types.js +++ b/lib/types/session-types.js @@ -1,13 +1,16 @@ // @flow +import t, { type TInterface } from 'tcomb'; + import type { AuthActionSource } from './account-types.js'; -import type { CalendarQuery } from './entry-types.js'; +import { type CalendarQuery, calendarQueryValidator } from './entry-types.js'; import type { MixedRawThreadInfos } from './thread-types.js'; import { type UserInfo, type CurrentUserInfo, type LoggedOutUserInfo, } from './user-types.js'; +import { tShape } from '../utils/validation-utils.js'; export const cookieLifetime = 30 * 24 * 60 * 60 * 1000; // in milliseconds // Interval the server waits after a state check before starting a new one @@ -95,12 +98,19 @@ }; export type SessionState = { - calendarQuery: CalendarQuery, - messagesCurrentAsOf: number, - updatesCurrentAsOf: number, - watchedIDs: $ReadOnlyArray, + +calendarQuery: CalendarQuery, + +messagesCurrentAsOf: number, + +updatesCurrentAsOf: number, + +watchedIDs: $ReadOnlyArray, }; +export const sessionStateValidator: TInterface = tShape({ + calendarQuery: calendarQueryValidator, + messagesCurrentAsOf: t.Number, + updatesCurrentAsOf: t.Number, + watchedIDs: t.list(t.String), +}); + export type SessionIdentification = Partial<{ cookie: ?string, sessionID: ?string,