@highstate/library 0.8.0 → 0.9.1

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "sourceHashes": {
3
- "./dist/index.js": "87b93b45d5c7ee264151628635db26d22961524bc86f599c8bfb9655f27980e9"
3
+ "./dist/index.js": "1ab143e511c4a91fc067388c4cdcde7726707de91dcb701b1f064047eef6dd8e"
4
4
  }
5
5
  }
package/dist/index.js CHANGED
@@ -7,11 +7,12 @@ var __export = (target, all) => {
7
7
  // src/common.ts
8
8
  var common_exports = {};
9
9
  __export(common_exports, {
10
- endpointEntity: () => endpointEntity,
11
10
  existingServer: () => existingServer,
12
11
  fileContentEntity: () => fileContentEntity,
13
12
  fileEntity: () => fileEntity,
14
13
  fileMetaEntity: () => fileMetaEntity,
14
+ l3EndpointEntity: () => l3EndpointEntity,
15
+ l4EndpointEntity: () => l4EndpointEntity,
15
16
  script: () => script,
16
17
  serverEntity: () => serverEntity
17
18
  });
@@ -84,14 +85,25 @@ var serverEntity = defineEntity2({
84
85
  color: "#009688"
85
86
  }
86
87
  });
87
- var endpointEntity = defineEntity2({
88
- type: "common.endpoint",
88
+ var l3EndpointEntity = defineEntity2({
89
+ type: "common.l3-endpoint",
89
90
  schema: Type2.Object({
90
91
  endpoint: Type2.String()
91
92
  }),
92
93
  meta: {
93
- color: "#FFC107",
94
- description: "The L3-L4 endpoint for some network service."
94
+ color: "#1B5E20",
95
+ description: "The L3 endpoint for some service. May be a domain name or an IP address."
96
+ }
97
+ });
98
+ var l4EndpointEntity = defineEntity2({
99
+ type: "common.l4-endpoint",
100
+ schema: Type2.Object({
101
+ endpoint: Type2.String(),
102
+ port: Type2.Number()
103
+ }),
104
+ meta: {
105
+ color: "#F57F17",
106
+ description: "The L4 endpoint for some service. Extends an L3 endpoint with a port."
95
107
  }
96
108
  });
97
109
  var existingServer = defineUnit2({
@@ -373,9 +385,11 @@ __export(k8s_exports, {
373
385
  serviceTypeSchema: () => serviceTypeSchema,
374
386
  sharedClusterArgs: () => sharedClusterArgs,
375
387
  statefulSetEntity: () => statefulSetEntity,
376
- tlsIssuerEntity: () => tlsIssuerEntity
388
+ tlsIssuerEntity: () => tlsIssuerEntity,
389
+ tunDevicePolicySchema: () => tunDevicePolicySchema
377
390
  });
378
391
  import { defineEntity as defineEntity5, defineUnit as defineUnit5, Type as Type5 } from "@highstate/contract";
392
+ import { Literal } from "@sinclair/typebox";
379
393
 
380
394
  // src/dns.ts
381
395
  var dns_exports = {};
@@ -420,6 +434,16 @@ var record = defineUnit4({
420
434
  });
421
435
 
422
436
  // src/k8s.ts
437
+ var tunDevicePolicySchema = Type5.Union([
438
+ Type5.Object({
439
+ type: Literal("host")
440
+ }),
441
+ Type5.Object({
442
+ type: Literal("plugin"),
443
+ resourceName: Type5.String(),
444
+ resourceValue: Type5.String()
445
+ })
446
+ ]);
423
447
  var clusterInfoSchema = Type5.Object({
424
448
  id: Type5.String(),
425
449
  name: Type5.String(),
@@ -427,7 +451,15 @@ var clusterInfoSchema = Type5.Object({
427
451
  externalIps: Type5.Array(Type5.String()),
428
452
  fqdn: Type5.Optional(Type5.String()),
429
453
  kubeApiServerIp: Type5.Optional(Type5.String()),
430
- kubeApiServerPort: Type5.Optional(Type5.Number())
454
+ kubeApiServerPort: Type5.Optional(Type5.Number()),
455
+ /**
456
+ * Specifies the policy for using the tun device inside containers.
457
+ *
458
+ * If not provided, the default policy is `host` which assumes just mounting /dev/net/tun from the host.
459
+ *
460
+ * For some runtimes, like Talos's one, the /dev/net/tun device is not available in the host, so the plugin policy should be used.
461
+ */
462
+ tunDevicePolicy: Type5.Optional(tunDevicePolicySchema)
431
463
  });
432
464
  var serviceTypeSchema = Type5.StringEnum(["NodePort", "LoadBalancer", "ClusterIP"]);
433
465
  var metadataSchema = Type5.Object({
@@ -534,7 +566,24 @@ var sharedClusterArgs = {
534
566
  var existingCluster = defineUnit5({
535
567
  type: "k8s.existing-cluster",
536
568
  args: {
537
- ...sharedClusterArgs
569
+ ...sharedClusterArgs,
570
+ /**
571
+ * The policy for using the tun device inside containers.
572
+ *
573
+ * If not provided, the default policy is `host` which assumes just mounting /dev/net/tun from the host.
574
+ *
575
+ * For some runtimes, like Talos's one, the /dev/net/tun device is not available in the host, so the plugin policy should be used.
576
+ *
577
+ * @schema
578
+ */
579
+ tunDevicePolicy: {
580
+ ...Type5.Optional(tunDevicePolicySchema),
581
+ description: `The policy for using the tun device inside containers.
582
+
583
+ If not provided, the default policy is \`host\` which assumes just mounting /dev/net/tun from the host.
584
+
585
+ For some runtimes, like Talos's one, the /dev/net/tun device is not available in the host, so the plugin policy should be used.`
586
+ }
538
587
  },
539
588
  secrets: {
540
589
  /**
@@ -788,20 +837,41 @@ var cluster = defineUnit6({
788
837
  * Allow scheduling workloads on the master nodes.
789
838
  *
790
839
  * By default, "true" if no worker nodes are provided.
840
+ *
841
+ * @schema
791
842
  */
792
- scheduleOnMasters: Type6.Boolean(),
843
+ scheduleOnMasters: {
844
+ ...Type6.Boolean(),
845
+ description: `Allow scheduling workloads on the master nodes.
846
+
847
+ By default, "true" if no worker nodes are provided.`
848
+ },
793
849
  /**
794
850
  * The endpoint of the cluster.
795
851
  *
796
852
  * By default, the first master node's endpoint is used.
853
+ *
854
+ * @schema
797
855
  */
798
- endpoint: Type6.Optional(Type6.String()),
856
+ endpoint: {
857
+ ...Type6.Optional(Type6.String()),
858
+ description: `The endpoint of the cluster.
859
+
860
+ By default, the first master node's endpoint is used.`
861
+ },
799
862
  /**
800
863
  * The name of the cluster.
801
864
  *
802
865
  * By default, the name of the instance is used.
866
+ *
867
+ * @schema
803
868
  */
804
- clusterName: Type6.Optional(Type6.String()),
869
+ clusterName: {
870
+ ...Type6.Optional(Type6.String()),
871
+ description: `The name of the cluster.
872
+
873
+ By default, the name of the instance is used.`
874
+ },
805
875
  /**
806
876
  * The CNI plugin to use.
807
877
  *
@@ -811,31 +881,70 @@ var cluster = defineUnit6({
811
881
  * - "none" (disable CNI, must be installed manually)
812
882
  *
813
883
  * The "cilium" CNI plugin is recommended to cover advanced network policies like FQDNs.
884
+ *
885
+ * @schema
814
886
  */
815
- cni: { ...cniSchema, default: "cilium" },
887
+ cni: {
888
+ ...Type6.Default(cniSchema, "cilium"),
889
+ description: `The CNI plugin to use.
890
+
891
+ The following options are available:
892
+ - "cilium" (default)
893
+ - "flannel" (built-in in Talos)
894
+ - "none" (disable CNI, must be installed manually)
895
+
896
+ The "cilium" CNI plugin is recommended to cover advanced network policies like FQDNs.`
897
+ },
816
898
  /**
817
899
  * The CSI plugin to use.
818
900
  *
819
901
  * The following options are available:
820
902
  * - "local-path-provisioner" (default)
821
903
  * - "none" (disable CSI, must be installed manually if needed)
904
+ *
905
+ * @schema
822
906
  */
823
- csi: { ...csiSchema, default: "local-path-provisioner" },
907
+ csi: {
908
+ ...Type6.Default(csiSchema, "local-path-provisioner"),
909
+ description: `The CSI plugin to use.
910
+
911
+ The following options are available:
912
+ - "local-path-provisioner" (default)
913
+ - "none" (disable CSI, must be installed manually if needed)`
914
+ },
824
915
  /**
825
916
  * The shared configuration patch.
826
917
  * It will be applied to all nodes.
918
+ *
919
+ * @schema
827
920
  */
828
- sharedConfigPatch: Type6.Optional(Type6.Record(Type6.String(), Type6.Any())),
921
+ sharedConfigPatch: {
922
+ ...Type6.Optional(Type6.Record(Type6.String(), Type6.Any())),
923
+ description: `The shared configuration patch.
924
+ It will be applied to all nodes.`
925
+ },
829
926
  /**
830
927
  * The master configuration patch.
831
928
  * It will be applied to all master nodes.
929
+ *
930
+ * @schema
832
931
  */
833
- masterConfigPatch: Type6.Optional(Type6.Record(Type6.String(), Type6.Any())),
932
+ masterConfigPatch: {
933
+ ...Type6.Optional(Type6.Record(Type6.String(), Type6.Any())),
934
+ description: `The master configuration patch.
935
+ It will be applied to all master nodes.`
936
+ },
834
937
  /**
835
938
  * The worker configuration patch.
836
939
  * It will be applied to all worker nodes.
940
+ *
941
+ * @schema
837
942
  */
838
- workerConfigPatch: Type6.Optional(Type6.Record(Type6.String(), Type6.Any()))
943
+ workerConfigPatch: {
944
+ ...Type6.Optional(Type6.Record(Type6.String(), Type6.Any())),
945
+ description: `The worker configuration patch.
946
+ It will be applied to all worker nodes.`
947
+ }
839
948
  },
840
949
  inputs: {
841
950
  masters: {
@@ -954,7 +1063,7 @@ var network = defineUnit7({
954
1063
  * @schema
955
1064
  */
956
1065
  backend: {
957
- ...backendSchema,
1066
+ ...Type7.Default(backendSchema, "wireguard"),
958
1067
  description: `The backend to use for the WireGuard network.
959
1068
 
960
1069
  Possible values are:
@@ -1216,7 +1325,7 @@ var peer = defineUnit7({
1216
1325
  * @schema
1217
1326
  */
1218
1327
  publicKey: {
1219
- ...Type7.String(),
1328
+ ...Type7.Optional(Type7.String()),
1220
1329
  description: `The public key of the WireGuard peer.`
1221
1330
  }
1222
1331
  },
@@ -1236,6 +1345,34 @@ var peer = defineUnit7({
1236
1345
  description: `The network to use for the WireGuard peer.
1237
1346
 
1238
1347
  If not provided, the peer will use default network configuration.`
1348
+ },
1349
+ /**
1350
+ * The existing WireGuard peer to extend.
1351
+ *
1352
+ * @schema
1353
+ */
1354
+ peer: {
1355
+ ...{
1356
+ entity: peerEntity,
1357
+ required: false
1358
+ },
1359
+ description: `The existing WireGuard peer to extend.`
1360
+ },
1361
+ /**
1362
+ * The L4 endpoint of the peer.
1363
+ *
1364
+ * Will take priority over all calculated endpoints if provided.
1365
+ *
1366
+ * @schema
1367
+ */
1368
+ l4Endpoint: {
1369
+ ...{
1370
+ entity: l4EndpointEntity,
1371
+ required: false
1372
+ },
1373
+ description: `The L4 endpoint of the peer.
1374
+
1375
+ Will take priority over all calculated endpoints if provided.`
1239
1376
  }
1240
1377
  },
1241
1378
  outputs: {
@@ -1289,6 +1426,8 @@ var identity = defineUnit7({
1289
1426
  *
1290
1427
  * If overridden, does not affect node which implements the identity, but is used in the peer configuration of other nodes.
1291
1428
  *
1429
+ * Will take priority over all calculated endpoints and `l4Endpoint` input.
1430
+ *
1292
1431
  * @schema
1293
1432
  */
1294
1433
  endpoint: {
@@ -1297,7 +1436,9 @@ var identity = defineUnit7({
1297
1436
 
1298
1437
  By default, the endpoint is calculated as \`externalIp:listenPort\`.
1299
1438
 
1300
- If overridden, does not affect node which implements the identity, but is used in the peer configuration of other nodes.`
1439
+ If overridden, does not affect node which implements the identity, but is used in the peer configuration of other nodes.
1440
+
1441
+ Will take priority over all calculated endpoints and \`l4Endpoint\` input.`
1301
1442
  },
1302
1443
  /**
1303
1444
  * The FQDN of the WireGuard identity.
@@ -1317,7 +1458,7 @@ var identity = defineUnit7({
1317
1458
  the FQDN will be registered with the DNS provider.`
1318
1459
  },
1319
1460
  /**
1320
- * Whether to register the FQDN of the identity with the DNS provider.
1461
+ * Whether to register the FQDN of the identity with the matching DNS providers.
1321
1462
  *
1322
1463
  * By default, `true`.
1323
1464
  *
@@ -1325,7 +1466,7 @@ var identity = defineUnit7({
1325
1466
  */
1326
1467
  registerFqdn: {
1327
1468
  ...Type7.Default(Type7.Boolean(), true),
1328
- description: `Whether to register the FQDN of the identity with the DNS provider.
1469
+ description: `Whether to register the FQDN of the identity with the matching DNS providers.
1329
1470
 
1330
1471
  By default, \`true\`.`
1331
1472
  }
@@ -1396,19 +1537,55 @@ var identity = defineUnit7({
1396
1537
  * The Kubernetes cluster associated with the identity.
1397
1538
  *
1398
1539
  * If provided, will be used to obtain the external IP or FQDN of the identity.
1540
+ *
1541
+ * @schema
1399
1542
  */
1400
1543
  k8sCluster: {
1401
- entity: clusterEntity2,
1402
- required: false
1544
+ ...{
1545
+ entity: clusterEntity2,
1546
+ required: false
1547
+ },
1548
+ description: `The Kubernetes cluster associated with the identity.
1549
+
1550
+ If provided, will be used to obtain the external IP or FQDN of the identity.`
1403
1551
  },
1404
- dnsProvider: {
1405
- entity: providerEntity,
1406
- required: false
1552
+ /**
1553
+ * The L4 endpoint of the identity.
1554
+ *
1555
+ * Will take priority over all calculated endpoints if provided.
1556
+ *
1557
+ * @schema
1558
+ */
1559
+ l4Endpoint: {
1560
+ ...{
1561
+ entity: l4EndpointEntity,
1562
+ required: false
1563
+ },
1564
+ description: `The L4 endpoint of the identity.
1565
+
1566
+ Will take priority over all calculated endpoints if provided.`
1567
+ },
1568
+ /**
1569
+ * The DNS providers to register the FQDN of the identity with.
1570
+ *
1571
+ * @schema
1572
+ */
1573
+ dnsProviders: {
1574
+ ...{
1575
+ entity: providerEntity,
1576
+ required: false,
1577
+ multiple: true
1578
+ },
1579
+ description: `The DNS providers to register the FQDN of the identity with.`
1407
1580
  }
1408
1581
  },
1409
1582
  outputs: {
1410
1583
  identity: identityEntity,
1411
- peer: peerEntity
1584
+ peer: peerEntity,
1585
+ l4Endpoint: {
1586
+ entity: l4EndpointEntity,
1587
+ required: false
1588
+ }
1412
1589
  },
1413
1590
  meta: {
1414
1591
  description: "The WireGuard identity with the public key.",
@@ -2215,7 +2392,16 @@ var peer2 = defineUnit22({
2215
2392
  type: "mullvad.peer",
2216
2393
  args: {
2217
2394
  hostname: Type22.Optional(Type22.String()),
2218
- endpointType: Type22.Optional({ ...endpointType, default: "fqdn" })
2395
+ endpointType: Type22.Optional({ ...endpointType, default: "fqdn" }),
2396
+ /**
2397
+ * Whether to include Mullvad DNS servers in the peer configuration.
2398
+ *
2399
+ * @schema
2400
+ */
2401
+ includeDns: {
2402
+ ...Type22.Default(Type22.Boolean(), true),
2403
+ description: `Whether to include Mullvad DNS servers in the peer configuration.`
2404
+ }
2219
2405
  },
2220
2406
  inputs: {
2221
2407
  /**
@@ -2229,7 +2415,8 @@ var peer2 = defineUnit22({
2229
2415
  }
2230
2416
  },
2231
2417
  outputs: {
2232
- peer: peerEntity
2418
+ peer: peerEntity,
2419
+ l4Endpoint: l4EndpointEntity
2233
2420
  },
2234
2421
  meta: {
2235
2422
  displayName: "Mullvad Peer",
@@ -2488,6 +2675,152 @@ var secrets = defineUnit25({
2488
2675
  path: "secrets"
2489
2676
  }
2490
2677
  });
2678
+
2679
+ // src/obfuscators/index.ts
2680
+ var obfuscators_exports = {};
2681
+ __export(obfuscators_exports, {
2682
+ phantun: () => phantun_exports
2683
+ });
2684
+
2685
+ // src/obfuscators/phantun.ts
2686
+ var phantun_exports = {};
2687
+ __export(phantun_exports, {
2688
+ deobfuscator: () => deobfuscator,
2689
+ obfuscator: () => obfuscator
2690
+ });
2691
+ import { defineUnit as defineUnit26 } from "@highstate/contract";
2692
+
2693
+ // src/obfuscators/shared.ts
2694
+ import { Type as Type26 } from "@sinclair/typebox";
2695
+ var deobfuscatorSpec = {
2696
+ args: {
2697
+ /**
2698
+ * The L4 endpoint to forward deobfuscated traffic to.
2699
+ *
2700
+ * Will take precedence over the `targetEndpoint` input.
2701
+ *
2702
+ * @schema
2703
+ */
2704
+ targetEndpoint: {
2705
+ ...Type26.Optional(Type26.String()),
2706
+ description: `The L4 endpoint to forward deobfuscated traffic to.
2707
+
2708
+ Will take precedence over the \`targetEndpoint\` input.`
2709
+ }
2710
+ },
2711
+ inputs: {
2712
+ /**
2713
+ * The Kubernetes cluster to deploy the deobfuscator on.
2714
+ *
2715
+ * @schema
2716
+ */
2717
+ k8sCluster: {
2718
+ ...clusterEntity2,
2719
+ description: `The Kubernetes cluster to deploy the deobfuscator on.`
2720
+ },
2721
+ /**
2722
+ * The L4 endpoint to forward deobfuscated traffic to.
2723
+ *
2724
+ * @schema
2725
+ */
2726
+ targetEndpoint: {
2727
+ ...l4EndpointEntity,
2728
+ description: `The L4 endpoint to forward deobfuscated traffic to.`
2729
+ }
2730
+ },
2731
+ outputs: {
2732
+ /**
2733
+ * The L4 endpoint of the deobfuscator accepting obfuscated traffic.
2734
+ *
2735
+ * @schema
2736
+ */
2737
+ endpoint: {
2738
+ ...l4EndpointEntity,
2739
+ description: `The L4 endpoint of the deobfuscator accepting obfuscated traffic.`
2740
+ }
2741
+ }
2742
+ };
2743
+ var obfuscatorSpec = {
2744
+ args: {
2745
+ /**
2746
+ * The endpoint of the deobfuscator to pass obfuscated traffic to.
2747
+ *
2748
+ * Will take precedence over the `l4Endpoint` input.
2749
+ *
2750
+ * @schema
2751
+ */
2752
+ endpoint: {
2753
+ ...Type26.Optional(Type26.String()),
2754
+ description: `The endpoint of the deobfuscator to pass obfuscated traffic to.
2755
+
2756
+ Will take precedence over the \`l4Endpoint\` input.`
2757
+ }
2758
+ },
2759
+ inputs: {
2760
+ /**
2761
+ * The Kubernetes cluster to deploy the obfuscator on.
2762
+ *
2763
+ * @schema
2764
+ */
2765
+ k8sCluster: {
2766
+ ...clusterEntity2,
2767
+ description: `The Kubernetes cluster to deploy the obfuscator on.`
2768
+ },
2769
+ /**
2770
+ * The L4 endpoint of the deobfuscator to pass obfuscated traffic to.
2771
+ *
2772
+ * @schema
2773
+ */
2774
+ endpoint: {
2775
+ ...{
2776
+ entity: l4EndpointEntity,
2777
+ required: false
2778
+ },
2779
+ description: `The L4 endpoint of the deobfuscator to pass obfuscated traffic to.`
2780
+ }
2781
+ },
2782
+ outputs: {
2783
+ /**
2784
+ * The L4 endpoint accepting unobfuscated traffic.
2785
+ *
2786
+ * @schema
2787
+ */
2788
+ entryEndpoint: {
2789
+ ...l4EndpointEntity,
2790
+ description: `The L4 endpoint accepting unobfuscated traffic.`
2791
+ }
2792
+ }
2793
+ };
2794
+
2795
+ // src/obfuscators/phantun.ts
2796
+ var deobfuscator = defineUnit26({
2797
+ type: "obfuscators.phantun.deobfuscator",
2798
+ ...deobfuscatorSpec,
2799
+ meta: {
2800
+ displayName: "Phantun Deobfuscator",
2801
+ description: "The Phantun Deobfuscator deployed on Kubernetes.",
2802
+ primaryIcon: "mdi:network-outline",
2803
+ secondaryIcon: "mdi:hide"
2804
+ },
2805
+ source: {
2806
+ package: "@highstate/obfuscators",
2807
+ path: "phantun/deobfuscator"
2808
+ }
2809
+ });
2810
+ var obfuscator = defineUnit26({
2811
+ type: "obfuscators.phantun.obfuscator",
2812
+ ...obfuscatorSpec,
2813
+ meta: {
2814
+ displayName: "Phantun Obfuscator",
2815
+ description: "The Phantun Obfuscator deployed on Kubernetes.",
2816
+ primaryIcon: "mdi:network-outline",
2817
+ secondaryIcon: "mdi:hide"
2818
+ },
2819
+ source: {
2820
+ package: "@highstate/obfuscators",
2821
+ path: "phantun/obfuscator"
2822
+ }
2823
+ });
2491
2824
  export {
2492
2825
  apps_exports as apps,
2493
2826
  cloudflare_exports as cloudflare,
@@ -2497,6 +2830,7 @@ export {
2497
2830
  k8s_exports as k8s,
2498
2831
  mullvad_exports as mullvad,
2499
2832
  nixos_exports as nixos,
2833
+ obfuscators_exports as obfuscators,
2500
2834
  proxmox_exports as proxmox,
2501
2835
  restic_exports as restic,
2502
2836
  sops_exports as sops,