chore: remove tor from startos core

Tor is being moved from a built-in OS feature to a service. This removes
the Arti-based Tor client, onion address management, hidden service
creation, and all related code from the core backend, frontend, and SDK.

- Delete core/src/net/tor/ module (~2060 lines)
- Remove OnionAddress, TorSecretKey, TorController from all consumers
- Remove HostnameInfo::Onion and HostAddress::Onion variants
- Remove onion CRUD RPC endpoints and tor subcommand
- Remove tor key handling from account and backup/restore
- Remove ~12 tor-related Cargo dependencies (arti-client, torut, etc.)
- Remove tor UI components, API methods, mock data, and routes
- Remove OnionHostname and tor patterns/regexes from SDK
- Add v0_4_0_alpha_20 database migration to strip onion data
- Bump version to 0.4.0-alpha.20
This commit is contained in:
Aiden McClelland
2026-02-10 13:28:24 -07:00
parent 1974dfd66f
commit 2ee403e7de
53 changed files with 3147 additions and 9306 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +1,3 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ErrorData = { details: string; debug: string }
export type ErrorData = { details: string; debug: string; info: unknown }

View File

@@ -5,7 +5,6 @@ import type { PublicDomainConfig } from './PublicDomainConfig'
export type Host = {
bindings: { [key: number]: BindInfo }
onions: string[]
publicDomains: { [key: string]: PublicDomainConfig }
privateDomains: Array<string>
/**

View File

@@ -1,8 +1,10 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { GatewayInfo } from './GatewayInfo'
import type { IpHostname } from './IpHostname'
import type { OnionHostname } from './OnionHostname'
export type HostnameInfo =
| { kind: 'ip'; gateway: GatewayInfo; public: boolean; hostname: IpHostname }
| { kind: 'onion'; hostname: OnionHostname }
export type HostnameInfo = {
kind: 'ip'
gateway: GatewayInfo
public: boolean
hostname: IpHostname
}

View File

@@ -1,7 +0,0 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type OnionHostname = {
value: string
port: number | null
sslPort: number | null
}

View File

@@ -149,7 +149,6 @@ export { NetInfo } from './NetInfo'
export { NetworkInfo } from './NetworkInfo'
export { NetworkInterfaceInfo } from './NetworkInterfaceInfo'
export { NetworkInterfaceType } from './NetworkInterfaceType'
export { OnionHostname } from './OnionHostname'
export { OsIndex } from './OsIndex'
export { OsVersionInfoMap } from './OsVersionInfoMap'
export { OsVersionInfo } from './OsVersionInfo'

View File

@@ -20,7 +20,6 @@ export const getHostname = (url: string): Hostname | null => {
}
type FilterKinds =
| 'onion'
| 'mdns'
| 'domain'
| 'ip'
@@ -42,27 +41,25 @@ type VisibilityFilter<V extends 'public' | 'private'> = V extends 'public'
| (HostnameInfo & { public: false })
| VisibilityFilter<Exclude<V, 'private'>>
: never
type KindFilter<K extends FilterKinds> = K extends 'onion'
? (HostnameInfo & { kind: 'onion' }) | KindFilter<Exclude<K, 'onion'>>
: K extends 'mdns'
type KindFilter<K extends FilterKinds> = K extends 'mdns'
?
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'local' } })
| KindFilter<Exclude<K, 'mdns'>>
: K extends 'domain'
?
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'local' } })
| KindFilter<Exclude<K, 'mdns'>>
: K extends 'domain'
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'domain' } })
| KindFilter<Exclude<K, 'domain'>>
: K extends 'ipv4'
?
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'domain' } })
| KindFilter<Exclude<K, 'domain'>>
: K extends 'ipv4'
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'ipv4' } })
| KindFilter<Exclude<K, 'ipv4'>>
: K extends 'ipv6'
?
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'ipv4' } })
| KindFilter<Exclude<K, 'ipv4'>>
: K extends 'ipv6'
?
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'ipv6' } })
| KindFilter<Exclude<K, 'ipv6'>>
: K extends 'ip'
? KindFilter<Exclude<K, 'ip'> | 'ipv4' | 'ipv6'>
: never
| (HostnameInfo & { kind: 'ip'; hostname: { kind: 'ipv6' } })
| KindFilter<Exclude<K, 'ipv6'>>
: K extends 'ip'
? KindFilter<Exclude<K, 'ip'> | 'ipv4' | 'ipv6'>
: never
type FilterReturnTy<F extends Filter> = F extends {
visibility: infer V extends 'public' | 'private'
@@ -90,10 +87,6 @@ const nonLocalFilter = {
const publicFilter = {
visibility: 'public',
} as const
const onionFilter = {
kind: 'onion',
} as const
type Formats = 'hostname-info' | 'urlstring' | 'url'
type FormatReturnTy<
F extends Filter,
@@ -124,7 +117,6 @@ export type Filled<F extends Filter = {}> = {
nonLocal: Filled<typeof nonLocalFilter & Filter>
public: Filled<typeof publicFilter & Filter>
onion: Filled<typeof onionFilter & Filter>
}
export type FilledAddressInfo = AddressInfo & Filled
export type ServiceInterfaceFilled = {
@@ -162,9 +154,7 @@ export const addressHostToUrl = (
scheme in knownProtocols &&
port === knownProtocols[scheme as keyof typeof knownProtocols].defaultPort
let hostname
if (host.kind === 'onion') {
hostname = host.hostname.value
} else if (host.kind === 'ip') {
if (host.kind === 'ip') {
if (host.hostname.kind === 'domain') {
hostname = host.hostname.value
} else if (host.hostname.kind === 'ipv6') {
@@ -201,13 +191,9 @@ function filterRec(
hostnames = hostnames.filter((h) => invert !== pred(h))
}
if (filter.visibility === 'public')
hostnames = hostnames.filter(
(h) => invert !== (h.kind === 'onion' || h.public),
)
hostnames = hostnames.filter((h) => invert !== h.public)
if (filter.visibility === 'private')
hostnames = hostnames.filter(
(h) => invert !== (h.kind !== 'onion' && !h.public),
)
hostnames = hostnames.filter((h) => invert !== !h.public)
if (filter.kind) {
const kind = new Set(
Array.isArray(filter.kind) ? filter.kind : [filter.kind],
@@ -219,10 +205,7 @@ function filterRec(
hostnames = hostnames.filter(
(h) =>
invert !==
((kind.has('onion') && h.kind === 'onion') ||
(kind.has('mdns') &&
h.kind === 'ip' &&
h.hostname.kind === 'local') ||
((kind.has('mdns') && h.kind === 'ip' && h.hostname.kind === 'local') ||
(kind.has('domain') &&
h.kind === 'ip' &&
h.hostname.kind === 'domain') ||
@@ -266,11 +249,6 @@ export const filledAddress = (
filterRec(hostnames, publicFilter, false),
),
)
const getOnion = once(() =>
filledAddressFromHostnames<typeof onionFilter & F>(
filterRec(hostnames, onionFilter, false),
),
)
return {
...addressInfo,
hostnames,
@@ -294,9 +272,6 @@ export const filledAddress = (
get public(): Filled<typeof publicFilter & F> {
return getPublic()
},
get onion(): Filled<typeof onionFilter & F> {
return getOnion()
},
}
}

View File

@@ -21,11 +21,6 @@ export const localHostname: Pattern = {
description: 'Must be a valid ".local" hostname',
}
export const torHostname: Pattern = {
regex: regexes.torHostname.matches(),
description: 'Must be a valid Tor (".onion") hostname',
}
export const url: Pattern = {
regex: regexes.url.matches(),
description: 'Must be a valid URL',
@@ -36,11 +31,6 @@ export const localUrl: Pattern = {
description: 'Must be a valid ".local" URL',
}
export const torUrl: Pattern = {
regex: regexes.torUrl.matches(),
description: 'Must be a valid Tor (".onion") URL',
}
export const ascii: Pattern = {
regex: regexes.ascii.matches(),
description:

View File

@@ -39,10 +39,6 @@ export const localHostname = new ComposableRegex(
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local/,
)
export const torHostname = new ComposableRegex(
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion/,
)
// https://ihateregex.io/expr/url/
export const url = new ComposableRegex(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,
@@ -52,10 +48,6 @@ export const localUrl = new ComposableRegex(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,
)
export const torUrl = new ComposableRegex(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,
)
// https://ihateregex.io/expr/ascii/
export const ascii = new ComposableRegex(/[ -~]*/)

