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 @@ -56,6 +56,7 @@ KeyserverLogOutResult, LogOutResult, } from '../types/account-types.js'; +import type { SetPeerDeviceListsPayload } from '../types/aux-user-types.js'; import type { UpdateUserAvatarRequest, UpdateUserAvatarResponse, @@ -1481,6 +1482,11 @@ failed: 'RESTORE_USER_FAILED', }); +export type RestoreUserResult = $ReadOnly<{ + ...IdentityAuthResult, + ...SetPeerDeviceListsPayload, +}>; + export { changeKeyserverUserPasswordActionTypes, changeKeyserverUserPassword, diff --git a/lib/reducers/aux-user-reducer.js b/lib/reducers/aux-user-reducer.js --- a/lib/reducers/aux-user-reducer.js +++ b/lib/reducers/aux-user-reducer.js @@ -9,6 +9,7 @@ setPeerDeviceListsActionType, } from '../actions/aux-user-actions.js'; import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js'; +import { restoreUserActionTypes } from '../actions/user-actions.js'; import { auxUserStoreOpsHandlers, type AuxUserStoreOperation, @@ -134,7 +135,10 @@ auxUserStore: newAuxUserStore, auxUserStoreOperations: [], }; - } else if (action.type === setPeerDeviceListsActionType) { + } else if ( + action.type === setPeerDeviceListsActionType || + action.type === restoreUserActionTypes.success + ) { const replaceOperations: ReplaceAuxUserInfoOperation[] = []; for (const userID in action.payload.deviceLists) { const { accountMissingStatus, ...rest } = diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -172,6 +172,7 @@ ProcessHoldersFailedPayload, ProcessHoldersFinishedPayload, } from '../actions/holder-actions.js'; +import type { RestoreUserResult } from '../actions/user-actions.js'; import type { UpdateConnectionStatusPayload, SetLateResponsePayload, @@ -1674,7 +1675,7 @@ } | { +type: 'RESTORE_USER_SUCCESS', - +payload: IdentityAuthResult, + +payload: RestoreUserResult, +loadingInfo: LoadingInfo, }, }>; diff --git a/native/account/restore.js b/native/account/restore.js --- a/native/account/restore.js +++ b/native/account/restore.js @@ -2,14 +2,16 @@ import invariant from 'invariant'; import * as React from 'react'; +import { Platform } from 'react-native'; -import { restoreUserActionTypes } from 'lib/actions/user-actions.js'; +import { + restoreUserActionTypes, + type RestoreUserResult, +} from 'lib/actions/user-actions.js'; import { useLogIn } from 'lib/hooks/login-hooks.js'; import { IdentityClientContext } from 'lib/shared/identity-client-context.js'; -import type { - IdentityAuthResult, - SignedDeviceList, -} from 'lib/types/identity-service-types.js'; +import type { SignedDeviceList } from 'lib/types/identity-service-types.js'; +import { platformToIdentityDeviceType } from 'lib/types/identity-service-types.js'; import { getConfig } from 'lib/utils/config.js'; import { getContentSigningKey } from 'lib/utils/crypto-utils.js'; import { composeRawDeviceList } from 'lib/utils/device-list-utils.js'; @@ -19,6 +21,7 @@ import { useClientBackup } from '../backup/use-client-backup.js'; import { commCoreModule } from '../native-modules.js'; +import { codeVersion, persistConfig } from '../redux/persist.js'; function useRestoreProtocol(): ( // username or wallet address @@ -28,7 +31,7 @@ // social proof for SIWE restore siweMessage?: string, siweSignature?: string, -) => Promise { +) => Promise { const identityContext = React.useContext(IdentityClientContext); invariant(identityContext, 'identity context not set'); const { identityClient } = identityContext; @@ -101,10 +104,21 @@ ); } - //6. Return IdentityAuthResult result + //6. Return the result + const platformDetails = { + deviceType: platformToIdentityDeviceType[Platform.OS], + codeVersion, + stateVersion: persistConfig.version, + }; return { ...result, preRequestUserState, + deviceLists: { [userID]: initialDeviceList }, + usersPlatformDetails: { + [userID]: { + [primaryDeviceID]: platformDetails, + }, + }, }; }, [