@highstate/library 0.8.0 → 0.9.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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "sourceHashes": {
3
- "./dist/index.js": "87b93b45d5c7ee264151628635db26d22961524bc86f599c8bfb9655f27980e9"
3
+ "./dist/index.js": "96273d947e9e36f05c2bcbe5a88585cf5a7ce7107623d4ec834e4dc9ce86418a"
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
  /**
@@ -954,7 +1003,7 @@ var network = defineUnit7({
954
1003
  * @schema
955
1004
  */
956
1005
  backend: {
957
- ...backendSchema,
1006
+ ...Type7.Default(backendSchema, "wireguard"),
958
1007
  description: `The backend to use for the WireGuard network.
959
1008
 
960
1009
  Possible values are:
@@ -1216,7 +1265,7 @@ var peer = defineUnit7({
1216
1265
  * @schema
1217
1266
  */
1218
1267
  publicKey: {
1219
- ...Type7.String(),
1268
+ ...Type7.Optional(Type7.String()),
1220
1269
  description: `The public key of the WireGuard peer.`
1221
1270
  }
1222
1271
  },
@@ -1236,6 +1285,34 @@ var peer = defineUnit7({
1236
1285
  description: `The network to use for the WireGuard peer.
1237
1286
 
1238
1287
  If not provided, the peer will use default network configuration.`
1288
+ },
1289
+ /**
1290
+ * The existing WireGuard peer to extend.
1291
+ *
1292
+ * @schema
1293
+ */
1294
+ peer: {
1295
+ ...{
1296
+ entity: peerEntity,
1297
+ required: false
1298
+ },
1299
+ description: `The existing WireGuard peer to extend.`
1300
+ },
1301
+ /**
1302
+ * The L4 endpoint of the peer.
1303
+ *
1304
+ * Will take priority over all calculated endpoints if provided.
1305
+ *
1306
+ * @schema
1307
+ */
1308
+ l4Endpoint: {
1309
+ ...{
1310
+ entity: l4EndpointEntity,
1311
+ required: false
1312
+ },
1313
+ description: `The L4 endpoint of the peer.
1314
+
1315
+ Will take priority over all calculated endpoints if provided.`
1239
1316
  }
1240
1317
  },
1241
1318
  outputs: {
@@ -1289,6 +1366,8 @@ var identity = defineUnit7({
1289
1366
  *
1290
1367
  * If overridden, does not affect node which implements the identity, but is used in the peer configuration of other nodes.
1291
1368
  *
1369
+ * Will take priority over all calculated endpoints and `l4Endpoint` input.
1370
+ *
1292
1371
  * @schema
1293
1372
  */
1294
1373
  endpoint: {
@@ -1297,7 +1376,9 @@ var identity = defineUnit7({
1297
1376
 
1298
1377
  By default, the endpoint is calculated as \`externalIp:listenPort\`.
1299
1378
 
1300
- If overridden, does not affect node which implements the identity, but is used in the peer configuration of other nodes.`
1379
+ If overridden, does not affect node which implements the identity, but is used in the peer configuration of other nodes.
1380
+
1381
+ Will take priority over all calculated endpoints and \`l4Endpoint\` input.`
1301
1382
  },
1302
1383
  /**
1303
1384
  * The FQDN of the WireGuard identity.
@@ -1317,7 +1398,7 @@ var identity = defineUnit7({
1317
1398
  the FQDN will be registered with the DNS provider.`
1318
1399
  },
1319
1400
  /**
1320
- * Whether to register the FQDN of the identity with the DNS provider.
1401
+ * Whether to register the FQDN of the identity with the matching DNS providers.
1321
1402
  *
1322
1403
  * By default, `true`.
1323
1404
  *
@@ -1325,7 +1406,7 @@ var identity = defineUnit7({
1325
1406
  */
1326
1407
  registerFqdn: {
1327
1408
  ...Type7.Default(Type7.Boolean(), true),
1328
- description: `Whether to register the FQDN of the identity with the DNS provider.
1409
+ description: `Whether to register the FQDN of the identity with the matching DNS providers.
1329
1410
 
1330
1411
  By default, \`true\`.`
1331
1412
  }
@@ -1396,19 +1477,55 @@ var identity = defineUnit7({
1396
1477
  * The Kubernetes cluster associated with the identity.
1397
1478
  *
1398
1479
  * If provided, will be used to obtain the external IP or FQDN of the identity.
1480
+ *
1481
+ * @schema
1399
1482
  */
1400
1483
  k8sCluster: {
1401
- entity: clusterEntity2,
1402
- required: false
1484
+ ...{
1485
+ entity: clusterEntity2,
1486
+ required: false
1487
+ },
1488
+ description: `The Kubernetes cluster associated with the identity.
1489
+
1490
+ If provided, will be used to obtain the external IP or FQDN of the identity.`
1403
1491
  },
1404
- dnsProvider: {
1405
- entity: providerEntity,
1406
- required: false
1492
+ /**
1493
+ * The L4 endpoint of the identity.
1494
+ *
1495
+ * Will take priority over all calculated endpoints if provided.
1496
+ *
1497
+ * @schema
1498
+ */
1499
+ l4Endpoint: {
1500
+ ...{
1501
+ entity: l4EndpointEntity,
1502
+ required: false
1503
+ },
1504
+ description: `The L4 endpoint of the identity.
1505
+
1506
+ Will take priority over all calculated endpoints if provided.`
1507
+ },
1508
+ /**
1509
+ * The DNS providers to register the FQDN of the identity with.
1510
+ *
1511
+ * @schema
1512
+ */
1513
+ dnsProviders: {
1514
+ ...{
1515
+ entity: providerEntity,
1516
+ required: false,
1517
+ multiple: true
1518
+ },
1519
+ description: `The DNS providers to register the FQDN of the identity with.`
1407
1520
  }
1408
1521
  },
1409
1522
  outputs: {
1410
1523
  identity: identityEntity,
1411
- peer: peerEntity
1524
+ peer: peerEntity,
1525
+ l4Endpoint: {
1526
+ entity: l4EndpointEntity,
1527
+ required: false
1528
+ }
1412
1529
  },
1413
1530
  meta: {
1414
1531
  description: "The WireGuard identity with the public key.",
@@ -2215,7 +2332,16 @@ var peer2 = defineUnit22({
2215
2332
  type: "mullvad.peer",
2216
2333
  args: {
2217
2334
  hostname: Type22.Optional(Type22.String()),
2218
- endpointType: Type22.Optional({ ...endpointType, default: "fqdn" })
2335
+ endpointType: Type22.Optional({ ...endpointType, default: "fqdn" }),
2336
+ /**
2337
+ * Whether to include Mullvad DNS servers in the peer configuration.
2338
+ *
2339
+ * @schema
2340
+ */
2341
+ includeDns: {
2342
+ ...Type22.Default(Type22.Boolean(), true),
2343
+ description: `Whether to include Mullvad DNS servers in the peer configuration.`
2344
+ }
2219
2345
  },
2220
2346
  inputs: {
2221
2347
  /**
@@ -2229,7 +2355,8 @@ var peer2 = defineUnit22({
2229
2355
  }
2230
2356
  },
2231
2357
  outputs: {
2232
- peer: peerEntity
2358
+ peer: peerEntity,
2359
+ l4Endpoint: l4EndpointEntity
2233
2360
  },
2234
2361
  meta: {
2235
2362
  displayName: "Mullvad Peer",
@@ -2488,6 +2615,152 @@ var secrets = defineUnit25({
2488
2615
  path: "secrets"
2489
2616
  }
2490
2617
  });
2618
+
2619
+ // src/obfuscators/index.ts
2620
+ var obfuscators_exports = {};
2621
+ __export(obfuscators_exports, {
2622
+ phantun: () => phantun_exports
2623
+ });
2624
+
2625
+ // src/obfuscators/phantun.ts
2626
+ var phantun_exports = {};
2627
+ __export(phantun_exports, {
2628
+ deobfuscator: () => deobfuscator,
2629
+ obfuscator: () => obfuscator
2630
+ });
2631
+ import { defineUnit as defineUnit26 } from "@highstate/contract";
2632
+
2633
+ // src/obfuscators/shared.ts
2634
+ import { Type as Type26 } from "@sinclair/typebox";
2635
+ var deobfuscatorSpec = {
2636
+ args: {
2637
+ /**
2638
+ * The L4 endpoint to forward deobfuscated traffic to.
2639
+ *
2640
+ * Will take precedence over the `targetEndpoint` input.
2641
+ *
2642
+ * @schema
2643
+ */
2644
+ targetEndpoint: {
2645
+ ...Type26.Optional(Type26.String()),
2646
+ description: `The L4 endpoint to forward deobfuscated traffic to.
2647
+
2648
+ Will take precedence over the \`targetEndpoint\` input.`
2649
+ }
2650
+ },
2651
+ inputs: {
2652
+ /**
2653
+ * The Kubernetes cluster to deploy the deobfuscator on.
2654
+ *
2655
+ * @schema
2656
+ */
2657
+ k8sCluster: {
2658
+ ...clusterEntity2,
2659
+ description: `The Kubernetes cluster to deploy the deobfuscator on.`
2660
+ },
2661
+ /**
2662
+ * The L4 endpoint to forward deobfuscated traffic to.
2663
+ *
2664
+ * @schema
2665
+ */
2666
+ targetEndpoint: {
2667
+ ...l4EndpointEntity,
2668
+ description: `The L4 endpoint to forward deobfuscated traffic to.`
2669
+ }
2670
+ },
2671
+ outputs: {
2672
+ /**
2673
+ * The L4 endpoint of the deobfuscator accepting obfuscated traffic.
2674
+ *
2675
+ * @schema
2676
+ */
2677
+ endpoint: {
2678
+ ...l4EndpointEntity,
2679
+ description: `The L4 endpoint of the deobfuscator accepting obfuscated traffic.`
2680
+ }
2681
+ }
2682
+ };
2683
+ var obfuscatorSpec = {
2684
+ args: {
2685
+ /**
2686
+ * The endpoint of the deobfuscator to pass obfuscated traffic to.
2687
+ *
2688
+ * Will take precedence over the `l4Endpoint` input.
2689
+ *
2690
+ * @schema
2691
+ */
2692
+ endpoint: {
2693
+ ...Type26.Optional(Type26.String()),
2694
+ description: `The endpoint of the deobfuscator to pass obfuscated traffic to.
2695
+
2696
+ Will take precedence over the \`l4Endpoint\` input.`
2697
+ }
2698
+ },
2699
+ inputs: {
2700
+ /**
2701
+ * The Kubernetes cluster to deploy the obfuscator on.
2702
+ *
2703
+ * @schema
2704
+ */
2705
+ k8sCluster: {
2706
+ ...clusterEntity2,
2707
+ description: `The Kubernetes cluster to deploy the obfuscator on.`
2708
+ },
2709
+ /**
2710
+ * The L4 endpoint of the deobfuscator to pass obfuscated traffic to.
2711
+ *
2712
+ * @schema
2713
+ */
2714
+ endpoint: {
2715
+ ...{
2716
+ entity: l4EndpointEntity,
2717
+ required: false
2718
+ },
2719
+ description: `The L4 endpoint of the deobfuscator to pass obfuscated traffic to.`
2720
+ }
2721
+ },
2722
+ outputs: {
2723
+ /**
2724
+ * The L4 endpoint accepting unobfuscated traffic.
2725
+ *
2726
+ * @schema
2727
+ */
2728
+ entryEndpoint: {
2729
+ ...l4EndpointEntity,
2730
+ description: `The L4 endpoint accepting unobfuscated traffic.`
2731
+ }
2732
+ }
2733
+ };
2734
+
2735
+ // src/obfuscators/phantun.ts
2736
+ var deobfuscator = defineUnit26({
2737
+ type: "obfuscators.phantun.deobfuscator",
2738
+ ...deobfuscatorSpec,
2739
+ meta: {
2740
+ displayName: "Phantun Deobfuscator",
2741
+ description: "The Phantun Deobfuscator deployed on Kubernetes.",
2742
+ primaryIcon: "mdi:network-outline",
2743
+ secondaryIcon: "mdi:hide"
2744
+ },
2745
+ source: {
2746
+ package: "@highstate/obfuscators",
2747
+ path: "phantun/deobfuscator"
2748
+ }
2749
+ });
2750
+ var obfuscator = defineUnit26({
2751
+ type: "obfuscators.phantun.obfuscator",
2752
+ ...obfuscatorSpec,
2753
+ meta: {
2754
+ displayName: "Phantun Obfuscator",
2755
+ description: "The Phantun Obfuscator deployed on Kubernetes.",
2756
+ primaryIcon: "mdi:network-outline",
2757
+ secondaryIcon: "mdi:hide"
2758
+ },
2759
+ source: {
2760
+ package: "@highstate/obfuscators",
2761
+ path: "phantun/obfuscator"
2762
+ }
2763
+ });
2491
2764
  export {
2492
2765
  apps_exports as apps,
2493
2766
  cloudflare_exports as cloudflare,
@@ -2497,6 +2770,7 @@ export {
2497
2770
  k8s_exports as k8s,
2498
2771
  mullvad_exports as mullvad,
2499
2772
  nixos_exports as nixos,
2773
+ obfuscators_exports as obfuscators,
2500
2774
  proxmox_exports as proxmox,
2501
2775
  restic_exports as restic,
2502
2776
  sops_exports as sops,