diff --git a/CHANGELOG.md b/CHANGELOG.md index f70994a..d827d87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## v1.3.5 β€” 2026-09-06 + +One bug, and the one everybody with the Android app and their own API key ran into. Web bundle and +APK; the API only carries the version number. + +- πŸ”‘ **"Bring my own API key" works on the phone.** Since v1.3.0 every key-store call on Android + hung before it started: the secure-storage plugin was handed to the app as the value of a promise, + and a Capacitor plugin object answers *any* property name with a native method β€” `then` + included β€” so the promise took it for a thenable, called a native `SecureStorage.then()` that does + not exist, and never settled. That one stuck `await` was all three reports at once: "Save and use + the Coach" greyed out forever, the key "not saved" when you came back, and a Coach that sat on + "thinking…" without end because the job read the key first. The plugin now travels inside a plain + object, a test drives the store through a Capacitor-style proxy so it cannot come back, and the + whole flow β€” save, intake, plan, restart with the key still there β€” was run on an emulator before + tagging. The web app and the "use my self-hosted openGym" mode were never affected. + (issues #42, #58; reported by many on Discord) + ## v1.3.4 β€” 2026-09-05 Two things noticed on the phone right after v1.3.3. Web bundle and APK; the API only carries the diff --git a/README.md b/README.md index 4fd335f..792815b 100644 --- a/README.md +++ b/README.md @@ -210,9 +210,9 @@ host side of that volume, not the variable. ## Roadmap The plan lives in [ROADMAP.md](ROADMAP.md) and on the -[GitLab milestones](https://gitlab.com/DuarteSantos8/opengym/-/milestones): v1.3.4 programmes and +[GitLab milestones](https://gitlab.com/DuarteSantos8/opengym/-/milestones): v1.3.5 programmes and progression (explicit warm-up/work phases, AMRAP driver selection, multi-week programmes, adaptive -1RM), v1.3.5 accounts and sync (password and OIDC login, personal-trainer role, remote MCP), v1.3.6 +1RM), v1.3.6 accounts and sync (password and OIDC login, personal-trainer role, remote MCP), v1.3.7 mobile (timer in the notification bar, widgets, Withings). Ideas and merge requests welcome β€” the [board](https://gitlab.com/DuarteSantos8/opengym/-/boards) shows what is planned, in progress and waiting for a test on the staging instance. diff --git a/ROADMAP.md b/ROADMAP.md index 81edabb..4e56b93 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -57,7 +57,7 @@ Left over from this block: - A real pause for the workout timers (#29 asked for it) - Discord announcement (owner) -## v1.3.4 β€” Programmes & progression (October 2026) +## v1.3.5 β€” Programmes & progression (October 2026) **Theme: training structure beyond one weekly template.** Most of this is the Space-Hermes series. It changes the training model (per-set roles, explicit phases, normalisation on every persist), so @@ -81,7 +81,7 @@ it goes in one MR at a time, each rebased and tested on gym-test before the next - Catalogue cleanup: exercises that should not carry weight, incline and interval fields for cardio (#46); timers for planks and outdoor cardio are already there, document them (#45) -## v1.3.5 β€” Accounts & sync (November 2026) +## v1.3.6 β€” Accounts & sync (November 2026) **Theme: who may sign in, and what else may read or write your data.** @@ -99,7 +99,7 @@ it goes in one MR at a time, each rebased and tested on gym-test before the next logged sessions lost after editing a routine (#25) - Admin: per-user export, invite management, audit log filters -## v1.3.6 β€” Mobile (December 2026) +## v1.3.7 β€” Mobile (December 2026) **Theme: the Android app catches up with the web app.** diff --git a/api/openapi.yaml b/api/openapi.yaml index 0f65de3..6b9c29c 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -6,7 +6,7 @@ openapi: 3.1.0 info: title: openGym API - version: 1.3.4 + version: 1.3.5 summary: Passkey (WebAuthn) auth + per-user state storage for openGym description: | The backend of [openGym](https://opengym.duarte-santos.ch) β€” a free, open-source diff --git a/api/package-lock.json b/api/package-lock.json index f42f699..0075e84 100644 --- a/api/package-lock.json +++ b/api/package-lock.json @@ -1,12 +1,12 @@ { "name": "gym-api", - "version": "1.3.4", + "version": "1.3.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gym-api", - "version": "1.3.4", + "version": "1.3.5", "license": "AGPL-3.0-or-later", "dependencies": { "@simplewebauthn/server": "^13.1.1", diff --git a/api/package.json b/api/package.json index 1fda9b0..c799536 100644 --- a/api/package.json +++ b/api/package.json @@ -1,6 +1,6 @@ { "name": "gym-api", - "version": "1.3.4", + "version": "1.3.5", "private": true, "type": "module", "main": "server.js", diff --git a/frontend/android/app/build.gradle b/frontend/android/app/build.gradle index 8cb0f77..e0bae38 100644 --- a/frontend/android/app/build.gradle +++ b/frontend/android/app/build.gradle @@ -7,8 +7,8 @@ android { applicationId "ch.duartesantos.opengym" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion - versionCode 18 - versionName "1.3.4" + versionCode 19 + versionName "1.3.5" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" aaptOptions { // Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps. diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 529b7d8..7b7ff5b 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "opengym-frontend", - "version": "1.3.4", + "version": "1.3.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "opengym-frontend", - "version": "1.3.4", + "version": "1.3.5", "license": "AGPL-3.0-or-later", "dependencies": { "@aparajita/capacitor-secure-storage": "^7.1.6", diff --git a/frontend/package.json b/frontend/package.json index 4006d10..daf84a0 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "opengym-frontend", "private": true, - "version": "1.3.4", + "version": "1.3.5", "type": "module", "scripts": { "dev": "vite", diff --git a/frontend/src/lib/coach-secrets.js b/frontend/src/lib/coach-secrets.js index 4ed7aa9..3939d11 100644 --- a/frontend/src/lib/coach-secrets.js +++ b/frontend/src/lib/coach-secrets.js @@ -10,12 +10,19 @@ const KEY = 'coach.apiKey' const memory = new Map() +// The loaded plugin travels inside a plain object, never as a promise's own value (no `await` +// or `.then` may ever hand the proxy back bare β€” the wrapper below is the whole point). Capacitor's +// registerPlugin() hands out a Proxy that answers EVERY property name with a native-method +// wrapper β€” `then` included β€” so a promise that resolves to the proxy itself takes it for a +// thenable, calls SecureStorage.then() on the native side ("not implemented on android"), and +// never settles. That one await hung the whole feature on the phone: "Save and use the Coach" +// greyed out forever, the key "not saved", the Coach "thinking" without end (issues #42, #58). let pluginPromise = null function plugin() { if (!pluginPromise) { pluginPromise = import('@aparajita/capacitor-secure-storage') - .then(m => (m && m.SecureStorage && typeof m.SecureStorage.get === 'function' ? m.SecureStorage : null)) - .catch(() => null) + .then(m => ({ store: m && m.SecureStorage && typeof m.SecureStorage.get === 'function' ? m.SecureStorage : null })) + .catch(() => ({ store: null })) } return pluginPromise } @@ -30,7 +37,7 @@ export const withTimeout = (promise, ms = NATIVE_TIMEOUT_MS) => new Promise((res }) export async function getApiKey() { - const p = await plugin() + const { store: p } = await plugin() if (p) { try { const v = await withTimeout(p.get(KEY)); return typeof v === 'string' && v ? v : null } catch { /* fall through */ } } @@ -39,14 +46,14 @@ export async function getApiKey() { export async function setApiKey(value) { const v = String(value || '').trim() if (!v) return clearApiKey() - const p = await plugin() + const { store: p } = await plugin() if (p) { try { await withTimeout(p.set(KEY, v)); memory.delete(KEY); return } catch { /* fall through */ } } memory.set(KEY, v) } export async function clearApiKey() { - const p = await plugin() + const { store: p } = await plugin() if (p) { try { await withTimeout(p.remove(KEY)) } catch { /* nothing to clear */ } } memory.delete(KEY) } diff --git a/frontend/src/lib/coach-secrets.test.js b/frontend/src/lib/coach-secrets.test.js new file mode 100644 index 0000000..34934f7 --- /dev/null +++ b/frontend/src/lib/coach-secrets.test.js @@ -0,0 +1,48 @@ +// @vitest-environment node +import { describe, it, expect, vi, beforeEach } from 'vitest' + +// A stand-in for what @capacitor/core's registerPlugin() really returns: a Proxy that turns ANY +// property β€” `then` included β€” into a method wrapper whose native call fails asynchronously +// without ever invoking the callbacks it was handed. Resolving a promise with that object makes +// the promise wait for `then` to call back, which it never does (issues #42 / #58). +const calls = [] +const backing = new Map() +const impl = { + get: async k => (backing.has(k) ? backing.get(k) : null), + set: async (k, v) => { backing.set(k, v) }, + remove: async k => backing.delete(k) +} +const SecureStorage = new Proxy({}, { + get(_, prop) { + if (prop === '$$typeof') return undefined + if (prop === 'toJSON') return () => ({}) + return (...args) => { + calls.push(String(prop)) + if (impl[prop]) return impl[prop](...args) + return Promise.reject(new Error(`"SecureStorage.${String(prop)}()" is not implemented on android`)) + } + } +}) +vi.mock('@aparajita/capacitor-secure-storage', () => ({ SecureStorage })) + +const secrets = await import('./coach-secrets.js') + +const within = (p, ms) => Promise.race([p, new Promise((_, rej) => setTimeout(() => rej(new Error(`hung for ${ms} ms`)), ms))]) + +describe('coach-secrets against a Capacitor-style plugin proxy', () => { + beforeEach(() => { calls.length = 0; backing.clear() }) + + it('a round trip settles instead of waiting on the proxy\'s never-answering then()', async () => { + await within(secrets.setApiKey('sk-live-1'), 1000) + expect(await within(secrets.getApiKey(), 1000)).toBe('sk-live-1') + await within(secrets.clearApiKey(), 1000) + expect(await within(secrets.getApiKey(), 1000)).toBe(null) + expect(calls).not.toContain('then') + }) + + it('goes through the platform store, not the in-memory fallback', async () => { + await within(secrets.setApiKey('sk-live-2'), 1000) + expect([...backing.keys()]).toEqual(['coach.apiKey']) + expect(calls).toEqual(['set']) + }) +}) diff --git a/website/api.html b/website/api.html index 528e6bc..34c19b5 100644 --- a/website/api.html +++ b/website/api.html @@ -1,6 +1,6 @@ @@ -232,7 +232,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon

OpenAPI 3.1.0 - openGym v1.3.4 + openGym v1.3.5 28 endpoints AGPL-3.0-or-later

diff --git a/website/index.html b/website/index.html index 8ddaaf2..1a6d78d 100644 --- a/website/index.html +++ b/website/index.html @@ -404,7 +404,7 @@ try {
Download for Android -

v1.3.4 Β· 27.7 MB Β· Android 6.0+ Β· signed APK. Your browser will ask +

v1.3.5 Β· 27.7 MB Β· Android 6.0+ Β· signed APK. Your browser will ask before installing; that is normal outside the Play Store.

Every release is also built and signed by CI and attached to the GitLab