feat: added os arch and release channel to desktop update requests to the file server

we now use blindVersionSignRequest
pull/3281/head
yougotwill 3 months ago
parent a412fb5642
commit 8bd89de35a

@ -15,3 +15,4 @@ export const isWindows = (minVersion?: string) => {
}; };
export const getOSArchitecture = () => os.arch(); export const getOSArchitecture = () => os.arch();
export const getOSPlatform = () => os.platform();

@ -8,7 +8,7 @@ import {
import { fromUInt8ArrayToBase64 } from '../../utils/String'; import { fromUInt8ArrayToBase64 } from '../../utils/String';
import { NetworkTime } from '../../../util/NetworkTime'; import { NetworkTime } from '../../../util/NetworkTime';
import { DURATION } from '../../constants'; import { DURATION } from '../../constants';
import { getOSArchitecture } from '../../../OS'; import { getOSArchitecture, getOSPlatform } from '../../../OS';
import type { ReleaseChannels } from '../../../updater/types'; import type { ReleaseChannels } from '../../../updater/types';
import { Storage } from '../../../util/storage'; import { Storage } from '../../../util/storage';
@ -16,7 +16,7 @@ export const fileServerHost = 'filev2.getsession.org';
export const fileServerURL = `http://${fileServerHost}`; export const fileServerURL = `http://${fileServerHost}`;
export const fileServerPubKey = 'da21e1d886c6fbaea313f75298bd64aab03a97ce985b46bb2dad9f2089c8ee59'; export const fileServerPubKey = 'da21e1d886c6fbaea313f75298bd64aab03a97ce985b46bb2dad9f2089c8ee59';
const RELEASE_VERSION_ENDPOINT = '/session_version?platform=desktop'; const RELEASE_VERSION_ENDPOINT = '/session_version';
const POST_GET_FILE_ENDPOINT = '/file'; const POST_GET_FILE_ENDPOINT = '/file';
@ -133,15 +133,23 @@ const parseStatusCodeFromOnionRequestV4 = (
* This call is onion routed and so do not expose our ip to github nor the file server. * This call is onion routed and so do not expose our ip to github nor the file server.
*/ */
export const getLatestReleaseFromFileServer = async ( export const getLatestReleaseFromFileServer = async (
userEd25519SecretKey: Uint8Array userEd25519SecretKey: Uint8Array,
releaseType?: ReleaseChannels
): Promise<string | null> => { ): Promise<string | null> => {
const sigTimestampSeconds = NetworkTime.getNowWithNetworkOffsetSeconds(); const sigTimestampSeconds = NetworkTime.getNowWithNetworkOffsetSeconds();
const blindedPkHex = await BlindingActions.blindVersionPubkey({ const blindedPkHex = await BlindingActions.blindVersionPubkey({
ed25519SecretKey: userEd25519SecretKey, ed25519SecretKey: userEd25519SecretKey,
}); });
const signature = await BlindingActions.blindVersionSign({ const method = 'GET';
const releaseChannel = Storage.get('releaseChannel') as ReleaseChannels;
const endpoint = `${RELEASE_VERSION_ENDPOINT}?platform=desktop&os=${getOSPlatform()}&arch=${getOSArchitecture()}${releaseChannel ? `&release_channel=${releaseType || releaseChannel}` : ''}`;
const signature = await BlindingActions.blindVersionSignRequest({
ed25519SecretKey: userEd25519SecretKey, ed25519SecretKey: userEd25519SecretKey,
sigTimestampSeconds, sigTimestampSeconds,
sigMethod: method,
sigPath: endpoint,
sigBody: null,
}); });
const headers = { const headers = {
@ -150,16 +158,15 @@ export const getLatestReleaseFromFileServer = async (
'X-FS-Signature': fromUInt8ArrayToBase64(signature), 'X-FS-Signature': fromUInt8ArrayToBase64(signature),
}; };
const releaseChannel = Storage.get('releaseChannel') as ReleaseChannels; const params = {
const endpoint = `${RELEASE_VERSION_ENDPOINT}&arch=${getOSArchitecture()}${releaseChannel ? `&releases=${releaseChannel}` : ''}`;
const result = await OnionSending.sendJsonViaOnionV4ToFileServer({
abortSignal: new AbortController().signal, abortSignal: new AbortController().signal,
endpoint, endpoint,
method: 'GET', method,
stringifiedBody: null, stringifiedBody: null,
headers, headers,
timeoutMs: 10 * DURATION.SECONDS, timeoutMs: 10 * DURATION.SECONDS,
}); };
const result = await OnionSending.sendJsonViaOnionV4ToFileServer(params);
if (!batchGlobalIsSuccess(result) || parseStatusCodeFromOnionRequestV4(result) !== 200) { if (!batchGlobalIsSuccess(result) || parseStatusCodeFromOnionRequestV4(result) !== 200) {
return null; return null;

Loading…
Cancel
Save