From 46aaae1055f58ea39b3ec2f2478e0a676e69752d Mon Sep 17 00:00:00 2001 From: Evan Bowers Date: Tue, 17 Nov 2026 11:28:07 -0800 Subject: [PATCH 1/4] Device apps (portal): consent asked as graphql asks it, under the account the device or product was read for graphql asks consentRoot of any release that runs as root or declares capabilities (app-catalog.ts consentAsked/asksConsent), unless a consent kept covers it (coversRootAmong). The portal asked only for root releases, so a restricted app declaring person-certificates or ssh-exec was enabled, added, pinned or moved without the yes, and graphql refused it. One rule now, in helpers/appsHelper: consentAsked/asksConsent, and consentCovers (coversRootAmong, over the catalogue's releases, newest first). Every place the portal decides uses it: - useAppSwitch (Apps section, app page, connect panel, device catalogue): asks where graphql names a release awaiting consent (awaitingRoot, enabled or not), or for an app not on the device yet whose release asks. - The app page's channel, pin and Unpin: the releases the change gives (addAsks), asked first where one asks and the kept consent does not cover it, while the app is enabled. - Add an app (devices, tag, product) and the fleet's Pin and Update. - Product policy: needsConsent, or, turning one on, the release the product names (productRelease) read from the catalogue and weighed against the product's consent. The words say what is asked: root's full control where the release runs as root, else what it asks of remote.it, with its capabilities either way. Lines that said "needs to run as root" for any consent say so only where graphql's words or the catalogue say root. The release-consent lookup names the account the device or product was read under: RootConsent, useReleaseAsks and useAppSwitch take accountId as a required argument, and the product policy page passes the account useProductPolicy read the product under, which it omitted. Co-Authored-By: Claude Opus 5.5 --- frontend/src/components/AppRootConsent.tsx | 150 ++++++++++++------ frontend/src/components/DeviceApps.test.tsx | 32 ++++ .../src/components/ProductPolicyApps.test.tsx | 76 ++++++++- frontend/src/components/ProductPolicyApps.tsx | 106 +++++++++---- frontend/src/helpers/appsHelper.test.ts | 58 +++++++ frontend/src/helpers/appsHelper.ts | 79 ++++++++- frontend/src/hooks/useDeviceApps.ts | 6 +- frontend/src/hooks/useProductPolicy.ts | 3 +- frontend/src/i18n/locales/de/app.json | 19 ++- frontend/src/i18n/locales/en/app.json | 19 ++- frontend/src/i18n/locales/es/app.json | 19 ++- frontend/src/i18n/locales/ja/app.json | 19 ++- frontend/src/pages/AppAddDialog.test.tsx | 29 +++- frontend/src/pages/AppAddDialog.tsx | 64 ++++---- frontend/src/pages/AppPage.test.tsx | 30 ++++ frontend/src/pages/AppPage.tsx | 58 +++++-- frontend/src/pages/DeviceAppPage.test.tsx | 49 +++++- frontend/src/pages/DeviceAppPage.tsx | 69 +++++--- .../pages/ProductsPage/ProductPolicyPage.tsx | 3 +- 19 files changed, 708 insertions(+), 180 deletions(-) diff --git a/frontend/src/components/AppRootConsent.tsx b/frontend/src/components/AppRootConsent.tsx index b18df87db..be8b3a5db 100644 --- a/frontend/src/components/AppRootConsent.tsx +++ b/frontend/src/components/AppRootConsent.tsx @@ -4,77 +4,117 @@ import { Box, Typography } from '@mui/material' import type { DeviceApp } from '../services/graphQLDeviceApps' import { AppChange, refused } from '../services/deviceAppsShared' import type { DeviceApps } from '../hooks/useDeviceApps' -import { capabilityWords } from '../helpers/appsHelper' +import { asksConsent, capabilityWords, ConsentAsking } from '../helpers/appsHelper' import { graphQLCatalogApp } from '../services/graphQLAppCatalog' import { Confirm } from './Confirm' -/* Asking for the person's yes to a root app's full control, in words naming the app, its publisher and that it gets - full control of the device (presence-server docs/device-apps-design.md, "Root, shown and consented to"), and what - else it asks of remote.it — its capabilities, part of the consent (presence-contract docs/self-contained-apps.md, - "Manifest"). For a product it says the yes covers every device in the product, now and later, as graphql keeps it - on the product. +/* Asking for the person's yes to what a release asks (helpers/appsHelper asksConsent, graphql's rule): to run as root — + full control of the device (presence-server docs/device-apps-design.md, "Root, shown and consented to") — and the + capabilities it declares (presence-contract docs/self-contained-apps.md, "Manifest"), in words naming the app and its + publisher. A root release is asked as root, its capabilities beside; a restricted one that declares capabilities is + asked for those. For a product it says the yes covers every device in the product, now and later, as graphql keeps + it on the product. - The capabilities named are the release's the yes is given to (release), not the version the device runs: a release - may ask more than the one before it, and graphql takes the yes as covering what that release asks. They are read - from its catalogue entry (useReleaseAsks); until they are, the yes waits. */ + What is asked is the release's the yes is given to (release), not the version the device runs: a release may ask + more than the one before it, and graphql takes the yes as covering what that release asks. It is read from its + catalogue entry, under the account the device or product was read for (useReleaseAsks); until it is, the yes waits. + action: the confirm button's words, where they are not turning it on, for a release that runs as root or not. */ export const RootConsent: React.FC<{ - app?: { id?: string; name: string; publisher: string; capabilities?: string[] } // open while there is one + // open while there is one; root and capabilities: the app's own, where the catalogue does not name the release + app?: { id?: string; name: string; publisher: string; root: boolean; capabilities?: string[] } product?: boolean // a product's consent, for every device in it - action?: string // the confirm button's words, where they are not turning it on - // A release of an app already on that newly runs as root: the consent moves it there (a re-consent). + action?: (root: boolean) => string + // A release of an app already on that newly asks for consent: the consent moves it there (a re-consent). version?: string | null // The release the yes is given to, where it is not version: a pin, the release enabling gives. None: the app's own. release?: string | null - accountId?: string // whose catalogue names the release: the device's account + accountId: string | undefined // whose catalogue names the release: the device's or the product's account onConfirm: () => void onDeny: () => void }> = ({ app, product, action, version, release, accountId, onConfirm, onDeny }) => { const { t } = useTranslation() const words = { app: app?.name, publisher: app?.publisher, version } const asks = useReleaseAsks(app, release ?? version, accountId) + const root = asks ? asks.root : !!app?.root return ( {version && ( - {product + {root + ? product + ? t( + 'productApps.rootUpdate', + '{{app}} {{version}} needs to run as root. Its devices stay on the version they run until you consent.', + words + ) + : t( + 'deviceApps.rootUpdate', + '{{app}} {{version}} needs to run as root. This device stays on the version it runs until you consent.', + words + ) + : product ? t( - 'productApps.rootUpdate', - '{{app}} {{version}} needs to run as root. Its devices stay on the version they run until you consent.', + 'productApps.asksUpdate', + '{{app}} {{version}} asks more of remote.it. Its devices stay on the version they run until you consent.', words ) : t( - 'deviceApps.rootUpdate', - '{{app}} {{version}} needs to run as root. This device stays on the version it runs until you consent.', + 'deviceApps.asksUpdate', + '{{app}} {{version}} asks more of remote.it. This device stays on the version it runs until you consent.', words )} )} - - {product + + {root + ? product + ? t( + 'productApps.rootBody', + '{{app}}, published by {{publisher}}, runs as root: it gets full control of this device — every file, account and program on it — on every device in this product, now and later.', + words + ) + : t( + 'deviceApps.rootBody', + '{{app}}, published by {{publisher}}, runs as root: it gets full control of this device — every file, account and program on it.', + words + ) + : product ? t( - 'productApps.rootBody', - '{{app}}, published by {{publisher}}, runs as root: it gets full control of this device — every file, account and program on it — on every device in this product, now and later.', + 'productApps.asksBody', + '{{app}}, published by {{publisher}}, runs restricted, with an account of its own on every device in this product, now and later.', words ) : t( - 'deviceApps.rootBody', - '{{app}}, published by {{publisher}}, runs as root: it gets full control of this device — every file, account and program on it.', + 'deviceApps.asksBody', + '{{app}}, published by {{publisher}}, runs restricted, with an account of its own on this device.', words )} - + {product ? t( @@ -88,16 +128,16 @@ export const RootConsent: React.FC<{ ) } -/* What the release a consent is for asks of remote.it (its capabilities): its catalogue entry's for that release; the - app's own where no release is named, or where the catalogue does not answer for it (an API without one, an error, a - release it does not list — graphql still refuses a yes that does not cover what the release asks). undefined while - it is read. */ +/* What the release a consent is for asks (whether it runs as root, and its capabilities): its catalogue entry's for + that release, read under the account the device or product was read for; the app's own where no release is named, + or where the catalogue does not answer for it (an API without one, an error, a release it does not list — graphql + still refuses a yes that does not cover what the release asks). undefined while it is read. */ export function useReleaseAsks( - app: { id?: string; capabilities?: string[] } | undefined, + app: { id?: string; root: boolean; capabilities?: string[] } | undefined, release: string | null | undefined, - accountId?: string -): string[] | undefined { - const [read, setRead] = useState<{ key: string; asks: string[] | null }>() + accountId: string | undefined +): ConsentAsking | undefined { + const [read, setRead] = useState<{ key: string; asks: ConsentAsking | null }>() const key = app?.id && release ? `${accountId ?? ''}/${app.id}/${release}` : '' useEffect(() => { if (!key || !app?.id || !release) return @@ -105,16 +145,17 @@ export function useReleaseAsks( graphQLCatalogApp(app.id, { accountId, releases: 100 }).then(answer => { if (!current) return const entry = typeof answer === 'object' && answer ? answer.releases.find(r => r.version === release) : undefined - setRead({ key, asks: entry ? entry.capabilities : null }) + setRead({ key, asks: entry ? { root: entry.root, capabilities: entry.capabilities } : null }) }) return () => { current = false } }, [key]) if (!app) return undefined - if (!key) return app.capabilities ?? [] + const own = { root: app.root, capabilities: app.capabilities ?? [] } + if (!key) return own if (read?.key !== key) return undefined - return read.asks ?? app.capabilities ?? [] + return read.asks ?? own } // What an app asks of remote.it beyond running, a line each: in its consent, and where it is offered. @@ -140,16 +181,16 @@ export const AppCapabilities: React.FC<{ capabilities?: string[]; title?: string } /* Enabling or disabling an app, from wherever it is offered (the device's Apps section, the app's page on the device, - an app's service's connect panel). A root app is enabled only once the person says yes (RootConsent); that yes is - consentRoot, which graphql refuses a root app without. Disabling, or a restricted app, at once. A release that newly - runs as root while the app is enabled (awaitingRoot) is asked for the same way (reconsent): the yes is - setDeviceAppRelease's consentRoot alone — Update now —, which moves the device to that release. graphql's refusal, - in its words, goes to onRefused; a change made, to onChanged. */ + an app's service's connect panel, the device's catalogue). An app is enabled only once the person says yes + (RootConsent) where graphql asks for one (needsConsent); that yes is consentRoot. Disabling, or an app that asks for + nothing a consent does not already cover, at once. A release that newly asks while the app is enabled (awaitingRoot) + is asked for the same way (reconsent): the yes is setDeviceAppRelease's consentRoot alone — Update now —, which moves + the device to that release. graphql's refusal, in its words, goes to onRefused; a change made, to onChanged. */ export function useAppSwitch( { turn, setRelease }: Pick & Partial>, - onRefused?: (reason: string) => void, - onChanged?: (app: DeviceApp) => void, - accountId?: string // the device's account, whose catalogue names the release consented to + onRefused: ((reason: string) => void) | undefined, + onChanged: ((app: DeviceApp) => void) | undefined, + accountId: string | undefined // the device's account, whose catalogue names the release consented to ) { const { t } = useTranslation() const [asking, setAsking] = useState() @@ -160,7 +201,7 @@ export function useAppSwitch( } const flip = (app: DeviceApp, enabled: boolean) => { - if (enabled && app.root) setAsking(app) + if (enabled && needsConsent(app)) setAsking(app) else turn(app, enabled).then(done(app)) } @@ -169,7 +210,8 @@ export function useAppSwitch( const waiting = (app?: DeviceApp) => !!app?.enabled && (!!app.awaitingRoot || app.heldBack?.reason === 'consent') const updating = waiting(asking) ? asking?.awaitingRoot || asking?.latest || '' : null // The release the yes goes to: the one waiting for it, else the one enabling gives — its pin, else its channel's. - const target = updating || asking?.pinned || asking?.latest || asking?.release || asking?.version || null + const target = + updating || asking?.awaitingRoot || asking?.pinned || asking?.latest || asking?.release || asking?.version || null const consent = ( t('deviceApps.rootUpdateAction', 'Consent and update') : undefined} onConfirm={() => { const app = asking setAsking(undefined) @@ -191,3 +233,9 @@ export function useAppSwitch( return { flip, reconsent, consent } } + +/* Whether turning an app on asks the person's yes, as graphql decides it: a release waiting for one (awaitingRoot — + graphql names it, enabled or not, where what its release asks is not covered by the consent kept with it), or, for + one the device does not have yet (offered: no consent kept), a release that asks for one (asksConsent). */ +export const needsConsent = (app: Pick) => + !!app.awaitingRoot || (asksConsent(app) && !app.rootConsent) diff --git a/frontend/src/components/DeviceApps.test.tsx b/frontend/src/components/DeviceApps.test.tsx index 23640191b..9c536a169 100644 --- a/frontend/src/components/DeviceApps.test.tsx +++ b/frontend/src/components/DeviceApps.test.tsx @@ -288,6 +288,38 @@ describe('the switch enables and disables', () => { expect(turn).toHaveBeenCalledWith(expect.objectContaining({ id: 'remoteit.console' }), true, true) }) + it('a restricted app that declares capabilities asks the yes to them first, in their words', async () => { + apps.value = { ...apps.value, apps: [backup({ capabilities: ['ssh-exec'] })] } + const page = await render() + await click(switchOf(appRow(page, 'acme.backup'))) + expect(turn).not.toHaveBeenCalled() + expect(page.querySelector('[data-confirm-title]')?.textContent).toBe('Allow Backup what it asks?') + expect(page.querySelector('[data-root-consent]')?.getAttribute('data-root-consent')).toBe('capabilities') + expect(page.querySelector('[data-confirm] [data-app-capability]')?.getAttribute('data-app-capability')).toBe('ssh-exec') + expect(page.querySelector('[data-confirm-ok]')?.textContent).toBe('Allow and turn on') + await click(page.querySelector('[data-confirm-ok]')) + expect(turn).toHaveBeenCalledWith(expect.objectContaining({ id: 'acme.backup' }), true, true) + }) + + it('a consent kept that covers its release (none awaited): turned on at once; one awaited asks again', async () => { + const consent = { by: 'U1', email: null, at: '2026-11-10T00:00:00Z', version: '1.4.0', via: 'person' } + apps.value = { ...apps.value, apps: [consoleApp({ enabled: false, state: 'disabled', rootConsent: consent })] } + let page = await render() + await click(switchOf(appRow(page, 'remoteit.console'))) + expect(page.querySelector('[data-confirm]')).toBeNull() + expect(turn).toHaveBeenCalledWith(expect.objectContaining({ id: 'remoteit.console' }), true) + act(() => root.unmount()) + turn.mockClear() + apps.value = { + ...apps.value, + apps: [consoleApp({ enabled: false, state: 'disabled', rootConsent: consent, awaitingRoot: '1.5.0' })], + } + page = await render() + await click(switchOf(appRow(page, 'remoteit.console'))) + expect(turn).not.toHaveBeenCalled() + expect(page.querySelector('[data-confirm-title]')?.textContent).toBe('Run Console as root?') + }) + it('a restricted app at once; any app disabled at once', async () => { const page = await render() await click(switchOf(appRow(page, 'acme.backup'))) diff --git a/frontend/src/components/ProductPolicyApps.test.tsx b/frontend/src/components/ProductPolicyApps.test.tsx index d766ea9df..713ab8a0e 100644 --- a/frontend/src/components/ProductPolicyApps.test.tsx +++ b/frontend/src/components/ProductPolicyApps.test.tsx @@ -2,9 +2,9 @@ import React, { act } from 'react' import { createRoot, Root } from 'react-dom/client' import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest' -const { setApp, setAppSetting } = vi.hoisted(() => ({ setApp: vi.fn(), setAppSetting: vi.fn() })) -// The release a consent names is read from its catalogue entry; none here: the app's own capabilities. -vi.mock('../services/graphQLAppCatalog', () => ({ graphQLCatalogApp: () => Promise.resolve('UNSERVED') })) +const { setApp, setAppSetting, catalog } = vi.hoisted(() => ({ setApp: vi.fn(), setAppSetting: vi.fn(), catalog: vi.fn() })) +// The release a consent names is read from its catalogue entry; unserved by default: the app's own. +vi.mock('../services/graphQLAppCatalog', () => ({ graphQLCatalogApp: catalog })) vi.mock('../services/post', () => ({ post: vi.fn() })) vi.mock('../services/graphQL', () => ({ graphQLGetErrors: vi.fn(), @@ -149,13 +149,25 @@ async function render( document.body.appendChild(container) root = createRoot(container) await act(async () => - root.render() + root.render( + + ) ) return container } afterEach(() => act(() => root.unmount())) +// The console's catalogue entry: stable gives `current`; each release as it runs and what it declares. +const CONSOLE_ALL = ['person-accounts', 'person-certificates', 'ssh-exec'] +const consoleCatalog = (current: string, releases: { version: string; root: boolean; capabilities: string[] }[]) => ({ + id: 'remoteit.console', + accountChannel: null, + channels: [{ channel: 'stable', current, candidate: null, share: 0 }], + releases: releases.map(r => ({ ...r, withdrawn: null })), +}) + beforeEach(() => { + catalog.mockReset().mockResolvedValue('UNSERVED') setApp.mockReset().mockResolvedValue(true) setAppSetting.mockReset().mockResolvedValue(true) onChanged.mockReset() @@ -269,16 +281,56 @@ describe('a product’s Apps block', () => { expect(page.querySelector('[data-confirm]')).toBeNull() }) - it('a consent kept: shown with who and when, and the app turned on without asking again', async () => { + it('a consent kept that covers the release it names: shown with who and when, and the app turned on without asking again', async () => { + catalog.mockResolvedValue(consoleCatalog('1.4.0', [{ version: '1.4.0', root: true, capabilities: CONSOLE_ALL }])) const page = await render([ consoleApp({ state: 'disabled', rootConsent: { by: 'evan@example.com', at: '2026-11-12T18:00:00Z', version: '1.4.0' } }), ]) expect(line(page, 'remoteit.console', 'consent')).toMatch(/^Consented to run as root by evan@example.com, .*2026/) await pick(onOf(page, 'remoteit.console'), 'enabled') + expect(catalog).toHaveBeenCalledWith('remoteit.console', { accountId: 'A1', releases: 100 }) expect(page.querySelector('[data-confirm]')).toBeNull() expect(setApp).toHaveBeenCalledWith('P1', 'remoteit.console', 'enabled', { channel: 'stable', version: null }) }) + it('a consent kept that the release it names asks more than: asked again, for that release', async () => { + // 1.5.0 newly declares ssh-exec: the consent to 1.4.0 does not cover it (graphql's coversRootAmong). + catalog.mockResolvedValue( + consoleCatalog('1.5.0', [ + { version: '1.5.0', root: true, capabilities: CONSOLE_ALL }, + { version: '1.4.0', root: true, capabilities: ['person-accounts', 'person-certificates'] }, + ]) + ) + const page = await render([ + consoleApp({ state: 'disabled', rootConsent: { by: 'evan@example.com', at: '2026-11-12T18:00:00Z', version: '1.4.0' } }), + ]) + await pick(onOf(page, 'remoteit.console'), 'enabled') + expect(setApp).not.toHaveBeenCalled() + const confirm = page.querySelector('[data-confirm]')! + expect(confirm.querySelector('[data-confirm-title]')!.textContent).toBe('Run Console as root on this product’s devices?') + expect([...confirm.querySelectorAll('[data-app-capability]')].map(c => c.getAttribute('data-app-capability'))).toEqual(CONSOLE_ALL) + await click(confirm.querySelector('[data-confirm-ok]')) + expect(setApp).toHaveBeenCalledWith('P1', 'remoteit.console', 'enabled', { channel: 'stable', version: null, consentRoot: true }) + }) + + it('a restricted app that declares capabilities asks as a root one does, in words for what it asks', async () => { + const page = await render([logs({ capabilities: ['person-certificates'] })]) + await pick(onOf(page, 'acme.logs'), 'enabled') + expect(setApp).not.toHaveBeenCalled() + const confirm = page.querySelector('[data-confirm]')! + expect(confirm.querySelector('[data-confirm-title]')!.textContent).toBe('Allow Logs what it asks on this product’s devices?') + expect(confirm.querySelector('[data-root-consent]')!.textContent).toBe( + 'Logs, published by Acme, runs restricted, with an account of its own on every device in this product, now and later.' + ) + expect(confirm.textContent).toContain('It asks of remote.it:') + expect([...confirm.querySelectorAll('[data-app-capability]')].map(c => c.textContent)).toEqual([ + '· Signs in people by remote.it certificate', + ]) + expect(confirm.querySelector('[data-confirm-ok]')!.textContent).toBe('Allow and turn on') + await click(confirm.querySelector('[data-confirm-ok]')) + expect(setApp).toHaveBeenCalledWith('P1', 'acme.logs', 'enabled', { channel: null, version: null, consentRoot: true }) + }) + it('a new release that needs root: said, and consented to from its row', async () => { const page = await render([ consoleApp({ @@ -288,7 +340,7 @@ describe('a product’s Apps block', () => { }), ]) expect(line(page, 'remoteit.console', 'needs-consent')).toBe( - 'A new version needs to run as root: its devices are not turned on until you consent' + 'A new version needs your consent: its devices are not turned on until you consent' ) expect(line(page, 'remoteit.console', 'consent')).toBeUndefined() await click(row(page, 'remoteit.console').querySelector('[data-product-app-consent-action]')) @@ -441,20 +493,28 @@ describe('root, and a release that newly asks for it', () => { }) it('its devices stay on the release they run until someone consents; the dialog says which release, for every device', async () => { - // What they are given (1.4.0) runs restricted — graphql's root is the release given — beside the root one waiting. + // What they are given (1.4.0) runs restricted — graphql's root is the release given — beside the root one waiting, + // which the dialog reads from the catalogue under the product's account. + catalog.mockResolvedValue( + consoleCatalog('1.5.0', [ + { version: '1.5.0', root: true, capabilities: CONSOLE_ALL }, + { version: '1.4.0', root: false, capabilities: [] }, + ]) + ) const page = await render([ consoleApp({ state: 'enabled', root: false, version: '1.4.0', needsConsent: true, awaitingRoot: '1.5.0', rootConsent: null }), ]) expect(line(page, 'remoteit.console', 'root')).toBeUndefined() expect(line(page, 'remoteit.console', 'about')).toBe('By remote.it · 1.4.0 · Stable') expect(line(page, 'remoteit.console', 'needs-consent')).toBe( - 'A new version (1.5.0) needs to run as root: its devices stay on 1.4.0 until you consent' + 'A new version (1.5.0) needs your consent: its devices stay on 1.4.0 until you consent' ) await click(row(page, 'remoteit.console').querySelector('[data-product-app-consent-action]')) const confirm = page.querySelector('[data-confirm]')! expect(confirm.querySelector('[data-root-consent-update]')?.textContent).toBe( 'Console 1.5.0 needs to run as root. Its devices stay on the version they run until you consent.' ) + expect(catalog).toHaveBeenCalledWith('remoteit.console', { accountId: 'A1', releases: 100 }) expect(confirm.textContent).toContain('on every device in this product, now and later') await click(confirm.querySelector('[data-confirm-ok]')) expect(setApp).toHaveBeenCalledWith('P1', 'remoteit.console', 'enabled', { diff --git a/frontend/src/components/ProductPolicyApps.tsx b/frontend/src/components/ProductPolicyApps.tsx index 1071b4a8a..a1788b18a 100644 --- a/frontend/src/components/ProductPolicyApps.tsx +++ b/frontend/src/components/ProductPolicyApps.tsx @@ -7,6 +7,7 @@ import { ProductAppState, ProductAppSetting, ProductRemovedSetting, + ProductRootConsent, ProductSync, graphQLSetDeviceProductApp, graphQLSetDeviceProductAppSetting, @@ -17,11 +18,13 @@ import { SelectSetting } from './SelectSetting' import { timeOptions } from './Timestamp' import { Notice } from './Notice' import { Icon } from './Icon' -import { appIcon, capabilitiesLine } from '../helpers/appsHelper' +import { appIcon, asksConsent, capabilitiesLine, consentCovers, productRelease } from '../helpers/appsHelper' +import { graphQLCatalogApp } from '../services/graphQLAppCatalog' import { LIST_ITEM_ICON_WIDTH, spacing } from '../styling' type Props = { productId: string + accountId: string | undefined // the account the product was read under, whose catalogue names its releases apps: ProductApp[] sync: ProductSync manage: boolean @@ -40,20 +43,24 @@ const UNSET = '' its options, inside its row and lined up under its name. One the product sets is locked on its devices while it is synced or enforced; a setting the release says may not be forced is given to them but not locked, and is said so. - A root app is enabled for the product only once the person says yes to its full control of every device in the - product, now and later, and to what else it asks of remote.it (components/AppRootConsent); graphql keeps that consent on the product, and asks for it again - when a new release newly runs as root, its devices staying on its last restricted release meanwhile (or not turned - on, where there is none). Turning an app on needs Scripting in the product's account as well as managing the - product; graphql says so where it refuses, and its words are shown. + An app whose release asks for a consent (helpers/appsHelper asksConsent: it runs as root, or declares capabilities) + is enabled for the product only once the person says yes — to its full control of every device in the product, now + and later, where it runs as root, and to what it asks of remote.it (components/AppRootConsent); graphql keeps that + consent on the product, and asks for it again when a new release newly asks for more (needsConsent), its devices + staying on the release before meanwhile (or not turned on, where there is none). graphql says whether the consent + kept covers its release only while the app is enabled (needsConsent): turning one on, the release the product names + (productRelease) is read from the catalogue, under the product's account, and weighed as graphql weighs it + (consentCovers) — asked where the catalogue cannot say. Turning an app on needs Scripting in the product's account + as well as managing the product; graphql says so where it refuses, and its words are shown. A setting a release deprecates is shown, with why, only where the product sets a value; one a later release removed is listed as Removed in , with no effect on its devices, until graphql's daily sweep deletes it — or the product clears it here. */ -export const ProductPolicyApps: React.FC = ({ productId, apps, sync, manage, onChanged }) => { +export const ProductPolicyApps: React.FC = ({ productId, accountId, apps, sync, manage, onChanged }) => { const { t } = useTranslation() const [saving, setSaving] = useState() const [refusal, setRefusal] = useState() - const [asking, setAsking] = useState() + const [asking, setAsking] = useState<{ app: ProductApp; release: string | null }>() if (!apps.length) return null @@ -67,11 +74,16 @@ export const ProductPolicyApps: React.FC = ({ productId, apps, sync, mana onChanged() } - // Enabling a root app without a consent that covers its release asks for one first — one whose devices stay on a - // restricted release (root says that one) while a root one waits (needsConsent) included. - const setApp = (app: ProductApp, state: ProductAppState | null, consentRoot?: boolean) => { - if (state === 'enabled' && !consentRoot && (app.root || app.needsConsent) && (!app.rootConsent || app.needsConsent)) - return setAsking(app) + // Enabling an app whose release asks for a consent the product's does not cover asks for it first — one whose devices + // stay on the release before while a new one waits (needsConsent) included. + const setApp = async (app: ProductApp, state: ProductAppState | null, consentRoot?: boolean) => { + if (state === 'enabled' && !consentRoot) { + if (app.needsConsent) return setAsking({ app, release: app.awaitingRoot ?? null }) + if (asksConsent(app)) { + const asks = await namedAsks(app) + if (asks !== false) return setAsking({ app, release: asks }) + } + } write(app.id, t('productApps.notChanged', 'The app was not changed.'), () => graphQLSetDeviceProductApp( productId, @@ -84,6 +96,19 @@ export const ProductPolicyApps: React.FC = ({ productId, apps, sync, mana ) } + // The release enabling names, where it asks for a consent the product's does not cover (none where the catalogue + // cannot say which); false where it asks for none, or is covered. + const namedAsks = async (app: ProductApp): Promise => { + setSaving(app.id) + const answer = await graphQLCatalogApp(app.id, { accountId, releases: 100 }) + setSaving(undefined) + const catalog = typeof answer === 'object' && answer ? answer : undefined + const named = catalog && productRelease(catalog, app.channel, app.pinned) + if (!catalog || !named) return null + if (!asksConsent(named) || consentCovers(app.rootConsent, named, catalog.releases)) return false + return named.version + } + const setSetting = (app: ProductApp, name: string, value: any) => write(`${app.id}.${name}`, t('productSettings.notChanged', 'The setting was not changed.'), () => graphQLSetDeviceProductAppSetting(productId, app.id, name, value) @@ -137,28 +162,19 @@ export const ProductPolicyApps: React.FC = ({ productId, apps, sync, mana )} {app.locked && {lockedLine(t, sync)}} {app.rootConsent && !app.needsConsent && ( - - {t( - 'productApps.consentedAll', - 'Consented to run as root by {{by}}, {{when}}: for every device in this product, now and later', - { - by: app.rootConsent.email || app.rootConsent.by, - when: when(app.rootConsent.at), - } - )} - + {consentedLine(t, app.root, app.rootConsent)} )} {app.needsConsent && ( {app.awaitingRoot && app.version ? t( - 'productApps.needsConsentStay', - 'A new version ({{version}}) needs to run as root: its devices stay on {{current}} until you consent', + 'productApps.needsConsentAsksStay', + 'A new version ({{version}}) needs your consent: its devices stay on {{current}} until you consent', { version: app.awaitingRoot, current: app.version } ) : t( - 'productApps.needsConsent', - 'A new version needs to run as root: its devices are not turned on until you consent' + 'productApps.needsConsentAsks', + 'A new version needs your consent: its devices are not turned on until you consent' )} )} @@ -170,7 +186,7 @@ export const ProductPolicyApps: React.FC = ({ productId, apps, sync, mana size="small" color="warning" disabled={saving === app.id} - onClick={() => setAsking(app)} + onClick={() => setAsking({ app, release: app.awaitingRoot ?? null })} data-product-app-consent-action > {t('productApps.consent', 'Consent…')} @@ -230,12 +246,20 @@ export const ProductPolicyApps: React.FC = ({ productId, apps, sync, mana )} + root + ? t('productApps.consentAction', 'Consent to full control') + : t('productApps.consentAsksAction', 'Consent') + : undefined + } onConfirm={() => { - const app = asking + const app = asking?.app setAsking(undefined) if (app) setApp(app, 'enabled', true) }} @@ -408,6 +432,22 @@ function about(t: TFunction, app: ProductApp) { .join(' · ') } +// Who consented for the product, and when: to its running as root where it does, else to what it asks. +function consentedLine(t: TFunction, root: boolean, consent: ProductRootConsent): string { + const words = { by: consent.email || consent.by, when: when(consent.at) } + return root + ? t( + 'productApps.consentedAll', + 'Consented to run as root by {{by}}, {{when}}: for every device in this product, now and later', + words + ) + : t( + 'productApps.consentedAllAsks', + 'Consented by {{by}}, {{when}}: for every device in this product, now and later', + words + ) +} + const lockedLine = (t: TFunction, sync: ProductSync) => sync === 'enforced' ? t('productApps.lockedEnforced', 'Locked on its devices (enforced)') diff --git a/frontend/src/helpers/appsHelper.test.ts b/frontend/src/helpers/appsHelper.test.ts index d7f9c4537..11e015536 100644 --- a/frontend/src/helpers/appsHelper.test.ts +++ b/frontend/src/helpers/appsHelper.test.ts @@ -2,6 +2,10 @@ import { describe, it, expect } from 'vitest' import type { TFunction } from 'i18next' import { addAsks, + asksConsent, + consentCovers, + heldBackReason, + productRelease, appHost, appIcon, capabilitiesLine, @@ -196,3 +200,57 @@ describe('addAsks: what adding an app gives, and so asks', () => { expect(addAsks(own, 'beta')).toEqual({ versions: ['1.2.0', '1.1.0'], root: true, capabilities: ['person-certificates'] }) }) }) + +describe('consent, as graphql asks it (app-catalog.ts consentAsked, coversRootAmong)', () => { + const r = (version: string, root: boolean, capabilities: string[] = []) => ({ version, root, capabilities }) + // Newest first, as the catalogue lists them. + const releases = [r('1.6.0', true, ['ssh-exec']), r('1.5.0', true), r('1.4.0', false), r('1.3.0', true)] + + it('asked by a release that runs as root, or declares any capability; not by one that does neither', () => { + expect(asksConsent(r('1', true))).toBe(true) + expect(asksConsent(r('1', false, ['person-certificates']))).toBe(true) + expect(asksConsent(r('1', false))).toBe(false) + expect(asksConsent(undefined)).toBe(false) + }) + + it('a consent covers the release it was given to, earlier ones, and later ones asking nothing more with none between lacking it', () => { + const to = (version: string | null) => ({ version }) + expect(consentCovers(null, releases[1], releases)).toBe(false) + expect(consentCovers(to(null), releases[0], releases)).toBe(true) // from before consents were kept + expect(consentCovers(to('1.5.0'), releases[1], releases)).toBe(true) + expect(consentCovers(to('1.5.0'), releases[3], releases)).toBe(true) + // 1.6.0 asks ssh-exec as well: not covered by 1.5.0's. + expect(consentCovers(to('1.5.0'), releases[0], releases)).toBe(false) + // Root, restricted, root: 1.3.0's does not reach 1.5.0 past 1.4.0. + expect(consentCovers(to('1.3.0'), releases[1], releases)).toBe(false) + // Given to a release that asked less: not covered. + expect(consentCovers(to('1.4.0'), releases[1], releases)).toBe(false) + // One not among those read: only its own release. + expect(consentCovers(to('1.0.0'), releases[1], releases)).toBe(false) + expect(consentCovers(to('1.0.0'), r('1.0.0', true), releases)).toBe(true) + }) + + it('a product’s release: its pin, else its channel’s current, the account’s or stable’s', () => { + const app = { + accountChannel: 'beta', + channels: [ + { channel: 'stable', current: '1.4.0', candidate: null, share: 0 }, + { channel: 'beta', current: '1.5.0', candidate: '1.6.0', share: 50 }, + ], + releases: [{ ...r('1.6.0', true), withdrawn: null }, { ...r('1.5.0', true), withdrawn: null }, { ...r('1.4.0', false), withdrawn: null }], + } as any + expect(productRelease(app, null, null)?.version).toBe('1.5.0') + expect(productRelease(app, 'stable', null)?.version).toBe('1.4.0') + expect(productRelease(app, 'stable', '1.6.0')?.version).toBe('1.6.0') + expect(productRelease({ ...app, channels: [app.channels[0]] }, 'beta', null)?.version).toBe('1.4.0') + }) + + it('held for consent, in words for what the release waiting asks, as graphql says it', () => { + expect(heldBackReason(t, { reason: 'consent', detail: 'A new version needs to run as root' })).toBe( + 'A new version needs to run as root' + ) + expect(heldBackReason(t, { reason: 'consent', detail: 'A new version asks for ssh-exec' })).toBe( + 'A new version asks more of remote.it' + ) + }) +}) diff --git a/frontend/src/helpers/appsHelper.ts b/frontend/src/helpers/appsHelper.ts index fde709adc..fd192e443 100644 --- a/frontend/src/helpers/appsHelper.ts +++ b/frontend/src/helpers/appsHelper.ts @@ -8,7 +8,7 @@ import type { } from '../services/graphQLDeviceApps' import { needsNewer } from '../services/deviceAppsShared' import type { SettingLock } from '../services/productPolicy' -import type { CatalogApp } from '../services/graphQLAppCatalog' +import type { CatalogApp, CatalogAppRelease } from '../services/graphQLAppCatalog' import { timeOptions } from '../components/Timestamp' /* The words the Apps pages share (presence-server docs/device-apps-design.md, "The Apps pages"): who publishes an app, @@ -138,6 +138,54 @@ export function releaseChannelName( : t('apps.channelCandidate', '{{channel}} candidate', { channel: channelName(t, channel) }) } +/* What a release asks a consent for, as graphql decides it (app-catalog.ts consentAsked): to run as root, and each + capability it declares. A release that asks anything is turned on, pinned or moved to only with the person's yes + (consentRoot), in words saying what it asks — root's full control where it runs as root, the capabilities where it + declares them —, unless a consent already given covers it. One rule, wherever the portal decides. */ +export type ConsentAsking = { root: boolean; capabilities?: string[] | null } +export const consentAsked = (release: ConsentAsking): string[] => [ + ...(release.root ? ['root'] : []), + ...(release.capabilities ?? []), +] +export const asksConsent = (release: ConsentAsking | null | undefined): boolean => + !!release && consentAsked(release).length > 0 + +/* Whether a consent covers a release (graphql's coversRootAmong): one given to no release (from before consents were + kept) covers as it always did; one given to a release covers `named` where that release asked everything `named` + asks, and `named` is that release or an earlier one, or a later one with no release between lacking any of it. + releases: the app's, newest first (by version), as the catalogue lists them, withdrawn ones too. Where either is not + among them (only the newest are read), it covers only the release it was given to: asking again is safe — graphql + keeps the newer yes —, while a yes not asked is refused. */ +export function consentCovers( + consent: { version?: string | null } | null | undefined, + named: ConsentAsking & { version: string }, + releases: (ConsentAsking & { version: string })[] +): boolean { + if (!consent) return false + if (!consent.version) return true + const asked = consentAsked(named) + const has = (release: ConsentAsking) => asked.every(ask => consentAsked(release).includes(ask)) + const given = releases.findIndex(release => release.version === consent.version) + const at = releases.findIndex(release => release.version === named.version) + if (given < 0 || at < 0) return consent.version === named.version + if (!has(releases[given])) return false + return at >= given || releases.slice(at + 1, given).every(has) +} + +/* The release a product names for an app (graphql's productRelease): its pin, else its channel's current — the + account's channel where it names none, else stable —, else stable's current. None where that is withdrawn, or not + among the releases read. */ +export function productRelease( + app: CatalogApp, + channel: string | null | undefined, + pin: string | null | undefined +): CatalogAppRelease | undefined { + const current = (name: string) => app.channels.find(c => c.channel === name)?.current + const version = pin || current(channel || app.accountChannel || 'stable') || current('stable') + const release = app.releases.find(r => r.version === version) + return release?.withdrawn ? undefined : release +} + /* What adding an app gives the devices, and so what it asks (graphql's releaseFor and channelVersion): the release pinned; else what the channel chosen gives — the account's where none is, else stable —: its candidate to the devices in its share, its current to the rest, and a channel naming none stable's. A withdrawn release is given to @@ -241,6 +289,32 @@ export function consentLine(t: TFunction, consent: DeviceAppRootConsent): string } } +// The yes, in words: to full control where a release runs as root, else to what it asks of remote.it. +export function allowLine(t: TFunction, root: boolean, product: boolean, publisher: string, app: string): string { + const words = { publisher, app } + if (root) + return product + ? t( + 'apps.allowRootProduct', + 'I allow {{publisher}}’s {{app}} full control of every device in this product', + words + ) + : t('apps.allowRootDevices', 'I allow {{publisher}}’s {{app}} full control of these devices', words) + return product + ? t('apps.allowAsksProduct', 'I allow {{publisher}}’s {{app}} what it asks on every device in this product', words) + : t('apps.allowAsksDevices', 'I allow {{publisher}}’s {{app}} what it asks on these devices', words) +} + +// A release waiting for a consent, by what it asks: to run as root, or more of remote.it (its capabilities). +export const heldConsentWords = (t: TFunction, root: boolean) => + root + ? t('apps.heldConsent', 'A new version needs to run as root') + : t('apps.heldConsentAsks', 'A new version asks more of remote.it') +// Whether the release a consent is waited for runs as root, as graphql's words for it say (device-apps.ts +// needsConsentOf: "… needs to run as root", else "… asks for "); none said: as before capabilities did. +export const heldConsentRoot = (heldBack: Pick) => + !heldBack.detail || /run as root/.test(heldBack.detail) + // The machine's administrator refusing root apps (apps_root_control off), as graphql or the device says it. const ROOT_REFUSED = /apps_root_control off|no apps that run as root/ @@ -341,7 +415,8 @@ export function heldBackReason(t: TFunction, heldBack: AppHeldBack, pinned?: str case 'pinned': return pinned ? t('apps.heldPinnedTo', 'Pinned to {{version}}', { version: pinned }) : t('apps.heldPinned', 'Pinned') case 'consent': - return t('apps.heldConsent', 'A new version needs to run as root') + // graphql says what the release waiting asks (device-apps.ts needsConsentOf): running as root, or capabilities. + return heldConsentWords(t, heldConsentRoot(heldBack)) case 'daemon': return t('deviceApps.needsNewer', 'Needs a newer remote.it on this device') default: diff --git a/frontend/src/hooks/useDeviceApps.ts b/frontend/src/hooks/useDeviceApps.ts index 48efee822..99feafb6a 100644 --- a/frontend/src/hooks/useDeviceApps.ts +++ b/frontend/src/hooks/useDeviceApps.ts @@ -41,10 +41,10 @@ export type DeviceApps = { // What it may add (the device's catalogue): read once its apps are, and again after one is added or removed. available?: AvailableApp[] switching?: string // the app being changed, waited for - // Enabled or disabled; an app the device has no row for (one offered) is added. consentRoot: the person said yes to a - // root app's full control of the device (components/AppRootConsent). + // Enabled or disabled; an app the device has no row for (one offered) is added. consentRoot: the person said yes to + // what its release asks — root's full control of the device, its capabilities (components/AppRootConsent). turn: (app: DeviceApp, enabled: boolean, consentRoot?: boolean) => Promise> - // Its channel and pin; consentRoot alone is Update now, to a release waiting for root consent. + // Its channel and pin; consentRoot alone is Update now, to a release waiting for a consent. setRelease: (app: DeviceApp, release: AppRelease) => Promise> // Removed from the device, its files and data with it. remove: (app: DeviceApp) => Promise> diff --git a/frontend/src/hooks/useProductPolicy.ts b/frontend/src/hooks/useProductPolicy.ts index 40118f8ef..88db5771e 100644 --- a/frontend/src/hooks/useProductPolicy.ts +++ b/frontend/src/hooks/useProductPolicy.ts @@ -98,7 +98,8 @@ export function useProductPolicy(productId?: string) { () => (enabled ? products.read(key, productId!, accountId) : Promise.resolve()), [enabled, key] ) - return { served, policy, reload } + // accountId: the account it was read under, whose catalogue names its apps' releases. + return { served, policy, reload, accountId } } // A device's product: for a device of the account in view (its accountId), a virtual one has none of its own. diff --git a/frontend/src/i18n/locales/de/app.json b/frontend/src/i18n/locales/de/app.json index acd82325d..2fc86d807 100644 --- a/frontend/src/i18n/locales/de/app.json +++ b/frontend/src/i18n/locales/de/app.json @@ -214,6 +214,8 @@ "addToProduct": "", "adminLocal": "", "adminOff": "", + "allowAsksDevices": "Ich erlaube {{app}} von {{publisher}}, was es auf diesen Geräten verlangt", + "allowAsksProduct": "Ich erlaube {{app}} von {{publisher}}, was es auf jedem Gerät in diesem Produkt verlangt", "allowRootDevices": "", "allowRootProduct": "", "allTags": "", @@ -269,6 +271,7 @@ "grantUntil": "", "heldBack": "", "heldConsent": "", + "heldConsentAsks": "Eine neue Version verlangt mehr von remote.it", "heldPending": "", "heldPinned": "", "heldPinnedTo": "", @@ -310,6 +313,7 @@ "outcomeUnchanged": "", "pin": "", "pinAction": "", + "pinAsksAction": "Erlauben und festlegen", "pinnedTo": "", "pinRootAction": "", "pinSelected": "", @@ -365,6 +369,8 @@ "toTag": "", "unpin": "", "unserved": "", + "updateAsksBody": "Eine neue Version von {{app}}, veröffentlicht von {{publisher}}, verlangt auf jedem ausgewählten Gerät mehr von remote.it. Aktualisieren Sie nur, wenn Sie {{publisher}} diese Geräte anvertrauen.", + "updateAsksTitle": "{{app}} auf eine Version aktualisieren, die mehr verlangt?", "updateNow": "", "updateRootAction": "", "updateRootBody": "", @@ -1175,6 +1181,10 @@ }, "deviceApps": { "addNeedsScripting": "Eine App hinzuzufügen führt Code auf diesem Gerät aus: Dafür ist dort Scripting nötig.", + "asksAction": "Erlauben und einschalten", + "asksBody": "{{app}}, veröffentlicht von {{publisher}}, läuft eingeschränkt, mit einem eigenen Konto auf diesem Gerät.", + "asksTitle": "{{app}} erlauben, was es verlangt?", + "asksUpdate": "{{app}} {{version}} verlangt mehr von remote.it. Dieses Gerät bleibt auf seiner Version, bis Sie zustimmen.", "beta": "", "between": "Von {{min}} bis {{max}}", "clearDeprecated": "Leeren: zurück zum Standard", @@ -3205,16 +3215,21 @@ "title": "Produkt erstellen" }, "productApps": { + "asksBody": "{{app}}, veröffentlicht von {{publisher}}, läuft eingeschränkt, mit einem eigenen Konto auf jedem Gerät in diesem Produkt, jetzt und künftig.", + "asksTitle": "{{app}} auf den Geräten dieses Produkts erlauben, was es verlangt?", + "asksUpdate": "{{app}} {{version}} verlangt mehr von remote.it. Seine Geräte bleiben auf ihrer Version, bis Sie zustimmen.", "clearRemoved": "Leeren", "consent": "", "consentAction": "", + "consentAsksAction": "Zustimmen", "consentedAll": "Als root zugestimmt von {{by}}, {{when}}: für jedes Gerät in diesem Produkt, jetzt und künftig", + "consentedAllAsks": "Zugestimmt von {{by}}, {{when}}: für jedes Gerät in diesem Produkt, jetzt und künftig", "hintEnforcedStates": "", "hintStates": "", "lockedEnforced": "", "lockedSynced": "", - "needsConsent": "", - "needsConsentStay": "Eine neue Version ({{version}}) muss als root laufen: Seine Geräte bleiben auf {{current}}, bis Sie zustimmen", + "needsConsentAsks": "Eine neue Version braucht Ihre Zustimmung: Seine Geräte werden erst eingeschaltet, wenn Sie zustimmen", + "needsConsentAsksStay": "Eine neue Version ({{version}}) braucht Ihre Zustimmung: Seine Geräte bleiben auf {{current}}, bis Sie zustimmen", "noRelease": "", "notChanged": "", "notLocked": "", diff --git a/frontend/src/i18n/locales/en/app.json b/frontend/src/i18n/locales/en/app.json index 16eb7ecf5..11b3bd545 100644 --- a/frontend/src/i18n/locales/en/app.json +++ b/frontend/src/i18n/locales/en/app.json @@ -214,6 +214,8 @@ "addToProduct": "Set Enabled on {{product}}", "adminLocal": "Kept local by this device’s administrator: changed on the device only", "adminOff": "Turned off on this device by its administrator", + "allowAsksDevices": "I allow {{publisher}}’s {{app}} what it asks on these devices", + "allowAsksProduct": "I allow {{publisher}}’s {{app}} what it asks on every device in this product", "allowRootDevices": "I allow {{publisher}}’s {{app}} full control of these devices", "allowRootProduct": "I allow {{publisher}}’s {{app}} full control of every device in this product", "allTags": "All of these", @@ -269,6 +271,7 @@ "grantUntil": "Granted until {{day}}, renewed by itself", "heldBack": "Held back: {{reason}}", "heldConsent": "A new version needs to run as root", + "heldConsentAsks": "A new version asks more of remote.it", "heldPending": "Given, and the device has not said it runs it yet", "heldPinned": "Pinned", "heldPinnedTo": "Pinned to {{version}}", @@ -310,6 +313,7 @@ "outcomeUnchanged": "Unchanged", "pin": "Pin", "pinAction": "Pin", + "pinAsksAction": "Allow and pin", "pinnedTo": "Pinned to {{version}}", "pinRootAction": "Pin with full control", "pinSelected": "Pin selected…", @@ -365,6 +369,8 @@ "toTag": "A tag", "unpin": "Unpin", "unserved": "This server does not have apps.", + "updateAsksBody": "A new version of {{app}}, published by {{publisher}}, asks more of remote.it on each device selected. Update only if you trust {{publisher}} with them.", + "updateAsksTitle": "Update {{app}} to a version that asks more?", "updateNow": "Update now…", "updateRootAction": "Consent and update", "updateRootBody": "A new version of {{app}}, published by {{publisher}}, runs as root: it gets full control of each device selected — every file, account and program on it. Update only if you trust {{publisher}} with them.", @@ -1175,6 +1181,10 @@ }, "deviceApps": { "addNeedsScripting": "Adding an app runs code on this device: it needs Scripting there.", + "asksAction": "Allow and turn on", + "asksBody": "{{app}}, published by {{publisher}}, runs restricted, with an account of its own on this device.", + "asksTitle": "Allow {{app}} what it asks?", + "asksUpdate": "{{app}} {{version}} asks more of remote.it. This device stays on the version it runs until you consent.", "beta": "Beta", "between": "From {{min}} to {{max}}", "clearDeprecated": "Clear: back to its default", @@ -3205,16 +3215,21 @@ "title": "Create Product" }, "productApps": { + "asksBody": "{{app}}, published by {{publisher}}, runs restricted, with an account of its own on every device in this product, now and later.", + "asksTitle": "Allow {{app}} what it asks on this product’s devices?", + "asksUpdate": "{{app}} {{version}} asks more of remote.it. Its devices stay on the version they run until you consent.", "clearRemoved": "Clear", "consent": "Consent…", "consentAction": "Consent to full control", + "consentAsksAction": "Consent", "consentedAll": "Consented to run as root by {{by}}, {{when}}: for every device in this product, now and later", + "consentedAllAsks": "Consented by {{by}}, {{when}}: for every device in this product, now and later", "hintEnforcedStates": "An app set here is locked on its devices. One not listed is removed from them, as the product is enforced.", "hintStates": "Enabled adds and runs it on the product’s devices, Disabled adds it stopped, Removed takes it off them. One left unset is each device’s own. One set here is locked on its devices while the product is synced or enforced.", "lockedEnforced": "Locked on its devices (enforced)", "lockedSynced": "Locked on its devices (synced)", - "needsConsent": "A new version needs to run as root: its devices are not turned on until you consent", - "needsConsentStay": "A new version ({{version}}) needs to run as root: its devices stay on {{current}} until you consent", + "needsConsentAsks": "A new version needs your consent: its devices are not turned on until you consent", + "needsConsentAsksStay": "A new version ({{version}}) needs your consent: its devices stay on {{current}} until you consent", "noRelease": "No release here yet", "notChanged": "The app was not changed.", "notLocked": "Given to its devices, not locked: this setting can’t be fixed", diff --git a/frontend/src/i18n/locales/es/app.json b/frontend/src/i18n/locales/es/app.json index 24eb14c2d..fd051b68b 100644 --- a/frontend/src/i18n/locales/es/app.json +++ b/frontend/src/i18n/locales/es/app.json @@ -217,6 +217,8 @@ "addToProduct": "", "adminLocal": "", "adminOff": "", + "allowAsksDevices": "Permito a {{app}} de {{publisher}} lo que pide en estos dispositivos", + "allowAsksProduct": "Permito a {{app}} de {{publisher}} lo que pide en todos los dispositivos de este producto", "allowRootDevices": "", "allowRootProduct": "", "allTags": "", @@ -276,6 +278,7 @@ "grantUntil": "", "heldBack": "", "heldConsent": "", + "heldConsentAsks": "Una nueva versión pide más a remote.it", "heldPending": "", "heldPinned": "", "heldPinnedTo": "", @@ -317,6 +320,7 @@ "outcomeUnchanged": "", "pin": "", "pinAction": "", + "pinAsksAction": "Permitir y fijar", "pinnedTo": "", "pinRootAction": "", "pinSelected": "", @@ -372,6 +376,8 @@ "toTag": "", "unpin": "", "unserved": "", + "updateAsksBody": "Una nueva versión de {{app}}, publicada por {{publisher}}, pide más a remote.it en cada dispositivo seleccionado. Actualiza solo si confías en {{publisher}} con ellos.", + "updateAsksTitle": "¿Actualizar {{app}} a una versión que pide más?", "updateNow": "", "updateRootAction": "", "updateRootBody": "", @@ -1189,6 +1195,10 @@ }, "deviceApps": { "addNeedsScripting": "Añadir una app ejecuta código en este dispositivo: necesita Scripting en él.", + "asksAction": "Permitir y activar", + "asksBody": "{{app}}, publicada por {{publisher}}, se ejecuta restringida, con una cuenta propia en este dispositivo.", + "asksTitle": "¿Permitir a {{app}} lo que pide?", + "asksUpdate": "{{app}} {{version}} pide más a remote.it. Este dispositivo sigue en la versión que ejecuta hasta que des tu consentimiento.", "beta": "", "between": "De {{min}} a {{max}}", "clearDeprecated": "Borrar: volver al valor predeterminado", @@ -3264,16 +3274,21 @@ "title": "Crear producto" }, "productApps": { + "asksBody": "{{app}}, publicada por {{publisher}}, se ejecuta restringida, con una cuenta propia en todos los dispositivos de este producto, ahora y en el futuro.", + "asksTitle": "¿Permitir a {{app}} lo que pide en los dispositivos de este producto?", + "asksUpdate": "{{app}} {{version}} pide más a remote.it. Sus dispositivos siguen en la versión que ejecutan hasta que des tu consentimiento.", "clearRemoved": "Borrar", "consent": "", "consentAction": "", + "consentAsksAction": "Dar consentimiento", "consentedAll": "Consentimiento para ejecutarse como root de {{by}}, {{when}}: para todos los dispositivos de este producto, ahora y en el futuro", + "consentedAllAsks": "Consentido por {{by}}, {{when}}: para todos los dispositivos de este producto, ahora y en el futuro", "hintEnforcedStates": "", "hintStates": "", "lockedEnforced": "", "lockedSynced": "", - "needsConsent": "", - "needsConsentStay": "Una nueva versión ({{version}}) necesita ejecutarse como root: sus dispositivos siguen en {{current}} hasta que des tu consentimiento", + "needsConsentAsks": "Una nueva versión necesita tu consentimiento: sus dispositivos no se activan hasta que des tu consentimiento", + "needsConsentAsksStay": "Una nueva versión ({{version}}) necesita tu consentimiento: sus dispositivos siguen en {{current}} hasta que des tu consentimiento", "noRelease": "", "notChanged": "", "notLocked": "", diff --git a/frontend/src/i18n/locales/ja/app.json b/frontend/src/i18n/locales/ja/app.json index 19181d0b6..68a5429fa 100644 --- a/frontend/src/i18n/locales/ja/app.json +++ b/frontend/src/i18n/locales/ja/app.json @@ -211,6 +211,8 @@ "addToProduct": "", "adminLocal": "", "adminOff": "", + "allowAsksDevices": "{{publisher}} の {{app}} がこれらのデバイスで求めることを許可します", + "allowAsksProduct": "{{publisher}} の {{app}} がこの製品のすべてのデバイスで求めることを許可します", "allowRootDevices": "", "allowRootProduct": "", "allTags": "", @@ -262,6 +264,7 @@ "grantUntil": "", "heldBack": "", "heldConsent": "", + "heldConsentAsks": "新しいバージョンは remote.it により多くを求めます", "heldPending": "", "heldPinned": "", "heldPinnedTo": "", @@ -303,6 +306,7 @@ "outcomeUnchanged": "", "pin": "", "pinAction": "", + "pinAsksAction": "許可して固定", "pinnedTo": "", "pinRootAction": "", "pinSelected": "", @@ -358,6 +362,8 @@ "toTag": "", "unpin": "", "unserved": "", + "updateAsksBody": "{{publisher}} が公開する {{app}} の新しいバージョンは、選択した各デバイスで remote.it により多くを求めます。{{publisher}} を信頼できる場合にのみ更新してください。", + "updateAsksTitle": "{{app}} をより多くを求めるバージョンに更新しますか?", "updateNow": "", "updateRootAction": "", "updateRootBody": "", @@ -1161,6 +1167,10 @@ }, "deviceApps": { "addNeedsScripting": "アプリの追加はこのデバイスでコードを実行します: Scripting 権限が必要です。", + "asksAction": "許可してオンにする", + "asksBody": "{{publisher}} が公開する {{app}} は、このデバイス上の専用アカウントで制限付きで実行されます。", + "asksTitle": "{{app}} が求めることを許可しますか?", + "asksUpdate": "{{app}} {{version}} は remote.it により多くを求めます。同意するまで、このデバイスは現在のバージョンのままです。", "beta": "", "between": "{{min}} から {{max}} まで", "clearDeprecated": "クリア: 既定値に戻す", @@ -3146,16 +3156,21 @@ "title": "プロダクトを作成" }, "productApps": { + "asksBody": "{{publisher}} が公開する {{app}} は、この製品のすべてのデバイス (現在および今後) 上の専用アカウントで制限付きで実行されます。", + "asksTitle": "この製品のデバイスで {{app}} が求めることを許可しますか?", + "asksUpdate": "{{app}} {{version}} は remote.it により多くを求めます。同意するまで、デバイスは現在のバージョンのままです。", "clearRemoved": "クリア", "consent": "", "consentAction": "", + "consentAsksAction": "同意する", "consentedAll": "{{by}} が root での実行に同意 ({{when}}): このプロダクトのすべてのデバイス (今後追加されるものも含む)", + "consentedAllAsks": "{{by}} が {{when}} に同意: この製品のすべてのデバイス (現在および今後) が対象", "hintEnforcedStates": "", "hintStates": "", "lockedEnforced": "", "lockedSynced": "", - "needsConsent": "", - "needsConsentStay": "新しいバージョン ({{version}}) は root での実行が必要です: 同意するまで、デバイスは {{current}} のままです", + "needsConsentAsks": "新しいバージョンには同意が必要です: 同意するまで、デバイスはオンになりません", + "needsConsentAsksStay": "新しいバージョン ({{version}}) には同意が必要です: 同意するまで、デバイスは {{current}} のままです", "noRelease": "", "notChanged": "", "notLocked": "", diff --git a/frontend/src/pages/AppAddDialog.test.tsx b/frontend/src/pages/AppAddDialog.test.tsx index 027cf90c1..77337dde2 100644 --- a/frontend/src/pages/AppAddDialog.test.tsx +++ b/frontend/src/pages/AppAddDialog.test.tsx @@ -236,13 +236,33 @@ describe('the root consent', () => { expect(said()).toEqual(['· AI commands go through this app']) }) - it('a restricted app says what it asks of remote.it above Add, with no consent asked', async () => { + it('a restricted app that declares capabilities asks the yes to them, as graphql does: Add only once it is given', async () => { catalog.mockResolvedValue(accountRelease({ capabilities: ['person-certificates'] })) await render() + await tick('D1') expect($('[data-app-add-root]')).toBeNull() expect($('[data-app-add-capabilities]').textContent).toBe( - 'It asks of remote.it:· Signs in people by remote.it certificate' + 'It asks of remote.it:· Signs in people by remote.it certificateI allow Acme’s Backup what it asks on these devices' ) + expect(submit().disabled).toBe(true) + await click($('[data-app-add-consent]')) + await click(submit()) + expect(addMany).toHaveBeenCalledWith('acme.backup', { deviceIds: ['D1'], accountId: undefined, consentRoot: true }) + // For a product: every device in it. + await act(async () => root.unmount()) + container.remove() + await render() + await click($('[data-app-add-to="product"] input')) + expect($('[data-app-add-capabilities]').textContent).toContain('I allow Acme’s Backup what it asks on every device in this product') + }) + + it('a release that asks for nothing: no yes asked', async () => { + await render() + await tick('D1') + expect($('[data-app-add-root]')).toBeNull() + expect($('[data-app-add-capabilities]')).toBeNull() + await click(submit()) + expect(addMany).toHaveBeenCalledWith('acme.backup', { deviceIds: ['D1'], accountId: undefined }) }) it('a channel chosen: what the releases it gives ask — its current’s, and its candidate’s for the devices in its share', async () => { @@ -253,8 +273,11 @@ describe('the root consent', () => { await tick('D1') expect($('[data-app-add-capabilities]')).toBeNull() await select($('[data-app-add-channel]'), 'beta') - expect($('[data-app-add-capabilities]').textContent).toBe('It asks of remote.it:· AI commands go through this app') + expect($('[data-app-add-capabilities]').textContent).toBe( + 'It asks of remote.it:· AI commands go through this appI allow Acme’s Backup what it asks on these devices' + ) expect($('[data-app-add-root]')).toBeNull() + expect(submit().disabled).toBe(true) // Its candidate (1.5.0-rc.1, to 10% of its devices) runs as root: the yes is asked, for beta's releases. act(() => root.unmount()) container.remove() diff --git a/frontend/src/pages/AppAddDialog.tsx b/frontend/src/pages/AppAddDialog.tsx index 96efaa7a2..241bea7e1 100644 --- a/frontend/src/pages/AppAddDialog.tsx +++ b/frontend/src/pages/AppAddDialog.tsx @@ -33,7 +33,7 @@ import { AppChangeResults } from '../components/AppChangeResults' import { LoadingMessage } from '../components/LoadingMessage' import { Notice } from '../components/Notice' import { AppCapabilities } from '../components/AppRootConsent' -import { addAsks, adminControlLine, channelName } from '../helpers/appsHelper' +import { addAsks, adminControlLine, allowLine, asksConsent, channelName } from '../helpers/appsHelper' type Target = 'devices' | 'tag' | 'product' @@ -49,10 +49,11 @@ type Target = 'devices' | 'tag' | 'product' the product's root consent. Channel the account's, stable or beta; and a version to pin, where wanted. What it asks is the releases the choice gives (helpers/appsHelper addAsks): the pin, else the channel's — not the - account's channel's where another is chosen. One that runs as root asks the person's yes in words before Add is - offered: full control of each device — of every device in the product, now and later, for a product —, and what - else it asks of remote.it (its capabilities), said in the same place; a restricted one says them above Add. The yes - is to those releases, for that target (and product): another choice asks it again. + account's channel's where another is chosen. Where they ask for a consent (asksConsent, graphql's rule) the + person's yes, in words, comes before Add is offered: to full control of each device where one runs as root — of + every device in the product, now and later, for a product —, and to what they ask of remote.it (their + capabilities), said in the same place. The yes is to those releases, for that target (and product): another choice + asks it again. Devices and a tag call addDeviceApps (at most 500 devices a call: more, and it says to add it to a product); each device's result is listed after — Added · Enabled · Already there · Refused: . */ @@ -129,6 +130,7 @@ export const AppAddDialog: React.FC = () => { const asks = ready ? addAsks(ready, channel, pinning ? version : undefined) : undefined const root = !!asks?.root const capabilities = asks?.capabilities + const asking = asksConsent(asks) const consentFor = [target, target === 'product' ? productId : '', ...(asks?.versions ?? [])].join('/') const consented = consentedTo === consentFor const product = products.find(p => p.id === productId) @@ -136,12 +138,12 @@ export const AppAddDialog: React.FC = () => { const tooMany = target !== 'product' && count > MANY_DEVICES_MAX const chosen = target === 'devices' ? ticked.length > 0 : target === 'tag' ? tagged.length > 0 : !!product const done = !!results || !!productDone - const canAdd = !!ready && chosen && !tooMany && (!root || consented) && !busy && !done + const canAdd = !!ready && chosen && !tooMany && (!asking || consented) && !busy && !done const release = { ...(channel && { channel }), ...(pinning && version && { version }), - ...(root && consented && { consentRoot: true }), + ...(asking && consented && { consentRoot: true }), } const add = async () => { @@ -369,23 +371,24 @@ export const AppAddDialog: React.FC = () => { )} - {!root && !!capabilities?.length && ( - - - - )} - {root && ( - + {asking && ( + - - {target === 'product' - ? t('apps.rootProduct', '{{app}} runs as root: full control of every device in this product, now and later.', { app: ready.name }) - : t('apps.rootDevices', '{{app}} runs as root: full control of each device.', { app: ready.name })} - - + {root && ( + + {target === 'product' + ? t('apps.rootProduct', '{{app}} runs as root: full control of every device in this product, now and later.', { app: ready.name }) + : t('apps.rootDevices', '{{app}} runs as root: full control of each device.', { app: ready.name })} + + )} + { inputProps={{ 'data-app-add-consent': true } as any} /> } - label={ - target === 'product' - ? t('apps.allowRootProduct', 'I allow {{publisher}}’s {{app}} full control of every device in this product', { - publisher: ready.publisher.name, - app: ready.name, - }) - : t('apps.allowRootDevices', 'I allow {{publisher}}’s {{app}} full control of these devices', { - publisher: ready.publisher.name, - app: ready.name, - }) - } + label={allowLine(t, root, target === 'product', ready.publisher.name, ready.name)} /> @@ -430,7 +423,7 @@ export const AppAddDialog: React.FC = () => { {done ? t('apps.done', 'Done') : t('apps.cancel', 'Cancel')} {!done && ( - )} {app.enabled && app.heldBack?.reason === 'pinned' && !held && ( - )} @@ -277,7 +302,7 @@ export const DeviceAppPage: React.FC = () => { variant="standard" value={app.channel ?? ''} disabled={runLocked || !!saving} - onChange={e => e.target.value !== (app.channel ?? '') && release('channel', { channel: e.target.value })} + onChange={e => e.target.value !== (app.channel ?? '') && move('channel', { channel: e.target.value })} SelectProps={{ native: true }} inputProps={{ 'data-app-channel': true, 'aria-label': t('apps.channel', 'Channel') }} > @@ -296,7 +321,7 @@ export const DeviceAppPage: React.FC = () => { variant="standard" value={app.pinned ?? ''} disabled={runLocked || !!saving} - onChange={e => e.target.value !== (app.pinned ?? '') && pin(e.target.value)} + onChange={e => e.target.value !== (app.pinned ?? '') && move('pin', { version: e.target.value })} SelectProps={{ native: true }} inputProps={{ 'data-app-pin': true, 'aria-label': t('apps.pin', 'Pin') }} > @@ -508,16 +533,22 @@ export const DeviceAppPage: React.FC = () => { )} {consent} + moving?.values.version + ? root + ? t('apps.pinRootAction', 'Pin with full control') + : t('apps.pinAsksAction', 'Allow and pin') + : t('deviceApps.rootUpdateAction', 'Consent and update') + } onConfirm={() => { - const version = pinning - setPinning(undefined) - if (version) release('pin', { version, consentRoot: true }) + const move = moving + setMoving(undefined) + if (move) release(move.key, { ...move.values, consentRoot: true }) }} - onDeny={() => setPinning(undefined)} + onDeny={() => setMoving(undefined)} /> { const product = products.find(p => p.id === productId) const accountId = useSelector(selectActiveAccountId) const manage = useSelector(selectPermissions).includes('ADMIN') - const { served, policy, reload } = useProductPolicy(productId) + const { served, policy, reload, accountId: readUnder } = useProductPolicy(productId) if (!product) return @@ -76,6 +76,7 @@ export const ProductPolicyPage: React.FC = () => { {policy.apps && ( Date: Tue, 17 Nov 2026 11:32:46 -0800 Subject: [PATCH 2/4] Device apps (portal): a channel's consent names every release it may give A channel rolling out a candidate gives a device its candidate or its current, by the device's bucket, which is graphql's to compute. The app page's channel change asked for one of them (the root one, where one was), so a candidate declaring a capability the current does not was consented to without being named. RootConsent and useReleaseAsks now take several releases and say what they ask together; the channel, pin and Unpin changes name every release they may give that asks for a consent the kept one does not cover. Co-Authored-By: Claude Opus 5.5 --- frontend/src/components/AppRootConsent.tsx | 42 +++++++++++++--------- frontend/src/pages/DeviceAppPage.test.tsx | 18 ++++++++++ frontend/src/pages/DeviceAppPage.tsx | 14 ++++---- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/frontend/src/components/AppRootConsent.tsx b/frontend/src/components/AppRootConsent.tsx index be8b3a5db..030cd1bf5 100644 --- a/frontend/src/components/AppRootConsent.tsx +++ b/frontend/src/components/AppRootConsent.tsx @@ -16,7 +16,8 @@ import { Confirm } from './Confirm' it on the product. What is asked is the release's the yes is given to (release), not the version the device runs: a release may ask - more than the one before it, and graphql takes the yes as covering what that release asks. It is read from its + more than the one before it, and graphql takes the yes as covering what that release asks. Where the change may give + one of several (a channel's candidate or current, by the device's bucket), all they ask together. It is read from its catalogue entry, under the account the device or product was read for (useReleaseAsks); until it is, the yes waits. action: the confirm button's words, where they are not turning it on, for a release that runs as root or not. */ export const RootConsent: React.FC<{ @@ -26,8 +27,9 @@ export const RootConsent: React.FC<{ action?: (root: boolean) => string // A release of an app already on that newly asks for consent: the consent moves it there (a re-consent). version?: string | null - // The release the yes is given to, where it is not version: a pin, the release enabling gives. None: the app's own. - release?: string | null + // The release the yes is given to, where it is not version: a pin, the release enabling gives — or the releases a + // change may give. None: the app's own. + release?: string | string[] | null accountId: string | undefined // whose catalogue names the release: the device's or the product's account onConfirm: () => void onDeny: () => void @@ -128,34 +130,42 @@ export const RootConsent: React.FC<{ ) } -/* What the release a consent is for asks (whether it runs as root, and its capabilities): its catalogue entry's for - that release, read under the account the device or product was read for; the app's own where no release is named, - or where the catalogue does not answer for it (an API without one, an error, a release it does not list — graphql - still refuses a yes that does not cover what the release asks). undefined while it is read. */ +/* What the releases a consent is for ask (whether one runs as root, and their capabilities, together): each its + catalogue entry's, read under the account the device or product was read for; the app's own where no release is + named, or where the catalogue does not answer for one (an API without one, an error, a release it does not list — + graphql still refuses a yes that does not cover what the release asks). undefined while they are read. */ export function useReleaseAsks( app: { id?: string; root: boolean; capabilities?: string[] } | undefined, - release: string | null | undefined, + release: string | string[] | null | undefined, accountId: string | undefined ): ConsentAsking | undefined { - const [read, setRead] = useState<{ key: string; asks: ConsentAsking | null }>() - const key = app?.id && release ? `${accountId ?? ''}/${app.id}/${release}` : '' + const [read, setRead] = useState<{ key: string; asks: ConsentAsking[] }>() + const releases = (Array.isArray(release) ? release : [release]).filter((r): r is string => !!r) + const key = app?.id && releases.length ? `${accountId ?? ''}/${app.id}/${releases.join(',')}` : '' + const own = app ? { root: app.root, capabilities: app.capabilities ?? [] } : undefined useEffect(() => { - if (!key || !app?.id || !release) return + if (!key || !app?.id || !own) return let current = true graphQLCatalogApp(app.id, { accountId, releases: 100 }).then(answer => { if (!current) return - const entry = typeof answer === 'object' && answer ? answer.releases.find(r => r.version === release) : undefined - setRead({ key, asks: entry ? { root: entry.root, capabilities: entry.capabilities } : null }) + const listed = typeof answer === 'object' && answer ? answer.releases : [] + const asks = releases.map(version => { + const entry = listed.find(r => r.version === version) + return entry ? { root: entry.root, capabilities: entry.capabilities } : own + }) + setRead({ key, asks }) }) return () => { current = false } }, [key]) - if (!app) return undefined - const own = { root: app.root, capabilities: app.capabilities ?? [] } + if (!own) return undefined if (!key) return own if (read?.key !== key) return undefined - return read.asks ?? own + return { + root: read.asks.some(asks => asks.root), + capabilities: [...new Set(read.asks.flatMap(asks => asks.capabilities ?? []))], + } } // What an app asks of remote.it beyond running, a line each: in its consent, and where it is offered. diff --git a/frontend/src/pages/DeviceAppPage.test.tsx b/frontend/src/pages/DeviceAppPage.test.tsx index bc750afa3..811962d87 100644 --- a/frontend/src/pages/DeviceAppPage.test.tsx +++ b/frontend/src/pages/DeviceAppPage.test.tsx @@ -309,6 +309,24 @@ describe('channel and pin', () => { expect(setRelease).toHaveBeenLastCalledWith(expect.objectContaining({ id: 'acme.backup' }), { channel: 'beta', consentRoot: true }) }) + it('a channel rolling out a candidate: the yes names what its current and its candidate ask together', async () => { + // Which of them this device is given is its bucket's: a root current, and a restricted candidate asking ssh-exec. + const releases = [ + { version: '1.6.0', root: false, withdrawn: null, capabilities: ['ssh-exec'] }, + { version: '1.5.0', root: true, withdrawn: null, capabilities: [] }, + { version: '1.4.0', root: false, withdrawn: null, capabilities: [] }, + ] + const channels = [CATALOG.channels[0], { channel: 'beta', current: '1.5.0', candidate: '1.6.0', share: 10 }] + catalog.mockResolvedValue({ ...CATALOG, channels, releases }) + const page = await render() + await select(page.querySelector('[data-app-channel]') as HTMLSelectElement, 'beta') + expect(setRelease).not.toHaveBeenCalled() + expect(page.querySelector('[data-confirm-title]')?.textContent).toBe('Run Backup as root?') + expect([...page.querySelectorAll('[data-confirm] [data-app-capability]')].map(c => c.getAttribute('data-app-capability'))).toEqual(['ssh-exec']) + await click(page.querySelector('[data-confirm-ok]')) + expect(setRelease).toHaveBeenLastCalledWith(expect.objectContaining({ id: 'acme.backup' }), { channel: 'beta', consentRoot: true }) + }) + it('a release that declares capabilities asks as a root one does; a consent that covers it does not ask again', async () => { const releases = [ { version: '1.6.0', root: false, withdrawn: null, capabilities: ['ssh-exec'] }, diff --git a/frontend/src/pages/DeviceAppPage.tsx b/frontend/src/pages/DeviceAppPage.tsx index ab5fe190b..c0d0874af 100644 --- a/frontend/src/pages/DeviceAppPage.tsx +++ b/frontend/src/pages/DeviceAppPage.tsx @@ -86,8 +86,8 @@ export const DeviceAppPage: React.FC = () => { const [refusal, setRefusal] = useState() const [saving, setSaving] = useState() const [removing, setRemoving] = useState(false) - // A channel or pin whose release asks for a consent, asked first: the change, and the release the yes is to. - const [moving, setMoving] = useState<{ key: string; values: Move; release: string }>() + // A channel or pin whose release asks for a consent, asked first: the change, and the releases the yes is to. + const [moving, setMoving] = useState<{ key: string; values: Move; releases: string[] }>() const [catalog, setCatalog] = useState() const failed = (reason: string) => setRefusal(reason || t('apps.notChanged', 'The app was not changed.')) const { flip, reconsent, consent } = useAppSwitch(deviceApps, failed, undefined, device?.accountId) @@ -174,8 +174,9 @@ export const DeviceAppPage: React.FC = () => { if (app.pinned && !pins.includes(app.pinned)) pins.unshift(app.pinned) /* A channel or a pin (or none): the releases it gives the device (helpers/appsHelper addAsks — a channel's candidate or current, by its bucket). While the app is enabled, one that asks for a consent the one kept with the app does - not cover is asked first, as graphql refuses it without (the one running as root named, where one does); a - disabled app is given no release, and asks nothing until it is enabled. */ + not cover is asked first, as graphql refuses it without — every such release named, as which of them the device + is given is its bucket's, graphql's to say; a disabled app is given no release, and asks nothing until it is + enabled. */ const move = (key: string, values: Move) => { const releases = catalog?.releases ?? [] const given = @@ -186,8 +187,7 @@ export const DeviceAppPage: React.FC = () => { .map(version => releases.find(r => r.version === version)) .filter((named): named is CatalogAppRelease => !!named && asksConsent(named)) .filter(named => !consentCovers(app.rootConsent, named, releases)) - const named = asking.find(r => r.root) ?? asking[0] - if (named) return setMoving({ key, values, release: named.version }) + if (asking.length) return setMoving({ key, values, releases: asking.map(named => named.version) }) release(key, values) } // Whether the release waiting for a consent runs as root, where the catalogue lists it; else as the app's own does. @@ -534,7 +534,7 @@ export const DeviceAppPage: React.FC = () => { {consent} moving?.values.version From 8d626dfc8d49caba5725e2239110d7228db29728 Mon Sep 17 00:00:00 2001 From: Evan Bowers Date: Tue, 17 Nov 2026 11:38:54 -0800 Subject: [PATCH 3/4] Device apps (portal): the fleet's Update names what the release it moves to asks Update selected unpins the devices (version ""), moving each to the release its channel gives it (latest). Its consent named the pinned release's capabilities, and asked only for devices held for consent: a device pinned elsewhere was moved to a release asking more without the yes, and graphql refused it. It now asks where a device is held for consent or would move off a pin to a release that asks, and names what those latest releases ask together (root as graphql's held-back words say where the catalogue does not list one). The tests no longer change the shared catalogue fixture's releases in place. Co-Authored-By: Claude Opus 5.5 --- frontend/src/pages/AppPage.test.tsx | 24 ++++++++++++++++++++++++ frontend/src/pages/AppPage.tsx | 22 ++++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/AppPage.test.tsx b/frontend/src/pages/AppPage.test.tsx index e9d9a0054..8152a1fc4 100644 --- a/frontend/src/pages/AppPage.test.tsx +++ b/frontend/src/pages/AppPage.test.tsx @@ -264,6 +264,9 @@ describe('your devices', () => { it('a device held for root consent: Update asks first, in words, and passes consentRoot', async () => { catalog.mockImplementation(async () => { const app = backup() + // Its channel's release (1.4.0, latest) runs as root. + app.releases = [...app.releases] + app.releases[1] = { ...app.releases[1], root: true } app.devices.items[1] = { ...app.devices.items[1], heldBack: { reason: 'consent', detail: '' } } return app }) @@ -279,6 +282,7 @@ describe('your devices', () => { it('Pin selected… picks a standing release; a root one only with the yes ticked', async () => { catalog.mockImplementation(async () => { const app = backup() + app.releases = [...app.releases] app.releases[0] = { ...app.releases[0], root: true } return app }) @@ -302,6 +306,7 @@ describe('your devices', () => { it('a release that declares capabilities: Update and Pin ask the yes to what it asks, in its words', async () => { catalog.mockImplementation(async () => { const app = backup() + app.releases = [...app.releases] app.releases[0] = { ...app.releases[0], root: false, capabilities: ['ssh-exec'] } app.devices.items[1] = { ...app.devices.items[1], @@ -329,6 +334,25 @@ describe('your devices', () => { expect(setMany).toHaveBeenLastCalledWith('acme.backup', ['80:00:00:00:01:00:00:01'], { version: '1.5.0-beta.2', consentRoot: true }) }) + it('Update off a pin names what the channel’s release asks, not the pinned one’s; one asking nothing updates at once', async () => { + catalog.mockImplementation(async () => { + const app = backup() + // kiosk-4 is pinned to 1.4.0, which asks person-accounts; its channel gives 1.5.0-beta.2, which asks ssh-exec. + app.releases = [...app.releases] + app.releases[0] = { ...app.releases[0], capabilities: ['ssh-exec'] } + app.releases[1] = { ...app.releases[1], capabilities: ['person-accounts'] } + return app + }) + const page = await render() + await check(page, 'kiosk-4') + await click(page.querySelector('[data-fleet-update]')) + expect(setMany).not.toHaveBeenCalled() + expect(page.querySelector('[data-fleet-consent]')?.getAttribute('data-fleet-consent')).toBe('capabilities') + expect([...page.querySelectorAll('[data-confirm] [data-app-capability]')].map(c => c.getAttribute('data-app-capability'))).toEqual(['ssh-exec']) + await click(page.querySelector('[data-confirm-ok]')) + expect(setMany).toHaveBeenCalledWith('acme.backup', ['80:00:00:00:01:00:00:03'], { version: '', consentRoot: true }) + }) + it('a call refused whole: its words', async () => { setMany.mockResolvedValue({ reason: 'More than 500 devices: add it to a product' }) const page = await render() diff --git a/frontend/src/pages/AppPage.tsx b/frontend/src/pages/AppPage.tsx index 358f7da99..acf05291f 100644 --- a/frontend/src/pages/AppPage.tsx +++ b/frontend/src/pages/AppPage.tsx @@ -154,14 +154,20 @@ export const AppPage: React.FC = () => { const devices = app.devices?.items ?? [] const chosen = devices.filter(d => selected.includes(d.deviceId)) - const waiting = chosen.filter(d => d.heldBack?.reason === 'consent') - const needsConsent = waiting.length > 0 - // What the releases they wait for ask: to run as root where graphql says one does, and their capabilities where the - // catalogue lists them (their pin's, else their channel's). - const updateRoot = waiting.some(d => heldConsentRoot(d.heldBack!)) - const updateAsks = [ - ...new Set(waiting.flatMap(d => app.releases.find(r => r.version === (d.pinned || d.latest))?.capabilities ?? [])), - ] + /* Update selected unpins them (version ""): each is moved to the release its channel gives it (latest — graphql's, + by its bucket). It asks the yes where that release asks for one a device may not have: one held for a consent, or + one pinned elsewhere that it would move off (its consent unknown here; graphql keeps the newer yes). What it asks + is those releases' together, as the catalogue lists them — where it does not, root as graphql's words for the + held-back say. */ + const releaseOf = (version: string | null) => app.releases.find(r => r.version === version) + const moving = chosen.filter( + d => + d.heldBack?.reason === 'consent' || + (d.enabled && !!d.pinned && d.latest !== d.pinned && asksConsent(releaseOf(d.latest))) + ) + const needsConsent = moving.length > 0 + const updateRoot = moving.some(d => releaseOf(d.latest)?.root ?? (!!d.heldBack && heldConsentRoot(d.heldBack))) + const updateAsks = [...new Set(moving.flatMap(d => releaseOf(d.latest)?.capabilities ?? []))] const standing = app.releases.filter(r => !r.withdrawn) const pinRelease = standing.find(r => r.version === pinTo) // A pin to a release that asks for a consent (asksConsent, graphql's rule) takes the yes: each device's own consent From 24ff748dc8a713bc61289e384fe44e29497fdf8d Mon Sep 17 00:00:00 2001 From: Evan Bowers Date: Tue, 17 Nov 2026 11:47:26 -0800 Subject: [PATCH 4/4] Device apps (portal): a release whose asks are not known is said so, and no yes is taken for it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Where the catalogue did not answer for the release a consent was for (an API without one, an error, a release older than those read), the portal showed the app's own fields instead: the release it runs, not the one the yes moves it to. A restricted app held for a root release was then asked as restricted, and the yes still authorized root. What a named release asks is now known or not: useReleaseAsks answers null for one the catalogue does not list, and RootConsent says so ("What this version asks could not be read …"), words for root, and keeps the yes. addAsks says known: false for a release not read and the Add dialog waits; the fleet's Update waits likewise; the app page's channel and pin ask for a release not read rather than skipping it. The app's own fields are used only where they are the release in question: an app offered to the device, whose fields are what its release asks there. useAppSwitch names awaitingRoot alone, as graphql's DeviceApp capabilities describe the release given, not the one awaited. The device app page and the Add dialog read the newest 100 releases, as the consent lookup does. Co-Authored-By: Claude Opus 5.5 --- frontend/src/components/AppRootConsent.tsx | 56 +++++++++++-------- .../src/components/ProductPolicyApps.test.tsx | 14 ++++- frontend/src/helpers/appsHelper.test.ts | 16 ++++-- frontend/src/helpers/appsHelper.ts | 13 +++-- frontend/src/i18n/locales/de/app.json | 1 + frontend/src/i18n/locales/en/app.json | 1 + frontend/src/i18n/locales/es/app.json | 1 + frontend/src/i18n/locales/ja/app.json | 1 + frontend/src/pages/AppAddDialog.test.tsx | 6 ++ frontend/src/pages/AppAddDialog.tsx | 14 ++++- frontend/src/pages/AppPage.tsx | 18 ++++-- frontend/src/pages/DeviceAppPage.test.tsx | 15 +++-- frontend/src/pages/DeviceAppPage.tsx | 15 ++--- 13 files changed, 116 insertions(+), 55 deletions(-) diff --git a/frontend/src/components/AppRootConsent.tsx b/frontend/src/components/AppRootConsent.tsx index 030cd1bf5..344761124 100644 --- a/frontend/src/components/AppRootConsent.tsx +++ b/frontend/src/components/AppRootConsent.tsx @@ -37,11 +37,12 @@ export const RootConsent: React.FC<{ const { t } = useTranslation() const words = { app: app?.name, publisher: app?.publisher, version } const asks = useReleaseAsks(app, release ?? version, accountId) - const root = asks ? asks.root : !!app?.root + // Not known (null): asked as the most it could be, and not given until it is. + const root = asks ? asks.root : true return ( + {asks === null && ( + + {t( + 'apps.asksUnknown', + 'What this version asks could not be read, so it cannot be consented to here. Try again later.' + )} + + )} () +): ConsentAsking | null | undefined { + const [read, setRead] = useState<{ key: string; asks: ConsentAsking | null }>() const releases = (Array.isArray(release) ? release : [release]).filter((r): r is string => !!r) const key = app?.id && releases.length ? `${accountId ?? ''}/${app.id}/${releases.join(',')}` : '' - const own = app ? { root: app.root, capabilities: app.capabilities ?? [] } : undefined useEffect(() => { - if (!key || !app?.id || !own) return + if (!key || !app?.id) return let current = true graphQLCatalogApp(app.id, { accountId, releases: 100 }).then(answer => { if (!current) return const listed = typeof answer === 'object' && answer ? answer.releases : [] - const asks = releases.map(version => { - const entry = listed.find(r => r.version === version) - return entry ? { root: entry.root, capabilities: entry.capabilities } : own + const entries = releases.map(version => listed.find(r => r.version === version)) + const known = entries.every(entry => !!entry) + setRead({ + key, + asks: known + ? { + root: entries.some(entry => entry!.root), + capabilities: [...new Set(entries.flatMap(entry => entry!.capabilities))], + } + : null, }) - setRead({ key, asks }) }) return () => { current = false } }, [key]) - if (!own) return undefined - if (!key) return own + if (!app) return undefined + if (!key) return { root: app.root, capabilities: app.capabilities ?? [] } if (read?.key !== key) return undefined - return { - root: read.asks.some(asks => asks.root), - capabilities: [...new Set(read.asks.flatMap(asks => asks.capabilities ?? []))], - } + return read.asks } // What an app asks of remote.it beyond running, a line each: in its consent, and where it is offered. @@ -219,9 +231,9 @@ export function useAppSwitch( // An enabled app held back for a release that runs as root: the yes moves it there. const waiting = (app?: DeviceApp) => !!app?.enabled && (!!app.awaitingRoot || app.heldBack?.reason === 'consent') const updating = waiting(asking) ? asking?.awaitingRoot || asking?.latest || '' : null - // The release the yes goes to: the one waiting for it, else the one enabling gives — its pin, else its channel's. - const target = - updating || asking?.awaitingRoot || asking?.pinned || asking?.latest || asking?.release || asking?.version || null + // The release the yes goes to: the one waiting for it (graphql's awaitingRoot, enabled or not). None for an app + // offered to the device: its own fields are what its release asks there. + const target = updating || asking?.awaitingRoot || null const consent = ( ({ vi.mock('./Icon', () => ({ Icon: ({ name }: any) => (name ? : null) })) vi.mock('./Notice', () => ({ Notice: ({ children }: any) =>
{children}
})) vi.mock('./Confirm', () => ({ - Confirm: ({ open, title, action, children, onConfirm, onDeny }: any) => + Confirm: ({ open, title, action, children, disabled, onConfirm, onDeny }: any) => open ? (
{title} {children} -