@highstate/library 0.20.0 → 0.25.0

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.
Files changed (61) hide show
  1. package/dist/highstate.library.msgpack +0 -0
  2. package/dist/index.js +4260 -3948
  3. package/package.json +12 -12
  4. package/src/abbreviations.ts +2 -0
  5. package/src/apps/index.ts +1 -0
  6. package/src/apps/vault.ts +374 -0
  7. package/src/common/access-point.ts +150 -4
  8. package/src/common/filter.ts +40 -0
  9. package/src/common/index.ts +1 -0
  10. package/src/common/server.ts +131 -1
  11. package/src/databases/etcd.ts +12 -4
  12. package/src/databases/index.ts +1 -0
  13. package/src/databases/minio.ts +19 -0
  14. package/src/databases/mongodb.ts +12 -4
  15. package/src/databases/mysql.ts +12 -4
  16. package/src/databases/postgresql.ts +12 -4
  17. package/src/databases/rustfs.ts +169 -0
  18. package/src/dns.ts +3 -3
  19. package/src/index.ts +3 -0
  20. package/src/k3s.ts +129 -3
  21. package/src/k8s/apps/envoy-gateway.ts +50 -0
  22. package/src/k8s/apps/etcd.ts +1 -1
  23. package/src/k8s/apps/grafana.ts +1 -1
  24. package/src/k8s/apps/index.ts +4 -0
  25. package/src/k8s/apps/mariadb.ts +1 -1
  26. package/src/k8s/apps/matrix-stack.ts +2 -1
  27. package/src/k8s/apps/minio.ts +2 -2
  28. package/src/k8s/apps/mongodb.ts +1 -1
  29. package/src/k8s/apps/postgresql.ts +1 -1
  30. package/src/k8s/apps/rustfs.ts +119 -0
  31. package/src/k8s/apps/shared.ts +16 -1
  32. package/src/k8s/apps/signoz.ts +32 -0
  33. package/src/k8s/apps/traefik.ts +5 -5
  34. package/src/k8s/apps/valkey.ts +1 -1
  35. package/src/k8s/apps/vault.ts +113 -0
  36. package/src/k8s/apps/vaultwarden.ts +31 -2
  37. package/src/k8s/apps/workload.ts +12 -14
  38. package/src/k8s/cert-manager.ts +44 -2
  39. package/src/k8s/cilium.ts +3 -16
  40. package/src/k8s/coredns.ts +62 -0
  41. package/src/k8s/gateway.ts +25 -0
  42. package/src/k8s/index.ts +1 -0
  43. package/src/k8s/scheduling.ts +87 -0
  44. package/src/k8s/service-args.ts +109 -0
  45. package/src/k8s/shared.ts +26 -0
  46. package/src/k8s/workload.ts +21 -0
  47. package/src/netaminity.ts +950 -0
  48. package/src/network/address-space.ts +14 -0
  49. package/src/network/endpoint.ts +12 -1
  50. package/src/network/index.ts +1 -0
  51. package/src/network/network.ts +58 -0
  52. package/src/restic.ts +2 -1
  53. package/src/ssh.ts +27 -0
  54. package/src/third-party/gcp.ts +427 -0
  55. package/src/third-party/index.ts +1 -0
  56. package/src/third-party/yandex.ts +194 -1
  57. package/src/tls.ts +135 -6
  58. package/src/utils.ts +16 -1
  59. package/src/wireguard.ts +273 -4
  60. package/LICENSE +0 -21
  61. package/dist/index.js.map +0 -1
package/src/wireguard.ts CHANGED
@@ -80,7 +80,7 @@ export const networkArgs = {
80
80
  /**
81
81
  * The extra parameters for the amneziawg backend.
82
82
  */
83
- amnezia: amneziaParametersSchema.optional(),
83
+ amnezia: amneziaParametersSchema.default({}),
84
84
  }
85
85
 