View File

@@ -1,9 +1,9 @@
import * as fs from "fs"
import * as fs from 'fs'
// https://stackoverflow.com/questions/2970525/converting-any-string-into-camel-case
export function camelCase(value: string) {
return value
.replace(/([\(\)\[\]])/g, "")
.replace(/([\(\)\[\]])/g, '')
.replace(/^([A-Z])|[\s-_](\w)/g, function (match, p1, p2, offset) {
if (p2) return p2.toUpperCase()
return p1.toLowerCase()
@@ -23,12 +23,12 @@ export async function oldSpecToBuilder(
}
function isString(x: unknown): x is string {
return typeof x === "string"
return typeof x === 'string'
}
export default async function makeFileContentFromOld(
inputData: Promise<any> | any,
{ StartSdk = "start-sdk", nested = true } = {},
{ StartSdk = 'start-sdk', nested = true } = {},
) {
const outputLines: string[] = []
outputLines.push(`
@@ -37,16 +37,16 @@ const {InputSpec, List, Value, Variants} = sdk
`)
const data = await inputData
const namedConsts = new Set(["InputSpec", "Value", "List"])
const inputSpecName = newConst("inputSpecSpec", convertInputSpec(data))
const namedConsts = new Set(['InputSpec', 'Value', 'List'])
const inputSpecName = newConst('inputSpecSpec', convertInputSpec(data))
outputLines.push(`export type InputSpecSpec = typeof ${inputSpecName}._TYPE;`)
return outputLines.join("\n")
return outputLines.join('\n')
function newConst(key: string, data: string, type?: string) {
const variableName = getNextConstName(camelCase(key))
outputLines.push(
`export const ${variableName}${!type ? "" : `: ${type}`} = ${data};`,
`export const ${variableName}${!type ? '' : `: ${type}`} = ${data};`,
)
return variableName
}
@@ -55,7 +55,7 @@ const {InputSpec, List, Value, Variants} = sdk
return newConst(key, data)
}
function convertInputSpecInner(data: any) {
let answer = "{"
let answer = '{'
for (const [key, value] of Object.entries(data)) {
const variableName = maybeNewConst(key, convertValueSpec(value))
@@ -69,7 +69,7 @@ const {InputSpec, List, Value, Variants} = sdk
}
function convertValueSpec(value: any): string {
switch (value.type) {
case "string": {
case 'string': {
if (value.textarea) {
return `${rangeToTodoComment(
value?.range,
@@ -99,12 +99,12 @@ const {InputSpec, List, Value, Variants} = sdk
warning: value.warning || null,
masked: value.masked || false,
placeholder: value.placeholder || null,
inputmode: "text",
inputmode: 'text',
patterns: value.pattern
? [
{
regex: value.pattern,
description: value["pattern-description"],
description: value['pattern-description'],
},
]
: [],
@@ -115,7 +115,7 @@ const {InputSpec, List, Value, Variants} = sdk
2,
)})`
}
case "number": {
case 'number': {
return `${rangeToTodoComment(
value?.range,
)}Value.number(${JSON.stringify(
@@ -136,7 +136,7 @@ const {InputSpec, List, Value, Variants} = sdk
2,
)})`
}
case "boolean": {
case 'boolean': {
return `Value.toggle(${JSON.stringify(
{
name: value.name || null,
@@ -148,15 +148,15 @@ const {InputSpec, List, Value, Variants} = sdk
2,
)})`
}
case "enum": {
case 'enum': {
const allValueNames = new Set([
...(value?.["values"] || []),
...Object.keys(value?.["value-names"] || {}),
...(value?.['values'] || []),
...Object.keys(value?.['value-names'] || {}),
])
const values = Object.fromEntries(
Array.from(allValueNames)
.filter(isString)
.map((key) => [key, value?.spec?.["value-names"]?.[key] || key]),
.map((key) => [key, value?.spec?.['value-names']?.[key] || key]),
)
return `Value.select(${JSON.stringify(
{
@@ -170,9 +170,9 @@ const {InputSpec, List, Value, Variants} = sdk
2,
)} as const)`
}
case "object": {
case 'object': {
const specName = maybeNewConst(
value.name + "_spec",
value.name + '_spec',
convertInputSpec(value.spec),
)
return `Value.object({
@@ -180,10 +180,10 @@ const {InputSpec, List, Value, Variants} = sdk
description: ${JSON.stringify(value.description || null)},
}, ${specName})`
}
case "union": {
case 'union': {
const variants = maybeNewConst(
value.name + "_variants",
convertVariants(value.variants, value.tag["variant-names"] || {}),
value.name + '_variants',
convertVariants(value.variants, value.tag['variant-names'] || {}),
)
return `Value.union({
@@ -194,18 +194,18 @@ const {InputSpec, List, Value, Variants} = sdk
variants: ${variants},
})`
}
case "list": {
if (value.subtype === "enum") {
case 'list': {
if (value.subtype === 'enum') {
const allValueNames = new Set([
...(value?.spec?.["values"] || []),
...Object.keys(value?.spec?.["value-names"] || {}),
...(value?.spec?.['values'] || []),
...Object.keys(value?.spec?.['value-names'] || {}),
])
const values = Object.fromEntries(
Array.from(allValueNames)
.filter(isString)
.map((key: string) => [
key,
value?.spec?.["value-names"]?.[key] ?? key,
value?.spec?.['value-names']?.[key] ?? key,
]),
)
return `Value.multiselect(${JSON.stringify(
@@ -222,10 +222,10 @@ const {InputSpec, List, Value, Variants} = sdk
2,
)})`
}
const list = maybeNewConst(value.name + "_list", convertList(value))
const list = maybeNewConst(value.name + '_list', convertList(value))
return `Value.list(${list})`
}
case "pointer": {
case 'pointer': {
return `/* TODO deal with point removed point "${value.name}" */null as any`
}
}
@@ -234,7 +234,7 @@ const {InputSpec, List, Value, Variants} = sdk
function convertList(value: any) {
switch (value.subtype) {
case "string": {
case 'string': {
return `${rangeToTodoComment(value?.range)}List.text(${JSON.stringify(
{
name: value.name || null,
@@ -253,7 +253,7 @@ const {InputSpec, List, Value, Variants} = sdk
? [
{
regex: value.spec.pattern,
description: value?.spec?.["pattern-description"],
description: value?.spec?.['pattern-description'],
},
]
: [],
@@ -281,12 +281,12 @@ const {InputSpec, List, Value, Variants} = sdk
// placeholder: value?.spec?.placeholder || null,
// })})`
// }
case "enum": {
return "/* error!! list.enum */"
case 'enum': {
return '/* error!! list.enum */'
}
case "object": {
case 'object': {
const specName = maybeNewConst(
value.name + "_spec",
value.name + '_spec',
convertInputSpec(value.spec.spec),
)
return `${rangeToTodoComment(value?.range)}List.obj({
@@ -297,20 +297,20 @@ const {InputSpec, List, Value, Variants} = sdk
description: ${JSON.stringify(value.description || null)},
}, {
spec: ${specName},
displayAs: ${JSON.stringify(value?.spec?.["display-as"] || null)},
uniqueBy: ${JSON.stringify(value?.spec?.["unique-by"] || null)},
displayAs: ${JSON.stringify(value?.spec?.['display-as'] || null)},
uniqueBy: ${JSON.stringify(value?.spec?.['unique-by'] || null)},
})`
}
case "union": {
case 'union': {
const variants = maybeNewConst(
value.name + "_variants",
value.name + '_variants',
convertVariants(
value.spec.variants,
value.spec["variant-names"] || {},
value.spec['variant-names'] || {},
),
)
const unionValueName = maybeNewConst(
value.name + "_union",
value.name + '_union',
`${rangeToTodoComment(value?.range)}
Value.union({
name: ${JSON.stringify(value?.spec?.tag?.name || null)},
@@ -324,7 +324,7 @@ const {InputSpec, List, Value, Variants} = sdk
`,
)
const listInputSpec = maybeNewConst(
value.name + "_list_inputSpec",
value.name + '_list_inputSpec',
`
InputSpec.of({
"union": ${unionValueName}
@@ -340,8 +340,8 @@ const {InputSpec, List, Value, Variants} = sdk
warning: ${JSON.stringify(value.warning || null)},
}, {
spec: ${listInputSpec},
displayAs: ${JSON.stringify(value?.spec?.["display-as"] || null)},
uniqueBy: ${JSON.stringify(value?.spec?.["unique-by"] || null)},
displayAs: ${JSON.stringify(value?.spec?.['display-as'] || null)},
uniqueBy: ${JSON.stringify(value?.spec?.['unique-by'] || null)},
})`
}
}
@@ -352,7 +352,7 @@ const {InputSpec, List, Value, Variants} = sdk
variants: Record<string, unknown>,
variantNames: Record<string, string>,
): string {
let answer = "Variants.of({"
let answer = 'Variants.of({'
for (const [key, value] of Object.entries(variants)) {
const variantSpec = maybeNewConst(key, convertInputSpec(value))
answer += `"${key}": {name: "${
@@ -373,7 +373,7 @@ const {InputSpec, List, Value, Variants} = sdk
}
function rangeToTodoComment(range: string | undefined) {
if (!range) return ""
if (!range) return ''
return `/* TODO: Convert range for this value (${range})*/`
}