diff --git a/frontend/src/buttons/ServiceConnectButton.tsx b/frontend/src/buttons/ServiceConnectButton.tsx
index e7571112b..5206cc7c0 100644
--- a/frontend/src/buttons/ServiceConnectButton.tsx
+++ b/frontend/src/buttons/ServiceConnectButton.tsx
@@ -11,11 +11,12 @@ import { ErrorButton } from '../buttons/ErrorButton'
import { DesktopUI } from '../components/DesktopUI'
import { Gutters } from '../components/Gutters'
import { LocalSubnetConnect } from '../components/LocalSubnetConnect'
-import { isConsoleService } from '../helpers/sshHelper'
+import { opensTerminal } from '../helpers/sshHelper'
import { useLocalSignIn, useSubnetReach } from '../hooks/useLocalSubnetName'
import { LocalSignInNotice } from '../components/LocalSignInNotice'
import { BrowserGatewayConnect } from '../components/BrowserGatewayConnect'
-import { ConsoleTerminalOption } from '../components/ConsoleTerminal'
+import { AppTerminalOption } from '../components/AppTerminal'
+import { useServiceApp } from '../hooks/useDeviceApps'
import { useApplication } from '../hooks/useApplication'
import { Link } from '../components/Link'
import { LocalPortConnect } from '../components/LocalPortConnect'
@@ -35,6 +36,10 @@ export const ServiceConnectButton: React.FC = () => {
// (services/browserGateway), the proxy one step away as for a local name.
const web = useApplication(service, connection).urlForm
const ssh = service?.typeID === 28
+ // The app the service belongs to, where it does: one whose service is ssh and that signs people in by certificate
+ // opens in our web SSH as well, with the person's own account (components/AppTerminal).
+ const serving = useServiceApp(device, service)
+ const byCertificate = opensTerminal(serving.app, serving.appService)
const gateway = !local && reach.checked && !!reach.name && (!!web || ssh) && !proxy
// A local port of this machine (services/localPorts), where it runs our daemon: asked for here, or open already —
// then it is what the panel shows, until it is disconnected.
@@ -125,7 +130,12 @@ export const ServiceConnectButton: React.FC = () => {
) : named ? (
{local ? (
-
+
) : (
{
port: service.port || 22,
title: service.name,
service: service.id,
- console: isConsoleService(service),
+ byCertificate,
}
: undefined
}
@@ -167,10 +177,10 @@ export const ServiceConnectButton: React.FC = () => {
{portLink}
)}
- {/* The console: our web SSH, an option beside the ways above. */}
- {isConsoleService(service) && (
+ {/* An app's ssh service that signs people in by certificate: our web SSH, an option beside the ways above. */}
+ {byCertificate && (
-
+
)}
{/* The service's other ports here that this machine's daemon lists: the machine's, opened by someone else. */}
diff --git a/frontend/src/components/AppCatalogRow.tsx b/frontend/src/components/AppCatalogRow.tsx
index 17b10f298..533fdaae3 100644
--- a/frontend/src/components/AppCatalogRow.tsx
+++ b/frontend/src/components/AppCatalogRow.tsx
@@ -1,11 +1,12 @@
import React from 'react'
import { useTranslation } from 'react-i18next'
import { Box, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography } from '@mui/material'
-import { firstPartyApp } from './firstPartyApps'
+import { appIcon, capabilitiesLine } from '../helpers/appsHelper'
import { Icon } from './Icon'
/* One app in the catalogue (presence-server docs/device-apps-design.md, "The Apps pages"): its name, its publisher with
- Verified: and Yours for the account's own, Runs as root or Restricted, its description, its platforms and
+ Verified: and Yours for the account's own, Runs as root or Restricted and what else it asks of remote.it
+ (its capabilities, in words), its icon from how its service opens, its description, its platforms and
what is said beside them (how many devices have it, or why this device cannot take it). The row opens the app;
its action (Add…) sits at its end. */
export type AppCatalogRowProps = {
@@ -15,6 +16,8 @@ export type AppCatalogRowProps = {
verifiedDomain?: string | null
own?: boolean // the account's own publisher
root: boolean
+ capabilities?: string[]
+ protocol?: string | null // how its service opens: its icon
description?: string | null
platforms?: string | null // as families
aside?: React.ReactNode // beside the platforms: how many devices have it
@@ -30,6 +33,8 @@ export const AppCatalogRow: React.FC = ({
verifiedDomain,
own,
root,
+ capabilities,
+ protocol,
description,
platforms,
aside,
@@ -41,7 +46,7 @@ export const AppCatalogRow: React.FC = ({
const body = (
<>
-
+ = ({
? t('apps.runsAsRootFull', 'Runs as root: full control of the device')
: t('apps.restricted', 'Restricted')}
+ {!!capabilities?.length && (
+
+ {capabilitiesLine(t, capabilities)}
+
+ )}
}
secondaryTypographyProps={{ component: 'div' }}
diff --git a/frontend/src/components/AppRootConsent.tsx b/frontend/src/components/AppRootConsent.tsx
index 5933671b9..344761124 100644
--- a/frontend/src/components/AppRootConsent.tsx
+++ b/frontend/src/components/AppRootConsent.tsx
@@ -1,66 +1,131 @@
-import React, { useState } from 'react'
+import React, { useEffect, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { Typography } from '@mui/material'
+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 { 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"). 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.
+
+ 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. 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<{
- app?: { name: string; publisher: 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 — 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
-}> = ({ app, product, action, version, onConfirm, onDeny }) => {
+}> = ({ 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)
+ // Not known (null): asked as the most it could be, and not given until it is.
+ const root = asks ? asks.root : true
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
)}
+ {asks === null && (
+
+ {t(
+ 'apps.asksUnknown',
+ 'What this version asks could not be read, so it cannot be consented to here. Try again later.'
+ )}
+
+ )}
+
{product
? t(
@@ -74,16 +139,80 @@ export const RootConsent: React.FC<{
)
}
+/* 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 (an app offered to the device: its fields are the release the device would be given). null where a release
+ named is not one the catalogue answers for (an API without one, an error, one it does not list): what it asks is
+ not known, and a yes to it is not taken. undefined while they are read. */
+export function useReleaseAsks(
+ app: { id?: string; root: boolean; capabilities?: string[] } | undefined,
+ release: string | string[] | null | undefined,
+ accountId: string | undefined
+): 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(',')}` : ''
+ useEffect(() => {
+ 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 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,
+ })
+ })
+ return () => {
+ current = false
+ }
+ }, [key])
+ if (!app) return undefined
+ if (!key) return { root: app.root, capabilities: app.capabilities ?? [] }
+ if (read?.key !== key) return undefined
+ return read.asks
+}
+
+// What an app asks of remote.it beyond running, a line each: in its consent, and where it is offered.
+export const AppCapabilities: React.FC<{ capabilities?: string[]; title?: string }> = ({ capabilities, title }) => {
+ const { t } = useTranslation()
+ if (!capabilities?.length) return null
+ return (
+
+ {title ?? t('apps.capabilitiesAlso', 'It also asks of remote.it:')}
+ {capabilities.map(capability => (
+
+ · {capabilityWords(t, capability)}
+
+ ))}
+
+ )
+}
+
/* Enabling or disabling an app, from wherever it is offered (the device's Apps section, the app's page on the device,
- the console'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
+ 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()
@@ -94,7 +223,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))
}
@@ -102,12 +231,17 @@ 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 (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 = (
t('deviceApps.rootUpdateAction', 'Consent and update') : undefined}
onConfirm={() => {
const app = asking
setAsking(undefined)
@@ -121,3 +255,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/AppTerminal.test.tsx b/frontend/src/components/AppTerminal.test.tsx
new file mode 100644
index 000000000..796ad46f9
--- /dev/null
+++ b/frontend/src/components/AppTerminal.test.tsx
@@ -0,0 +1,254 @@
+import React, { act } from 'react'
+import { createRoot, Root } from 'react-dom/client'
+import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
+
+const { apps, name, openTerminal, env } = vi.hoisted(() => ({
+ apps: { value: {} as any },
+ name: { value: 'pi-evan.on.remote.it' as string | undefined },
+ openTerminal: vi.fn(),
+ env: { isNative: false },
+}))
+// The device's apps as the API says them; which one a service belongs to is the portal's own rule (appsHelper).
+// 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') }))
+vi.mock('../hooks/useDeviceApps', async () => {
+ const { appServiceOf, isAppService, serviceApp } = await import('../helpers/appsHelper')
+ return {
+ useServiceApp: (device?: IDevice, service?: IService) => {
+ const read = device && isAppService(service) ? apps.value : {}
+ const app = serviceApp(read.apps, service)
+ return { ...read, app, appService: appServiceOf(app, service) }
+ },
+ }
+})
+vi.mock('../hooks/useLocalSubnetName', () => ({
+ useSubnetName: (deviceId?: string) => (deviceId ? name.value : undefined),
+}))
+vi.mock('../helpers/terminalHelper', () => ({ openTerminal }))
+vi.mock('../services/browser', () => ({ default: env, windowOpen: vi.fn() }))
+vi.mock('./Confirm', () => ({
+ Confirm: ({ open, title, children, onConfirm, onDeny }: any) =>
+ open ? (
+
+ {title} {children}
+
+
+
+ ) : null,
+}))
+vi.mock('./Icon', () => ({ Icon: () => null }))
+vi.mock('../buttons/IconButton', () => ({
+ IconButton: ({ onClick, title }: any) => ,
+}))
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (_key: string, text: string, values?: any) => text.replace(/{{(\w+)}}/g, (_, k) => values?.[k] ?? ''),
+ }),
+}))
+
+import { AppTerminalAction, AppTerminalButton, AppTerminalOption } from './AppTerminal'
+import { useServiceApp } from '../hooks/useDeviceApps'
+import type { DeviceApp } from '../services/graphQLDeviceApps'
+import { withServices } from '../test/deviceApps'
+;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
+
+// Any app whose service is ssh and that signs people in by certificate: not the console, nor named anywhere.
+const shellService = { id: 'S1', name: 'Shell', typeID: 28, host: 'remoteit-app-acme-shell', port: 2222 } as IService
+const sshService = { id: 'S2', name: 'SSH', typeID: 28, host: 'localhost', port: 22 } as IService
+const device = (permissions = ['CONNECT', 'MANAGE', 'SCRIPTING']) =>
+ ({ id: 'D1', name: 'Pi', permissions, services: [shellService, sshService] } as unknown as IDevice)
+const app = (state: string, extra: Partial = {}): DeviceApp =>
+ withServices({
+ id: 'acme.shell',
+ name: 'Shell',
+ publisher: 'Acme',
+ root: true,
+ enabled: state !== 'disabled',
+ channel: 'stable',
+ state: state as any,
+ detail: null,
+ // graphql names no service while it is disabled: it is found by its host.
+ serviceId: state === 'disabled' ? null : 'S1',
+ protocol: 'ssh',
+ capabilities: ['person-certificates'],
+ hostKey: null,
+ sessions: [],
+ sessionsOpen: 0,
+ version: null,
+ settings: [],
+ ...extra,
+ })
+const turn = vi.fn()
+
+let root: Root
+async function render(node: React.ReactNode) {
+ const container = document.createElement('div')
+ root = createRoot(container)
+ await act(async () => root.render(node))
+ return container
+}
+const click = (el: Element | null) => act(() => (el as HTMLElement).click())
+
+// The connect panel reads its service's app once (ServiceConnectButton) and gives it to the option.
+const Option: React.FC<{ device?: IDevice; service?: IService }> = ({ device, service }) => (
+
+)
+
+const shell = () => apps.value.apps[0]
+
+beforeEach(() => {
+ apps.value = { apps: [app('running')], switching: undefined, turn }
+ name.value = 'pi-evan.on.remote.it'
+ env.isNative = false
+ openTerminal.mockReset()
+ turn.mockReset().mockResolvedValue(true)
+})
+afterEach(() => act(() => root.unmount()))
+
+describe('AppTerminalOption — the connect panel of an app’s ssh service', () => {
+ it('offers web SSH while the app runs, opening it on its service’s port, titled by the app', async () => {
+ const container = await render()
+ expect(container.textContent).toBe('Open in web SSH')
+ await click(container.querySelector('a'))
+ expect(openTerminal).toHaveBeenCalledWith({
+ name: 'pi-evan.on.remote.it',
+ port: 2222,
+ title: 'Shell',
+ service: 'S1',
+ })
+ })
+
+ it('says it opens in the browser from the desktop or mobile app', async () => {
+ env.isNative = true
+ const container = await render()
+ expect(container.textContent).toBe('Open in web SSH, in your browser')
+ })
+
+ it('only for an app whose service is ssh and that declares person-certificates', async () => {
+ for (const extra of [
+ { capabilities: [] },
+ { capabilities: ['ssh-exec'] },
+ { protocol: 'tcp' },
+ { protocol: null },
+ ]) {
+ apps.value.apps = [app('running', extra)]
+ expect((await render()).textContent).toBe('')
+ act(() => root.unmount())
+ }
+ await render(null)
+ })
+
+ it('is nothing for a service no app has, without a name in device subnets, or without apps', async () => {
+ expect((await render()).textContent).toBe('')
+ act(() => root.unmount())
+ name.value = undefined
+ expect((await render()).textContent).toBe('')
+ act(() => root.unmount())
+ name.value = 'pi-evan.on.remote.it'
+ apps.value = { apps: null }
+ expect((await render()).textContent).toBe('')
+ })
+
+ it('is nothing for an app service its app does not name: an earlier one, stopped', async () => {
+ apps.value.apps = [app('running', { serviceId: 'S9' })]
+ expect((await render()).textContent).toBe('')
+ })
+
+ it('says the app is off, and turns it on — it runs as root — once the person says yes to that', async () => {
+ apps.value.apps = [app('disabled')]
+ const container = await render()
+ expect(container.textContent).toBe('Shell is disabled: enable it to open it in web SSH Enable it')
+ await click(container.querySelector('a'))
+ expect(turn).not.toHaveBeenCalled()
+ expect(container.querySelector('[data-confirm]')?.textContent).toContain(
+ 'Shell, published by Acme, runs as root: it gets full control of this device'
+ )
+ expect(container.querySelector('[data-confirm]')?.textContent).toContain('Signs in people by remote.it certificate')
+ await click(container.querySelector('[data-confirm-ok]'))
+ expect(turn).toHaveBeenCalledWith(shell(), true, true)
+ })
+
+ it('not turned on when the person says no', async () => {
+ apps.value.apps = [app('disabled')]
+ const container = await render()
+ await click(container.querySelector('a'))
+ await click(container.querySelector('[data-confirm-deny]'))
+ expect(turn).not.toHaveBeenCalled()
+ expect(container.querySelector('[data-confirm]')).toBeNull()
+ })
+
+ it('does not offer turning it on to those who may not run code on the device: Manage and Scripting', async () => {
+ apps.value.apps = [app('disabled')]
+ for (const permissions of [['CONNECT'], ['CONNECT', 'MANAGE'], ['CONNECT', 'SCRIPTING']]) {
+ const container = await render()
+ expect(container.textContent).toBe('Shell is disabled: enable it to open it in web SSH')
+ expect(container.querySelector('a')).toBeNull()
+ act(() => root.unmount())
+ }
+ await render(null)
+ })
+
+ it('says what the device is doing: starting, unavailable, or waited for', async () => {
+ apps.value.apps = [app('starting')]
+ expect((await render()).textContent).toBe(
+ 'Shell is starting: web SSH opens it once it runs'
+ )
+ act(() => root.unmount())
+ apps.value.apps = [app('unavailable', { detail: 'no sshd' })]
+ expect((await render()).textContent).toBe(
+ 'Not available here: no sshd'
+ )
+ act(() => root.unmount())
+ apps.value = { apps: [app('running')], switching: 'acme.shell', turn }
+ expect((await render()).textContent).toBe(
+ 'Waiting for the device…'
+ )
+ })
+})
+
+describe('AppTerminalButton — the service’s row in the device’s services', () => {
+ it('opens web SSH while the app runs, without opening the row', async () => {
+ const row = vi.fn()
+ const container = await render(
+
+
+
+ )
+ const button = container.querySelector('[data-terminal]')
+ expect(button?.getAttribute('title')).toBe('Open in web SSH')
+ await click(button)
+ expect(openTerminal).toHaveBeenCalledWith(expect.objectContaining({ name: 'pi-evan.on.remote.it', port: 2222 }))
+ expect(row).not.toHaveBeenCalled()
+ })
+
+ it('is nothing while the app does not run, for an app that opens no terminal, or for another service', async () => {
+ apps.value.apps = [app('disabled')]
+ expect((await render()).innerHTML).toBe('')
+ act(() => root.unmount())
+ apps.value.apps = [app('running', { protocol: 'https' })]
+ expect((await render()).innerHTML).toBe('')
+ act(() => root.unmount())
+ apps.value.apps = [app('running')]
+ expect((await render()).innerHTML).toBe('')
+ })
+})
+
+describe('AppTerminalAction — Open terminal in the device’s Apps', () => {
+ it('while it runs, through its service’s port; nothing for an app that opens no terminal', async () => {
+ const action = (shell: DeviceApp) =>
+ let container = await render(action(app('running')))
+ await click(container.querySelector('[data-app-terminal]'))
+ expect(openTerminal).toHaveBeenCalledWith({
+ name: 'pi-evan.on.remote.it',
+ port: 2222,
+ title: 'Shell',
+ service: 'S1',
+ })
+ act(() => root.unmount())
+ container = await render(action(app('starting')))
+ expect(container.innerHTML).toBe('')
+ act(() => root.unmount())
+ container = await render(action(app('running', { capabilities: [] })))
+ expect(container.innerHTML).toBe('')
+ })
+})
diff --git a/frontend/src/components/AppTerminal.tsx b/frontend/src/components/AppTerminal.tsx
new file mode 100644
index 000000000..ef2779825
--- /dev/null
+++ b/frontend/src/components/AppTerminal.tsx
@@ -0,0 +1,137 @@
+import React from 'react'
+import { useTranslation } from 'react-i18next'
+import type { TFunction } from 'i18next'
+import { Button, Typography } from '@mui/material'
+import browser from '../services/browser'
+import { DeviceApp, DeviceAppService } from '../services/graphQLDeviceApps'
+import { ServiceApp, useServiceApp } from '../hooks/useDeviceApps'
+import { useAppSwitch } from './AppRootConsent'
+import { useSubnetName } from '../hooks/useLocalSubnetName'
+import { opensTerminal } from '../helpers/sshHelper'
+import { openTerminal } from '../helpers/terminalHelper'
+import { IconButton } from '../buttons/IconButton'
+import { Link } from './Link'
+import { Icon } from './Icon'
+
+/* An app's service opened in our web SSH (pages/TerminalPage), for any app's service that is ssh where the app signs
+ people in by remote.it certificate (helpers/sshHelper opensTerminal) — from wherever it is picked: the device's Apps
+ section and the app's page there, its service's row in the device's services and its connect panel. Always the
+ same: the device's name in device subnets, the service's port, the person's own account and a certificate for it,
+ and the host key the device reports for the app, which the terminal checks. An option beside the service's own ways
+ to connect, which stay as they are. Nothing where the device has no name in device subnets or the API has no apps.
+ From the desktop and mobile apps it opens in the web portal, in the system browser (helpers/terminalHelper). */
+
+function open(app: DeviceApp, serviceId: string, name: string, port: number) {
+ openTerminal({ name, port, title: app.name, service: serviceId })
+}
+
+const label = (t: TFunction) =>
+ browser.isNative
+ ? t('appTerminal.openInBrowser', 'Open in web SSH, in your browser')
+ : t('appTerminal.open', 'Open in web SSH')
+
+const servicePort = (device: IDevice | undefined, serviceId: string | null) =>
+ device?.services?.find(service => service.id === serviceId)?.port
+
+/** Open terminal, in the device's Apps section and on the app's page there, for one of its services: while it runs. */
+export const AppTerminalAction: React.FC<{ device: IDevice; app: DeviceApp; service: DeviceAppService }> = ({
+ device,
+ app,
+ service,
+}) => {
+ const { t } = useTranslation()
+ const terminal = opensTerminal(app, service)
+ const name = useSubnetName(terminal ? device.id : undefined)
+ const port = servicePort(device, service.serviceId)
+ if (!terminal || app.state !== 'running' || !name || !port || !service.serviceId) return null
+ const serviceId = service.serviceId
+ return (
+
+ )
+}
+
+/** A service's row in its device's services: a terminal button while its app runs. */
+export const AppTerminalButton: React.FC<{ device: IDevice; service: IService }> = ({ device, service }) => {
+ const { t } = useTranslation()
+ const { app, appService } = useServiceApp(device, service)
+ const terminal = opensTerminal(app, appService)
+ const name = useSubnetName(terminal ? device.id : undefined)
+ const port = service.port
+ if (!app || !terminal || app.state !== 'running' || appService?.serviceId !== service.id || !name || !port) return null
+ return (
+ {
+ // The row opens the service's page: the button is not the row.
+ event.stopPropagation()
+ open(app, service.id, name, port)
+ }}
+ />
+ )
+}
+
+/** A service's connect panel, where its app opens a terminal (serving: useServiceApp, read by the panel): Open in web
+ * SSH while the app runs, whichever way the panel connects it — its name on this machine, the browser's client (where
+ * the panel's own terminal button is this too) or the proxy; otherwise what the app is doing — and, for those who may
+ * run code on the device (Manage and Scripting), turning it on, with their yes to its running as root
+ * (components/AppRootConsent). */
+export const AppTerminalOption: React.FC<{ device?: IDevice; service?: IService; serving: ServiceApp }> = ({
+ device,
+ service,
+ serving: { app, appService, switching, turn, setRelease },
+}) => {
+ const { t } = useTranslation()
+ const terminal = opensTerminal(app, appService)
+ const name = useSubnetName(terminal ? device?.id : undefined)
+ const { flip, consent } = useAppSwitch({ turn, setRelease }, undefined, undefined, device?.accountId)
+ if (!app || !terminal || !name) return null
+ // Not where its product holds it off: graphql refuses that, naming the product.
+ const canTurnOn =
+ !app.locked && !!device?.permissions?.includes('MANAGE') && !!device?.permissions?.includes('SCRIPTING')
+
+ const port = service?.port
+ if (app.state === 'running' && !switching) {
+ const serviceId = appService?.serviceId
+ if (!serviceId || !port) return null
+ return (
+
+ open(app, serviceId, name, port)}>
+
+ {label(t)}
+
+
+ )
+ }
+
+ const status = switching
+ ? t('deviceApps.switching', 'Waiting for the device…')
+ : app.state === 'starting'
+ ? t('appTerminal.starting', '{{app}} is starting: web SSH opens it once it runs', { app: app.name })
+ : app.state === 'unavailable'
+ ? t('deviceApps.unavailable', 'Not available here: {{detail}}', { detail: app.detail })
+ : t('appTerminal.disabled', '{{app}} is disabled: enable it to open it in web SSH', { app: app.name })
+
+ return (
+
+ {status}
+ {app.state === 'disabled' && !switching && canTurnOn && (
+ <>
+ {' '}
+ flip(app, true)}>{t('appTerminal.enable', 'Enable it')}
+ >
+ )}
+ {consent}
+
+ )
+}
diff --git a/frontend/src/components/BrowserGatewayConnect.tsx b/frontend/src/components/BrowserGatewayConnect.tsx
index a30525f8f..0a1e706ea 100644
--- a/frontend/src/components/BrowserGatewayConnect.tsx
+++ b/frontend/src/components/BrowserGatewayConnect.tsx
@@ -12,9 +12,10 @@ import { Icon } from './Icon'
browser's remote.it client — nothing to install, and no connection to start. An SSH service opens a terminal in
this app instead (pages/TerminalPage), its session through the same client — from the desktop app, in the web
portal (helpers/terminalHelper). The counterpart of LocalSubnetConnect,
- which is shown instead when an agent here does reach it. The console's plain ssh command is offered to copy as well:
- it works from a machine signed in on its remote.it device app. */
-type Props = { name: string; terminal?: { port: number; title?: string; service?: string; console?: boolean } }
+ which is shown instead when an agent here does reach it. The plain ssh command of an app's service that signs people
+ in by certificate (byCertificate) is offered to copy as well: it works from a machine signed in on its remote.it
+ device app. */
+type Props = { name: string; terminal?: { port: number; title?: string; service?: string; byCertificate?: boolean } }
export const BrowserGatewayConnect: React.FC = ({ name, terminal }) => {
const { t } = useTranslation()
@@ -57,14 +58,14 @@ export const BrowserGatewayConnect: React.FC = ({ name, terminal }) => {
{t('browserGatewayConnect.failed', 'Could not open it: try again')}
)}
- {terminal?.console && (
+ {terminal?.byCertificate && (
{sshCommand(name, terminal.port)} —{' '}
{t('localSubnetConnect.sshHint', 'Works from a machine signed in on its remote.it device app')}
)}
- {terminal?.console && }
+ {terminal?.byCertificate && }
- device?.services?.find(service => service.id === app.serviceId)?.port
-
-const ConsoleHostKey: React.FC = ({ app }) => {
- const { t } = useTranslation()
- const [hostKey, setHostKey] = useState(null)
- const running = app.state === 'running' && app.serviceId
-
- useEffect(() => {
- setHostKey(null)
- if (!running || !app.serviceId) return
- let current = true
- graphQLSshHostKey(app.serviceId).then(key => current && setHostKey(key))
- return () => {
- current = false
- }
- }, [running, app.serviceId])
-
- if (!running || !hostKey) return null
- return (
-
- {t('deviceApps.hostKey', 'Host key {{key}}', { key: hostKey })}
-
- )
-}
-
-const ConsoleOpenTerminal: React.FC = ({ device, app }) => {
- const { t } = useTranslation()
- const name = useSubnetName(device.id)
- const port = consolePort(device, app)
- if (app.state !== 'running' || !name || !port || !app.serviceId) return null
- return (
-
- )
-}
-
-export const CONSOLE_APP: FirstPartyApp = {
- icon: 'terminal',
- state: (t, app) =>
- app.state === 'running'
- ? t('deviceApps.consoleRunning', 'Running — logins by certificate, nothing listening on the device')
- : app.state === 'disabled'
- ? t('deviceApps.consoleDisabled', 'Disabled — a terminal on this device, from this app, by certificate')
- : undefined,
- settings: t => ({
- ai_commands: {
- label: t('deviceApps.consoleAiCommands', 'Allow AI commands'),
- help: t(
- 'deviceApps.consoleAiCommandsHelp',
- "AI assistants you authorize may run commands on this device's console through remote.it's MCP server. The device's administrator can turn this off on the machine."
- ),
- },
- }),
- Lines: ConsoleHostKey,
- Actions: ConsoleOpenTerminal,
-}
diff --git a/frontend/src/components/ConsoleTerminal.test.tsx b/frontend/src/components/ConsoleTerminal.test.tsx
deleted file mode 100644
index 6708a01b6..000000000
--- a/frontend/src/components/ConsoleTerminal.test.tsx
+++ /dev/null
@@ -1,186 +0,0 @@
-import React, { act } from 'react'
-import { createRoot, Root } from 'react-dom/client'
-import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
-
-const { apps, name, openTerminal, env } = vi.hoisted(() => ({
- apps: { value: {} as any },
- name: { value: 'pi-evan.on.remote.it' as string | undefined },
- openTerminal: vi.fn(),
- env: { isNative: false },
-}))
-vi.mock('../hooks/useDeviceApps', () => ({ useDeviceApps: (deviceId?: string) => (deviceId ? apps.value : {}) }))
-vi.mock('../hooks/useLocalSubnetName', () => ({
- useSubnetName: (deviceId?: string) => (deviceId ? name.value : undefined),
-}))
-vi.mock('../helpers/terminalHelper', () => ({ openTerminal }))
-vi.mock('../services/browser', () => ({ default: env, windowOpen: vi.fn() }))
-vi.mock('./Confirm', () => ({
- Confirm: ({ open, title, children, onConfirm, onDeny }: any) =>
- open ? (
-
- {title} {children}
-
-
-
- ) : null,
-}))
-vi.mock('./Icon', () => ({ Icon: () => null }))
-vi.mock('../buttons/IconButton', () => ({
- IconButton: ({ onClick, title }: any) => ,
-}))
-vi.mock('react-i18next', () => ({
- useTranslation: () => ({
- t: (_key: string, text: string, values?: any) => text.replace(/{{(\w+)}}/g, (_, k) => values?.[k] ?? ''),
- }),
-}))
-
-import { ConsoleTerminalButton, ConsoleTerminalOption } from './ConsoleTerminal'
-;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
-
-const consoleService = { id: 'S1', name: 'Console', typeID: 28, host: 'remoteit-console', port: 2222 } as IService
-const sshService = { id: 'S2', name: 'SSH', typeID: 28, host: 'localhost', port: 22 } as IService
-const device = (permissions = ['CONNECT', 'MANAGE', 'SCRIPTING']) =>
- ({ id: 'D1', name: 'Pi', permissions } as unknown as IDevice)
-const app = (state: string, extra: any = {}) => ({
- id: 'remoteit.console',
- name: 'Console',
- publisher: 'remote.it',
- root: true,
- enabled: state !== 'disabled',
- channel: 'stable',
- state,
- detail: null,
- serviceId: state === 'disabled' ? null : 'S1',
- version: null,
- settings: [],
- ...extra,
-})
-const turn = vi.fn()
-
-let root: Root
-async function render(node: React.ReactNode) {
- const container = document.createElement('div')
- root = createRoot(container)
- await act(async () => root.render(node))
- return container
-}
-const click = (el: Element | null) => act(() => (el as HTMLElement).click())
-
-beforeEach(() => {
- apps.value = { console: app('running'), switching: undefined, turn }
- name.value = 'pi-evan.on.remote.it'
- env.isNative = false
- openTerminal.mockReset()
- turn.mockReset().mockResolvedValue(true)
-})
-afterEach(() => act(() => root.unmount()))
-
-describe('ConsoleTerminalOption — the console’s connect panel', () => {
- it('offers web SSH while the console runs, opening it on its service’s port as the Apps section does', async () => {
- const container = await render()
- expect(container.textContent).toBe('Open in web SSH')
- await click(container.querySelector('a'))
- expect(openTerminal).toHaveBeenCalledWith({
- name: 'pi-evan.on.remote.it',
- port: 2222,
- title: 'Console',
- service: 'S1',
- })
- })
-
- it('says it opens in the browser from the desktop or mobile app', async () => {
- env.isNative = true
- const container = await render()
- expect(container.textContent).toBe('Open in web SSH, in your browser')
- })
-
- it('is nothing for another SSH service, without a name in device subnets, or without apps', async () => {
- expect((await render()).textContent).toBe('')
- act(() => root.unmount())
- name.value = undefined
- expect((await render()).textContent).toBe('')
- act(() => root.unmount())
- name.value = 'pi-evan.on.remote.it'
- apps.value = { console: undefined }
- expect((await render()).textContent).toBe('')
- })
-
- it('is nothing for a console service the console app does not name', async () => {
- apps.value.console = app('running', { serviceId: 'S9' })
- expect((await render()).textContent).toBe('')
- })
-
- it('says the console is off, and turns it on — it runs as root — once the person says yes to that', async () => {
- apps.value.console = app('disabled')
- const container = await render()
- expect(container.textContent).toBe('The console is disabled: enable it to open it in web SSH Enable it')
- await click(container.querySelector('a'))
- expect(turn).not.toHaveBeenCalled()
- expect(container.querySelector('[data-confirm]')?.textContent).toContain(
- 'Console, published by remote.it, runs as root: it gets full control of this device'
- )
- await click(container.querySelector('[data-confirm-ok]'))
- expect(turn).toHaveBeenCalledWith(apps.value.console, true, true)
- })
-
- it('not turned on when the person says no', async () => {
- apps.value.console = app('disabled')
- const container = await render()
- await click(container.querySelector('a'))
- await click(container.querySelector('[data-confirm-deny]'))
- expect(turn).not.toHaveBeenCalled()
- expect(container.querySelector('[data-confirm]')).toBeNull()
- })
-
- it('does not offer turning it on to those who may not run code on the device: Manage and Scripting', async () => {
- apps.value.console = app('disabled')
- for (const permissions of [['CONNECT'], ['CONNECT', 'MANAGE'], ['CONNECT', 'SCRIPTING']]) {
- const container = await render()
- expect(container.textContent).toBe('The console is disabled: enable it to open it in web SSH')
- expect(container.querySelector('a')).toBeNull()
- act(() => root.unmount())
- }
- await render(null)
- })
-
- it('says what the device is doing: starting, unavailable, or waited for', async () => {
- apps.value.console = app('starting')
- expect((await render()).textContent).toBe(
- 'The console is starting: web SSH opens it once it runs'
- )
- act(() => root.unmount())
- apps.value.console = app('unavailable', { detail: 'no sshd' })
- expect((await render()).textContent).toBe(
- 'Not available here: no sshd'
- )
- act(() => root.unmount())
- apps.value = { console: app('running'), switching: 'remoteit.console', turn }
- expect((await render()).textContent).toBe(
- 'Waiting for the device…'
- )
- })
-})
-
-describe('ConsoleTerminalButton — the console’s row in the device’s services', () => {
- it('opens web SSH while the console runs, without opening the row', async () => {
- const row = vi.fn()
- const container = await render(
-
-
-
- )
- const button = container.querySelector('[data-terminal]')
- expect(button?.getAttribute('title')).toBe('Open in web SSH')
- await click(button)
- expect(openTerminal).toHaveBeenCalledWith(expect.objectContaining({ name: 'pi-evan.on.remote.it', port: 2222 }))
- expect(row).not.toHaveBeenCalled()
- })
-
- it('is nothing while the console does not run, or for another service', async () => {
- apps.value.console = app('disabled')
- expect((await render()).innerHTML).toBe('')
- act(() => root.unmount())
- apps.value.console = app('running')
- expect((await render()).innerHTML).toBe('')
- })
-})
diff --git a/frontend/src/components/ConsoleTerminal.tsx b/frontend/src/components/ConsoleTerminal.tsx
deleted file mode 100644
index 7a2abcc38..000000000
--- a/frontend/src/components/ConsoleTerminal.tsx
+++ /dev/null
@@ -1,120 +0,0 @@
-import React from 'react'
-import { useTranslation } from 'react-i18next'
-import type { TFunction } from 'i18next'
-import { Typography } from '@mui/material'
-import browser from '../services/browser'
-import { DeviceApp } from '../services/graphQLDeviceApps'
-import { useDeviceApps } from '../hooks/useDeviceApps'
-import { useAppSwitch } from './AppRootConsent'
-import { useSubnetName } from '../hooks/useLocalSubnetName'
-import { isConsoleService } from '../helpers/sshHelper'
-import { openTerminal } from '../helpers/terminalHelper'
-import { IconButton } from '../buttons/IconButton'
-import { Link } from './Link'
-import { Icon } from './Icon'
-
-/* The console's service opened in our web SSH (pages/TerminalPage) from wherever it is picked — its row in the device's
- services and its connect panel — as the device's Apps section opens it: the device's name in device subnets, the
- console's service's port, its login by certificate and the host key the device reports. An option beside the service's own
- ways to connect, which stay as they are. The service is the console's when its host is the console's (graphql
- CONSOLE_HOST, helpers/sshHelper) and, once the device's apps are read, it is the service the console app names.
- Nothing where the device has no name in device subnets or the API has no apps — as in the Apps section. From the
- desktop and mobile apps it opens in the web portal, in the system browser (helpers/terminalHelper). */
-
-type Target = { app?: DeviceApp; name?: string; port?: number }
-
-function useConsoleTarget(device?: IDevice, service?: IService) {
- const isConsole = isConsoleService(service)
- const apps = useDeviceApps(isConsole ? device?.id : undefined)
- const name = useSubnetName(isConsole ? device?.id : undefined)
- const app = apps.console
- // A console app that names another service is not this one's: an earlier console service, stopped.
- const mine = !!app && (!app.serviceId || app.serviceId === service?.id)
- return { apps, target: (isConsole && mine && name ? { app, name, port: service?.port } : {}) as Target }
-}
-
-function open(t: TFunction, { app, name, port }: Target) {
- if (!app?.serviceId || !port || !name) return
- openTerminal({ name, port, title: t('deviceApps.console', 'Console'), service: app.serviceId })
-}
-
-const label = (t: TFunction) =>
- browser.isNative
- ? t('consoleTerminal.openInBrowser', 'Open in web SSH, in your browser')
- : t('consoleTerminal.open', 'Open in web SSH')
-
-/** The console's row in a device's services: a terminal button while the console runs. */
-export const ConsoleTerminalButton: React.FC<{ device: IDevice; service: IService }> = ({ device, service }) => {
- const { t } = useTranslation()
- const { target } = useConsoleTarget(device, service)
- if (target.app?.state !== 'running' || !target.app.serviceId || !target.port) return null
- return (
- {
- // The row opens the service's page: the button is not the row.
- event.stopPropagation()
- open(t, target)
- }}
- />
- )
-}
-
-/** The console's connect panel: Open in web SSH while the console runs, whichever way the panel connects it — its
- * name on this machine, the browser's client (where the panel's own terminal button is this too) or the proxy;
- * otherwise what it is doing — and, for those who may run code on the device (Manage and Scripting), turning it on,
- * with their yes to its running as root (components/AppRootConsent). */
-export const ConsoleTerminalOption: React.FC<{ device?: IDevice; service?: IService }> = ({ device, service }) => {
- const { t } = useTranslation()
- const {
- apps: { switching, turn, setRelease },
- target,
- } = useConsoleTarget(device, service)
- const { flip, consent } = useAppSwitch({ turn, setRelease })
- const { app } = target
- if (!app) return null
- // Not where its product holds it off: graphql refuses that, naming the product.
- const canTurnOn =
- !app.locked && !!device?.permissions?.includes('MANAGE') && !!device?.permissions?.includes('SCRIPTING')
-
- if (app.state === 'running' && !switching) {
- if (!app.serviceId || !target.port) return null
- return (
-
- open(t, target)}>
-
- {label(t)}
-
-
- )
- }
-
- const status = switching
- ? t('deviceApps.switching', 'Waiting for the device…')
- : app.state === 'starting'
- ? t('consoleTerminal.starting', 'The console is starting: web SSH opens it once it runs')
- : app.state === 'unavailable'
- ? t('deviceApps.unavailable', 'Not available here: {{detail}}', { detail: app.detail })
- : t('consoleTerminal.disabled', 'The console is disabled: enable it to open it in web SSH')
-
- return (
-
- {status}
- {app.state === 'disabled' && !switching && canTurnOn && (
- <>
- {' '}
- flip(app, true)}>{t('consoleTerminal.enable', 'Enable it')}
- >
- )}
- {consent}
-
- )
-}
diff --git a/frontend/src/components/DeviceAppSetting.test.tsx b/frontend/src/components/DeviceAppSetting.test.tsx
new file mode 100644
index 000000000..1b65eb14f
--- /dev/null
+++ b/frontend/src/components/DeviceAppSetting.test.tsx
@@ -0,0 +1,133 @@
+import React, { act } from 'react'
+import { createRoot } from 'react-dom/client'
+import { describe, it, expect, vi } from 'vitest'
+
+vi.mock('../services/post', () => ({ post: vi.fn() }))
+vi.mock('../services/graphQL', () => ({ graphQLBasicRequest: vi.fn(), graphQLGetErrors: vi.fn() }))
+vi.mock('../hooks/useDeviceSettings', () => ({ useDeviceSettings: () => ({ setting: vi.fn() }) }))
+vi.mock('./ListItemSetting', () => ({
+ ListItemSetting: ({ label, subLabel, toggle, disabled, onClick }: any) => (
+
+ ),
+}))
+vi.mock('./SelectSetting', () => ({
+ SelectSetting: ({ value, values, disabled, helperText, onChange }: any) => (
+
+ {values.map((v: any) => (
+
+ ),
+}))
+vi.mock('react-i18next', () => ({
+ useTranslation: () => ({
+ t: (_key: string, text: string, values?: any) => text.replace(/{{(\w+)}}/g, (_, k) => values?.[k] ?? ''),
+ }),
+}))
+
+import { DeviceAppSetting } from './DeviceAppSetting'
+import type { DeviceAppSetting as Setting } from '../services/graphQLDeviceApps'
+;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
+
+// The console's "Allow AI commands" (forcible: its administrator may hold it on as well as off).
+const aiCommands = (control: string, more: Partial = {}): Setting => ({
+ name: 'ai_commands',
+ type: 'bool',
+ label: 'Allow AI commands',
+ help: 'Commands an AI runs on this device through MCP, as the people you allow',
+ default: true,
+ value: true,
+ at: null,
+ by: null,
+ onDevice: false,
+ control: control as any,
+ locked: null,
+ choices: null,
+ deprecated: null,
+ ...more,
+})
+
+async function render(setting: Setting, onChange = vi.fn()) {
+ const container = document.createElement('div')
+ await act(async () =>
+ createRoot(container).render(
+
+ )
+ )
+ return container
+}
+const row = (page: HTMLElement) => page.querySelector('[data-row]') as HTMLButtonElement
+
+describe('an app setting its device’s administrator holds', () => {
+ it('ai_commands held off: off, greyed, "Set by this device’s administrator" — no change offered', async () => {
+ const onChange = vi.fn()
+ const page = await render(aiCommands('off', { value: false }), onChange)
+ expect(row(page).dataset.on).toBe('false')
+ expect(row(page).disabled).toBe(true)
+ expect(row(page).textContent).toBe('Allow AI commands — Set by this device’s administrator')
+ await act(async () => row(page).click())
+ expect(onChange).not.toHaveBeenCalled()
+ })
+
+ it('ai_commands held on: on, greyed, said the same', async () => {
+ const page = await render(aiCommands('on', { value: true }))
+ expect(row(page).dataset.on).toBe('true')
+ expect(row(page).disabled).toBe(true)
+ expect(row(page).textContent).toBe('Allow AI commands — Set by this device’s administrator')
+ })
+
+ it('held by its administrator and its product: both said', async () => {
+ const page = await render(
+ aiCommands('off', { value: false, locked: { product: 'Kiosks', level: 'enforced' } as any })
+ )
+ expect(row(page).textContent).toBe(
+ 'Allow AI commands — Set by this device’s administrator · Managed by product Kiosks (enforced)'
+ )
+ })
+
+ it('not held: switched here, its help said; local is set on the device only; its product’s lock alone as before', async () => {
+ for (const control of ['cloud+local', 'cloud']) {
+ const onChange = vi.fn()
+ const page = await render(aiCommands(control), onChange)
+ expect(row(page).disabled).toBe(false)
+ expect(row(page).textContent).toBe(
+ 'Allow AI commands — Commands an AI runs on this device through MCP, as the people you allow'
+ )
+ await act(async () => row(page).click())
+ expect(onChange).toHaveBeenCalledWith(false)
+ }
+ const local = await render(aiCommands('local'))
+ expect(row(local).disabled).toBe(true)
+ expect(row(local).textContent).toBe('Allow AI commands — Set only on the device')
+ const product = await render(aiCommands('cloud+local', { locked: { product: 'Kiosks', level: 'synced' } as any }))
+ expect(row(product).disabled).toBe(true)
+ expect(row(product).textContent).toBe('Allow AI commands — Set by its product Kiosks')
+ })
+
+ it('a choice it fixes: that choice, greyed, said the same', async () => {
+ const mode: Setting = {
+ ...aiCommands('nightly'),
+ name: 'mode',
+ type: 'choice',
+ label: 'Back up',
+ help: null,
+ value: 'nightly',
+ default: 'hourly',
+ choices: [
+ { value: 'hourly', label: 'Every hour' },
+ { value: 'nightly', label: 'Every night' },
+ ],
+ }
+ const page = await render(mode)
+ const select = page.querySelector('[data-select]') as HTMLElement
+ expect(select.dataset.value).toBe('nightly')
+ expect(select.dataset.disabled).toBe('true')
+ expect(select.textContent).toBe('Set by this device’s administrator')
+ const free = await render({ ...mode, control: 'cloud+local' as any })
+ expect((free.querySelector('[data-select]') as HTMLElement).dataset.disabled).toBe('false')
+ })
+})
diff --git a/frontend/src/components/DeviceAppSetting.tsx b/frontend/src/components/DeviceAppSetting.tsx
index 5db43c379..811ef1a7c 100644
--- a/frontend/src/components/DeviceAppSetting.tsx
+++ b/frontend/src/components/DeviceAppSetting.tsx
@@ -4,6 +4,7 @@ import { Button, ListItem, TextField } from '@mui/material'
import type { TFunction } from 'i18next'
import { AppStringRules, DeviceAppSetting as Setting } from '../services/graphQLDeviceApps'
import { settingLocked } from '../services/graphQLDeviceSettings'
+import { productLockNote } from '../helpers/productPolicyHelper'
import { DeviceSettingChoice, DeviceSettingRow, deprecatedLine, settingNote } from './DeviceSettingRow'
import { spacing } from '../styling'
@@ -43,9 +44,25 @@ export const DeviceAppSetting: React.FC = props => {
)
}
+// Whether the device's administrator holds the setting (graphql's DeviceAppSetting.control, the device's
+// `._control`): off, on (where its release says forcible, as the console's ai_commands) or a choice it fixes.
+// The device applies the held value, and graphql refuses a change to it.
+export const adminHolds = (setting: Setting) =>
+ !!setting.control && !['cloud+local', 'cloud', 'local'].includes(setting.control)
+
+/* Why an app's setting is as it is, where that is not the portal's doing: held by the device's administrator — and by
+ its product too, where its product locks it — else what a device setting's row says (set only on the device, its
+ product's lock, a change made on the device). None for one set here. */
+export function appSettingNote(t: TFunction, setting: Setting): string | undefined {
+ if (!adminHolds(setting)) return settingNote(t, setting)
+ const held = t('deviceApps.settingAdminHeld', 'Set by this device’s administrator')
+ return setting.locked ? `${held} · ${productLockNote(t, setting.locked)}` : held
+}
+
const AppSettingControl: React.FC = ({ setting, label, help, disabled, onChange }) => {
const { t } = useTranslation()
const deprecated = deprecatedLine(t, setting.deprecated)
+ const note = appSettingNote(t, setting)
switch (setting.type) {
case 'bool':
@@ -55,7 +72,8 @@ const AppSettingControl: React.FC = ({ setting, label, help, disabled, on
hideIcon
disableGutters
label={label}
- subLabel={help}
+ subLabel={note || help}
+ quiet
deprecated={setting.deprecated}
disabled={disabled}
onChange={onChange}
@@ -71,6 +89,7 @@ const AppSettingControl: React.FC = ({ setting, label, help, disabled, on
label={label}
value={fixed ? setting.control : String(setting.value ?? '')}
choices={choices}
+ why={note}
note={deprecated || help || undefined}
disabled={disabled}
onChange={onChange}
@@ -148,7 +167,7 @@ const AppSettingField: React.FC = ({ setting, label, help, disabled, onCh
onChange(list ? listItems(text) : text)
}
- const note = [deprecatedLine(t, setting.deprecated), settingNote(t, setting) || help].filter(Boolean).join(' · ')
+ const note = [deprecatedLine(t, setting.deprecated), appSettingNote(t, setting) || help].filter(Boolean).join(' · ')
const max = setting.type === 'string' ? setting.declaration?.string?.max : undefined
return (
diff --git a/frontend/src/components/DeviceApps.test.tsx b/frontend/src/components/DeviceApps.test.tsx
index 6349264c6..9c536a169 100644
--- a/frontend/src/components/DeviceApps.test.tsx
+++ b/frontend/src/components/DeviceApps.test.tsx
@@ -2,24 +2,22 @@ import React, { act } from 'react'
import { createRoot, Root } from 'react-dom/client'
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
-const { apps, hostKey, name, openTerminal, push } = vi.hoisted(() => ({
+const { apps, name, openTerminal, push } = vi.hoisted(() => ({
push: vi.fn(),
apps: { value: {} as any },
- hostKey: vi.fn(),
name: { value: 'pi-evan.on.remote.it' as string | undefined },
openTerminal: 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') }))
vi.mock('../services/post', () => ({ post: vi.fn() }))
vi.mock('react-router-dom', () => ({ useHistory: () => ({ push }) }))
vi.mock('../services/graphQL', () => ({ graphQLBasicRequest: vi.fn(), graphQLGetErrors: vi.fn() }))
-vi.mock('../services/graphQLDeviceApps', async importOriginal => ({
- ...(await importOriginal()),
- graphQLSshHostKey: hostKey,
-}))
vi.mock('../hooks/useDeviceApps', () => ({ useDeviceApps: () => apps.value }))
vi.mock('../hooks/useDeviceSettings', () => ({ useDeviceSettings: () => ({ setting: () => undefined }) }))
vi.mock('../hooks/useLocalSubnetName', () => ({ useSubnetName: () => name.value }))
vi.mock('../helpers/terminalHelper', () => ({ openTerminal }))
+vi.mock('../services/browser', () => ({ default: { isNative: false }, windowOpen: vi.fn() }))
vi.mock('./Icon', () => ({ Icon: ({ name }: any) => (name ? : null) }))
vi.mock('./Confirm', () => ({
Confirm: ({ open, title, action, children, onConfirm, onDeny }: any) =>
@@ -42,6 +40,7 @@ vi.mock('react-i18next', () => ({
import { DeviceApps } from './DeviceApps'
import type { DeviceApp, DeviceAppSetting } from '../services/graphQLDeviceApps'
+import { withServices } from '../test/deviceApps'
;(globalThis as any).IS_REACT_ACT_ENVIRONMENT = true
const setting = (more: Partial = {}): DeviceAppSetting => ({
@@ -61,7 +60,8 @@ const setting = (more: Partial = {}): DeviceAppSetting => ({
...more,
})
-const consoleApp = (more: Partial = {}): DeviceApp => ({
+const consoleApp = (more: Partial = {}): DeviceApp =>
+ withServices({
id: 'remoteit.console',
name: 'Console',
publisher: 'remote.it',
@@ -72,11 +72,17 @@ const consoleApp = (more: Partial = {}): DeviceApp => ({
state: 'running',
detail: null,
serviceId: 'S1',
+ protocol: 'ssh',
+ capabilities: ['person-accounts', 'person-certificates', 'ssh-exec'],
+ hostKey: 'SHA256:abc',
+ sessions: [],
+ sessionsOpen: 0,
settings: [setting()],
...more,
-})
+ })
-const backup = (more: Partial = {}): DeviceApp => ({
+const backup = (more: Partial = {}): DeviceApp =>
+ withServices({
id: 'acme.backup',
name: 'Backup',
publisher: 'Acme',
@@ -87,6 +93,11 @@ const backup = (more: Partial = {}): DeviceApp => ({
state: 'disabled',
detail: null,
serviceId: null,
+ protocol: null,
+ capabilities: [],
+ hostKey: null,
+ sessions: [],
+ sessionsOpen: 0,
settings: [
setting({
name: 'mode',
@@ -103,10 +114,18 @@ const backup = (more: Partial = {}): DeviceApp => ({
setting({ name: 'keep', type: 'int', label: 'Keep this many', help: null, default: 7, value: 7 }),
],
...more,
-})
+ })
const device = (permissions = ['VIEW', 'CONNECT', 'MANAGE', 'SCRIPTING']) =>
- ({ id: 'D1', name: 'Pi', permissions, services: [{ id: 'S1', port: 2222 }] } as unknown as IDevice)
+ ({
+ id: 'D1',
+ name: 'Pi',
+ permissions,
+ services: [
+ { id: 'S1', port: 2222 },
+ { id: 'S3', port: 30022 },
+ ],
+ } as unknown as IDevice)
const turn = vi.fn()
const setRelease = vi.fn()
@@ -129,7 +148,6 @@ afterEach(() => {
beforeEach(() => {
turn.mockReset().mockResolvedValue(true)
setSetting.mockReset().mockResolvedValue(true)
- hostKey.mockReset().mockResolvedValue('SHA256:abc')
openTerminal.mockReset()
push.mockReset()
name.value = 'pi-evan.on.remote.it'
@@ -270,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')))
@@ -292,13 +342,64 @@ describe('the switch enables and disables', () => {
})
})
-describe('the console’s Open terminal stays in its row', () => {
- it('while it runs, through its service’s port; no other app has it', async () => {
+describe('drawn from what the API says, none by its id', () => {
+ // Anyone's app whose service is ssh and that signs people in by certificate.
+ const shell = consoleApp({
+ id: 'acme.shell',
+ name: 'Shell',
+ publisher: 'Acme',
+ root: false,
+ serviceId: 'S3',
+ capabilities: ['person-certificates'],
+ })
+
+ it('Open terminal in the row of any app whose service is ssh and that declares person-certificates, while it runs', async () => {
+ apps.value.apps = [
+ shell,
+ backup(),
+ consoleApp({ id: 'acme.web', serviceId: 'S1', protocol: 'https', capabilities: [] }),
+ ]
+ const page = await render()
+ await click(appRow(page, 'acme.shell').querySelector('[data-app-terminal]'))
+ expect(openTerminal).toHaveBeenCalledWith({
+ name: 'pi-evan.on.remote.it',
+ port: 30022,
+ title: 'Shell',
+ service: 'S3',
+ })
+ expect(appRow(page, 'acme.backup').querySelector('[data-app-terminal]')).toBeNull()
+ expect(appRow(page, 'acme.web').querySelector('[data-app-terminal]')).toBeNull()
+ })
+
+ it('the console as any such app: Open terminal through its service’s port', async () => {
+ const page = await render()
+ await click(appRow(page, 'remoteit.console').querySelector('[data-app-terminal]'))
+ expect(openTerminal).toHaveBeenCalledWith({
+ name: 'pi-evan.on.remote.it',
+ port: 2222,
+ title: 'Console',
+ service: 'S1',
+ })
+ })
+
+ it('no Open terminal while it does not run, or without a name in device subnets', async () => {
+ apps.value.apps = [{ ...shell, state: 'starting' }]
+ let page = await render()
+ expect(page.querySelector('[data-app-terminal]')).toBeNull()
+ act(() => root.unmount())
+ container.remove()
+ apps.value.apps = [shell]
+ name.value = undefined
+ page = await render()
+ expect(page.querySelector('[data-app-terminal]')).toBeNull()
+ })
+
+ it('its icon from how its service opens', async () => {
+ apps.value.apps = [shell, backup(), consoleApp({ id: 'acme.web', protocol: 'https' })]
const page = await render()
- const button = [...appRow(page, 'remoteit.console').querySelectorAll('button')].find(b => b.textContent === 'Open terminal')
- await click(button!)
- expect(openTerminal).toHaveBeenCalledWith(expect.objectContaining({ name: 'pi-evan.on.remote.it', port: 2222, service: 'S1' }))
- expect(appRow(page, 'acme.backup').textContent).not.toContain('Open terminal')
+ expect(appRow(page, 'acme.shell').querySelector('[data-icon="terminal"]')).not.toBeNull()
+ expect(appRow(page, 'acme.web').querySelector('[data-icon="globe"]')).not.toBeNull()
+ expect(appRow(page, 'acme.backup').querySelector('[data-icon="cube"]')).not.toBeNull()
})
})
diff --git a/frontend/src/components/DeviceApps.tsx b/frontend/src/components/DeviceApps.tsx
index c2728cc52..c969a276b 100644
--- a/frontend/src/components/DeviceApps.tsx
+++ b/frontend/src/components/DeviceApps.tsx
@@ -14,19 +14,30 @@ import {
Typography,
} from '@mui/material'
import { useHistory } from 'react-router-dom'
-import { DeviceApp, SCREENVIEW } from '../services/graphQLDeviceApps'
+import { DeviceApp, DeviceAppService, SCREENVIEW } from '../services/graphQLDeviceApps'
import { useDeviceApps } from '../hooks/useDeviceApps'
import { useAppSwitch } from './AppRootConsent'
-import { firstPartyApp } from './firstPartyApps'
-import { adminLine, adminRefuses, heldBackLine, managedLine, offered, runsAsWord, stateWord } from '../helpers/appsHelper'
+import { AppTerminalAction } from './AppTerminal'
+import {
+ adminLine,
+ adminRefuses,
+ appIcon,
+ heldBackLine,
+ managedLine,
+ offered,
+ openWord,
+ runsAsWord,
+ stateWord,
+} from '../helpers/appsHelper'
import { Notice } from './Notice'
import { Icon } from './Icon'
/* A device's apps on its Configure page (presence-server docs/device-apps-design.md, "The Apps pages", the device's Apps
section): the device's own apps, a row each — its publisher, Runs as root or Restricted, the version it runs, its
state in a word, held back where it is —, its Enabled switch, and the row opening the app on this device
- (/devices/:deviceID/apps/:appID), where its settings, channel, pin and Remove are. The console's Open terminal stays
- in its row. Add opens the catalogue for this device (/devices/:deviceID/apps/add), offered only where there is
+ (/devices/:deviceID/apps/:appID), where its settings, channel, pin and Remove are. Every app is drawn from what the
+ API says of it, none by its id: its icon from how its service opens, and Open terminal in its row for one whose
+ service is ssh and that signs people in by certificate (components/AppTerminal). Add opens the catalogue for this device (/devices/:deviceID/apps/add), offered only where there is
something it can add.
Enabling runs code on the device, so it needs Scripting as well as Manage, and a root release no consent covers asks
@@ -40,11 +51,14 @@ import { Icon } from './Icon'
export const DeviceApps: React.FC<{ device: IDevice }> = ({ device }) => {
const { t } = useTranslation()
const history = useHistory()
- const deviceApps = useDeviceApps(device.id)
+ const deviceApps = useDeviceApps(device.id, { accountId: device.accountId })
const { apps, available, switching } = deviceApps
const [refusal, setRefusal] = useState()
- const { flip, consent } = useAppSwitch(deviceApps, reason =>
- setRefusal(reason || t('apps.notChanged', 'The app was not changed.'))
+ const { flip, consent } = useAppSwitch(
+ deviceApps,
+ reason => setRefusal(reason || t('apps.notChanged', 'The app was not changed.')),
+ undefined,
+ device.accountId
)
const canManage = !!device.permissions?.includes('MANAGE')
const canRun = canManage && !!device.permissions?.includes('SCRIPTING')
@@ -118,13 +132,12 @@ export const DeviceApps: React.FC<{ device: IDevice }> = ({ device }) => {
)}
{apps.map(app => {
- const own = firstPartyApp(app.id)
const removing = app.state === 'removing'
const enabled = switching === app.id ? !app.enabled : app.enabled
const row = (
<>
-
+ = ({ device }) => {
/>
>
)
- // The switch and the console's Open terminal act alone: a click on them is not the row's.
+ // The switch and Open terminal act alone: a click on them is not the row's.
const actions = removing ? null : (
event.stopPropagation()}>
- {own?.Actions && }
+ {app.services.map(service => (
+
+ ))}
= ({ device }) => {
)
}
-/* Open, for any app reached as a service (serviceId) while it runs: its service's connection, started and launched as
- its application type launches — HTTP opens in the browser —, as any service's Connect page does. remote.it's own apps
- with a part of their own (components/firstPartyApps: the console's Open terminal) have theirs instead. */
-export const AppOpen: React.FC<{ device: IDevice; app: DeviceApp }> = ({ device, app }) => {
+/* Open, for one of an app's services while the app runs and the service is served (serviceId): its connection,
+ started and launched as its application type launches (graphql makes the type from the manifest's protocol: http and
+ https open in the browser, vnc and rdp in a viewer, udp nothing: a port for the person's own UDP client), as any
+ service's Connect page does — a multi-port service's on its first port, its launch port; said by its protocol (Open
+ page, Open screen, Connect). One that opens as a terminal (helpers/sshHelper opensTerminal) has Open terminal
+ instead (components/AppTerminal). */
+export const AppOpen: React.FC<{ device: IDevice; app: DeviceApp; service: DeviceAppService }> = ({
+ device,
+ app,
+ service,
+}) => {
const { t } = useTranslation()
const history = useHistory()
- if (!app.enabled || app.state !== 'running' || !app.serviceId) return null
+ if (!app.enabled || app.state !== 'running' || !service.serviceId) return null
return (
)
}
diff --git a/frontend/src/components/DeviceSettingRow.tsx b/frontend/src/components/DeviceSettingRow.tsx
index 04ebb47da..43b27bb5f 100644
--- a/frontend/src/components/DeviceSettingRow.tsx
+++ b/frontend/src/components/DeviceSettingRow.tsx
@@ -88,14 +88,17 @@ export const DeviceSettingChoice: React.FC<{
value: string // the value standing, as the setting's control fixes it
choices: ISelect[]
note?: React.ReactNode // the setting's state, below who set it
+ why?: string // who set it, or why it is fixed, in the caller's words (an app's setting); else a device setting's
disabled?: boolean
onChange: (value: string) => void
-}> = ({ setting, icon, hideIcon, label, value, choices, note, disabled, onChange }) => {
+}> = ({ setting, icon, hideIcon, label, value, choices, note, why: said, disabled, onChange }) => {
const { t } = useTranslation()
const fixed = choices.find(choice => choice.key === setting.control)
- const why = fixed
- ? t('deviceSetting.controlFixedTo', "Set to {{value}} by the device's administrator", { value: fixed.name })
- : settingNote(t, setting)
+ const why =
+ said ??
+ (fixed
+ ? t('deviceSetting.controlFixedTo', "Set to {{value}} by the device's administrator", { value: fixed.name })
+ : settingNote(t, setting))
return (
: port 443 on a name is the host's web service, under
the stage's certificate, whatever port it is on (presence-server docs/subnet-https.md) — and that URL is what is
shown and copied, since : is the service's own port, plain http. An SSH service is shown and copied as
- the command that reaches it, plain `ssh`: the console's works as it is from a machine signed in on its remote.it
- device app, which gets a certificate for its own ssh (connectd remoteit-device ssh-config). A multi-port
+ the command that reaches it, plain `ssh`: that of an app signing people in by certificate (byCertificate) works as it
+ is from a machine signed in on its remote.it device app, which gets a certificate for its own ssh (connectd
+ remoteit-device ssh-config), and says so. A multi-port
service is reached here on every port it lists, each by its own number (graphql-api docs/MULTI-PORT-SERVICES.md), so
they are all shown; what is copied and launched is the first, as for a connection. A web service whose device passed
its redirect to https:// on the same host back to the browser (services/graphQLDetectedScheme redirectLoops) would
only loop on its name: Launch says so first, and the way out is its type, HTTPS on the port it redirects to. */
-type Props = { local: LocalSubnetName; service?: IService; connection?: IConnection }
+type Props = { local: LocalSubnetName; service?: IService; connection?: IConnection; byCertificate?: boolean }
-export const LocalSubnetConnect: React.FC = ({ local, service, connection }) => {
+export const LocalSubnetConnect: React.FC = ({ local, service, connection, byCertificate }) => {
const { t } = useTranslation()
const port = service?.port
const ssh = service?.typeID === 28
@@ -118,7 +119,7 @@ export const LocalSubnetConnect: React.FC = ({ local, service, connection
{t('localSubnetConnect.address', 'resolves here to {{address}}', { address: local.address })}
)}
- {isConsoleService(service) && (
+ {byCertificate && (
{t('localSubnetConnect.sshHint', 'Works from a machine signed in on its remote.it device app')}
diff --git a/frontend/src/components/ProductPolicyApps.test.tsx b/frontend/src/components/ProductPolicyApps.test.tsx
index 1a12c1bf0..7ff05beb0 100644
--- a/frontend/src/components/ProductPolicyApps.test.tsx
+++ b/frontend/src/components/ProductPolicyApps.test.tsx
@@ -2,7 +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() }))
+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(),
@@ -39,12 +41,12 @@ vi.mock('./SelectSetting', () => ({
vi.mock('./Icon', () => ({ Icon: ({ name }: any) => (name ? : null) }))
vi.mock('./Notice', () => ({ Notice: ({ children }: any) =>
{title}
{children}
-
{!done && (
-
+
{busy
? t('apps.adding', 'Adding…')
: target === 'product'
@@ -446,3 +462,4 @@ function whyNot(t: TFunction, device: AppTarget): string | undefined {
if (device.offer.refused) return device.offer.refused
if (!device.offer.version) return t('deviceApps.noRelease', 'No release of it here yet')
}
+
diff --git a/frontend/src/pages/AppPage.test.tsx b/frontend/src/pages/AppPage.test.tsx
index b8a88d4c1..8152a1fc4 100644
--- a/frontend/src/pages/AppPage.test.tsx
+++ b/frontend/src/pages/AppPage.test.tsx
@@ -29,7 +29,6 @@ vi.mock('../components/Notice', () => ({ Notice: ({ children }: any) =>
({ LoadingMessage: () => }))
vi.mock('../components/Link', () => ({ Link: ({ to, children, ...rest }: any) => {children} }))
vi.mock('../components/Icon', () => ({ Icon: () => null }))
-vi.mock('../components/firstPartyApps', () => ({ firstPartyApp: () => undefined }))
vi.mock('../components/Confirm', () => ({
Confirm: ({ open, title, action, disabled, children, onConfirm, onDeny }: any) =>
open ? (
@@ -106,6 +105,7 @@ describe('the app in the catalogue', () => {
expect(page.querySelector('[data-title]')?.textContent).toBe('Backup')
expect(page.querySelector('[data-app-about]')?.textContent).toBe('1.4.0 · Acme · Verified: acme.com · Yours')
expect(page.querySelector('[data-app-runs]')?.textContent).toBe('Restricted')
+ expect(page.querySelector('[data-app-asks]')).toBeNull()
expect(page.querySelector('[data-app-platforms]')?.textContent).toBe('linux-amd64 · linux-arm64 · linux-arm64-musl')
await click(page.querySelector('[data-app-add]'))
expect(push).toHaveBeenCalledWith('/apps/acme.backup/add')
@@ -122,6 +122,19 @@ describe('the app in the catalogue', () => {
expect(page.querySelector('[data-app-runs]')?.textContent).toBe('Runs as root: full control of the device')
})
+ it('what it asks of remote.it beside how it runs — the app’s, and each release’s with its root', async () => {
+ params.appID = 'remoteit.console'
+ catalog.mockResolvedValue(mockCatalogApp('remoteit.console'))
+ const page = await render()
+ const asks =
+ 'Keeps accounts for the people you share with · Signs in people by remote.it certificate · AI commands go through this app'
+ expect(page.querySelector('[data-app-asks]')?.textContent).toBe(asks)
+ await click(page.querySelector('[data-app-release="1.4.0"]'))
+ expect(page.querySelector('[data-app-release-notes="1.4.0"]')?.textContent).toContain(
+ `Runs as root: full control of the device · ${asks}`
+ )
+ })
+
it('channels on this stage, a candidate’s share; the account’s channel set by setAccountAppChannel', async () => {
const page = await render()
expect(page.querySelector('[data-app-channel="beta"]')?.textContent).toContain('Candidate 1.5.0-rc.1 to 10% of devices')
@@ -251,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
})
@@ -266,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
})
@@ -286,6 +303,56 @@ describe('your devices', () => {
expect(setMany).toHaveBeenLastCalledWith('acme.backup', ['80:00:00:00:01:00:00:01'], { version: '1.4.0' })
})
+ 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],
+ pinned: null,
+ latest: app.releases[0].version,
+ heldBack: { reason: 'consent', detail: 'A new version asks for ssh-exec' },
+ }
+ return app
+ })
+ const page = await render()
+ await check(page, 'nas')
+ await click(page.querySelector('[data-fleet-update]'))
+ expect(setMany).not.toHaveBeenCalled()
+ expect(page.querySelector('[data-confirm-title]')?.textContent).toBe('Update Backup to a version that asks more?')
+ expect(page.querySelector('[data-fleet-consent]')?.getAttribute('data-fleet-consent')).toBe('capabilities')
+ expect(page.querySelector('[data-confirm] [data-app-capability]')?.getAttribute('data-app-capability')).toBe('ssh-exec')
+ await click(page.querySelector('[data-confirm-ok]'))
+ expect(setMany).toHaveBeenCalledWith('acme.backup', ['80:00:00:00:01:00:00:02'], { version: '', consentRoot: true })
+ await check(page, 'pi-kitchen')
+ await click(page.querySelector('[data-fleet-pin]'))
+ expect((page.querySelector('[data-confirm-ok]') as HTMLButtonElement).disabled).toBe(true)
+ expect(page.querySelector('[data-confirm]')?.textContent).toContain('I allow Acme’s Backup what it asks on these devices')
+ await click(page.querySelector('[data-fleet-pin-consent]'))
+ await click(page.querySelector('[data-confirm-ok]'))
+ 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 086b108c9..442827f4d 100644
--- a/frontend/src/pages/AppPage.tsx
+++ b/frontend/src/pages/AppPage.tsx
@@ -33,7 +33,6 @@ import {
} from '../services/graphQLAppCatalog'
import { DeviceAppChange, graphQLSetDeviceAppsRelease, refused } from '../services/graphQLDeviceApps'
import { AppChangeResults } from '../components/AppChangeResults'
-import { firstPartyApp } from '../components/firstPartyApps'
import { LoadingMessage } from '../components/LoadingMessage'
import { Container } from '../components/Container'
import { Confirm } from '../components/Confirm'
@@ -42,7 +41,19 @@ import { Notice } from '../components/Notice'
import { Title } from '../components/Title'
import { Link } from '../components/Link'
import { Icon } from '../components/Icon'
-import { channelName, day, heldBackLine, heldBackReason, releaseChannelName, stateWord } from '../helpers/appsHelper'
+import { AppCapabilities } from '../components/AppRootConsent'
+import {
+ allowLine,
+ appIcon,
+ asksConsent,
+ capabilitiesLine,
+ channelName,
+ day,
+ heldBackLine,
+ heldBackReason,
+ releaseChannelName,
+ stateWord,
+} from '../helpers/appsHelper'
const RELEASES_PAGE = 20
// The version filter's choices besides a version: any (no filter), and none reported — catalogApp's devices(version: ""),
@@ -55,12 +66,14 @@ const NO_VERSION = '-'
/* The app in the catalogue (presence-server docs/device-apps-design.md, "The Apps pages", /apps/:appID), from
catalogApp:
- its name and version, its publisher (Verified, Yours), Runs as root or Restricted, its description and platforms;
+ its name and version, its publisher (Verified, Yours), Runs as root or Restricted and what else it asks of
+ remote.it (its capabilities, in words), its description and platforms;
Add… (/apps/:appID/add), and Manage releases for the account's own publisher (the Publisher page, where releases
are published);
Channels on this stage — each channel's release, its candidate and to how many of the devices — and the channel
this account follows (setAccountAppChannel);
- Releases, newest first: each version, its date, where this stage's channels point at it, root, its platforms,
+ Releases, newest first: each version, its date, where this stage's channels point at it, root and its
+ capabilities, its platforms,
withdrawn, and its notes opened in place; Show more;
Your devices: how many in all, enabled, disabled, up to date and held back, and the held back by why (fleet.total,
fleet.heldBackBy); each device's version running, channel, state, and up to date or held back with the reason in
@@ -140,10 +153,25 @@ export const AppPage: React.FC = () => {
const devices = app.devices?.items ?? []
const chosen = devices.filter(d => selected.includes(d.deviceId))
- const needsConsent = chosen.some(d => d.heldBack?.reason === 'consent')
+ /* 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; one it does not list is not known, and the yes waits. */
+ 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 && (!releaseOf(d.latest) || asksConsent(releaseOf(d.latest))))
+ )
+ const needsConsent = moving.length > 0
+ const updateKnown = moving.every(d => !!releaseOf(d.latest))
+ const updateRoot = !updateKnown || moving.some(d => releaseOf(d.latest)?.root)
+ 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)
- const pinNeedsConsent = !!pinRelease?.root
+ // A pin to a release that asks for a consent (asksConsent, graphql's rule) takes the yes: each device's own consent
+ // may or may not cover it.
+ const pinNeedsConsent = asksConsent(pinRelease)
const many = async (values: { version: string; consentRoot?: boolean }) => {
setBusy(true)
@@ -176,7 +204,7 @@ export const AppPage: React.FC = () => {
-
+
{[
@@ -194,6 +222,11 @@ export const AppPage: React.FC = () => {
? t('apps.runsAsRootFull', 'Runs as root: full control of the device')
: t('apps.restricted', 'Restricted')}
+ {!!app.capabilities.length && (
+
+ {capabilitiesLine(t, app.capabilities)}
+
+ )}
{app.description && (
{app.description}
@@ -443,7 +476,12 @@ export const AppPage: React.FC = () => {
{
setAsking(undefined)
@@ -451,13 +489,31 @@ export const AppPage: React.FC = () => {
}}
onDeny={() => setAsking(undefined)}
>
-
- {t(
- 'apps.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.',
- { app: app.name, publisher: app.publisher.name }
- )}
+
+ {updateRoot
+ ? t(
+ 'apps.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.',
+ { app: app.name, publisher: app.publisher.name }
+ )
+ : t(
+ '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.',
+ { app: app.name, publisher: app.publisher.name }
+ )}
+ {!updateKnown && (
+
+ {t(
+ 'apps.asksUnknown',
+ 'What this version asks could not be read, so it cannot be consented to here. Try again later.'
+ )}
+
+ )}
+ {
))}
- {pinNeedsConsent && (
+ {pinNeedsConsent && pinRelease && (
+
+ )}
+ {pinNeedsConsent && pinRelease && (
{
inputProps={{ 'data-fleet-pin-consent': true } as any}
/>
}
- label={t('apps.allowRootDevices', 'I allow {{publisher}}’s {{app}} full control of these devices', {
- publisher: app.publisher.name,
- app: app.name,
- })}
+ label={allowLine(t, pinRelease.root, false, app.publisher.name, app.name)}
/>
)}
@@ -512,7 +571,7 @@ export const AppPage: React.FC = () => {
}
/* A release: its version, date, where this stage's channels point at it or that it was withdrawn, the first line of
- its notes — opened in place to all of them, with root and its platforms. */
+ its notes — opened in place to all of them, with root, what else it asks of remote.it and its platforms. */
const ReleaseRow: React.FC<{
release: CatalogAppRelease
channels: CatalogAppChannel[]
@@ -543,6 +602,7 @@ const ReleaseRow: React.FC<{
release.root
? t('apps.runsAsRootFull', 'Runs as root: full control of the device')
: t('apps.restricted', 'Restricted'),
+ capabilitiesLine(t, release.capabilities),
release.platforms.join(' · '),
]
.filter(Boolean)
diff --git a/frontend/src/pages/AppsPage.test.tsx b/frontend/src/pages/AppsPage.test.tsx
index e20af7400..dd24807d9 100644
--- a/frontend/src/pages/AppsPage.test.tsx
+++ b/frontend/src/pages/AppsPage.test.tsx
@@ -17,7 +17,6 @@ vi.mock('../components/Gutters', () => ({ Gutters: ({ children }: any) =>
}))
vi.mock('../components/LoadingMessage', () => ({ LoadingMessage: () => }))
vi.mock('../components/Icon', () => ({ Icon: () => null }))
-vi.mock('../components/firstPartyApps', () => ({ firstPartyApp: () => undefined }))
vi.mock('react-i18next', () => {
const fill = (text: string, values?: any) => text.replace(/{{(\w+)}}/g, (_, k) => values?.[k] ?? '')
return {
@@ -69,6 +68,11 @@ describe('Apps, the account’s catalogue', () => {
expect(backup.querySelector('[data-catalog-aside]')?.textContent).toBe('4 devices')
const console = row(page, 'remoteit.console')
expect(console.querySelector('[data-catalog-runs]')?.textContent).toBe('Runs as root: full control of the device')
+ // What it asks of remote.it, beside Runs as root; an ordinary app asks nothing.
+ expect(console.querySelector('[data-catalog-capabilities]')?.textContent).toBe(
+ 'Keeps accounts for the people you share with · Signs in people by remote.it certificate · AI commands go through this app'
+ )
+ expect(backup.querySelector('[data-catalog-capabilities]')).toBeNull()
expect(console.querySelector('[data-catalog-platforms]')?.textContent).toBe('linux · darwin · windows')
expect(row(page, 'remoteit.files').querySelector('[data-catalog-aside]')?.textContent).toBe('—')
})
diff --git a/frontend/src/pages/AppsPage.tsx b/frontend/src/pages/AppsPage.tsx
index d3f052eca..a084332b9 100644
--- a/frontend/src/pages/AppsPage.tsx
+++ b/frontend/src/pages/AppsPage.tsx
@@ -104,6 +104,8 @@ export const AppsPage: React.FC = () => {
verifiedDomain={app.publisher.verifiedDomain}
own={app.publisher.own}
root={app.root}
+ capabilities={app.capabilities}
+ protocol={app.protocol}
description={app.description}
platforms={app.version ? platformsLine(t, app.platforms) : t('apps.noRelease', 'No release here yet')}
aside={
diff --git a/frontend/src/pages/DeviceAppCatalogPage.test.tsx b/frontend/src/pages/DeviceAppCatalogPage.test.tsx
index 56fdf00ea..05e599889 100644
--- a/frontend/src/pages/DeviceAppCatalogPage.test.tsx
+++ b/frontend/src/pages/DeviceAppCatalogPage.test.tsx
@@ -3,6 +3,8 @@ import { createRoot, Root } from 'react-dom/client'
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
const { apps, push } = vi.hoisted(() => ({ apps: { value: {} as any }, push: 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') }))
vi.mock('react-router-dom', () => ({ useHistory: () => ({ push }) }))
vi.mock('../services/Context', async () => ({ DeviceContext: (await import('react')).createContext({}) }))
vi.mock('../hooks/useDeviceApps', () => ({ useDeviceApps: () => apps.value }))
@@ -17,7 +19,6 @@ vi.mock('../components/Notice', () => ({ Notice: ({ children }: any) =>
({ LoadingMessage: () => }))
vi.mock('../components/Link', () => ({ Link: ({ to, children }: any) => {children} }))
vi.mock('../components/Icon', () => ({ Icon: () => null }))
-vi.mock('../components/firstPartyApps', () => ({ firstPartyApp: () => undefined }))
vi.mock('../components/Confirm', () => ({
Confirm: ({ open, title, children, onConfirm }: any) =>
open ? (
@@ -58,7 +59,7 @@ async function render(permissions = ['VIEW', 'CONNECT', 'MANAGE', 'SCRIPTING'])
container = document.createElement('div')
document.body.appendChild(container)
root = createRoot(container)
- const device = { id: 'D1', name: 'pi-kitchen', permissions } as unknown as IDevice
+ const device = { id: 'D1', name: 'pi-kitchen', accountId: 'A1', permissions } as unknown as IDevice
await act(async () =>
root.render(
@@ -155,4 +156,34 @@ describe('the catalogue for this device', () => {
page = await render()
expect(page.querySelector('[data-catalog-empty]')?.textContent).toBe('There is no app this device does not have already.')
})
+
+ it('what each asks of remote.it, as graphql gives it for the release offered, beside Runs as root — and named in the consent', async () => {
+ apps.value.available = [
+ available({ capabilities: [], protocol: 'https' }),
+ available({
+ id: 'acme.shell',
+ name: 'Shell',
+ publisher: 'Acme',
+ root: true,
+ capabilities: ['person-accounts', 'person-certificates'],
+ protocol: 'ssh',
+ }),
+ ]
+ const page = await render()
+ expect(offer(page, 'acme.shell').querySelector('[data-catalog-capabilities]')?.textContent).toBe(
+ 'Keeps accounts for the people you share with · Signs in people by remote.it certificate'
+ )
+ expect(offer(page, 'remoteit.files').querySelector('[data-catalog-capabilities]')).toBeNull()
+ await click(offer(page, 'acme.shell').querySelector('[data-available-add]'))
+ expect([...page.querySelectorAll('[data-confirm] [data-app-capability]')].map(c => c.textContent)).toEqual([
+ '· Keeps accounts for the people you share with',
+ '· Signs in people by remote.it certificate',
+ ])
+ await click(page.querySelector('[data-confirm-ok]'))
+ expect(turn).toHaveBeenCalledWith(
+ expect.objectContaining({ id: 'acme.shell', capabilities: ['person-accounts', 'person-certificates'] }),
+ true,
+ true
+ )
+ })
})
diff --git a/frontend/src/pages/DeviceAppCatalogPage.tsx b/frontend/src/pages/DeviceAppCatalogPage.tsx
index 222d72730..964c5f3b5 100644
--- a/frontend/src/pages/DeviceAppCatalogPage.tsx
+++ b/frontend/src/pages/DeviceAppCatalogPage.tsx
@@ -19,22 +19,24 @@ import { adminControlLine, offered } from '../helpers/appsHelper'
/* The catalogue for this device (presence-server docs/device-apps-design.md, "The Apps pages",
/devices/:deviceID/apps/add): the apps it may take and does not have (graphql's Device.availableApps) — remote.it's
- and its own account's —, each with its publisher, Runs as root or Restricted, its description, and why it cannot be
- added here where it cannot: its administrator refuses it, or its stage has no release of it yet; and where its
- remote.it is too old to run it yet. A row opens the app in the catalogue; Add adds it here and enabled — a root app
- only with the person's yes (components/AppRootConsent) —, then opens it on this device. Adding runs code on the
- device: Scripting as well as Manage. */
+ and its own account's —, each with its publisher, Runs as root or Restricted and what else it asks of remote.it (its
+ capabilities, as graphql gives them for the release its stage gives), its description, and why it
+ cannot be added here where it cannot: its administrator refuses it, or its stage has no release of it yet; and where
+ its remote.it is too old to run it yet. A row opens the app in the catalogue; Add adds it here and enabled — a root
+ app only with the person's yes (components/AppRootConsent), which names its capabilities too —, then opens it on
+ this device. Adding runs code on the device: Scripting as well as Manage. */
export const DeviceAppCatalogPage: React.FC = () => {
const { t } = useTranslation()
const history = useHistory()
const { device } = useContext(DeviceContext)
- const deviceApps = useDeviceApps(device?.id)
+ const deviceApps = useDeviceApps(device?.id, { accountId: device?.accountId })
const { apps, available, switching } = deviceApps
const [refusal, setRefusal] = useState()
const { flip, consent } = useAppSwitch(
deviceApps,
reason => setRefusal(reason || t('apps.notAdded', 'The app was not added.')),
- app => device && history.push(`/devices/${device.id}/apps/${app.id}`)
+ app => device && history.push(`/devices/${device.id}/apps/${app.id}`),
+ device?.accountId
)
if (!device) return
@@ -91,6 +93,8 @@ export const DeviceAppCatalogPage: React.FC = () => {
publisher={app.publisher}
verifiedDomain={app.publisherVerifiedDomain}
root={app.root}
+ capabilities={app.capabilities}
+ protocol={app.protocol}
description={app.description}
aside={app.version}
onOpen={() => history.push(`/apps/${app.id}`)}
diff --git a/frontend/src/pages/DeviceAppPage.test.tsx b/frontend/src/pages/DeviceAppPage.test.tsx
index 11ce79509..bfd56cc16 100644
--- a/frontend/src/pages/DeviceAppPage.test.tsx
+++ b/frontend/src/pages/DeviceAppPage.test.tsx
@@ -2,23 +2,25 @@ import React, { act } from 'react'
import { createRoot, Root } from 'react-dom/client'
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'
-const { apps, catalog, push, params } = vi.hoisted(() => ({
+const { apps, catalog, push, params, openTerminal } = vi.hoisted(() => ({
apps: { value: {} as any },
catalog: vi.fn(),
push: vi.fn(),
params: { appID: 'acme.backup' },
+ openTerminal: vi.fn(),
}))
+// The page reads its services' ports with multiPortServices' formatting; nothing here asks the API.
+vi.mock('../services/post', () => ({ post: vi.fn() }))
vi.mock('react-router-dom', () => ({ useHistory: () => ({ push }), useParams: () => params }))
vi.mock('../services/Context', async () => ({ DeviceContext: (await import('react')).createContext({}) }))
vi.mock('../services/graphQLAppCatalog', () => ({ graphQLCatalogApp: catalog }))
vi.mock('../hooks/useDeviceApps', () => ({ useDeviceApps: () => apps.value }))
vi.mock('../hooks/useLocalSubnetName', () => ({ useSubnetName: () => 'pi.on.remote.it' }))
-vi.mock('../helpers/terminalHelper', () => ({ openTerminal: vi.fn() }))
+vi.mock('../helpers/terminalHelper', () => ({ openTerminal }))
+vi.mock('../services/browser', () => ({ default: { isNative: false }, windowOpen: vi.fn() }))
vi.mock('../services/graphQLDeviceApps', async () => ({
...(await import('../services/deviceAppsShared')),
- CONSOLE: 'remoteit.console',
SCREENVIEW: 'remoteit.screenview',
- graphQLSshHostKey: vi.fn(async () => 'SHA256:abc'),
}))
vi.mock('../components/DeviceAppSetting', () => ({
DeviceAppSetting: ({ setting, label, disabled, onChange }: any) => (
@@ -35,12 +37,12 @@ vi.mock('../components/LoadingMessage', () => ({ LoadingMessage: () =>