@highstate/library 0.9.16 → 0.9.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/highstate.library.msgpack +0 -0
- package/dist/index.js +727 -548
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
- package/src/apps/code-server.ts +5 -5
- package/src/apps/deployment.ts +20 -20
- package/src/apps/dns.ts +12 -12
- package/src/apps/gitea.ts +2 -2
- package/src/apps/grocy.ts +2 -2
- package/src/apps/hubble.ts +2 -2
- package/src/apps/kubernetes-dashboard.ts +2 -2
- package/src/apps/mariadb.ts +10 -10
- package/src/apps/maybe.ts +5 -5
- package/src/apps/mongodb.ts +10 -10
- package/src/apps/network.ts +6 -6
- package/src/apps/postgresql.ts +10 -10
- package/src/apps/shared.ts +16 -17
- package/src/apps/syncthing.ts +6 -6
- package/src/apps/traefik.ts +4 -4
- package/src/apps/vaultwarden.ts +4 -4
- package/src/apps/zitadel.ts +2 -2
- package/src/cloudflare.ts +4 -4
- package/src/common.ts +24 -24
- package/src/distributions/ubuntu.ts +8 -8
- package/src/dns.ts +10 -10
- package/src/files.ts +53 -64
- package/src/git.ts +7 -7
- package/src/k3s.ts +9 -9
- package/src/k8s.ts +118 -119
- package/src/mullvad.ts +5 -5
- package/src/network.ts +44 -44
- package/src/nixos.ts +15 -69
- package/src/obfuscators/phantun.ts +4 -4
- package/src/obfuscators/shared.ts +9 -9
- package/src/proxmox.ts +179 -59
- package/src/restic.ts +14 -14
- package/src/sops.ts +4 -4
- package/src/ssh.ts +19 -19
- package/src/talos.ts +15 -15
- package/src/timeweb.ts +13 -13
- package/src/utils.ts +3 -3
- package/src/wireguard.ts +82 -71
package/src/network.ts
CHANGED
@@ -1,48 +1,48 @@
|
|
1
|
-
import { defineEntity, defineUnit,
|
1
|
+
import { defineEntity, defineUnit, z } from "@highstate/contract"
|
2
2
|
|
3
|
-
export const endpointVisibilitySchema =
|
3
|
+
export const endpointVisibilitySchema = z.enum([
|
4
4
|
"public", // Reachable from the public internet
|
5
5
|
"external", // Reachable from outside the system boundary, but not public
|
6
6
|
"internal", // Reachable only from within the system or cluster
|
7
7
|
])
|
8
8
|
|
9
|
-
export const endpointFilterSchema =
|
9
|
+
export const endpointFilterSchema = endpointVisibilitySchema.array()
|
10
10
|
|
11
11
|
export const l3EndpointEntity = defineEntity({
|
12
12
|
type: "network.l3-endpoint",
|
13
13
|
|
14
|
-
schema:
|
15
|
-
|
14
|
+
schema: z.intersection(
|
15
|
+
z.object({
|
16
16
|
visibility: endpointVisibilitySchema,
|
17
|
-
metadata:
|
17
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
18
18
|
}),
|
19
|
-
|
20
|
-
|
21
|
-
type:
|
19
|
+
z.union([
|
20
|
+
z.object({
|
21
|
+
type: z.literal("hostname"),
|
22
22
|
|
23
23
|
/**
|
24
24
|
* The hostname of the endpoint in the format of a domain name.
|
25
25
|
*/
|
26
|
-
hostname:
|
26
|
+
hostname: z.string(),
|
27
27
|
}),
|
28
|
-
|
29
|
-
type:
|
28
|
+
z.object({
|
29
|
+
type: z.literal("ipv4"),
|
30
30
|
|
31
31
|
/**
|
32
32
|
* The IPv4 address of the endpoint.
|
33
33
|
*/
|
34
|
-
address:
|
34
|
+
address: z.string(),
|
35
35
|
}),
|
36
|
-
|
37
|
-
type:
|
36
|
+
z.object({
|
37
|
+
type: z.literal("ipv6"),
|
38
38
|
|
39
39
|
/**
|
40
40
|
* The IPv6 address of the endpoint.
|
41
41
|
*/
|
42
|
-
address:
|
42
|
+
address: z.string(),
|
43
43
|
}),
|
44
44
|
]),
|
45
|
-
|
45
|
+
),
|
46
46
|
|
47
47
|
meta: {
|
48
48
|
color: "#4CAF50",
|
@@ -50,17 +50,17 @@ export const l3EndpointEntity = defineEntity({
|
|
50
50
|
},
|
51
51
|
})
|
52
52
|
|
53
|
-
export const l4ProtocolSchema =
|
53
|
+
export const l4ProtocolSchema = z.enum(["tcp", "udp"])
|
54
54
|
|
55
|
-
export const l4PortInfoSchema =
|
56
|
-
port:
|
55
|
+
export const l4PortInfoSchema = z.object({
|
56
|
+
port: z.number(),
|
57
57
|
protocol: l4ProtocolSchema,
|
58
58
|
})
|
59
59
|
|
60
60
|
export const l4EndpointEntity = defineEntity({
|
61
61
|
type: "network.l4-endpoint",
|
62
62
|
|
63
|
-
schema:
|
63
|
+
schema: z.intersection(l3EndpointEntity.schema, l4PortInfoSchema),
|
64
64
|
|
65
65
|
meta: {
|
66
66
|
color: "#2196F3",
|
@@ -68,11 +68,11 @@ export const l4EndpointEntity = defineEntity({
|
|
68
68
|
},
|
69
69
|
})
|
70
70
|
|
71
|
-
export const l7AppInfoSchema =
|
71
|
+
export const l7AppInfoSchema = z.object({
|
72
72
|
/**
|
73
73
|
* The name of the application protocol used by the endpoint.
|
74
74
|
*/
|
75
|
-
appProtocol:
|
75
|
+
appProtocol: z.string(),
|
76
76
|
|
77
77
|
/**
|
78
78
|
* The resource path of the application endpoint, including query parameters.
|
@@ -80,13 +80,13 @@ export const l7AppInfoSchema = Type.Object({
|
|
80
80
|
*
|
81
81
|
* Example: `api/v1/resource?query=value`, `database?param=value`, `user/repo.git`.
|
82
82
|
*/
|
83
|
-
resource:
|
83
|
+
resource: z.string().optional(),
|
84
84
|
})
|
85
85
|
|
86
86
|
export const l7EndpointEntity = defineEntity({
|
87
87
|
type: "network.l7-endpoint",
|
88
88
|
|
89
|
-
schema:
|
89
|
+
schema: z.intersection(l4EndpointEntity.schema, l7AppInfoSchema),
|
90
90
|
|
91
91
|
meta: {
|
92
92
|
color: "#FF9800",
|
@@ -104,12 +104,12 @@ export const l3Endpoint = defineUnit({
|
|
104
104
|
*
|
105
105
|
* May be a domain name or an IP address.
|
106
106
|
*/
|
107
|
-
endpoint:
|
107
|
+
endpoint: z.string(),
|
108
108
|
|
109
109
|
/**
|
110
110
|
* The visibility of the endpoint.
|
111
111
|
*/
|
112
|
-
visibility:
|
112
|
+
visibility: endpointVisibilitySchema.default("public"),
|
113
113
|
},
|
114
114
|
|
115
115
|
outputs: {
|
@@ -117,10 +117,10 @@ export const l3Endpoint = defineUnit({
|
|
117
117
|
},
|
118
118
|
|
119
119
|
meta: {
|
120
|
-
|
120
|
+
title: "L3 Endpoint",
|
121
121
|
description: "An L3 endpoint for some service. May be a domain name or an IP address.",
|
122
|
-
|
123
|
-
|
122
|
+
icon: "mdi:network-outline",
|
123
|
+
iconColor: "#4CAF50",
|
124
124
|
defaultNamePrefix: "endpoint",
|
125
125
|
category: "Network",
|
126
126
|
},
|
@@ -146,12 +146,12 @@ export const l4Endpoint = defineUnit({
|
|
146
146
|
* - `tcp://endpoint:port`
|
147
147
|
* - `udp://endpoint:port`
|
148
148
|
*/
|
149
|
-
endpoint:
|
149
|
+
endpoint: z.string(),
|
150
150
|
|
151
151
|
/**
|
152
152
|
* The visibility of the endpoint.
|
153
153
|
*/
|
154
|
-
visibility:
|
154
|
+
visibility: endpointVisibilitySchema.default("public"),
|
155
155
|
},
|
156
156
|
|
157
157
|
outputs: {
|
@@ -159,10 +159,10 @@ export const l4Endpoint = defineUnit({
|
|
159
159
|
},
|
160
160
|
|
161
161
|
meta: {
|
162
|
-
|
162
|
+
title: "L4 Endpoint",
|
163
163
|
description: "An L4 endpoint for some service. Extends an L3 endpoint with a port.",
|
164
|
-
|
165
|
-
|
164
|
+
icon: "mdi:network-outline",
|
165
|
+
iconColor: "#2196F3",
|
166
166
|
defaultNamePrefix: "endpoint",
|
167
167
|
category: "Network",
|
168
168
|
},
|
@@ -180,7 +180,7 @@ export const l4Endpoint = defineUnit({
|
|
180
180
|
* - `external`: Reachable from outside the system boundary (e.g., LAN, VPC), but not public.
|
181
181
|
* - `internal`: Reachable only from within the application or infrastructure boundary (e.g., within a cluster).
|
182
182
|
*/
|
183
|
-
export type EndpointVisibility =
|
183
|
+
export type EndpointVisibility = z.infer<typeof endpointVisibilitySchema>
|
184
184
|
|
185
185
|
/**
|
186
186
|
* The list of endpoint visibility levels used to filter endpoints.
|
@@ -190,14 +190,14 @@ export type EndpointVisibility = Static<typeof endpointVisibilitySchema>
|
|
190
190
|
* - Otherwise, if any external endpoints exist, all external endpoints are selected.
|
191
191
|
* - If neither exist, all internal endpoints are selected.
|
192
192
|
*/
|
193
|
-
export type EndpointFilter =
|
194
|
-
|
195
|
-
export type L3Endpoint =
|
196
|
-
export type L4Endpoint =
|
197
|
-
export type L4Protocol =
|
198
|
-
export type L4PortInfo =
|
199
|
-
export type L7Endpoint =
|
200
|
-
export type L7AppInfo =
|
193
|
+
export type EndpointFilter = z.infer<typeof endpointFilterSchema>
|
194
|
+
|
195
|
+
export type L3Endpoint = z.infer<typeof l3EndpointEntity.schema>
|
196
|
+
export type L4Endpoint = z.infer<typeof l4EndpointEntity.schema>
|
197
|
+
export type L4Protocol = z.infer<typeof l4ProtocolSchema>
|
198
|
+
export type L4PortInfo = z.infer<typeof l4PortInfoSchema>
|
199
|
+
export type L7Endpoint = z.infer<typeof l7EndpointEntity.schema>
|
200
|
+
export type L7AppInfo = z.infer<typeof l7AppInfoSchema>
|
201
201
|
|
202
202
|
/**
|
203
203
|
* The L3 or L4 endpoint for some service.
|
package/src/nixos.ts
CHANGED
@@ -1,33 +1,7 @@
|
|
1
|
-
import { defineUnit,
|
1
|
+
import { defineUnit, z } from "@highstate/contract"
|
2
2
|
import { fileEntity, folderEntity } from "./files"
|
3
3
|
import { serverEntity } from "./common"
|
4
4
|
|
5
|
-
// export const moduleEntity = defineEntity({
|
6
|
-
// type: "nixos.module",
|
7
|
-
|
8
|
-
// schema: Type.Object({
|
9
|
-
// /**
|
10
|
-
// * The folder containing the NixOS module files.
|
11
|
-
// *
|
12
|
-
// * @schema
|
13
|
-
// */
|
14
|
-
// folder: folderEntity.schema,
|
15
|
-
|
16
|
-
// /**
|
17
|
-
// * The name of the module file entrypoint to use when importing this module.
|
18
|
-
// *
|
19
|
-
// * @schema
|
20
|
-
// */
|
21
|
-
// entrypoint: Type.String(),
|
22
|
-
// }),
|
23
|
-
|
24
|
-
// meta: {
|
25
|
-
// displayName: "NixOS Module",
|
26
|
-
// description: "The NixOS module reference.",
|
27
|
-
// color: "#5277c3",
|
28
|
-
// },
|
29
|
-
// })
|
30
|
-
|
31
5
|
export const inlineModule = defineUnit({
|
32
6
|
type: "nixos.inline-module",
|
33
7
|
|
@@ -37,14 +11,14 @@ export const inlineModule = defineUnit({
|
|
37
11
|
*
|
38
12
|
* If not provided, the name will be the name of the unit.
|
39
13
|
*/
|
40
|
-
moduleName:
|
14
|
+
moduleName: z.string().optional(),
|
41
15
|
|
42
16
|
/**
|
43
17
|
* The code of the NixOS module.
|
44
18
|
*
|
45
19
|
* In this code you can reference other modules and files by their names.
|
46
20
|
*/
|
47
|
-
code:
|
21
|
+
code: z.string().meta({ language: "nix" }),
|
48
22
|
},
|
49
23
|
|
50
24
|
inputs: {
|
@@ -65,10 +39,10 @@ export const inlineModule = defineUnit({
|
|
65
39
|
},
|
66
40
|
|
67
41
|
meta: {
|
68
|
-
|
42
|
+
title: "NixOS Inline Module",
|
69
43
|
description: "Creates a NixOS module from inline code.",
|
70
|
-
|
71
|
-
|
44
|
+
icon: "simple-icons:nixos",
|
45
|
+
iconColor: "#7ebae4",
|
72
46
|
secondaryIcon: "mdi:file-code",
|
73
47
|
category: "NixOS",
|
74
48
|
},
|
@@ -79,34 +53,6 @@ export const inlineModule = defineUnit({
|
|
79
53
|
},
|
80
54
|
})
|
81
55
|
|
82
|
-
// export const flakeEntity = defineEntity({
|
83
|
-
// type: "nixos.flake",
|
84
|
-
|
85
|
-
// schema: Type.Object({
|
86
|
-
// /**
|
87
|
-
// * The git repository where the flake is stored.
|
88
|
-
// *
|
89
|
-
// * @schema
|
90
|
-
// */
|
91
|
-
// repository: repositoryEntity.schema,
|
92
|
-
|
93
|
-
// /**
|
94
|
-
// * The relative path to the folder containing the flake.nix file.
|
95
|
-
// *
|
96
|
-
// * If not provided, the root of the repository will be used.
|
97
|
-
// *
|
98
|
-
// * @schema
|
99
|
-
// */
|
100
|
-
// flakePath: Type.Optional(Type.String()),
|
101
|
-
// }),
|
102
|
-
|
103
|
-
// meta: {
|
104
|
-
// displayName: "NixOS Flake",
|
105
|
-
// description: "The NixOS flake reference.",
|
106
|
-
// color: "#5277c3",
|
107
|
-
// },
|
108
|
-
// })
|
109
|
-
|
110
56
|
export const inlineFlake = defineUnit({
|
111
57
|
type: "nixos.inline-flake",
|
112
58
|
|
@@ -116,14 +62,14 @@ export const inlineFlake = defineUnit({
|
|
116
62
|
*
|
117
63
|
* If not provided, the name will be the name of the unit.
|
118
64
|
*/
|
119
|
-
flakeName:
|
65
|
+
flakeName: z.string().optional(),
|
120
66
|
|
121
67
|
/**
|
122
68
|
* The code of the `flake.nix` file.
|
123
69
|
*
|
124
70
|
* In this code you can reference other flakes, modules, files, and folders by their names.
|
125
71
|
*/
|
126
|
-
code:
|
72
|
+
code: z.string().meta({ language: "nix" }),
|
127
73
|
},
|
128
74
|
|
129
75
|
inputs: {
|
@@ -144,10 +90,10 @@ export const inlineFlake = defineUnit({
|
|
144
90
|
},
|
145
91
|
|
146
92
|
meta: {
|
147
|
-
|
93
|
+
title: "NixOS Inline Flake",
|
148
94
|
description: "Creates a NixOS flake from inline code.",
|
149
|
-
|
150
|
-
|
95
|
+
icon: "simple-icons:nixos",
|
96
|
+
iconColor: "#7ebae4",
|
151
97
|
secondaryIcon: "mdi:file-code",
|
152
98
|
category: "NixOS",
|
153
99
|
},
|
@@ -162,7 +108,7 @@ export const system = defineUnit({
|
|
162
108
|
type: "nixos.system",
|
163
109
|
|
164
110
|
args: {
|
165
|
-
system:
|
111
|
+
system: z.string().optional(),
|
166
112
|
},
|
167
113
|
|
168
114
|
inputs: {
|
@@ -175,10 +121,10 @@ export const system = defineUnit({
|
|
175
121
|
},
|
176
122
|
|
177
123
|
meta: {
|
178
|
-
|
124
|
+
title: "NixOS System",
|
179
125
|
description: "Creates a NixOS system on top of any server.",
|
180
|
-
|
181
|
-
|
126
|
+
icon: "simple-icons:nixos",
|
127
|
+
iconColor: "#7ebae4",
|
182
128
|
secondaryIcon: "codicon:vm",
|
183
129
|
category: "NixOS",
|
184
130
|
},
|
@@ -6,9 +6,9 @@ export const deobfuscator = defineUnit({
|
|
6
6
|
...deobfuscatorSpec,
|
7
7
|
|
8
8
|
meta: {
|
9
|
-
|
9
|
+
title: "Phantun Deobfuscator",
|
10
10
|
description: "The Phantun Deobfuscator deployed on Kubernetes.",
|
11
|
-
|
11
|
+
icon: "mdi:network-outline",
|
12
12
|
secondaryIcon: "mdi:hide",
|
13
13
|
category: "Obfuscators",
|
14
14
|
},
|
@@ -24,9 +24,9 @@ export const obfuscator = defineUnit({
|
|
24
24
|
...obfuscatorSpec,
|
25
25
|
|
26
26
|
meta: {
|
27
|
-
|
27
|
+
title: "Phantun Obfuscator",
|
28
28
|
description: "The Phantun Obfuscator deployed on Kubernetes.",
|
29
|
-
|
29
|
+
icon: "mdi:network-outline",
|
30
30
|
secondaryIcon: "mdi:hide",
|
31
31
|
category: "Obfuscators",
|
32
32
|
},
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { $args, $inputs, $outputs,
|
1
|
+
import { $args, $inputs, $outputs, z } from "@highstate/contract"
|
2
2
|
import { clusterEntity } from "../k8s"
|
3
3
|
import { l4EndpointEntity } from "../network"
|
4
4
|
|
@@ -9,21 +9,21 @@ export const deobfuscatorSpec = {
|
|
9
9
|
*
|
10
10
|
* By default, calculated as `deobfs-{type}-{name}`.
|
11
11
|
*/
|
12
|
-
appName:
|
12
|
+
appName: z.string().optional(),
|
13
13
|
|
14
14
|
/**
|
15
15
|
* The L4 endpoint to forward deobfuscated traffic to.
|
16
16
|
*
|
17
17
|
* Will take precedence over the `targetEndpoint` input.
|
18
18
|
*/
|
19
|
-
targetEndpoints:
|
19
|
+
targetEndpoints: z.string().array().default([]),
|
20
20
|
|
21
21
|
/**
|
22
22
|
* Whether to expose the deobfuscator service by "NodePort" or "LoadBalancer".
|
23
23
|
*
|
24
24
|
* By default, the service is not exposed and only accessible from within the cluster.
|
25
25
|
*/
|
26
|
-
external:
|
26
|
+
external: z.boolean().default(false),
|
27
27
|
}),
|
28
28
|
|
29
29
|
inputs: $inputs({
|
@@ -63,21 +63,21 @@ export const obfuscatorSpec = {
|
|
63
63
|
*
|
64
64
|
* By default, calculated as `obfs-{type}-{name}`.
|
65
65
|
*/
|
66
|
-
appName:
|
66
|
+
appName: z.string().optional(),
|
67
67
|
|
68
68
|
/**
|
69
69
|
* The endpoint of the deobfuscator to pass obfuscated traffic to.
|
70
70
|
*
|
71
71
|
* Will take precedence over the `endpoint` input.
|
72
72
|
*/
|
73
|
-
endpoints:
|
73
|
+
endpoints: z.string().array().default([]),
|
74
74
|
|
75
75
|
/**
|
76
76
|
* Whether to expose the obfuscator service by "NodePort" or "LoadBalancer".
|
77
77
|
*
|
78
78
|
* By default, the service is not exposed and only accessible from within the cluster.
|
79
79
|
*/
|
80
|
-
external:
|
80
|
+
external: z.boolean().default(false),
|
81
81
|
}),
|
82
82
|
|
83
83
|
inputs: $inputs({
|
@@ -109,5 +109,5 @@ export const obfuscatorSpec = {
|
|
109
109
|
}),
|
110
110
|
}
|
111
111
|
|
112
|
-
export type DeobfuscatorArgs =
|
113
|
-
export type ObfuscatorArgs =
|
112
|
+
export type DeobfuscatorArgs = z.infer<typeof deobfuscatorSpec.args>
|
113
|
+
export type ObfuscatorArgs = z.infer<typeof obfuscatorSpec.args>
|