diff --git a/lib/flow-typed/npm/tcomb_v3.x.x.js b/lib/flow-typed/npm/tcomb_v3.x.x.js --- a/lib/flow-typed/npm/tcomb_v3.x.x.js +++ b/lib/flow-typed/npm/tcomb_v3.x.x.js @@ -65,7 +65,7 @@ }; } - declare export class TEnums extends TBaseType { + declare export class TEnums extends TBaseType { meta: { +kind: 'enums', +name: string, @@ -119,7 +119,7 @@ ): TDict<{ [key: S]: T }>, union<+T>(types: $ReadOnlyArray>, name?: string): TUnion, +enums: { - of(enums: $ReadOnlyArray, name?: string): TEnums, + of(enums: $ReadOnlyArray | $ReadOnlyArray, name?: string): TEnums, }, irreducible( name: string, 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 @@ -131,6 +131,7 @@ ...state.auxUserInfos[userID], fid: state.auxUserInfos[userID]?.fid ?? null, deviceList: action.payload.deviceLists[userID], + devicesPlatformDetails: action.payload.usersPlatformDetails[userID], }, }, }); diff --git a/lib/reducers/aux-user-reducer.test.js b/lib/reducers/aux-user-reducer.test.js --- a/lib/reducers/aux-user-reducer.test.js +++ b/lib/reducers/aux-user-reducer.test.js @@ -6,7 +6,11 @@ setAuxUserFIDsActionType, setPeerDeviceListsActionType, } from '../actions/aux-user-actions.js'; -import type { RawDeviceList } from '../types/identity-service-types.js'; +import { + type RawDeviceList, + type IdentityPlatformDetails, + identityDeviceTypes, +} from '../types/identity-service-types.js'; jest.mock('../utils/config.js'); @@ -98,10 +102,33 @@ devices: ['D1', 'D2'], timestamp: 1, }; + const devicesPlatformDetails1: { + +[deviceID: string]: IdentityPlatformDetails, + } = { + D1: { + deviceType: identityDeviceTypes.ANDROID, + codeVersion: 350, + stateVersion: 75, + }, + D2: { + deviceType: identityDeviceTypes.WINDOWS, + codeVersion: 80, + stateVersion: 75, + }, + }; const deviceList2: RawDeviceList = { devices: ['D3'], timestamp: 1, }; + const devicesPlatformDetails2: { + +[deviceID: string]: IdentityPlatformDetails, + } = { + D3: { + deviceType: identityDeviceTypes.IOS, + codeVersion: 350, + stateVersion: 75, + }, + }; const updateAuxUserInfosAction = { type: setPeerDeviceListsActionType, @@ -110,6 +137,10 @@ userID_1: deviceList1, userID_2: deviceList2, }, + usersPlatformDetails: { + userID_1: devicesPlatformDetails1, + userID_2: devicesPlatformDetails2, + }, }, }; @@ -121,10 +152,12 @@ userID_1: { fid: 'farcasterID_1', deviceList: deviceList1, + devicesPlatformDetails: devicesPlatformDetails1, }, userID_2: { fid: null, deviceList: deviceList2, + devicesPlatformDetails: devicesPlatformDetails2, }, }, }); diff --git a/lib/types/aux-user-types.js b/lib/types/aux-user-types.js --- a/lib/types/aux-user-types.js +++ b/lib/types/aux-user-types.js @@ -4,9 +4,14 @@ FarcasterUser, RawDeviceList, UsersRawDeviceLists, + IdentityPlatformDetails, } from './identity-service-types.js'; -export type AuxUserInfo = { +fid: ?string, deviceList?: RawDeviceList }; +export type AuxUserInfo = { + +fid: ?string, + +deviceList?: RawDeviceList, + +devicesPlatformDetails?: { +[deviceID: string]: IdentityPlatformDetails }, +}; export type AuxUserInfos = { +[userID: string]: AuxUserInfo }; @@ -24,4 +29,7 @@ export type SetPeerDeviceListsPayload = { +deviceLists: UsersRawDeviceLists, + +usersPlatformDetails: { + +[userID: string]: { +[deviceID: string]: IdentityPlatformDetails }, + }, }; diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -1,6 +1,6 @@ // @flow -import t, { type TInterface, type TList, type TDict } from 'tcomb'; +import t, { type TInterface, type TList, type TDict, type TEnums } from 'tcomb'; import { identityKeysBlobValidator, @@ -17,6 +17,7 @@ currentUserInfoValidator, type CurrentUserInfo, } from './user-types.js'; +import { values } from '../utils/objects.js'; import { tUserID, tShape } from '../utils/validation-utils.js'; export type UserAuthMetadata = { @@ -322,3 +323,22 @@ WINDOWS: 4, MAC_OS: 5, }); + +export type IdentityDeviceType = $Values; +export const identityDeviceTypeValidator: TEnums = t.enums.of( + values(identityDeviceTypes), +); + +export type IdentityPlatformDetails = { + +deviceType: IdentityDeviceType, + +codeVersion: number, + +stateVersion?: number, + +majorDesktopVersion?: number, +}; +export const identityPlatformDetailsValidator: TInterface = + tShape({ + deviceType: identityDeviceTypeValidator, + codeVersion: t.Number, + stateVersion: t.maybe(t.Number), + majorDesktopVersion: t.maybe(t.Number), + });