mirror of
https://github.com/Start9Labs/start-sdk.git
synced 2026-03-30 12:21:57 +00:00
add descriptions and some renaming
This commit is contained in:
@@ -18,9 +18,8 @@ import {
|
|||||||
ActionResult,
|
ActionResult,
|
||||||
BackupOptions,
|
BackupOptions,
|
||||||
DeepPartial,
|
DeepPartial,
|
||||||
Address,
|
|
||||||
} from "./types"
|
} from "./types"
|
||||||
import * as regexes from "./util/regexes"
|
import * as patterns from "./util/patterns"
|
||||||
import { Utils } from "./util/utils"
|
import { Utils } from "./util/utils"
|
||||||
import { DependencyConfig } from "./dependencyConfig/DependencyConfig"
|
import { DependencyConfig } from "./dependencyConfig/DependencyConfig"
|
||||||
import { BackupSet, Backups } from "./backup/Backups"
|
import { BackupSet, Backups } from "./backup/Backups"
|
||||||
@@ -52,8 +51,6 @@ import {
|
|||||||
SetInterfaces,
|
SetInterfaces,
|
||||||
setupInterfaces,
|
setupInterfaces,
|
||||||
} from "./interfaces/setupInterfaces"
|
} from "./interfaces/setupInterfaces"
|
||||||
import { AddressReceipt } from "./interfaces/AddressReceipt"
|
|
||||||
import { Host } from "./interfaces/Host"
|
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
type AnyNeverCond<T extends any[], Then, Else> =
|
type AnyNeverCond<T extends any[], Then, Else> =
|
||||||
@@ -105,7 +102,7 @@ export class StartSdk<Manifest extends SDKManifest, Store, Vault> {
|
|||||||
of: healthCheck,
|
of: healthCheck,
|
||||||
runHealthScript,
|
runHealthScript,
|
||||||
},
|
},
|
||||||
regexes,
|
patterns,
|
||||||
setupActions: (...createdActions: CreatedAction<any, any, any>[]) =>
|
setupActions: (...createdActions: CreatedAction<any, any, any>[]) =>
|
||||||
setupActions<Store, Vault>(...createdActions),
|
setupActions<Store, Vault>(...createdActions),
|
||||||
setupBackups: (...args: SetupBackupsParams<Manifest>) =>
|
setupBackups: (...args: SetupBackupsParams<Manifest>) =>
|
||||||
|
|||||||
@@ -1,11 +1,4 @@
|
|||||||
import {
|
import { Address, Effects, HostName, NetworkInterface } from "../types"
|
||||||
Address,
|
|
||||||
Effects,
|
|
||||||
EnsureStorePath,
|
|
||||||
HostName,
|
|
||||||
NetworkInterface,
|
|
||||||
hostName,
|
|
||||||
} from "../types"
|
|
||||||
import * as regexes from "./regexes"
|
import * as regexes from "./regexes"
|
||||||
|
|
||||||
export type UrlString = string
|
export type UrlString = string
|
||||||
@@ -72,10 +65,10 @@ export const filledAddress = (
|
|||||||
...address,
|
...address,
|
||||||
hostnames,
|
hostnames,
|
||||||
get onionHostnames() {
|
get onionHostnames() {
|
||||||
return hostnames.filter(regexes.onionHost.test)
|
return hostnames.filter(regexes.torHostname.test)
|
||||||
},
|
},
|
||||||
get localHostnames() {
|
get localHostnames() {
|
||||||
return hostnames.filter(regexes.localHost.test)
|
return hostnames.filter(regexes.localHostname.test)
|
||||||
},
|
},
|
||||||
get ipHostnames() {
|
get ipHostnames() {
|
||||||
return hostnames.filter(either(regexes.ipv4.test, regexes.ipv6.test))
|
return hostnames.filter(either(regexes.ipv4.test, regexes.ipv6.test))
|
||||||
@@ -96,10 +89,10 @@ export const filledAddress = (
|
|||||||
return hostnames.map(toUrl)
|
return hostnames.map(toUrl)
|
||||||
},
|
},
|
||||||
get onionUrls() {
|
get onionUrls() {
|
||||||
return hostnames.filter(regexes.onionHost.test).map(toUrl)
|
return hostnames.filter(regexes.torHostname.test).map(toUrl)
|
||||||
},
|
},
|
||||||
get localUrls() {
|
get localUrls() {
|
||||||
return hostnames.filter(regexes.localHost.test).map(toUrl)
|
return hostnames.filter(regexes.localHostname.test).map(toUrl)
|
||||||
},
|
},
|
||||||
get ipUrls() {
|
get ipUrls() {
|
||||||
return hostnames
|
return hostnames
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { Address, Effects, EnsureStorePath, HostName, hostName } from "../types"
|
import { Effects, HostName } from "../types"
|
||||||
import * as regexes from "./regexes"
|
|
||||||
import {
|
import {
|
||||||
HostId,
|
HostId,
|
||||||
NetworkInterfaceFilled,
|
NetworkInterfaceFilled,
|
||||||
|
|||||||
59
lib/util/patterns.ts
Normal file
59
lib/util/patterns.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import { Pattern } from "../config/configTypes"
|
||||||
|
import * as regexes from "./regexes"
|
||||||
|
|
||||||
|
export const ipv6: Pattern = {
|
||||||
|
regex: regexes.ipv6.toString(),
|
||||||
|
description: "Must be a valid IPv6 address",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ipv4: Pattern = {
|
||||||
|
regex: regexes.ipv4.toString(),
|
||||||
|
description: "Must be a valid IPv4 address",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const hostname = {
|
||||||
|
regex: regexes.hostname.toString(),
|
||||||
|
description: "Must be a valid hostname",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const localHostname: Pattern = {
|
||||||
|
regex: regexes.localHostname.toString(),
|
||||||
|
description: 'Must be a valid ".local" hostname',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const torHostname: Pattern = {
|
||||||
|
regex: regexes.torHostname.toString(),
|
||||||
|
description: 'Must be a valid Tor (".onion") hostname',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const url: Pattern = {
|
||||||
|
regex: regexes.url.toString(),
|
||||||
|
description: "Must be a valid URL",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const localUrl: Pattern = {
|
||||||
|
regex: regexes.localUrl.toString(),
|
||||||
|
description: 'Must be a valid ".local" URL',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const torUrl: Pattern = {
|
||||||
|
regex: regexes.torUrl.toString(),
|
||||||
|
description: 'Must be a valid Tor (".onion") URL',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ascii: Pattern = {
|
||||||
|
regex: regexes.ascii.toString(),
|
||||||
|
description:
|
||||||
|
"May only contain ASCII characters. See https://www.w3schools.com/charsets/ref_html_ascii.asp",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const email: Pattern = {
|
||||||
|
regex: regexes.email.toString(),
|
||||||
|
description: "Must be a valid email address",
|
||||||
|
}
|
||||||
|
|
||||||
|
export const base64: Pattern = {
|
||||||
|
regex: regexes.base64.toString(),
|
||||||
|
description:
|
||||||
|
"May only contain base64 characters. See https://base64.guru/learn/base64-characters",
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
import { Pattern } from "../config/configTypes"
|
|
||||||
import * as regexes from "./regexes"
|
|
||||||
export const ipv6: Pattern = {
|
|
||||||
regex: regexes.ipv6.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const ipv4: Pattern = { regex: regexes.ipv4.toString(), description: "" }
|
|
||||||
|
|
||||||
export const url: Pattern = { regex: regexes.url.toString(), description: "" }
|
|
||||||
|
|
||||||
export const local: Pattern = {
|
|
||||||
regex: regexes.local.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const localHost: Pattern = {
|
|
||||||
regex: regexes.localHost.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
export const onion: Pattern = {
|
|
||||||
regex: regexes.onion.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
|
|
||||||
export const onionHost: Pattern = {
|
|
||||||
regex: regexes.onionHost.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
export const ascii: Pattern = {
|
|
||||||
regex: regexes.ascii.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
export const email: Pattern = {
|
|
||||||
regex: regexes.email.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
export const base64: Pattern = {
|
|
||||||
regex: regexes.base64.toString(),
|
|
||||||
description: "",
|
|
||||||
}
|
|
||||||
@@ -6,19 +6,23 @@ export const ipv6 =
|
|||||||
export const 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}/
|
/(\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 localHostname = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local/
|
||||||
|
|
||||||
|
export const torHostname = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion/
|
||||||
|
|
||||||
// https://ihateregex.io/expr/url/
|
// https://ihateregex.io/expr/url/
|
||||||
export const url =
|
export const url =
|
||||||
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
||||||
|
|
||||||
export const local =
|
export const localUrl =
|
||||||
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
||||||
|
|
||||||
export const localHost = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.local/
|
export const torUrl =
|
||||||
|
|
||||||
export const onion =
|
|
||||||
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
/(https?:\/\/)?(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion\b([-a-zA-Z0-9()!@:%_\+.~#?&\/\/=]*)/
|
||||||
|
|
||||||
export const onionHost = /[-a-zA-Z0-9@:%._\+~#=]{1,256}\.onion/
|
|
||||||
// https://ihateregex.io/expr/ascii/
|
// https://ihateregex.io/expr/ascii/
|
||||||
export const ascii = /^[ -~]*$/
|
export const ascii = /^[ -~]*$/
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user