mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
Merge branch 'next/minor' of github.com:Start9Labs/start-os into next/major
This commit is contained in:
@@ -8,7 +8,7 @@ import {
|
||||
SetHealth,
|
||||
BindParams,
|
||||
HostId,
|
||||
LanInfo,
|
||||
NetInfo,
|
||||
Host,
|
||||
ExportServiceInterfaceParams,
|
||||
ServiceInterface,
|
||||
@@ -117,7 +117,7 @@ export type Effects = {
|
||||
packageId?: PackageId
|
||||
hostId: HostId
|
||||
internalPort: number
|
||||
}): Promise<LanInfo>
|
||||
}): Promise<NetInfo>
|
||||
/** Removes all network bindings, called in the setupInputSpec */
|
||||
clearBindings(options: {
|
||||
except: { id: HostId; internalPort: number }[]
|
||||
@@ -129,12 +129,6 @@ export type Effects = {
|
||||
hostId: HostId
|
||||
callback?: () => void
|
||||
}): Promise<Host | null>
|
||||
/** Returns the primary url that a user has selected for a host, if it exists */
|
||||
getPrimaryUrl(options: {
|
||||
packageId?: PackageId
|
||||
hostId: HostId
|
||||
callback?: () => void
|
||||
}): Promise<UrlString | null>
|
||||
/** Returns the IP address of the container */
|
||||
getContainerIp(): Promise<string>
|
||||
// interface
|
||||
|
||||
@@ -94,8 +94,8 @@ export class InputSpec<Type extends Record<string, any>, Store = never> {
|
||||
},
|
||||
public validator: Parser<unknown, Type>,
|
||||
) {}
|
||||
_TYPE: Type = null as any as Type
|
||||
_PARTIAL: DeepPartial<Type> = null as any as DeepPartial<Type>
|
||||
public _TYPE: Type = null as any as Type
|
||||
public _PARTIAL: DeepPartial<Type> = null as any as DeepPartial<Type>
|
||||
async build(options: LazyBuildOptions<Store>) {
|
||||
const answer = {} as {
|
||||
[K in keyof Type]: ValueSpec
|
||||
|
||||
@@ -49,6 +49,9 @@ export class Value<Type, Store> {
|
||||
public build: LazyBuild<Store, ValueSpec>,
|
||||
public validator: Parser<unknown, Type>,
|
||||
) {}
|
||||
public _TYPE: Type = null as any as Type
|
||||
public _PARTIAL: DeepPartial<Type> = null as any as DeepPartial<Type>
|
||||
|
||||
static toggle(a: {
|
||||
name: string
|
||||
description?: string | null
|
||||
|
||||
@@ -25,9 +25,9 @@ export const customSmtp = InputSpec.of<InputSpecOf<SmtpValue>, never>({
|
||||
name: "From Address",
|
||||
required: true,
|
||||
default: null,
|
||||
placeholder: "<name>test@example.com",
|
||||
placeholder: "Example Name <test@example.com>",
|
||||
inputmode: "email",
|
||||
patterns: [Patterns.email],
|
||||
patterns: [Patterns.emailWithName],
|
||||
}),
|
||||
login: Value.text({
|
||||
name: "Login",
|
||||
|
||||
@@ -31,7 +31,7 @@ export type CurrentDependenciesResult<Manifest extends T.SDKManifest> = {
|
||||
[K in RequiredDependenciesOf<Manifest>]: DependencyRequirement
|
||||
} & {
|
||||
[K in OptionalDependenciesOf<Manifest>]?: DependencyRequirement
|
||||
} & Record<string, DependencyRequirement>
|
||||
}
|
||||
|
||||
export function setupDependencies<Manifest extends T.SDKManifest>(
|
||||
fn: (options: {
|
||||
@@ -48,14 +48,16 @@ export function setupDependencies<Manifest extends T.SDKManifest>(
|
||||
}
|
||||
const dependencyType = await fn(options)
|
||||
return await options.effects.setDependencies({
|
||||
dependencies: Object.entries(dependencyType).map(
|
||||
([id, { versionRange, ...x }, ,]) =>
|
||||
({
|
||||
// id,
|
||||
...x,
|
||||
versionRange: versionRange.toString(),
|
||||
}) as T.DependencyRequirement,
|
||||
),
|
||||
dependencies: Object.entries(dependencyType)
|
||||
.map(([k, v]) => [k, v as DependencyRequirement] as const)
|
||||
.map(
|
||||
([id, { versionRange, ...x }]) =>
|
||||
({
|
||||
id,
|
||||
...x,
|
||||
versionRange: versionRange.toString(),
|
||||
}) as T.DependencyRequirement,
|
||||
),
|
||||
})
|
||||
}
|
||||
return cell.updater
|
||||
|
||||
@@ -77,19 +77,18 @@ type BindOptionsByKnownProtocol =
|
||||
preferredExternalPort?: number
|
||||
addSsl?: AddSslOptions
|
||||
}
|
||||
export type BindOptionsByProtocol = BindOptionsByKnownProtocol | BindOptions
|
||||
|
||||
export type HostKind = BindParams["kind"]
|
||||
export type BindOptionsByProtocol =
|
||||
| BindOptionsByKnownProtocol
|
||||
| (BindOptions & { protocol: null })
|
||||
|
||||
const hasStringProtocol = object({
|
||||
protocol: string,
|
||||
}).test
|
||||
|
||||
export class Host {
|
||||
export class MultiHost {
|
||||
constructor(
|
||||
readonly options: {
|
||||
effects: Effects
|
||||
kind: HostKind
|
||||
id: string
|
||||
},
|
||||
) {}
|
||||
@@ -113,7 +112,7 @@ export class Host {
|
||||
async bindPort(
|
||||
internalPort: number,
|
||||
options: BindOptionsByProtocol,
|
||||
): Promise<Origin<this>> {
|
||||
): Promise<Origin> {
|
||||
if (hasStringProtocol(options)) {
|
||||
return await this.bindPortForKnown(options, internalPort)
|
||||
} else {
|
||||
@@ -130,7 +129,6 @@ export class Host {
|
||||
},
|
||||
) {
|
||||
const binderOptions = {
|
||||
kind: this.options.kind,
|
||||
id: this.options.id,
|
||||
internalPort,
|
||||
...options,
|
||||
@@ -163,7 +161,6 @@ export class Host {
|
||||
const secure: Security | null = !protoInfo.secure ? null : { ssl: false }
|
||||
|
||||
await this.options.effects.bind({
|
||||
kind: this.options.kind,
|
||||
id: this.options.id,
|
||||
internalPort,
|
||||
preferredExternalPort,
|
||||
@@ -190,21 +187,3 @@ function inObject<Key extends string>(
|
||||
): obj is { [K in Key]: unknown } {
|
||||
return key in obj
|
||||
}
|
||||
|
||||
// export class StaticHost extends Host {
|
||||
// constructor(options: { effects: Effects; id: string }) {
|
||||
// super({ ...options, kind: "static" })
|
||||
// }
|
||||
// }
|
||||
|
||||
// export class SingleHost extends Host {
|
||||
// constructor(options: { effects: Effects; id: string }) {
|
||||
// super({ ...options, kind: "single" })
|
||||
// }
|
||||
// }
|
||||
|
||||
export class MultiHost extends Host {
|
||||
constructor(options: { effects: Effects; id: string }) {
|
||||
super({ ...options, kind: "multi" })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { AddressInfo } from "../types"
|
||||
import { AddressReceipt } from "./AddressReceipt"
|
||||
import { Host, Scheme } from "./Host"
|
||||
import { MultiHost, Scheme } from "./Host"
|
||||
import { ServiceInterfaceBuilder } from "./ServiceInterfaceBuilder"
|
||||
|
||||
export class Origin<T extends Host> {
|
||||
export class Origin {
|
||||
constructor(
|
||||
readonly host: T,
|
||||
readonly host: MultiHost,
|
||||
readonly internalPort: number,
|
||||
readonly scheme: string | null,
|
||||
readonly sslScheme: string | null,
|
||||
@@ -46,7 +46,6 @@ export class Origin<T extends Host> {
|
||||
const {
|
||||
name,
|
||||
description,
|
||||
hasPrimary,
|
||||
id,
|
||||
type,
|
||||
username,
|
||||
@@ -67,7 +66,6 @@ export class Origin<T extends Host> {
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
hasPrimary,
|
||||
addressInfo,
|
||||
type,
|
||||
masked,
|
||||
|
||||
@@ -20,7 +20,6 @@ export class ServiceInterfaceBuilder {
|
||||
name: string
|
||||
id: string
|
||||
description: string
|
||||
hasPrimary: boolean
|
||||
type: ServiceInterfaceType
|
||||
username: string | null
|
||||
path: string
|
||||
|
||||
3
sdk/base/lib/osBindings/AcmeProvider.ts
Normal file
3
sdk/base/lib/osBindings/AcmeProvider.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type AcmeProvider = string
|
||||
@@ -1,13 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type AcmeSettings = {
|
||||
provider: string
|
||||
/**
|
||||
* email addresses for letsencrypt
|
||||
*/
|
||||
contact: Array<string>
|
||||
/**
|
||||
* domains to get letsencrypt certs for
|
||||
*/
|
||||
domains: string[]
|
||||
}
|
||||
export type AcmeSettings = { contact: Array<string> }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { BindOptions } from "./BindOptions"
|
||||
import type { LanInfo } from "./LanInfo"
|
||||
import type { NetInfo } from "./NetInfo"
|
||||
|
||||
export type BindInfo = { enabled: boolean; options: BindOptions; lan: LanInfo }
|
||||
export type BindInfo = { enabled: boolean; options: BindOptions; net: NetInfo }
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { AddSslOptions } from "./AddSslOptions"
|
||||
import type { HostId } from "./HostId"
|
||||
import type { HostKind } from "./HostKind"
|
||||
import type { Security } from "./Security"
|
||||
|
||||
export type BindParams = {
|
||||
kind: HostKind
|
||||
id: HostId
|
||||
internalPort: number
|
||||
preferredExternalPort: number
|
||||
|
||||
6
sdk/base/lib/osBindings/BindingSetPublicParams.ts
Normal file
6
sdk/base/lib/osBindings/BindingSetPublicParams.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type BindingSetPublicParams = {
|
||||
internalPort: number
|
||||
public: boolean | null
|
||||
}
|
||||
4
sdk/base/lib/osBindings/DomainConfig.ts
Normal file
4
sdk/base/lib/osBindings/DomainConfig.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { AcmeProvider } from "./AcmeProvider"
|
||||
|
||||
export type DomainConfig = { public: boolean; acme: AcmeProvider | null }
|
||||
@@ -7,7 +7,6 @@ export type ExportServiceInterfaceParams = {
|
||||
id: ServiceInterfaceId
|
||||
name: string
|
||||
description: string
|
||||
hasPrimary: boolean
|
||||
masked: boolean
|
||||
addressInfo: AddressInfo
|
||||
type: ServiceInterfaceType
|
||||
|
||||
3
sdk/base/lib/osBindings/ForgetInterfaceParams.ts
Normal file
3
sdk/base/lib/osBindings/ForgetInterfaceParams.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type ForgetInterfaceParams = { interface: string }
|
||||
@@ -1,10 +0,0 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { CallbackId } from "./CallbackId"
|
||||
import type { HostId } from "./HostId"
|
||||
import type { PackageId } from "./PackageId"
|
||||
|
||||
export type GetPrimaryUrlParams = {
|
||||
packageId?: PackageId
|
||||
hostId: HostId
|
||||
callback?: CallbackId
|
||||
}
|
||||
@@ -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 HostKind = "multi"
|
||||
export type GitHash = string
|
||||
@@ -1,13 +1,12 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { BindInfo } from "./BindInfo"
|
||||
import type { HostAddress } from "./HostAddress"
|
||||
import type { HostKind } from "./HostKind"
|
||||
import type { DomainConfig } from "./DomainConfig"
|
||||
import type { HostnameInfo } from "./HostnameInfo"
|
||||
|
||||
export type Host = {
|
||||
kind: HostKind
|
||||
bindings: { [key: number]: BindInfo }
|
||||
addresses: Array<HostAddress>
|
||||
onions: string[]
|
||||
domains: { [key: string]: DomainConfig }
|
||||
/**
|
||||
* COMPUTED: NetService::update
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { AcmeProvider } from "./AcmeProvider"
|
||||
|
||||
export type HostAddress =
|
||||
| { kind: "onion"; address: string }
|
||||
| { kind: "domain"; address: string }
|
||||
| {
|
||||
kind: "domain"
|
||||
address: string
|
||||
public: boolean
|
||||
acme: AcmeProvider | null
|
||||
}
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
export type IpHostname =
|
||||
| { kind: "ipv4"; value: string; port: number | null; sslPort: number | null }
|
||||
| { kind: "ipv6"; value: string; port: number | null; sslPort: number | null }
|
||||
| {
|
||||
kind: "ipv6"
|
||||
value: string
|
||||
scopeId: number
|
||||
port: number | null
|
||||
sslPort: number | null
|
||||
}
|
||||
| {
|
||||
kind: "local"
|
||||
value: string
|
||||
|
||||
@@ -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 { NetworkInterfaceType } from "./NetworkInterfaceType"
|
||||
|
||||
export type IpInfo = {
|
||||
ipv4Range: string | null
|
||||
ipv4: string | null
|
||||
ipv6Range: string | null
|
||||
ipv6: string | null
|
||||
scopeId: number
|
||||
deviceType: NetworkInterfaceType | null
|
||||
subnets: string[]
|
||||
wanIp: string | null
|
||||
ntpServers: string[]
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import type { Alerts } from "./Alerts"
|
||||
import type { Dependencies } from "./Dependencies"
|
||||
import type { Description } from "./Description"
|
||||
import type { GitHash } from "./GitHash"
|
||||
import type { HardwareRequirements } from "./HardwareRequirements"
|
||||
import type { ImageConfig } from "./ImageConfig"
|
||||
import type { ImageId } from "./ImageId"
|
||||
@@ -30,6 +31,6 @@ export type Manifest = {
|
||||
alerts: Alerts
|
||||
dependencies: Dependencies
|
||||
hardwareRequirements: HardwareRequirements
|
||||
gitHash: string | null
|
||||
gitHash?: GitHash
|
||||
osVersion: string
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type LanInfo = {
|
||||
export type NetInfo = {
|
||||
public: boolean
|
||||
assignedPort: number | null
|
||||
assignedSslPort: number | null
|
||||
}
|
||||
7
sdk/base/lib/osBindings/NetworkInterfaceInfo.ts
Normal file
7
sdk/base/lib/osBindings/NetworkInterfaceInfo.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
import type { IpInfo } from "./IpInfo"
|
||||
|
||||
export type NetworkInterfaceInfo = {
|
||||
public: boolean | null
|
||||
ipInfo: IpInfo | null
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type NetworkInterfaceSetPublicParams = {
|
||||
interface: string
|
||||
public: boolean | null
|
||||
}
|
||||
3
sdk/base/lib/osBindings/NetworkInterfaceType.ts
Normal file
3
sdk/base/lib/osBindings/NetworkInterfaceType.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type NetworkInterfaceType = "ethernet" | "wireless" | "wireguard"
|
||||
@@ -3,6 +3,7 @@ import type { Alerts } from "./Alerts"
|
||||
import type { DataUrl } from "./DataUrl"
|
||||
import type { DependencyMetadata } from "./DependencyMetadata"
|
||||
import type { Description } from "./Description"
|
||||
import type { GitHash } from "./GitHash"
|
||||
import type { HardwareRequirements } from "./HardwareRequirements"
|
||||
import type { MerkleArchiveCommitment } from "./MerkleArchiveCommitment"
|
||||
import type { PackageId } from "./PackageId"
|
||||
@@ -13,7 +14,7 @@ export type PackageVersionInfo = {
|
||||
icon: DataUrl
|
||||
description: Description
|
||||
releaseNotes: string
|
||||
gitHash: string
|
||||
gitHash: GitHash
|
||||
license: string
|
||||
wrapperRepo: string
|
||||
upstreamRepo: string
|
||||
|
||||
@@ -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 { AcmeProvider } from "./AcmeProvider"
|
||||
import type { AcmeSettings } from "./AcmeSettings"
|
||||
import type { Governor } from "./Governor"
|
||||
import type { IpInfo } from "./IpInfo"
|
||||
import type { Host } from "./Host"
|
||||
import type { LshwDevice } from "./LshwDevice"
|
||||
import type { NetworkInterfaceInfo } from "./NetworkInterfaceInfo"
|
||||
import type { ServerStatus } from "./ServerStatus"
|
||||
import type { SmtpValue } from "./SmtpValue"
|
||||
import type { WifiInfo } from "./WifiInfo"
|
||||
@@ -12,18 +14,13 @@ export type ServerInfo = {
|
||||
platform: string
|
||||
id: string
|
||||
hostname: string
|
||||
host: Host
|
||||
version: string
|
||||
packageVersionCompat: string
|
||||
postInitMigrationTodos: string[]
|
||||
lastBackup: string | null
|
||||
lanAddress: string
|
||||
onionAddress: string
|
||||
/**
|
||||
* for backwards compatibility
|
||||
*/
|
||||
torAddress: string
|
||||
ipInfo: { [key: string]: IpInfo }
|
||||
acme: AcmeSettings | null
|
||||
networkInterfaces: { [key: string]: NetworkInterfaceInfo }
|
||||
acme: { [key: AcmeProvider]: AcmeSettings }
|
||||
statusInfo: ServerStatus
|
||||
wifi: WifiInfo
|
||||
unreadNotificationCount: number
|
||||
|
||||
@@ -7,7 +7,6 @@ export type ServiceInterface = {
|
||||
id: ServiceInterfaceId
|
||||
name: string
|
||||
description: string
|
||||
hasPrimary: boolean
|
||||
masked: boolean
|
||||
addressInfo: AddressInfo
|
||||
type: ServiceInterfaceType
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type SetupResult = {
|
||||
torAddress: string
|
||||
torAddresses: Array<string>
|
||||
hostname: string
|
||||
lanAddress: string
|
||||
rootCa: string
|
||||
|
||||
10
sdk/base/lib/osBindings/TestSmtpParams.ts
Normal file
10
sdk/base/lib/osBindings/TestSmtpParams.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type TestSmtpParams = {
|
||||
server: string
|
||||
port: number
|
||||
from: string
|
||||
to: string
|
||||
login: string
|
||||
password: string | null
|
||||
}
|
||||
3
sdk/base/lib/osBindings/UnsetPublicParams.ts
Normal file
3
sdk/base/lib/osBindings/UnsetPublicParams.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
|
||||
|
||||
export type UnsetPublicParams = { interface: string }
|
||||
@@ -1,4 +1,5 @@
|
||||
export { AcceptSigners } from "./AcceptSigners"
|
||||
export { AcmeProvider } from "./AcmeProvider"
|
||||
export { AcmeSettings } from "./AcmeSettings"
|
||||
export { ActionId } from "./ActionId"
|
||||
export { ActionInput } from "./ActionInput"
|
||||
@@ -37,6 +38,7 @@ export { BackupTargetFS } from "./BackupTargetFS"
|
||||
export { Base64 } from "./Base64"
|
||||
export { BindId } from "./BindId"
|
||||
export { BindInfo } from "./BindInfo"
|
||||
export { BindingSetPublicParams } from "./BindingSetPublicParams"
|
||||
export { BindOptions } from "./BindOptions"
|
||||
export { BindParams } from "./BindParams"
|
||||
export { Blake3Commitment } from "./Blake3Commitment"
|
||||
@@ -66,6 +68,7 @@ export { DepInfo } from "./DepInfo"
|
||||
export { Description } from "./Description"
|
||||
export { DestroySubcontainerFsParams } from "./DestroySubcontainerFsParams"
|
||||
export { DeviceFilter } from "./DeviceFilter"
|
||||
export { DomainConfig } from "./DomainConfig"
|
||||
export { Duration } from "./Duration"
|
||||
export { EchoParams } from "./EchoParams"
|
||||
export { EditSignerParams } from "./EditSignerParams"
|
||||
@@ -73,6 +76,7 @@ export { EncryptedWire } from "./EncryptedWire"
|
||||
export { ExportActionParams } from "./ExportActionParams"
|
||||
export { ExportServiceInterfaceParams } from "./ExportServiceInterfaceParams"
|
||||
export { ExposeForDependentsParams } from "./ExposeForDependentsParams"
|
||||
export { ForgetInterfaceParams } from "./ForgetInterfaceParams"
|
||||
export { FullIndex } from "./FullIndex"
|
||||
export { FullProgress } from "./FullProgress"
|
||||
export { GetActionInputParams } from "./GetActionInputParams"
|
||||
@@ -82,7 +86,6 @@ export { GetOsVersionParams } from "./GetOsVersionParams"
|
||||
export { GetPackageParams } from "./GetPackageParams"
|
||||
export { GetPackageResponseFull } from "./GetPackageResponseFull"
|
||||
export { GetPackageResponse } from "./GetPackageResponse"
|
||||
export { GetPrimaryUrlParams } from "./GetPrimaryUrlParams"
|
||||
export { GetServiceInterfaceParams } from "./GetServiceInterfaceParams"
|
||||
export { GetServicePortForwardParams } from "./GetServicePortForwardParams"
|
||||
export { GetSslCertificateParams } from "./GetSslCertificateParams"
|
||||
@@ -90,13 +93,13 @@ export { GetSslKeyParams } from "./GetSslKeyParams"
|
||||
export { GetStatusParams } from "./GetStatusParams"
|
||||
export { GetStoreParams } from "./GetStoreParams"
|
||||
export { GetSystemSmtpParams } from "./GetSystemSmtpParams"
|
||||
export { GitHash } from "./GitHash"
|
||||
export { Governor } from "./Governor"
|
||||
export { Guid } from "./Guid"
|
||||
export { HardwareRequirements } from "./HardwareRequirements"
|
||||
export { HealthCheckId } from "./HealthCheckId"
|
||||
export { HostAddress } from "./HostAddress"
|
||||
export { HostId } from "./HostId"
|
||||
export { HostKind } from "./HostKind"
|
||||
export { HostnameInfo } from "./HostnameInfo"
|
||||
export { Hosts } from "./Hosts"
|
||||
export { Host } from "./Host"
|
||||
@@ -112,7 +115,6 @@ export { InstallingState } from "./InstallingState"
|
||||
export { InstallParams } from "./InstallParams"
|
||||
export { IpHostname } from "./IpHostname"
|
||||
export { IpInfo } from "./IpInfo"
|
||||
export { LanInfo } from "./LanInfo"
|
||||
export { ListPackageSignersParams } from "./ListPackageSignersParams"
|
||||
export { ListServiceInterfacesParams } from "./ListServiceInterfacesParams"
|
||||
export { ListVersionSignersParams } from "./ListVersionSignersParams"
|
||||
@@ -128,6 +130,10 @@ export { MountParams } from "./MountParams"
|
||||
export { MountTarget } from "./MountTarget"
|
||||
export { NamedHealthCheckResult } from "./NamedHealthCheckResult"
|
||||
export { NamedProgress } from "./NamedProgress"
|
||||
export { NetInfo } from "./NetInfo"
|
||||
export { NetworkInterfaceInfo } from "./NetworkInterfaceInfo"
|
||||
export { NetworkInterfaceSetPublicParams } from "./NetworkInterfaceSetPublicParams"
|
||||
export { NetworkInterfaceType } from "./NetworkInterfaceType"
|
||||
export { OnionHostname } from "./OnionHostname"
|
||||
export { OsIndex } from "./OsIndex"
|
||||
export { OsVersionInfoMap } from "./OsVersionInfoMap"
|
||||
@@ -181,6 +187,8 @@ export { SignAssetParams } from "./SignAssetParams"
|
||||
export { SignerInfo } from "./SignerInfo"
|
||||
export { SmtpValue } from "./SmtpValue"
|
||||
export { StartStop } from "./StartStop"
|
||||
export { TestSmtpParams } from "./TestSmtpParams"
|
||||
export { UnsetPublicParams } from "./UnsetPublicParams"
|
||||
export { UpdatingState } from "./UpdatingState"
|
||||
export { VerifyCifsParams } from "./VerifyCifsParams"
|
||||
export { VersionSignerParams } from "./VersionSignerParams"
|
||||
|
||||
@@ -26,7 +26,6 @@ import { SetDependenciesParams } from ".././osBindings"
|
||||
import { GetSystemSmtpParams } from ".././osBindings"
|
||||
import { GetServicePortForwardParams } from ".././osBindings"
|
||||
import { ExportServiceInterfaceParams } from ".././osBindings"
|
||||
import { GetPrimaryUrlParams } from ".././osBindings"
|
||||
import { ListServiceInterfacesParams } from ".././osBindings"
|
||||
import { ExportActionParams } from ".././osBindings"
|
||||
import { MountParams } from ".././osBindings"
|
||||
@@ -83,7 +82,6 @@ describe("startosTypeValidation ", () => {
|
||||
getServicePortForward: {} as GetServicePortForwardParams,
|
||||
clearServiceInterfaces: {} as ClearServiceInterfacesParams,
|
||||
exportServiceInterface: {} as ExportServiceInterfaceParams,
|
||||
getPrimaryUrl: {} as WithCallback<GetPrimaryUrlParams>,
|
||||
listServiceInterfaces: {} as WithCallback<ListServiceInterfacesParams>,
|
||||
mount: {} as MountParams,
|
||||
checkDependencies: {} as CheckDependenciesParam,
|
||||
|
||||
@@ -138,33 +138,6 @@ export declare const hostName: unique symbol
|
||||
// asdflkjadsf.onion | 1.2.3.4
|
||||
export type Hostname = string & { [hostName]: never }
|
||||
|
||||
export type HostnameInfoIp = {
|
||||
kind: "ip"
|
||||
networkInterfaceId: string
|
||||
public: boolean
|
||||
hostname:
|
||||
| {
|
||||
kind: "ipv4" | "ipv6" | "local"
|
||||
value: string
|
||||
port: number | null
|
||||
sslPort: number | null
|
||||
}
|
||||
| {
|
||||
kind: "domain"
|
||||
domain: string
|
||||
subdomain: string | null
|
||||
port: number | null
|
||||
sslPort: number | null
|
||||
}
|
||||
}
|
||||
|
||||
export type HostnameInfoOnion = {
|
||||
kind: "onion"
|
||||
hostname: { value: string; port: number | null; sslPort: number | null }
|
||||
}
|
||||
|
||||
export type HostnameInfo = HostnameInfoIp | HostnameInfoOnion
|
||||
|
||||
export type ServiceInterfaceId = string
|
||||
|
||||
export { ServiceInterface }
|
||||
|
||||
@@ -1,15 +1,6 @@
|
||||
import { ServiceInterfaceType } from "../types"
|
||||
import { knownProtocols } from "../interfaces/Host"
|
||||
import {
|
||||
AddressInfo,
|
||||
Host,
|
||||
HostAddress,
|
||||
Hostname,
|
||||
HostnameInfo,
|
||||
HostnameInfoIp,
|
||||
HostnameInfoOnion,
|
||||
IpInfo,
|
||||
} from "../types"
|
||||
import { AddressInfo, Host, Hostname, HostnameInfo } from "../types"
|
||||
import { Effects } from "../Effects"
|
||||
|
||||
export type UrlString = string
|
||||
@@ -48,8 +39,6 @@ export type ServiceInterfaceFilled = {
|
||||
name: string
|
||||
/** Human readable description, used as tooltip usually */
|
||||
description: string
|
||||
/** Whether or not the interface has a primary URL */
|
||||
hasPrimary: boolean
|
||||
/** Whether or not to mask the URIs for this interface. Useful if the URIs contain sensitive information, such as a password, macaroon, or API key */
|
||||
masked: boolean
|
||||
/** Information about the host for this binding */
|
||||
@@ -58,10 +47,6 @@ export type ServiceInterfaceFilled = {
|
||||
addressInfo: FilledAddressInfo | null
|
||||
/** Indicates if we are a ui/p2p/api for the kind of interface that this is representing */
|
||||
type: ServiceInterfaceType
|
||||
/** The primary hostname for the service, as chosen by the user */
|
||||
primaryHostname: Hostname | null
|
||||
/** The primary URL for the service, as chosen by the user */
|
||||
primaryUrl: UrlString | null
|
||||
}
|
||||
const either =
|
||||
<A>(...args: ((a: A) => boolean)[]) =>
|
||||
@@ -89,7 +74,9 @@ export const addressHostToUrl = (
|
||||
if (host.hostname.kind === "domain") {
|
||||
hostname = `${host.hostname.subdomain ? `${host.hostname.subdomain}.` : ""}${host.hostname.domain}`
|
||||
} else if (host.hostname.kind === "ipv6") {
|
||||
hostname = `[${host.hostname.value}]`
|
||||
hostname = host.hostname.value.startsWith("fe80::")
|
||||
? `[${host.hostname.value}%${host.hostname.scopeId}]`
|
||||
: `[${host.hostname.value}]`
|
||||
} else {
|
||||
hostname = host.hostname.value
|
||||
}
|
||||
@@ -200,23 +187,13 @@ const makeInterfaceFilled = async ({
|
||||
hostId,
|
||||
callback,
|
||||
})
|
||||
const primaryUrl = await effects.getPrimaryUrl({
|
||||
hostId,
|
||||
packageId,
|
||||
callback,
|
||||
})
|
||||
|
||||
const interfaceFilled: ServiceInterfaceFilled = {
|
||||
...serviceInterfaceValue,
|
||||
primaryUrl: primaryUrl,
|
||||
host,
|
||||
addressInfo: host
|
||||
? filledAddress(host, serviceInterfaceValue.addressInfo)
|
||||
: null,
|
||||
get primaryHostname() {
|
||||
if (primaryUrl == null) return null
|
||||
return getHostname(primaryUrl)
|
||||
},
|
||||
}
|
||||
return interfaceFilled
|
||||
}
|
||||
|
||||
@@ -30,22 +30,10 @@ const makeManyInterfaceFilled = async ({
|
||||
if (!host) {
|
||||
throw new Error(`host ${hostId} not found!`)
|
||||
}
|
||||
const primaryUrl = await effects
|
||||
.getPrimaryUrl({
|
||||
hostId,
|
||||
packageId,
|
||||
callback,
|
||||
})
|
||||
.catch(() => null)
|
||||
return {
|
||||
...serviceInterfaceValue,
|
||||
primaryUrl: primaryUrl,
|
||||
host,
|
||||
addressInfo: filledAddress(host, serviceInterfaceValue.addressInfo),
|
||||
get primaryHostname() {
|
||||
if (primaryUrl == null) return null
|
||||
return getHostname(primaryUrl)
|
||||
},
|
||||
}
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -2,58 +2,68 @@ import { Pattern } from "../actions/input/inputSpecTypes"
|
||||
import * as regexes from "./regexes"
|
||||
|
||||
export const ipv6: Pattern = {
|
||||
regex: regexes.ipv6.toString(),
|
||||
regex: regexes.ipv6.matches(),
|
||||
description: "Must be a valid IPv6 address",
|
||||
}
|
||||
|
||||
export const ipv4: Pattern = {
|
||||
regex: regexes.ipv4.toString(),
|
||||
regex: regexes.ipv4.matches(),
|
||||
description: "Must be a valid IPv4 address",
|
||||
}
|
||||
|
||||
export const hostname: Pattern = {
|
||||
regex: regexes.hostname.toString(),
|
||||
regex: regexes.hostname.matches(),
|
||||
description: "Must be a valid hostname",
|
||||
}
|
||||
|
||||
export const localHostname: Pattern = {
|
||||
regex: regexes.localHostname.toString(),
|
||||
regex: regexes.localHostname.matches(),
|
||||
description: 'Must be a valid ".local" hostname',
|
||||
}
|
||||
|
||||
export const torHostname: Pattern = {
|
||||
regex: regexes.torHostname.toString(),
|
||||
regex: regexes.torHostname.matches(),
|
||||
description: 'Must be a valid Tor (".onion") hostname',
|
||||
}
|
||||
|
||||
export const url: Pattern = {
|
||||
regex: regexes.url.toString(),
|
||||
regex: regexes.url.matches(),
|
||||
description: "Must be a valid URL",
|
||||
}
|
||||
|
||||
export const localUrl: Pattern = {
|
||||
regex: regexes.localUrl.toString(),
|
||||
regex: regexes.localUrl.matches(),
|
||||
description: 'Must be a valid ".local" URL',
|
||||
}
|
||||
|
||||
export const torUrl: Pattern = {
|
||||
regex: regexes.torUrl.toString(),
|
||||
regex: regexes.torUrl.matches(),
|
||||
description: 'Must be a valid Tor (".onion") URL',
|
||||
}
|
||||
|
||||
export const ascii: Pattern = {
|
||||
regex: regexes.ascii.toString(),
|
||||
regex: regexes.ascii.matches(),
|
||||
description:
|
||||
"May only contain ASCII characters. See https://www.w3schools.com/charsets/ref_html_ascii.asp",
|
||||
}
|
||||
|
||||
export const domain: Pattern = {
|
||||
regex: regexes.domain.matches(),
|
||||
description: "Must be a valid Fully Qualified Domain Name",
|
||||
}
|
||||
|
||||
export const email: Pattern = {
|
||||
regex: regexes.email.toString(),
|
||||
regex: regexes.email.matches(),
|
||||
description: "Must be a valid email address",
|
||||
}
|
||||
|
||||
export const emailWithName: Pattern = {
|
||||
regex: regexes.emailWithName.matches(),
|
||||
description: "Must be a valid email address, optionally with a name",
|
||||
}
|
||||
|
||||
export const base64: Pattern = {
|
||||
regex: regexes.base64.toString(),
|
||||
regex: regexes.base64.matches(),
|
||||
description:
|
||||
"May only contain base64 characters. See https://base64.guru/learn/base64-characters",
|
||||
}
|
||||
|
||||
@@ -1,34 +1,71 @@
|
||||
export class ComposableRegex {
|
||||
readonly regex: RegExp
|
||||
constructor(regex: RegExp | string) {
|
||||
if (regex instanceof RegExp) {
|
||||
this.regex = regex
|
||||
} else {
|
||||
this.regex = new RegExp(regex)
|
||||
}
|
||||
}
|
||||
asExpr(): string {
|
||||
return `(${this.regex.source})`
|
||||
}
|
||||
matches(): string {
|
||||
return `^${this.regex.source}$`
|
||||
}
|
||||
contains(): string {
|
||||
return this.regex.source
|
||||
}
|
||||
}
|
||||
|
||||
// https://ihateregex.io/expr/ipv6/
|
||||
export const ipv6 =
|
||||
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/
|
||||
export const ipv6 = new ComposableRegex(
|
||||
/(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))/,
|
||||
)
|
||||
|
||||
// https://ihateregex.io/expr/ipv4/
|
||||
export const ipv4 =
|
||||
/(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/
|
||||
export const ipv4 = new ComposableRegex(
|
||||
/(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/,
|
||||
)
|
||||
|
||||
export const hostname =
|
||||
/^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$/
|
||||
export const hostname = new ComposableRegex(
|
||||
/(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])/,
|
||||
)
|
||||
|
||||
export const localHostname = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local/
|
||||
export const localHostname = new ComposableRegex(
|
||||
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local/,
|
||||
)
|
||||
|
||||
export const torHostname = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion/
|
||||
export const torHostname = new ComposableRegex(
|
||||
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion/,
|
||||
)
|
||||
|
||||
// https://ihateregex.io/expr/url/
|
||||
export const url =
|
||||
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
||||
export const url = new ComposableRegex(
|
||||
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,
|
||||
)
|
||||
|
||||
export const localUrl =
|
||||
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
||||
export const localUrl = new ComposableRegex(
|
||||
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/,
|
||||
)
|
||||
|
||||
export const torUrl =
|
||||
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion\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 = /^[ -~]*$/
|
||||
export const ascii = new ComposableRegex(/[ -~]*/)
|
||||
|
||||
//https://ihateregex.io/expr/email/
|
||||
export const email = /[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+/
|
||||
export const domain = new ComposableRegex(/[A-Za-z0-9.-]+\.[A-Za-z]{2,}/)
|
||||
|
||||
// https://www.regular-expressions.info/email.html
|
||||
export const email = new ComposableRegex(`[A-Za-z0-9._%+-]+@${domain.asExpr()}`)
|
||||
|
||||
export const emailWithName = new ComposableRegex(
|
||||
`${email.asExpr()}|([^<]*<${email.asExpr()}>)`,
|
||||
)
|
||||
|
||||
//https://rgxdb.com/r/1NUN74O6
|
||||
export const base64 =
|
||||
/^(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))$/
|
||||
export const base64 = new ComposableRegex(
|
||||
/(?:[a-zA-Z0-9+\/]{4})*(?:|(?:[a-zA-Z0-9+\/]{3}=)|(?:[a-zA-Z0-9+\/]{2}==)|(?:[a-zA-Z0-9+\/]{1}===))/,
|
||||
)
|
||||
|
||||
2
sdk/base/package-lock.json
generated
2
sdk/base/package-lock.json
generated
@@ -13,7 +13,7 @@
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"ts-matches": "^6.1.0",
|
||||
"ts-matches": "^6.2.1",
|
||||
"yaml": "^2.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"isomorphic-fetch": "^3.0.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"mime-types": "^2.1.35",
|
||||
"ts-matches": "^6.1.0",
|
||||
"ts-matches": "^6.2.1",
|
||||
"yaml": "^2.2.2"
|
||||
},
|
||||
"prettier": {
|
||||
|
||||
Reference in New Issue
Block a user