diff --git a/keyserver/src/keyserver.js b/keyserver/src/keyserver.js --- a/keyserver/src/keyserver.js +++ b/keyserver/src/keyserver.js @@ -48,9 +48,10 @@ } from './uploads/uploads.js'; import { createAuthoritativeKeyserverConfigFiles } from './user/create-configs.js'; import { fetchIdentityInfo } from './user/identity.js'; -import { verifyUserLoggedIn } from './user/login.js'; +import { authAndSaveIdentityInfo } from './user/login.js'; import { initENSCache } from './utils/ens-cache.js'; import { initFCCache } from './utils/fc-cache.js'; +import { syncPlatformDetails } from './utils/identity-utils.js'; import { getContentSigningKey } from './utils/olm-utils.js'; import { isPrimaryNode, @@ -191,7 +192,15 @@ // We await here to ensure that the keyserver has been provisioned a // commServicesAccessToken. In the future, this will be necessary for // many keyserver operations. - const identityInfo = await verifyUserLoggedIn(); + let identityInfo = await fetchIdentityInfo(); + if (identityInfo && isPrimaryNode) { + // We are using persisted auth metadata here, so we should attempt + // to synchronize platform details with the identity service + ignorePromiseRejections(syncPlatformDetails(identityInfo)); + } + if (!identityInfo) { + identityInfo = await authAndSaveIdentityInfo(); + } if (!isPrimaryNode) { return; diff --git a/keyserver/src/user/login.js b/keyserver/src/user/login.js --- a/keyserver/src/user/login.js +++ b/keyserver/src/user/login.js @@ -258,4 +258,8 @@ } } -export { verifyUserLoggedIn, verifyUserLoggedInWithoutDB }; +export { + verifyUserLoggedIn, + verifyUserLoggedInWithoutDB, + authAndSaveIdentityInfo, +}; diff --git a/keyserver/src/utils/identity-utils.js b/keyserver/src/utils/identity-utils.js --- a/keyserver/src/utils/identity-utils.js +++ b/keyserver/src/utils/identity-utils.js @@ -5,6 +5,7 @@ import type { UserIdentitiesResponse } from 'lib/types/identity-service-types.js'; import { getContentSigningKey } from './olm-utils.js'; +import type { IdentityInfo } from '../user/identity.js'; import { verifyUserLoggedIn } from '../user/login.js'; async function findUserIdentities( @@ -23,4 +24,16 @@ ); } -export { findUserIdentities }; +async function syncPlatformDetails(identityInfo: IdentityInfo): Promise { + const [rustAPI, deviceID] = await Promise.all([ + getRustAPI(), + getContentSigningKey(), + ]); + return rustAPI.syncPlatformDetails( + identityInfo.userId, + deviceID, + identityInfo.accessToken, + ); +} + +export { findUserIdentities, syncPlatformDetails };