diff --git a/keyserver/src/responders/user-responders.js b/keyserver/src/responders/user-responders.js --- a/keyserver/src/responders/user-responders.js +++ b/keyserver/src/responders/user-responders.js @@ -20,7 +20,7 @@ LogOutResponse, RegisterResponse, RegisterRequest, - LogInResponse, + ServerLogInResponse, LogInRequest, UpdatePasswordRequest, UpdateUserSettingsRequest, @@ -307,7 +307,7 @@ async function processSuccessfulLogin( params: ProcessSuccessfulLoginParams, -): Promise { +): Promise { const { viewer, input, @@ -424,7 +424,7 @@ ]); const rawEntryInfos = entriesResult ? entriesResult.rawEntryInfos : null; - const response: LogInResponse = { + const response: ServerLogInResponse = { currentUserInfo, rawMessageInfos: messagesResult.rawMessageInfos, truncationStatuses: messagesResult.truncationStatuses, @@ -461,8 +461,8 @@ initialNotificationsEncryptedMessage: t.maybe(t.String), }); -export const logInResponseValidator: TInterface = - tShape({ +export const logInResponseValidator: TInterface = + tShape({ currentUserInfo: loggedInUserInfoValidator, rawMessageInfos: t.list(rawMessageInfoValidator), truncationStatuses: messageTruncationStatusesValidator, @@ -479,7 +479,7 @@ async function logInResponder( viewer: Viewer, request: LogInRequest, -): Promise { +): Promise { let identityKeys: ?IdentityKeysBlob; const { signedIdentityKeysBlob, initialNotificationsEncryptedMessage } = request; @@ -568,7 +568,7 @@ async function siweAuthResponder( viewer: Viewer, request: SIWEAuthRequest, -): Promise { +): Promise { const { message, signature, @@ -715,7 +715,7 @@ async function keyserverAuthResponder( viewer: Viewer, request: KeyserverAuthRequest, -): Promise { +): Promise { const { userID, deviceID, @@ -833,7 +833,7 @@ async function oldPasswordUpdateResponder( viewer: Viewer, request: UpdatePasswordRequest, -): Promise { +): Promise { if (request.calendarQuery) { request.calendarQuery = normalizeCalendarQuery(request.calendarQuery); } diff --git a/keyserver/src/updaters/account-updaters.js b/keyserver/src/updaters/account-updaters.js --- a/keyserver/src/updaters/account-updaters.js +++ b/keyserver/src/updaters/account-updaters.js @@ -8,7 +8,7 @@ ResetPasswordRequest, UpdatePasswordRequest, UpdateUserSettingsRequest, - LogInResponse, + ServerLogInResponse, } from 'lib/types/account-types.js'; import type { ClientAvatar, @@ -98,7 +98,7 @@ async function updatePassword( viewer: Viewer, request: UpdatePasswordRequest, -): Promise { +): Promise { /* eslint-enable no-unused-vars */ // We have no way to handle this request anymore throw new ServerError('deprecated'); diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js --- a/lib/actions/user-actions.js +++ b/lib/actions/user-actions.js @@ -19,11 +19,11 @@ UpdateUserSettingsRequest, PolicyAcknowledgmentRequest, ClaimUsernameResponse, - LogInResponse, LogInRequest, KeyserverAuthResult, KeyserverAuthInfo, KeyserverAuthRequest, + ClientLogInResponse, } from '../types/account-types.js'; import type { UpdateUserAvatarRequest, @@ -50,7 +50,7 @@ SubscriptionUpdateRequest, SubscriptionUpdateResult, } from '../types/subscription-types.js'; -import type { RawThreadInfos } from '../types/thread-types'; +import type { MinimallyEncodedRawThreadInfos } from '../types/thread-types'; import type { UserInfo, PasswordUpdate, @@ -263,15 +263,16 @@ }; } - const responses: { +[string]: LogInResponse } = await callKeyserverEndpoint( - 'keyserver_auth', - requests, - keyserverAuthCallServerEndpointOptions, - ); + const responses: { +[string]: ClientLogInResponse } = + await callKeyserverEndpoint( + 'keyserver_auth', + requests, + keyserverAuthCallServerEndpointOptions, + ); const userInfosArrays = []; - let threadInfos: RawThreadInfos = {}; + let threadInfos: MinimallyEncodedRawThreadInfos = {}; const calendarResult: WritableCalendarResult = { calendarQuery: keyserverAuthInfo.calendarQuery, rawEntryInfos: [], @@ -408,15 +409,16 @@ }; } - const responses: { +[string]: LogInResponse } = await callKeyserverEndpoint( - 'log_in', - requests, - logInCallServerEndpointOptions, - ); + const responses: { +[string]: ClientLogInResponse } = + await callKeyserverEndpoint( + 'log_in', + requests, + logInCallServerEndpointOptions, + ); const userInfosArrays = []; - let threadInfos: RawThreadInfos = {}; + let threadInfos: MinimallyEncodedRawThreadInfos = {}; const calendarResult: WritableCalendarResult = { calendarQuery: logInInfo.calendarQuery, rawEntryInfos: [], diff --git a/lib/types/account-types.js b/lib/types/account-types.js --- a/lib/types/account-types.js +++ b/lib/types/account-types.js @@ -15,7 +15,10 @@ type GenericMessagesResult, } from './message-types.js'; import type { PreRequestUserState } from './session-types.js'; -import { type RawThreadInfos } from './thread-types.js'; +import { + type RawThreadInfos, + type MinimallyEncodedRawThreadInfos, +} from './thread-types.js'; import { type UserInfo, type LoggedOutUserInfo, @@ -136,7 +139,7 @@ +initialNotificationsEncryptedMessage?: string, }; -export type LogInResponse = { +export type ServerLogInResponse = { +currentUserInfo: LoggedInUserInfo, +rawMessageInfos: $ReadOnlyArray, +truncationStatuses: MessageTruncationStatuses, @@ -150,8 +153,16 @@ +notAcknowledgedPolicies?: $ReadOnlyArray, }; +export type ClientLogInResponse = $ReadOnly<{ + ...ServerLogInResponse, + +cookieChange: $ReadOnly<{ + ...$PropertyType, + threadInfos: MinimallyEncodedRawThreadInfos, + }>, +}>; + export type LogInResult = { - +threadInfos: RawThreadInfos, + +threadInfos: MinimallyEncodedRawThreadInfos, +currentUserInfo: LoggedInUserInfo, +messagesResult: GenericMessagesResult, +userInfos: $ReadOnlyArray,