Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions frontend/src/buttons/ServiceConnectButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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)
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.
Expand Down Expand Up @@ -125,7 +130,12 @@ export const ServiceConnectButton: React.FC = () => {
) : named ? (
<Box sx={{ width: '100%' }}>
{local ? (
<LocalSubnetConnect local={local} service={service} connection={connection} />
<LocalSubnetConnect
local={local}
service={service}
connection={connection}
byCertificate={byCertificate}
/>
) : (
<BrowserGatewayConnect
name={reach.name!}
Expand All @@ -135,7 +145,7 @@ export const ServiceConnectButton: React.FC = () => {
port: service.port || 22,
title: service.name,
service: service.id,
console: isConsoleService(service),
byCertificate,
}
: undefined
}
Expand Down Expand Up @@ -167,10 +177,10 @@ export const ServiceConnectButton: React.FC = () => {
{portLink}
</Gutters>
)}
{/* 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 && (
<Gutters size="md" top={null} bottom={null}>
<ConsoleTerminalOption device={device} service={service} />
<AppTerminalOption device={device} service={service} serving={serving} />
</Gutters>
)}
{/* The service's other ports here that this machine's daemon lists: the machine's, opened by someone else. */}
Expand Down
16 changes: 13 additions & 3 deletions frontend/src/components/AppCatalogRow.tsx
Original file line number Diff line number Diff line change
@@ -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: <domain> and Yours for the account's own, Runs as root or Restricted, its description, its platforms and
Verified: <domain> 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 = {
Expand All @@ -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
Expand All @@ -30,6 +33,8 @@ export const AppCatalogRow: React.FC<AppCatalogRowProps> = ({
verifiedDomain,
own,
root,
capabilities,
protocol,
description,
platforms,
aside,
Expand All @@ -41,7 +46,7 @@ export const AppCatalogRow: React.FC<AppCatalogRowProps> = ({
const body = (
<>
<ListItemIcon sx={{ alignSelf: 'flex-start', marginTop: 0.5 }}>
<Icon name={firstPartyApp(id)?.icon ?? 'cube'} size="md" fixedWidth />
<Icon name={appIcon(protocol)} size="md" fixedWidth />
</ListItemIcon>
<ListItemText
primary={
Expand All @@ -61,6 +66,11 @@ export const AppCatalogRow: React.FC<AppCatalogRowProps> = ({
? t('apps.runsAsRootFull', 'Runs as root: full control of the device')
: t('apps.restricted', 'Restricted')}
</Typography>
{!!capabilities?.length && (
<Typography variant="caption" color="textSecondary" data-catalog-capabilities>
{capabilitiesLine(t, capabilities)}
</Typography>
)}
</Box>
}
secondaryTypographyProps={{ component: 'div' }}
Expand Down
36 changes: 31 additions & 5 deletions frontend/src/components/AppRootConsent.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import React, { 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 { capabilityWords } from '../helpers/appsHelper'
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. */
full control of the device (presence-server docs/device-apps-design.md, "Root, shown and consented to"), and what
else it asks of remote.it — its capabilities, part of the consent (presence-contract docs/self-contained-apps.md,
"Manifest"). For a product it says the yes covers every device in the product, now and later, as graphql keeps it
on the product. */
export const RootConsent: React.FC<{
app?: { name: string; publisher: string } // open while there is one
app?: { name: string; publisher: string; capabilities?: string[] } // open while there is one
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).
Expand Down Expand Up @@ -61,6 +64,7 @@ export const RootConsent: React.FC<{
words
)}
</Typography>
<AppCapabilities capabilities={app?.capabilities} />
<Typography variant="body2">
{product
? t(
Expand All @@ -74,8 +78,30 @@ export const RootConsent: React.FC<{
)
}

// 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 (
<Box sx={{ marginBottom: 1 }} data-app-capabilities>
<Typography variant="body2">{title ?? t('apps.capabilitiesAlso', 'It also asks of remote.it:')}</Typography>
{capabilities.map(capability => (
<Typography
key={capability}
variant="body2"
component="div"
sx={{ paddingLeft: 2 }}
data-app-capability={capability}
>
· {capabilityWords(t, capability)}
</Typography>
))}
</Box>
)
}

/* 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
an app's service's connect panel). A root app is enabled only once the person says yes (RootConsent); that yes is
consentRoot, which graphql refuses a root app without. Disabling, or a restricted app, at once. A release that newly
runs as root while the app is enabled (awaitingRoot) is asked for the same way (reconsent): the yes is
setDeviceAppRelease's consentRoot alone — Update now —, which moves the device to that release. graphql's refusal,
Expand Down
Loading
Loading