Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
push: keep /api/push/subscribe from taking another account's subscription (GHSA-568g-hg5j-h53q)
Boris 'B' Kurktchievbb46f50201b5
diff --git a/api/openapi.yaml b/api/openapi.yamlindex 931d4abb6..c4d0e695e 100644--- a/api/openapi.yaml+++ b/api/openapi.yaml@@ -1877,6 +1877,9 @@ paths:are dropped first. Re-subscribing an existing endpoint replaces it and keepsits original `created`. The client re-sends its subscription on everysigned-in boot, so a row the instance lost comes back on its own.+ An endpoint stored for another account moves to the caller only when the+ request carries that subscription's own keys (the same browser, signed into+ another account); otherwise it is a 409 and the row stays where it was.requestBody:required: truecontent:@@ -1909,6 +1912,14 @@ paths:malformed: { value: { error: "invalid subscription" } }private: { value: { error: "endpoint must not point at a private address" } }'401': { $ref: '#/components/responses/Unauthorized' }+ '409':+ description: >-+ The endpoint is stored for another account and the request does not carry+ that subscription's keys.+ content:+ application/json:+ schema: { $ref: '#/components/schemas/Error' }+ example: { error: "this subscription belongs to another account" }/api/push/status:get:diff --git a/api/server.js b/api/server.jsindex d67e7047b..a0b5916fd 100644--- a/api/server.js+++ b/api/server.js@@ -2351,6 +2351,20 @@ const routes = {// An upsert: the client re-sends its subscription on every boot (lib/push.js) so a row this// instance lost — pruned after a dead send, a rebuilt db.json — comes back without anyone// touching Settings. The same endpoint sent again keeps its original `created`.+ //+ // A row filed under another account moves only for a caller that sends its keys. The endpoint+ // alone is a URL, and whoever learned it could otherwise re-file it as theirs: the owner's+ // device stops getting their alerts, and the caller's are sent to it instead, encrypted to+ // keys of the caller's choosing. The keys are what the browser holds (the auth secret never+ // leaves it and this server), and the legitimate move carries them: a shared browser signed+ // into a second account re-registers the same subscription on boot, and the row should+ // follow the person now using it. Refusing that, or keeping both rows, would leave the first+ // account's reminders arriving on a device somebody else is using.+ const keyDigest = k => crypto.createHash('sha256').update(`${k?.p256dh}\n${k?.auth}`).digest();+ const sameKeys = k => crypto.timingSafeEqual(keyDigest(k), keyDigest(keys));+ if (db.subs.some(s => s.endpoint === sub.endpoint && s.userId !== user.id && !sameKeys(s.keys))) {+ return json(res, 409, { error: 'this subscription belongs to another account' });+ }const prev = db.subs.find(s => s.endpoint === sub.endpoint);// No usable id in the request (none, or not a short token) leaves the id the row already// has: the request is a re-send, not a request to forget which device the row is.diff --git a/api/test/server-push-status.test.js b/api/test/server-push-status.test.jsindex 3b242b9f3..fd7ee9408 100644--- a/api/test/server-push-status.test.js+++ b/api/test/server-push-status.test.js@@ -132,6 +132,30 @@ test('a rest started on a device whose row has no id rings that row, never anothassert.equal(sent(), 2, `after the repair the phone's alert goes to the phone alone:\n${h.log}`);});+test('another account cannot take over a subscription without its keys; the same browser can', async t => {+ const h = await startServer(t);+ const endpoint = 'https://push.example/victim';+ const browserKeys = { p256dh: 'p-victim', auth: 'a-victim' };+ assert.equal((await post(h, '/api/push/subscribe', { subscription: { endpoint, keys: browserKeys } })).status, 200);++ // u_test_2 has learned the endpoint URL, not the keys only the browser (and this server) hold.+ // That used to delete u_test_1's row and file the endpoint under u_test_2: u_test_1's phone+ // went quiet, and got u_test_2's alerts instead, or nothing at all under keys of their choosing.+ const r = await post(h, '/api/push/subscribe', { subscription: { endpoint, keys: { p256dh: 'p-mine', auth: 'a-mine' } } }, other);+ assert.equal(r.status, 409);+ assert.deepEqual(await r.json(), { error: 'this subscription belongs to another account' });+ assert.deepEqual(await status(h, endpoint), { subscribed: true, deviceId: null }, "the owner's row is untouched");+ assert.deepEqual(readDb(h).subs.map(s => [s.userId, s.keys.auth]), [['u_test_1', 'a-victim']]);++ // A shared browser: u_test_1 signed out (which leaves the push subscription in place), u_test_2+ // signed in, and boot re-registers the same subscription. That browser holds the keys, so the+ // row moves: u_test_1's reminders stop arriving on a device somebody else now uses.+ assert.equal((await post(h, '/api/push/subscribe', { subscription: { endpoint, keys: browserKeys } }, other)).status, 200);+ assert.deepEqual(await status(h, endpoint), { subscribed: false });+ assert.deepEqual(await status(h, endpoint, other), { subscribed: true, deviceId: null });+ assert.equal(readDb(h).subs.length, 1);+});+test('a rest timer belongs to the device that set it: another device cancelling does not silence it', async t => {// localhost resolves to a loopback address, which PUSH_AGENT refuses — every send fails locally// and quietly, and "push send failed" in the log is the proof that a send was attempted.diff --git a/frontend/src/lib/push.js b/frontend/src/lib/push.jsindex 78ee08432..2b37e2933 100644--- a/frontend/src/lib/push.js+++ b/frontend/src/lib/push.js@@ -55,7 +55,27 @@ const readyWorker = (ms = 8000) => Promise.race([new Promise((_, reject) => setTimeout(() => reject(new Error('Service worker not ready')), ms))])-const register = sub => api('/api/push/subscribe', { method: 'POST', body: JSON.stringify({ subscription: sub.toJSON(), deviceId: deviceId() }) })+const post = sub => api('/api/push/subscribe', { method: 'POST', body: JSON.stringify({ subscription: sub.toJSON(), deviceId: deviceId() }) })++/* Hands the server this browser's subscription. A 409 means the server has this endpoint filed+ under another account with keys other than the ones sent, and moves it only for a caller that+ holds its keys, so sending it again changes nothing. A fresh subscription (a new endpoint and+ new keys) is this browser's alone, so it is made and sent once more. If that fails too, the+ fresh one is dropped: a subscription the server does not hold only tells the rest timer that+ an alert is on its way (useUI's pushArmed) when none is. A retry the server answered is thrown+ with `refused` set, so Settings shows the switch off with the server's own words. One that+ never reached it (offline, or the browser would not subscribe) is thrown as it is, and+ Settings reads the browser's side, which by then holds nothing: off as well. */+async function register(reg, key, sub) {+ try { return await post(sub) } catch (e) { if (e.status !== 409) throw e }+ try {+ await sub.unsubscribe().catch(() => {})+ const fresh = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(key) })+ try { return await post(fresh) } catch (e) { await fresh.unsubscribe().catch(() => {}); throw e }+ } catch (e) {+ throw e.status ? Object.assign(e, { refused: true }) : e+ }+}export async function enablePush() {if (!pushSupported()) throw new Error('Push notifications are not supported in this browser')@@ -65,7 +85,7 @@ export async function enablePush() {const { key } = await api('/api/push/public-key')const subscription = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(key) })await shareDeviceId()- await register(subscription)+ await register(reg, key, subscription)}export async function disablePush() {@@ -87,7 +107,9 @@ export async function disablePush() {- the server has it under no device id or another one → sent again with this one, true;- the server lost it → re-registered, true;- the server's key changed → the old subscription is useless; unsubscribe, subscribe against- the new key, register, true.+ the new key, register, true;+ - the server has the endpoint under another account → a fresh subscription, sent once more+ (register above); if that is refused too, it throws with `refused` set.Network failures propagate — the caller decides what "unknown" means for it. */export async function syncPushSubscription() {if (!pushSupported() || Notification.permission !== 'granted') return false@@ -100,7 +122,7 @@ export async function syncPushSubscription() {if (mine && key && bytesToUrlBase64(mine) !== key.replace(/=+$/, '')) {await sub.unsubscribe().catch(() => {})sub = await reg.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: urlBase64ToUint8Array(key) })- await register(sub)+ await register(reg, key, sub)return true}// A row the server stores under no device id, or another one, is sent again with this@@ -112,7 +134,7 @@ export async function syncPushSubscription() {// never reports back would be a db.json write on every boot.const { subscribed, deviceId: storedAs } = await api('/api/push/status?endpoint=' + encodeURIComponent(sub.endpoint))const id = deviceId()- if (!subscribed || (id && storedAs !== undefined && storedAs !== id)) await register(sub)+ if (!subscribed || (id && storedAs !== undefined && storedAs !== id)) await register(reg, key, sub)return true}diff --git a/frontend/src/lib/push.test.js b/frontend/src/lib/push.test.jsindex f8e06eebc..cc7437525 100644--- a/frontend/src/lib/push.test.js+++ b/frontend/src/lib/push.test.js@@ -3,11 +3,20 @@import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'const calls = []+// What the server answers each POST /api/push/subscribe, in order; an Error is thrown the way+// api() throws one (message and status). Empty: { ok: true }.+const subscribeAnswers = []+const refusal = (status, message) => Object.assign(new Error(message), { status })vi.mock('./api.js', () => ({api: vi.fn(async (path, opts) => {calls.push([path, opts?.method || 'GET', opts?.body ? JSON.parse(opts.body) : null])if (path === '/api/push/public-key') return { key: KEY }if (path.startsWith('/api/push/status')) return serverHas ? { subscribed: true, deviceId: serverDevice === MINE ? localStorage.getItem('gym_device') : serverDevice } : { subscribed: false }+ if (path === '/api/push/subscribe' && subscribeAnswers.length) {+ const a = subscribeAnswers.shift()+ if (a instanceof Error) throw a+ return a+ }return { ok: true }})}))@@ -22,15 +31,21 @@ let serverHas = trueconst MINE = Symbol('this browser')let serverDevice = MINElet sub = null-const makeSub = key => ({- endpoint: 'https://push.example/e1', options: { applicationServerKey: keyBytes(key) },- toJSON: () => ({ endpoint: 'https://push.example/e1', keys: { p256dh: 'p', auth: 'a' } }),- unsubscribe: vi.fn(async () => { sub = null; return true })-})+// A subscription the push service hands out; the one a test starts with is e1, and every one+// made after it (pushManager.subscribe) is a new endpoint with new keys, as a real one is.+let made = 1+const makeSub = (key, n = 1) => {+ const s = {+ endpoint: 'https://push.example/e' + n, options: { applicationServerKey: keyBytes(key) },+ toJSON: () => ({ endpoint: 'https://push.example/e' + n, keys: n === 1 ? { p256dh: 'p', auth: 'a' } : { p256dh: 'p' + n, auth: 'a' + n } }),+ unsubscribe: vi.fn(async () => { if (sub === s) sub = null; return true })+ }+ return s+}const reg = {pushManager: {getSubscription: vi.fn(async () => sub),- subscribe: vi.fn(async ({ applicationServerKey }) => { sub = makeSub(KEY); sub.options.applicationServerKey = applicationServerKey; return sub })+ subscribe: vi.fn(async ({ applicationServerKey }) => { sub = makeSub(KEY, ++made); sub.options.applicationServerKey = applicationServerKey; return sub })}}@@ -39,6 +54,8 @@ const posts = () => calls.filter(c => c[0] === '/api/push/subscribe').map(c => cbeforeEach(() => {calls.length = 0+ subscribeAnswers.length = 0+ made = 1reg.pushManager.subscribe.mockClear()serverHas = trueserverDevice = MINE@@ -237,6 +254,75 @@ describe('the device id the worker re-registers with', () => {})})+// Since the server refuses to move an endpoint filed under another account unless the caller+// sends that row's own keys (409), a browser that holds the endpoint with other keys could never+// register again, and the switch read "on" from the browser's side all the while. The way out is+// a fresh subscription: a new endpoint and new keys, which nobody else can hold.+describe('a subscription the server has under another account', () => {+ const conflict = () => refusal(409, 'this subscription belongs to another account')++ it('is replaced by a fresh one, which is sent once more', async () => {+ const { syncPushSubscription } = await import('./push.js')+ const old = makeSub(KEY)+ sub = old+ serverHas = false+ subscribeAnswers.push(conflict())+ expect(await syncPushSubscription()).toBe(true)+ expect(old.unsubscribe).toHaveBeenCalledTimes(1)+ expect(reg.pushManager.subscribe).toHaveBeenCalledTimes(1)+ expect(new Uint8Array(reg.pushManager.subscribe.mock.calls[0][0].applicationServerKey)).toEqual(new Uint8Array(keyBytes(KEY)))+ expect(posts()).toEqual(['https://push.example/e1', 'https://push.example/e2'])+ expect(calls.at(-1)[2].subscription.keys).toEqual({ p256dh: 'p2', auth: 'a2' })+ expect(sub.endpoint).toBe('https://push.example/e2') // the browser keeps the fresh one+ })++ it('turning the switch on goes the same way', async () => {+ const { enablePush } = await import('./push.js')+ sub = makeSub(KEY) // subscribe() hands back the one it has+ reg.pushManager.subscribe.mockImplementationOnce(async () => sub)+ subscribeAnswers.push(conflict())+ await expect(enablePush()).resolves.toBeUndefined()+ expect(posts()).toEqual(['https://push.example/e1', 'https://push.example/e2'])+ expect(sub.endpoint).toBe('https://push.example/e2')+ })++ it('a fresh one refused as well is dropped, and the caller gets the server\'s words and `refused`', async () => {+ const { syncPushSubscription } = await import('./push.js')+ sub = makeSub(KEY)+ serverHas = false+ subscribeAnswers.push(conflict(), refusal(400, 'push endpoint not allowed'))+ const e = await syncPushSubscription().catch(x => x)+ expect(e).toBeInstanceOf(Error)+ expect(e).toMatchObject({ message: 'push endpoint not allowed', status: 400, refused: true })+ expect(posts()).toHaveLength(2) // one retry, never a loop+ expect(sub).toBeNull() // no subscription the server does not hold+ })++ it('a retry that never reaches the server is not the server refusing, and leaves nothing behind', async () => {+ const { enablePush } = await import('./push.js')+ subscribeAnswers.push(conflict(), new TypeError('Failed to fetch'))+ const e = await enablePush().catch(x => x)+ expect(e).toBeInstanceOf(TypeError)+ expect(e.message).toBe('Failed to fetch')+ expect(e.refused).toBeUndefined()+ expect(sub).toBeNull()+ })++ it('any other failure is not retried and is thrown as it was', async () => {+ const { syncPushSubscription } = await import('./push.js')+ const old = makeSub(KEY)+ sub = old+ serverHas = false+ subscribeAnswers.push(refusal(500, 'HTTP 500'))+ const e = await syncPushSubscription().catch(x => x)+ expect(e).toMatchObject({ message: 'HTTP 500', status: 500 })+ expect(e.refused).toBeUndefined()+ expect(old.unsubscribe).not.toHaveBeenCalled()+ expect(reg.pushManager.subscribe).not.toHaveBeenCalled()+ expect(posts()).toHaveLength(1)+ })+})+describe('pushSupported', () => {it('needs the service worker, PushManager, Notification and an https origin', async () => {const { pushSupported } = await import('./push.js')diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsxindex 9a651c58f..c1eaf4d99 100644--- a/frontend/src/views/Settings.jsx+++ b/frontend/src/views/Settings.jsx@@ -1126,13 +1126,17 @@ function PushCard({ S, update, toast }) {// "On" means the server holds this browser's subscription, not merely that the browser has// one: a row the instance dropped (dead send, rebuilt db.json) left the switch on with nothing// ever arriving. syncPushSubscription re-registers on the way; if the server cannot be asked- // (offline), the browser's side is the best answer available.+ // (offline), the browser's side is the best answer available. A server that refused this+ // browser's subscription, even a fresh one, has answered: the switch is off, with its reason.useEffect(() => {if (!supported) returnlet gone = falsesyncPushSubscription().then(ok => { if (!gone) setOn(ok) })- .catch(() => navigator.serviceWorker.ready.then(reg => reg.pushManager.getSubscription()).then(sub => { if (!gone) setOn(!!sub) }).catch(() => {}))+ .catch(e => {+ if (e?.refused) { if (!gone) { setOn(false); toast(e.message) } return }+ return navigator.serviceWorker.ready.then(reg => reg.pushManager.getSubscription()).then(sub => { if (!gone) setOn(!!sub) }).catch(() => {})+ })return () => { gone = true }}, [supported])diff --git a/frontend/src/views/Settings.push.test.jsx b/frontend/src/views/Settings.push.test.jsxnew file mode 100644index 000000000..5f60249f4--- /dev/null+++ b/frontend/src/views/Settings.push.test.jsx@@ -0,0 +1,119 @@+// @vitest-environment happy-dom+import React, { act } from 'react'+import { createRoot } from 'react-dom/client'+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'+import Settings from './Settings.jsx'+import { syncPushSubscription } from '../lib/push.js'++globalThis.IS_REACT_ACT_ENVIRONMENT = true++const mocks = vi.hoisted(() => {+ const state = { S: null, toast: null }+ state.snapshot = () => ({+ S: state.S,+ user: { id: 'u1', name: 'Test' }, // the Notifications card is signed-in (or mobile) only+ update: mut => {+ const next = structuredClone(state.S)+ mut(next)+ state.S = next+ },+ replaceState: vi.fn(), setUser: vi.fn(), pullState: vi.fn(), pushState: vi.fn(),+ signOut: vi.fn(), signOutAll: vi.fn(), resetDemo: vi.fn(), disconnectServer: vi.fn(),+ })+ return state+})+vi.mock('../store/useStore.js', () => {+ const useStore = selector => selector ? selector(mocks.snapshot()) : mocks.snapshot()+ useStore.getState = mocks.snapshot+ return { useStore, DEF: { reminder: { time: '17:30' } }, hasData: () => false }+})+vi.mock('../store/useUI.js', () => {+ const snap = () => ({ toast: mocks.toast, openSheet: vi.fn() })+ const useUI = selector => selector ? selector(snap()) : snap()+ useUI.getState = snap+ return { useUI }+})+vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} }))+vi.mock('../lib/api.js', () => ({+ api: vi.fn(() => new Promise(() => {})), webauthnOK: () => false, passkeyLogin: vi.fn(), passkeyRegister: vi.fn(), IS_ANDROID: false,+}))+// The switch is what this file is about, so push.js is a supported browser whose sync with the+// server each test decides.+vi.mock('../lib/push.js', () => ({+ pushSupported: () => true,+ enablePush: vi.fn(async () => {}),+ disablePush: vi.fn(async () => {}),+ sendTestPush: vi.fn(),+ syncPushSubscription: vi.fn(async () => true),+}))+vi.mock('../lib/wakelock.js', () => ({ wakeLockSupported: () => false }))+vi.mock('../lib/mobile.js', () => ({ MOBILE: false, isAndroid: () => Promise.resolve(false), shareExport: vi.fn(), syncReminder: vi.fn() }))+vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null }))+vi.mock('../sheets.jsx', () => ({+ starterPlanSheet: vi.fn(), confirmSheet: vi.fn(), importFromApp: vi.fn(),+ importFromHevy: vi.fn(), equipmentProfileSheet: vi.fn(),+}))++globalThis.__APP_VERSION__ ??= 'test'++let host, root+beforeEach(() => {+ mocks.S = {+ unit: 'kg', restSec: 90, restPauseSec: 15, sound: true, effort: 'none',+ gifSize: 'full', workouts: [], routines: [], exWeights: {},+ }+ mocks.toast = vi.fn()+ host = document.createElement('div')+ document.body.appendChild(host)+ root = createRoot(host)+})+afterEach(() => {+ act(() => root.unmount())+ host.remove()+})++const mount = async () => { await act(async () => { root.render(<Settings page="reminders" />) }) }+const rowTitled = title => [...host.querySelectorAll('.lrow')].find(r => r.querySelector('.lrow-t')?.textContent === title)+const switchIn = row => row.querySelector('[role="switch"]') || row.querySelector('input[type="checkbox"]') || row.querySelector('button')++// What the switch reads when Settings opens. "On" is the server holding this browser's+// subscription; when the server cannot be asked, the browser's own side stands in. A server that+// refused the subscription, a fresh one included (lib/push.js register), has answered, and the+// browser's side must not turn that into "on".+describe('Settings — what the Notifications switch shows when it opens', () => {+ const switchState = () => switchIn(rowTitled('Push notifications')).getAttribute('aria-checked')+ const originalWorker = Object.getOwnPropertyDescriptor(navigator, 'serviceWorker')+ const browserHolds = subscription => Object.defineProperty(navigator, 'serviceWorker', {+ configurable: true, value: { ready: Promise.resolve({ pushManager: { getSubscription: async () => subscription } }) },+ })+ afterEach(() => {+ if (originalWorker) Object.defineProperty(navigator, 'serviceWorker', originalWorker); else delete navigator.serviceWorker+ vi.mocked(syncPushSubscription).mockReset().mockImplementation(async () => true)+ })++ it('on, when the server holds this browser\'s subscription', async () => {+ await mount()+ expect(switchState()).toBe('true')+ expect(mocks.toast).not.toHaveBeenCalled()+ })++ it('the browser\'s side, when the server cannot be asked', async () => {+ browserHolds({ endpoint: 'https://push.example/e1' })+ vi.mocked(syncPushSubscription).mockRejectedValueOnce(new TypeError('Failed to fetch'))+ await mount()+ expect(switchState()).toBe('true')+ expect(mocks.toast).not.toHaveBeenCalled()+ })++ it('off, with the server\'s reason, when the server refused this browser\'s subscription', async () => {+ // By this point the real register() has dropped both subscriptions, so the browser holds+ // none. One is left here anyway, so the switch reads off because the server refused, and not+ // only because the fallback found nothing.+ browserHolds({ endpoint: 'https://push.example/e1' })+ vi.mocked(syncPushSubscription).mockRejectedValueOnce(+ Object.assign(new Error('this subscription belongs to another account'), { status: 409, refused: true }))+ await mount()+ expect(switchState()).toBe('false')+ expect(mocks.toast).toHaveBeenCalledWith('this subscription belongs to another account')+ })+})diff --git a/website/api.html b/website/api.htmlindex fece9ea1e..7867f4449 100644--- a/website/api.html+++ b/website/api.html@@ -1605,7 +1605,7 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon<span class="ep-sum">Register a Web-Push subscription</span></summary><div class="ep-body">-<p>Stores the browser's <code>PushSubscription</code> for this account. Only <code>endpoint</code> and the two protocol keys are kept. The endpoint must be a public <code>https://</code> URL; private/loopback/link-local addresses are refused (here and again at send time, against DNS rebinding). At most 20 subscriptions per user; the oldest are dropped first. Re-subscribing an existing endpoint replaces it and keeps its original <code>created</code>. The client re-sends its subscription on every signed-in boot, so a row the instance lost comes back on its own.</p>+<p>Stores the browser's <code>PushSubscription</code> for this account. Only <code>endpoint</code> and the two protocol keys are kept. The endpoint must be a public <code>https://</code> URL; private/loopback/link-local addresses are refused (here and again at send time, against DNS rebinding). At most 20 subscriptions per user; the oldest are dropped first. Re-subscribing an existing endpoint replaces it and keeps its original <code>created</code>. The client re-sends its subscription on every signed-in boot, so a row the instance lost comes back on its own. An endpoint stored for another account moves to the caller only when the request carries that subscription's own keys (the same browser, signed into another account); otherwise it is a 409 and the row stays where it was.</p><p class="ep-auth"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><rect x="4" y="11" width="16" height="10" rx="2.5"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/></svg><span>Requires a session: the cookie set at sign-in, or <code>Authorization: Bearer <token></code> from mobile-app pairing.</span></p><p class="ep-h">Request body <span class="p-hint">(JSON)</span></p><div class="ptab">@@ -1633,6 +1633,10 @@ main.api-main .lead { color: var(--fg-2); max-width: 58ch; margin: 14px 0 0; fon<div class="prow rrow"><span class="r-code s4">401</span><span class="p-desc">No session, expired/revoked session, or a disabled account.<span class="r-sig"><code>{"error":"not signed in"}</code></span></span>+ </div>+ <div class="prow rrow">+ <span class="r-code s4">409</span>+ <span class="p-desc">The endpoint is stored for another account and the request does not carry that subscription's keys.<span class="r-sig"><code>{"error":"this subscription belongs to another account"}</code></span></span></div></div></div>