86
86
  const configSharedArgs = $args({
@@ -121,6 +121,14 @@ export const networkEntity = defineEntity({
121
121
  })
122
122
 
123
123
  export const nodeExposePolicySchema = z.enum(["always", "when-has-endpoint", "never"])
124
+ export const feedDaemonSyncModeSchema = z.enum(["sse", "polling"])
125
+ export const feedDaemonBackendTypeSchema = z.enum([
126
+ "wg-quick",
127
+ "networkmanager",
128
+ "netns",
129
+ "windows",
130
+ "windows-manager",
131
+ ])
124
132
 
125
133
  export const feedDisplayInfoSchema = z.object({
126
134
  /**
@@ -171,6 +179,11 @@ export const feedMetadataSchema = z.object({
171
179
  * The display information of the tunnel.
172
180
  */
173
181
  displayInfo: feedDisplayInfoSchema,
182
+
183
+ /**
184
+ * The warning message to display for the tunnel.
185
+ */
186
+ warningMessage: z.string().optional(),
174
187
  })
175
188
 
176
189
  export const peerEntity = defineEntity({
@@ -330,6 +343,19 @@ export const configEntity = defineEntity({
330
343
  * The file containing the wg-quick configuration.
331
344
  */
332
345
  file: fileEntity,
346
+
347
+ /**
348
+ * The identity for which the config is generated.
349
+ */
350
+ identity: identityEntity,
351
+
352
+ /**
353
+ * The peers included in the config.
354
+ */
355
+ peers: {
356
+ entity: peerEntity,
357
+ multiple: true,
358
+ },
333
359
  },
334
360
 
335
361
  schema: z.object({
@@ -354,6 +380,8 @@ export type Network = EntityValue<typeof networkEntity>
354
380
  export type Identity = EntityValue<typeof identityEntity>
355
381
  export type Peer = EntityValue<typeof peerEntity>
356
382
  export type NodeExposePolicy = z.infer<typeof nodeExposePolicySchema>
383
+ export type FeedDaemonSyncMode = z.infer<typeof feedDaemonSyncModeSchema>
384
+ export type FeedDaemonBackendType = z.infer<typeof feedDaemonBackendTypeSchema>
357
385
  export type Config = EntityValue<typeof configEntity>
358
386
 
359
387
  export type NetworkInput = EntityInput<typeof networkEntity>
@@ -364,6 +392,40 @@ export type ConfigInput = EntityInput<typeof configEntity>
364
392
  export type FeedDisplayInfo = z.infer<typeof feedDisplayInfoSchema>
365
393
  export type FeedMetadata = z.infer<typeof feedMetadataSchema>
366
394
 
395
+ const feedDaemonArgs = $args({
396
+ /**
397
+ * The label of the feed in the wg-feed daemon config.
398
+ */
399
+ feedName: genericNameSchema.default("main"),
400
+
401
+ /**
402
+ * The label of the backend in the wg-feed daemon config.
403
+ */
404
+ backendName: genericNameSchema.default("default"),
405
+
406
+ /**
407
+ * The backend type used by the wg-feed daemon.
408
+ */
409
+ backendType: feedDaemonBackendTypeSchema.default("wg-quick"),
410
+
411
+ /**
412
+ * The sync mode used by the wg-feed daemon.
413
+ */
414
+ syncMode: feedDaemonSyncModeSchema.default("sse"),
415
+
416
+ /**
417
+ * The polling interval in seconds.
418
+ *
419
+ * If set to 0, wg-feed daemon uses the server-provided TTL.
420
+ */
421
+ pollingInterval: z.number().int().nonnegative().default(0),
422
+
423
+ /**
424
+ * The state file path used by the wg-feed daemon.
425
+ */
426
+ statePath: z.string().default("/var/lib/wg-feed/state.json"),
427
+ })
428
+
367
429
  /**
368
430
  * Holds the shared configuration for WireGuard identities, peers, and nodes.
369
431
  */
@@ -403,7 +465,14 @@ const sharedFeedArgs = $args({
403
465
  */
404
466
  provided: z.literal("yes"),
405
467
 
406
- ...pick(feedMetadataSchema.shape, ["id", "name", "enabled", "forced", "exclusive"]),
468
+ ...pick(feedMetadataSchema.shape, [
469
+ "id",
470
+ "name",
471
+ "enabled",
472
+ "forced",
473
+ "exclusive",
474
+ "warningMessage",
475
+ ]),
407
476
 
408
477
  // Highstate does not support nested objects in UI
409
478
  ...feedDisplayInfoSchema.shape,
@@ -733,10 +802,27 @@ export const nodeK8s = defineUnit({
733
802
  * By default, is false.
734
803
  */
735
804
  allowClusterPods: z.boolean().default(false),
805
+
806
+ /**
807
+ * Whether to drop all traffic from the interface using ip rule with priority 100.
808
+ *
809
+ * This is useful for preventing the traffic leaks before upstream node is attached via `downstreamInterface` input.
810
+ * They will add their own ip rule with <100 priority which allows traffic from the interface.
811
+ */
812
+ lockdownUpstream: z.boolean().default(false),
736
813
  },
737
814
 
738
815
  inputs: {
739
- identity: identityEntity,
816
+ identity: {
817
+ entity: identityEntity,
818
+ required: false,
819
+ },
820
+
821
+ config: {
822
+ entity: configEntity,
823
+ required: false,
824
+ },
825
+
740
826
  k8sCluster: clusterEntity,
741
827
 
742
828
  workload: {
@@ -823,6 +909,11 @@ export const nodeFeedK8s = defineUnit({
823
909
  */
824
910
  listenPort: z.number().default(51820),
825
911
 
912
+ /**
913
+ * The NodePort to assign when the node is exposed.
914
+ */
915
+ nodePort: z.number().int().min(30000).max(32767).optional(),
916
+
826
917
  /**
827
918
  * The name of the WireGuard interface to export as `interface` output.
828
919
  *
@@ -831,6 +922,13 @@ export const nodeFeedK8s = defineUnit({
831
922
  */
832
923
  interfaceName: z.string().default("wg0"),
833
924
 
925
+ ...feedDaemonArgs,
926
+
927
+ /**
928
+ * The wg-feed tunnel IDs to force-enable in the daemon config.
929
+ */
930
+ enabledTunnels: z.string().array().default([]),
931
+
834
932
  /**
835
933
  * List of CIDR blocks that should be blocked from forwarding through this WireGuard node.
836
934
  *
@@ -841,6 +939,14 @@ export const nodeFeedK8s = defineUnit({
841
939
  */
842
940
  forwardRestrictedSubnets: z.string().array().default([]),
843
941
 
942
+ /**
943
+ * Whether to drop all traffic from the interface using ip rule with priority 100.
944
+ *
945
+ * This is useful for preventing the traffic leaks before upstream node is attached via `downstreamInterface` input.
946
+ * They will add their own ip rule with <100 priority which allows traffic from the interface.
947
+ */
948
+ lockdownUpstream: z.boolean().default(false),
949
+
844
950
  /**
845
951
  * The extra specification of the container which runs the wg-feed daemon.
846
952
  *
@@ -903,6 +1009,114 @@ export const nodeFeedK8s = defineUnit({
903
1009
  },
904
1010
  })
905
1011
 
1012
+ /**
1013
+ * The wg-feed daemon deployed on a server using a systemd service.
1014
+ */
1015
+ export const nodeFeed = defineUnit({
1016
+ type: "wireguard.node.feed.v1",
1017
+
1018
+ args: {
1019
+ /**
1020
+ * The name of the wg-feed daemon systemd service.
1021
+ *
1022
+ * By default, the name is `wg-feed-${unitName}`.
1023
+ */
1024
+ serviceName: z.string().optional(),
1025
+
1026
+ /**
1027
+ * The UDP port that will be exposed by the output peer.
1028
+ */
1029
+ listenPort: z.number().default(51820),
1030
+
1031
+ /**
1032
+ * The name of the WireGuard interface to use for lockdown rules.
1033
+ *
1034
+ * Note: wg-feed may manage multiple tunnels.
1035
+ */
1036
+ interfaceName: z.string().default("wg0"),
1037
+
1038
+ /**
1039
+ * The path where the wg-feed daemon binary should be installed.
1040
+ */
1041
+ daemonPath: z.string().default("/usr/local/bin/wg-feed-daemon"),
1042
+
1043
+ /**
1044
+ * The path where the wg-feed daemon config should be written.
1045
+ */
1046
+ configPath: z.string().default("/etc/wg-feed/config.yaml"),
1047
+
1048
+ ...feedDaemonArgs,
1049
+
1050
+ /**
1051
+ * The wg-feed tunnel IDs to force-enable in the daemon config.
1052
+ */
1053
+ enabledTunnels: z.string().array().default([]),
1054
+
1055
+ /**
1056
+ * List of CIDR blocks that should be blocked from forwarding through this WireGuard node.
1057
+ *
1058
+ * This prevents other peers from reaching these destination CIDRs while still allowing
1059
+ * the peers in those CIDRs to access the internet and other allowed endpoints.
1060
+ */
1061
+ forwardRestrictedSubnets: z.string().array().default([]),
1062
+
1063
+ /**
1064
+ * Whether to drop all traffic from the interface using ip rule with priority 100.
1065
+ *
1066
+ * This is useful for preventing traffic leaks before another routing rule is installed.
1067
+ */
1068
+ lockdownUpstream: z.boolean().default(false),
1069
+ },
1070
+
1071
+ secrets: {
1072
+ /**
1073
+ * The wg-feed setup URLs to configure on the daemon.
1074
+ *
1075
+ * This is useful for URLs that include secret fragments such as age keys.
1076
+ */
1077
+ endpoints: z.string().array().default([]),
1078
+ },
1079
+
1080
+ inputs: {
1081
+ server: {
1082
+ entity: serverEntity,
1083
+ required: true,
1084
+ },
1085
+
1086
+ endpoints: {
1087
+ entity: l7EndpointEntity,
1088
+ multiple: true,
1089
+ required: false,
1090
+ },
1091
+
1092
+ peer: {
1093
+ entity: peerEntity,
1094
+ required: false,
1095
+ },
1096
+ },
1097
+
1098
+ outputs: {
1099
+ peer: {
1100
+ entity: peerEntity,
1101
+ required: false,
1102
+ },
1103
+ },
1104
+
1105
+ meta: {
1106
+ title: "WireGuard Feed Server Node",
1107
+ description: "The wg-feed daemon deployed on a server.",
1108
+ icon: "simple-icons:wireguard",
1109
+ iconColor: "#88171a",
1110
+ secondaryIcon: "mdi:server",
1111
+ category: "VPN",
1112
+ },
1113
+
1114
+ source: {
1115
+ package: "@highstate/wireguard",
1116
+ path: "node.feed",
1117
+ },
1118
+ })
1119
+
906
1120
  /**
907
1121
  * The WireGuard node deployed on a server using wg-quick systemd service.
908
1122
  */
@@ -958,7 +1172,16 @@ export const node = defineUnit({
958
1172
  },
959
1173
 
960
1174
  inputs: {
961
- identity: identityEntity,
1175
+ identity: {
1176
+ entity: identityEntity,
1177
+ required: false,
1178
+ },
1179
+
1180
+ config: {
1181
+ entity: configEntity,
1182
+ required: false,
1183
+ },
1184
+
962
1185
  server: {
963
1186
  entity: serverEntity,
964
1187
  required: true,
@@ -1034,6 +1257,43 @@ export const config = defineUnit({
1034
1257
  },
1035
1258
  })
1036
1259
 
1260
+ /**
1261
+ * Parses an existing WireGuard configuration into config, identity, network, and peer entities.
1262
+ */
1263
+ export const existingConfig = defineUnit({
1264
+ type: "wireguard.existing-config.v1",
1265
+
1266
+ args: {
1267
+ /**
1268
+ * The existing wg-quick or awg-quick configuration content.
1269
+ */
1270
+ config: z.string().meta({ language: "ini" }),
1271
+ },
1272
+
1273
+ outputs: {
1274
+ config: configEntity,
1275
+ identity: identityEntity,
1276
+ network: networkEntity,
1277
+ peers: {
1278
+ entity: peerEntity,
1279
+ multiple: true,
1280
+ },
1281
+ },
1282
+
1283
+ meta: {
1284
+ title: "Existing WireGuard Config",
1285
+ icon: "simple-icons:wireguard",
1286
+ iconColor: "#88171a",
1287
+ secondaryIcon: "mdi:file-import",
1288
+ category: "VPN",
1289
+ },
1290
+
1291
+ source: {
1292
+ package: "@highstate/wireguard",
1293
+ path: "existing-config",
1294
+ },
1295
+ })
1296
+
1037
1297
  /**
1038
1298
  * The WireGuard configuration bundle for the identity and peers.
1039
1299
  */
@@ -1055,6 +1315,10 @@ export const configBundle = defineUnit({
1055
1315
  multiple: true,
1056
1316
  required: false,
1057
1317
  },
1318
+ network: {
1319
+ entity: networkEntity,
1320
+ required: false,
1321
+ },
1058
1322
  },
1059
1323
 
1060
1324
  outputs: {
@@ -1113,6 +1377,11 @@ export const feed = defineUnit({
1113
1377
  * The display information of the feed.
1114
1378
  */
1115
1379
  displayInfo: feedDisplayInfoSchema,
1380
+
1381
+ /**
1382
+ * The warning message to display for the feed.
1383
+ */
1384
+ warningMessage: z.string().optional(),
1116
1385
  },
1117
1386
 
1118
1387
  secrets: {
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Exeteres
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.