Use X-Signal-Timestamp header

This commit is contained in:
Fedor Indutny 2025-01-16 20:17:04 -08:00 committed by GitHub
parent dfeb54f898
commit 47cf3266f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 27 additions and 18 deletions

View file

@ -7,7 +7,7 @@ import type { WebAPIType } from './textsecure/WebAPI';
import * as log from './logging/log';
import type { AciString } from './types/ServiceId';
import { parseIntOrThrow } from './util/parseIntOrThrow';
import { SECOND, HOUR } from './util/durations';
import { HOUR } from './util/durations';
import * as Bytes from './Bytes';
import { uuidToBytes } from './util/uuidToBytes';
import { dropNull } from './util/dropNull';
@ -87,14 +87,14 @@ export const refreshRemoteConfig = async (
server: WebAPIType
): Promise<void> => {
const now = Date.now();
const { config: newConfig, serverEpochTime } = await server.getConfig();
const { config: newConfig, serverTimestamp } = await server.getConfig();
const serverTimeSkew = serverEpochTime * SECOND - now;
const serverTimeSkew = serverTimestamp - now;
if (Math.abs(serverTimeSkew) > HOUR) {
log.warn(
'Remote Config: sever clock skew detected. ' +
`Server time ${serverEpochTime * SECOND}, local time ${now}`
`Server time ${serverTimestamp}, local time ${now}`
);
}