In-App-Update (!40) nachgeschaerft: Zeile nur mit APK-Asset, keine Installation ohne Pruefsumme, ein Release-Check pro App-Sitzung

This commit is contained in:
Duarte Santos committed 2026-09-05 14:27:28 +02:00
1 parent f7b664bcda
commit 067302fd16
17 files changed
+31 -8

No files matched your search

+2 -2
View File
@@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => {
const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex')
expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(626)
expect(inherited).toHaveLength(612)
expect(inherited).toHaveLength(613)
// If this fails, review the changed keys and wording before accepting a new hash. From
// frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('d0483d2d3a56ac55054229234fe54481e2b5c539b5836bbdc9305230cb8dd475')
expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('81d277306b3029090b7a2ba6cc19108ca207ea65d738487155123260b6e9525d')
})
test('does not leak European Portuguese UI terms', () => {
+8
View File
@@ -33,7 +33,15 @@ function compareSemver(a, b) {
* - apkUrl: direct download URL of the first .apk asset, or null
* - hashUrl: direct download URL of the .apk.sha256 hash file, or null
*/
// One request per app session: Settings is opened often, gitlab.com does not need to hear
// about it every time. The promise is cached, a failure is not.
let cached = null
export function resetUpdateCheck() { cached = null }
export async function checkForUpdate() {
if (!cached) cached = fetchLatest().catch(e => { cached = null; throw e })
return cached
}
async function fetchLatest() {
const res = await fetch(RELEASES_URL + '?per_page=1')
if (!res.ok) throw new Error(`GitLab API ${res.status}`)
const releases = await res.json()
+3 -3
View File
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
import { checkForUpdate, sha256 } from './update.js'
import { checkForUpdate, sha256, resetUpdateCheck } from './update.js'
// __APP_VERSION__ is defined at build time by vite.config.js (reads package.json).
// In the test environment vitest applies the same define, so it's available here.
@@ -28,7 +28,7 @@ describe('sha256', () => {
describe('checkForUpdate', () => {
let originalFetch
beforeEach(() => { originalFetch = globalThis.fetch })
beforeEach(() => { originalFetch = globalThis.fetch; resetUpdateCheck() })
afterEach(() => { globalThis.fetch = originalFetch })
function mockFetch(body, status = 200) {
@@ -231,7 +231,7 @@ describe('checkForUpdate', () => {
describe('semver comparison (via checkForUpdate behavior)', () => {
let originalFetch
beforeEach(() => { originalFetch = globalThis.fetch })
beforeEach(() => { originalFetch = globalThis.fetch; resetUpdateCheck() })
afterEach(() => { globalThis.fetch = originalFetch })
function mockRelease(tag) {
+1
View File
@@ -1199,4 +1199,5 @@ export default {
'Downloading update…': 'Update wird heruntergeladen…',
'{0} %': '{0} %',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Prüfsumme nicht verfügbar — Installation abgebrochen',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'Descargando actualización…',
'{0} %': '{0} %',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Suma de verificación no disponible — no se instala',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'Téléchargement de la mise à jour…',
'{0} %': '{0} %',
'{0} MB': '{0} Mo',
'Checksum not available — not installing': 'Somme de contrôle indisponible — installation annulée',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'अपडेट डाउनलोड हो रहा है…',
'{0} %': '{0}%',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'चेकसम उपलब्ध नहीं — इंस्टॉल नहीं किया गया',
}
+1
View File
@@ -1183,4 +1183,5 @@ export default {
'Downloading update…': 'Frissítés letöltése…',
'{0} %': '{0} %',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Ellenőrző összeg nem érhető el — nincs telepítés',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'Download dell’aggiornamento…',
'{0} %': '{0} %',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Checksum non disponibile — installazione annullata',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': '업데이트 다운로드 중…',
'{0} %': '{0}%',
'{0} MB': '{0} MB',
'Checksum not available — not installing': '체크섬을 확인할 수 없어 설치하지 않습니다',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'Pobieranie aktualizacji…',
'{0} %': '{0}%',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Suma kontrolna niedostępna — instalacja przerwana',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'A transferir atualização…',
'{0} %': '{0} %',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Soma de verificação indisponível — não instalado',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'Загрузка обновления…',
'{0} %': '{0} %',
'{0} MB': '{0} МБ',
'Checksum not available — not installing': 'Контрольная сумма недоступна — установка отменена',
}
+1
View File
@@ -1191,4 +1191,5 @@ export default {
'Downloading update…': 'กำลังดาวน์โหลดอัปเดต…',
'{0} %': '{0}%',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'ไม่มีค่าตรวจสอบ — ยกเลิกการติดตั้ง',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': 'Güncelleme indiriliyor…',
'{0} %': '%{0}',
'{0} MB': '{0} MB',
'Checksum not available — not installing': 'Sağlama toplamı yok — yüklenmedi',
}
+1
View File
@@ -1180,4 +1180,5 @@ export default {
'Downloading update…': '正在下载更新…',
'{0} %': '{0}%',
'{0} MB': '{0} MB',
'Checksum not available — not installing': '校验和不可用,已取消安装',
}
+5 -3
View File
@@ -74,14 +74,16 @@ export default function Settings() {
return <DownloadProgress ref={fn => { setProgress = fn }} />
}, { locked: true })
try {
// Fetch the expected SHA-256 hash if available
// The release always publishes the checksum next to the APK. Without it the file is
// not installed — a sideloaded binary is exactly the thing that should be verified.
let expectedHash = null
if (updateInfo.hashUrl) {
try {
const hashRes = await fetch(updateInfo.hashUrl)
if (hashRes.ok) expectedHash = (await hashRes.text()).split(/\s/)[0]
} catch (e) { /* proceed without hash verification */ }
} catch (e) { /* reported below */ }
}
if (!/^[0-9a-f]{64}$/i.test(expectedHash || '')) throw new Error(t('Checksum not available — not installing'))
await downloadAndInstall(updateInfo.apkUrl, expectedHash, (received, total) => {
if (setProgress) setProgress(received, total)
})
@@ -316,7 +318,7 @@ export default function Settings() {
{/* ---------- data: fill it, bring things over, back it up, wipe it ---------- */}
<Section title={t('Data')}>
{MOBILE && updateInfo?.hasUpdate && <Row icon="info" iconTint="var(--purple)" title={t('openGym v{0} available', updateInfo.latestVersion)}
{MOBILE && updateInfo?.hasUpdate && updateInfo.apkUrl && <Row icon="info" iconTint="var(--purple)" title={t('openGym v{0} available', updateInfo.latestVersion)}
accessory="chevron"
onClick={onUpdateRowClick} />}
<Row icon="sparkles" iconTint="var(--acc)" title={t('Load starter plan')} accessory="chevron" onClick={starterPlanSheet} />