@slicervm/sdk 0.1.6 → 0.1.7

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/index.d.cts CHANGED
@@ -27,6 +27,15 @@ interface VMInfo {
27
27
  status?: string;
28
28
  persistent?: boolean;
29
29
  }
30
+ /**
31
+ * Per-launch network policy override for isolated host groups.
32
+ * Omitted lists inherit the host group's policy. Empty lists intentionally
33
+ * clear that list for this VM launch.
34
+ */
35
+ interface CreateVMNetworkPolicy {
36
+ allow?: string[];
37
+ drop?: string[];
38
+ }
30
39
  interface CreateVMRequest {
31
40
  ramBytes?: number;
32
41
  cpus?: number;
@@ -39,6 +48,7 @@ interface CreateVMRequest {
39
48
  ip?: string;
40
49
  tags?: string[];
41
50
  secrets?: string[];
51
+ network?: CreateVMNetworkPolicy;
42
52
  }
43
53
  interface CreateVMResponse {
44
54
  hostname: string;
@@ -685,6 +695,185 @@ declare class SecretsAPI {
685
695
  delete(name: string): Promise<void>;
686
696
  }
687
697
 
698
+ /**
699
+ * Slicer egress-proxy admin API.
700
+ *
701
+ * Three resources:
702
+ * - clients: opaque token holders. Each VM (or other consumer) presents
703
+ * the token via HTTPS_PROXY; the proxy resolves it to the client and
704
+ * walks the client's allow rules.
705
+ * - secrets: upstream credentials (bearer or basic). When an allow rule
706
+ * references a secret, the proxy strips the client's Authorization on
707
+ * the inner request and substitutes the secret's value.
708
+ * - allow rules: per-client. host (exact, *.suffix wildcard, or "*"),
709
+ * optional method/path filters, optional secret reference, optional
710
+ * TTL, optional `passthrough` (TCP-splice CONNECT, no MITM).
711
+ *
712
+ * Calls go through slicerd's `/proxy/v1/*` broker (the same transport
713
+ * SlicerClient already uses for every other API), so no extra
714
+ * configuration is needed beyond a working SlicerClient.
715
+ *
716
+ * Wire shapes mirror the Go SDK at github.com/slicervm/sdk/proxy.go.
717
+ * Field-name conversion (snake_case ↔ camelCase) is handled in the
718
+ * `*FromWire` / `*ToWire` helpers; user-facing types are camelCase.
719
+ */
720
+
721
+ /** Credential type for upstream injection. */
722
+ type ProxySecretType = 'bearer' | 'basic';
723
+ declare const ProxySecretBearer: ProxySecretType;
724
+ /** For basic auth, the secret value must be in `user:pass` form. */
725
+ declare const ProxySecretBasic: ProxySecretType;
726
+ /** A registered proxy client. Tokens are never returned by list/get. */
727
+ interface ProxyClient {
728
+ name: string;
729
+ /** RFC 3339 timestamp. */
730
+ createdAt: string;
731
+ }
732
+ /**
733
+ * Returned only by `clients.create`. The token is shown once and never
734
+ * surfaced by any other endpoint — store it now or rotate the client.
735
+ */
736
+ interface ProxyClientCreated {
737
+ name: string;
738
+ token: string;
739
+ createdAt: string;
740
+ }
741
+ /**
742
+ * Optional input to `clients.create`. Pass `token` to bring your own
743
+ * literal (handy for demos and reproducible tests); omit for a
744
+ * server-minted high-entropy `spt_…` token (recommended).
745
+ */
746
+ interface CreateProxyClientOptions {
747
+ token?: string;
748
+ }
749
+ /** A registered upstream credential. `value` is never returned. */
750
+ interface ProxySecret {
751
+ name: string;
752
+ host: string;
753
+ /** Defaults to `bearer` when empty in older state files. */
754
+ type?: ProxySecretType;
755
+ createdAt: string;
756
+ }
757
+ interface CreateProxySecretRequest {
758
+ name: string;
759
+ host: string;
760
+ /** Defaults to `bearer` when omitted. */
761
+ type?: ProxySecretType;
762
+ /**
763
+ * Plaintext credential. For `bearer`, the raw token. For `basic`,
764
+ * must be in `user:pass` form (the proxy base64-encodes it on the
765
+ * inner request).
766
+ */
767
+ value: string;
768
+ }
769
+ /**
770
+ * Per-client allow entry. First-match-wins by declaration order.
771
+ *
772
+ * - When `secret` is set, the proxy strips the client's Authorization
773
+ * on the inner request and substitutes the secret's value.
774
+ * - `methods`/`paths` are optional filters (any-of within each list,
775
+ * all-of across lists). Empty list = any.
776
+ * - When `passthrough` is true, the proxy splices TCP both ways at
777
+ * CONNECT without terminating TLS. Cert-pinned clients work
778
+ * unchanged. Mutually exclusive with `secret`, `methods`, `paths`;
779
+ * the admin API rejects rules that combine them.
780
+ */
781
+ interface ProxyAllowRule {
782
+ host: string;
783
+ secret?: string;
784
+ methods?: string[];
785
+ paths?: string[];
786
+ /** RFC 3339 timestamp; absent / zero-value when no expiry. */
787
+ expires?: string;
788
+ passthrough?: boolean;
789
+ }
790
+ /** Input to `allows.add`. */
791
+ interface AddProxyAllowRequest {
792
+ client: string;
793
+ host: string;
794
+ secret?: string;
795
+ methods?: string[];
796
+ paths?: string[];
797
+ /**
798
+ * Time-to-live in seconds. 0 / omitted = never expires. Resolved to
799
+ * an absolute `expires` timestamp on the returned rule.
800
+ */
801
+ ttlSeconds?: number;
802
+ /** See ProxyAllowRule.passthrough. Mutually exclusive with secret/methods/paths. */
803
+ passthrough?: boolean;
804
+ }
805
+ /**
806
+ * Input to `allows.removeByTuple`. Mirrors the create payload minus
807
+ * `ttlSeconds` (TTL is mutable lifetime, not part of identity). The
808
+ * proxy matches the rule by (host, methods, paths, passthrough) and
809
+ * removes the single matching rule. Use when several rules share a
810
+ * host and you want surgical removal of one — pass exactly the same
811
+ * fields you used at create time.
812
+ */
813
+ interface RemoveProxyAllowByTupleRequest {
814
+ client: string;
815
+ host: string;
816
+ secret?: string;
817
+ methods?: string[];
818
+ paths?: string[];
819
+ passthrough?: boolean;
820
+ }
821
+ declare class ProxyAPI {
822
+ private readonly transport;
823
+ readonly clients: ProxyClientsAPI;
824
+ readonly secrets: ProxySecretsAPI;
825
+ readonly allows: ProxyAllowsAPI;
826
+ constructor(transport: TransportClient);
827
+ }
828
+ declare class ProxyClientsAPI {
829
+ private readonly transport;
830
+ constructor(transport: TransportClient);
831
+ /** Mint a new proxy client. The returned token is shown once. */
832
+ create(name: string, opts?: CreateProxyClientOptions): Promise<ProxyClientCreated>;
833
+ list(): Promise<ProxyClient[]>;
834
+ /**
835
+ * Revoke the token, drop every allow rule the client owned, and
836
+ * remove the client.
837
+ */
838
+ delete(name: string): Promise<void>;
839
+ /** List a client's allow rules in declaration order (first-match-wins). */
840
+ rules(name: string): Promise<ProxyAllowRule[]>;
841
+ }
842
+ declare class ProxySecretsAPI {
843
+ private readonly transport;
844
+ constructor(transport: TransportClient);
845
+ create(req: CreateProxySecretRequest): Promise<void>;
846
+ list(): Promise<ProxySecret[]>;
847
+ /**
848
+ * Remove a secret. Allow rules that reference it stop matching until
849
+ * the secret is recreated or the rule is rewritten.
850
+ */
851
+ delete(name: string): Promise<void>;
852
+ }
853
+ declare class ProxyAllowsAPI {
854
+ private readonly transport;
855
+ constructor(transport: TransportClient);
856
+ /** Add an allow rule. Returns the resolved rule with absolute `expires`. */
857
+ add(req: AddProxyAllowRequest): Promise<ProxyAllowRule>;
858
+ /**
859
+ * Host-bulk revoke: removes **every** rule on the client whose host
860
+ * matches. For surgical removal of one rule among siblings on the
861
+ * same host (e.g. several path-scoped rules on `github.com`), use
862
+ * `removeByTuple` instead.
863
+ */
864
+ remove(client: string, host: string): Promise<void>;
865
+ /**
866
+ * Surgical revoke: removes the single rule whose
867
+ * (host, methods, paths, passthrough) tuple matches the request.
868
+ * Pass exactly the same fields you used at create time. Method and
869
+ * host casing are normalised server-side, so `"GET"` / `"get"` and
870
+ * `"github.com"` / `"GITHUB.COM"` all match the same stored rule.
871
+ *
872
+ * Returns 404 (surfaced as a SlicerAPIError) when no rule matches.
873
+ */
874
+ removeByTuple(req: RemoveProxyAllowByTupleRequest): Promise<void>;
875
+ }
876
+
688
877
  /**
689
878
  * SlicerClient — grouped TypeScript client for the Slicer VM API.
690
879
  *
@@ -707,6 +896,7 @@ declare class SlicerClient {
707
896
  readonly hostGroups: HostGroupsAPI;
708
897
  readonly vms: VMsAPI;
709
898
  readonly secrets: SecretsAPI;
899
+ readonly proxy: ProxyAPI;
710
900
  constructor(opts: SlicerClientOptions);
711
901
  static fromEnv(overrides?: Partial<SlicerClientOptions>): SlicerClient;
712
902
  getInfo(): Promise<SlicerInfo>;
@@ -778,4 +968,4 @@ declare class SlicerShellSession {
778
968
  private teardown;
779
969
  }
780
970
 
781
- export { type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, type CreateSecretRequest, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
971
+ export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
package/dist/index.d.ts CHANGED
@@ -27,6 +27,15 @@ interface VMInfo {
27
27
  status?: string;
28
28
  persistent?: boolean;
29
29
  }
30
+ /**
31
+ * Per-launch network policy override for isolated host groups.
32
+ * Omitted lists inherit the host group's policy. Empty lists intentionally
33
+ * clear that list for this VM launch.
34
+ */
35
+ interface CreateVMNetworkPolicy {
36
+ allow?: string[];
37
+ drop?: string[];
38
+ }
30
39
  interface CreateVMRequest {
31
40
  ramBytes?: number;
32
41
  cpus?: number;
@@ -39,6 +48,7 @@ interface CreateVMRequest {
39
48
  ip?: string;
40
49
  tags?: string[];
41
50
  secrets?: string[];
51
+ network?: CreateVMNetworkPolicy;
42
52
  }
43
53
  interface CreateVMResponse {
44
54
  hostname: string;
@@ -685,6 +695,185 @@ declare class SecretsAPI {
685
695
  delete(name: string): Promise<void>;
686
696
  }
687
697
 
698
+ /**
699
+ * Slicer egress-proxy admin API.
700
+ *
701
+ * Three resources:
702
+ * - clients: opaque token holders. Each VM (or other consumer) presents
703
+ * the token via HTTPS_PROXY; the proxy resolves it to the client and
704
+ * walks the client's allow rules.
705
+ * - secrets: upstream credentials (bearer or basic). When an allow rule
706
+ * references a secret, the proxy strips the client's Authorization on
707
+ * the inner request and substitutes the secret's value.
708
+ * - allow rules: per-client. host (exact, *.suffix wildcard, or "*"),
709
+ * optional method/path filters, optional secret reference, optional
710
+ * TTL, optional `passthrough` (TCP-splice CONNECT, no MITM).
711
+ *
712
+ * Calls go through slicerd's `/proxy/v1/*` broker (the same transport
713
+ * SlicerClient already uses for every other API), so no extra
714
+ * configuration is needed beyond a working SlicerClient.
715
+ *
716
+ * Wire shapes mirror the Go SDK at github.com/slicervm/sdk/proxy.go.
717
+ * Field-name conversion (snake_case ↔ camelCase) is handled in the
718
+ * `*FromWire` / `*ToWire` helpers; user-facing types are camelCase.
719
+ */
720
+
721
+ /** Credential type for upstream injection. */
722
+ type ProxySecretType = 'bearer' | 'basic';
723
+ declare const ProxySecretBearer: ProxySecretType;
724
+ /** For basic auth, the secret value must be in `user:pass` form. */
725
+ declare const ProxySecretBasic: ProxySecretType;
726
+ /** A registered proxy client. Tokens are never returned by list/get. */
727
+ interface ProxyClient {
728
+ name: string;
729
+ /** RFC 3339 timestamp. */
730
+ createdAt: string;
731
+ }
732
+ /**
733
+ * Returned only by `clients.create`. The token is shown once and never
734
+ * surfaced by any other endpoint — store it now or rotate the client.
735
+ */
736
+ interface ProxyClientCreated {
737
+ name: string;
738
+ token: string;
739
+ createdAt: string;
740
+ }
741
+ /**
742
+ * Optional input to `clients.create`. Pass `token` to bring your own
743
+ * literal (handy for demos and reproducible tests); omit for a
744
+ * server-minted high-entropy `spt_…` token (recommended).
745
+ */
746
+ interface CreateProxyClientOptions {
747
+ token?: string;
748
+ }
749
+ /** A registered upstream credential. `value` is never returned. */
750
+ interface ProxySecret {
751
+ name: string;
752
+ host: string;
753
+ /** Defaults to `bearer` when empty in older state files. */
754
+ type?: ProxySecretType;
755
+ createdAt: string;
756
+ }
757
+ interface CreateProxySecretRequest {
758
+ name: string;
759
+ host: string;
760
+ /** Defaults to `bearer` when omitted. */
761
+ type?: ProxySecretType;
762
+ /**
763
+ * Plaintext credential. For `bearer`, the raw token. For `basic`,
764
+ * must be in `user:pass` form (the proxy base64-encodes it on the
765
+ * inner request).
766
+ */
767
+ value: string;
768
+ }
769
+ /**
770
+ * Per-client allow entry. First-match-wins by declaration order.
771
+ *
772
+ * - When `secret` is set, the proxy strips the client's Authorization
773
+ * on the inner request and substitutes the secret's value.
774
+ * - `methods`/`paths` are optional filters (any-of within each list,
775
+ * all-of across lists). Empty list = any.
776
+ * - When `passthrough` is true, the proxy splices TCP both ways at
777
+ * CONNECT without terminating TLS. Cert-pinned clients work
778
+ * unchanged. Mutually exclusive with `secret`, `methods`, `paths`;
779
+ * the admin API rejects rules that combine them.
780
+ */
781
+ interface ProxyAllowRule {
782
+ host: string;
783
+ secret?: string;
784
+ methods?: string[];
785
+ paths?: string[];
786
+ /** RFC 3339 timestamp; absent / zero-value when no expiry. */
787
+ expires?: string;
788
+ passthrough?: boolean;
789
+ }
790
+ /** Input to `allows.add`. */
791
+ interface AddProxyAllowRequest {
792
+ client: string;
793
+ host: string;
794
+ secret?: string;
795
+ methods?: string[];
796
+ paths?: string[];
797
+ /**
798
+ * Time-to-live in seconds. 0 / omitted = never expires. Resolved to
799
+ * an absolute `expires` timestamp on the returned rule.
800
+ */
801
+ ttlSeconds?: number;
802
+ /** See ProxyAllowRule.passthrough. Mutually exclusive with secret/methods/paths. */
803
+ passthrough?: boolean;
804
+ }
805
+ /**
806
+ * Input to `allows.removeByTuple`. Mirrors the create payload minus
807
+ * `ttlSeconds` (TTL is mutable lifetime, not part of identity). The
808
+ * proxy matches the rule by (host, methods, paths, passthrough) and
809
+ * removes the single matching rule. Use when several rules share a
810
+ * host and you want surgical removal of one — pass exactly the same
811
+ * fields you used at create time.
812
+ */
813
+ interface RemoveProxyAllowByTupleRequest {
814
+ client: string;
815
+ host: string;
816
+ secret?: string;
817
+ methods?: string[];
818
+ paths?: string[];
819
+ passthrough?: boolean;
820
+ }
821
+ declare class ProxyAPI {
822
+ private readonly transport;
823
+ readonly clients: ProxyClientsAPI;
824
+ readonly secrets: ProxySecretsAPI;
825
+ readonly allows: ProxyAllowsAPI;
826
+ constructor(transport: TransportClient);
827
+ }
828
+ declare class ProxyClientsAPI {
829
+ private readonly transport;
830
+ constructor(transport: TransportClient);
831
+ /** Mint a new proxy client. The returned token is shown once. */
832
+ create(name: string, opts?: CreateProxyClientOptions): Promise<ProxyClientCreated>;
833
+ list(): Promise<ProxyClient[]>;
834
+ /**
835
+ * Revoke the token, drop every allow rule the client owned, and
836
+ * remove the client.
837
+ */
838
+ delete(name: string): Promise<void>;
839
+ /** List a client's allow rules in declaration order (first-match-wins). */
840
+ rules(name: string): Promise<ProxyAllowRule[]>;
841
+ }
842
+ declare class ProxySecretsAPI {
843
+ private readonly transport;
844
+ constructor(transport: TransportClient);
845
+ create(req: CreateProxySecretRequest): Promise<void>;
846
+ list(): Promise<ProxySecret[]>;
847
+ /**
848
+ * Remove a secret. Allow rules that reference it stop matching until
849
+ * the secret is recreated or the rule is rewritten.
850
+ */
851
+ delete(name: string): Promise<void>;
852
+ }
853
+ declare class ProxyAllowsAPI {
854
+ private readonly transport;
855
+ constructor(transport: TransportClient);
856
+ /** Add an allow rule. Returns the resolved rule with absolute `expires`. */
857
+ add(req: AddProxyAllowRequest): Promise<ProxyAllowRule>;
858
+ /**
859
+ * Host-bulk revoke: removes **every** rule on the client whose host
860
+ * matches. For surgical removal of one rule among siblings on the
861
+ * same host (e.g. several path-scoped rules on `github.com`), use
862
+ * `removeByTuple` instead.
863
+ */
864
+ remove(client: string, host: string): Promise<void>;
865
+ /**
866
+ * Surgical revoke: removes the single rule whose
867
+ * (host, methods, paths, passthrough) tuple matches the request.
868
+ * Pass exactly the same fields you used at create time. Method and
869
+ * host casing are normalised server-side, so `"GET"` / `"get"` and
870
+ * `"github.com"` / `"GITHUB.COM"` all match the same stored rule.
871
+ *
872
+ * Returns 404 (surfaced as a SlicerAPIError) when no rule matches.
873
+ */
874
+ removeByTuple(req: RemoveProxyAllowByTupleRequest): Promise<void>;
875
+ }
876
+
688
877
  /**
689
878
  * SlicerClient — grouped TypeScript client for the Slicer VM API.
690
879
  *
@@ -707,6 +896,7 @@ declare class SlicerClient {
707
896
  readonly hostGroups: HostGroupsAPI;
708
897
  readonly vms: VMsAPI;
709
898
  readonly secrets: SecretsAPI;
899
+ readonly proxy: ProxyAPI;
710
900
  constructor(opts: SlicerClientOptions);
711
901
  static fromEnv(overrides?: Partial<SlicerClientOptions>): SlicerClient;
712
902
  getInfo(): Promise<SlicerInfo>;
@@ -778,4 +968,4 @@ declare class SlicerShellSession {
778
968
  private teardown;
779
969
  }
780
970
 
781
- export { type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, type CreateSecretRequest, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
971
+ export { type AddProxyAllowRequest, type AddressMapping, type AgentHealth, type BgDeleteResponse, type BgExecInfo, type BgExecRequest, type BgExecResponse, type BgKillOptions, type BgKillResponse, type BgLogOptions, type BgWaitExitResponse, type CreateProxyClientOptions, type CreateProxySecretRequest, type CreateSecretRequest, type CreateVMNetworkPolicy, type CreateVMOptions, type CreateVMRequest, type CreateVMResponse, type DeleteResponse, type ExecFrame, type ExecRequest, type ExecResult, type ExecResultBinary, type ExecStdio, ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, type FSEntry, type FSMkdirRequest, type FSWatchEvent, type FSWatchEventType, type FSWatchRequest, Forwarder, type ForwarderListener, type ForwarderOptions, GiB, type HostGroup, HostGroupsAPI, type ListOptions, MiB, NonRootUser, ProxyAPI, type ProxyAllowRule, ProxyAllowsAPI, type ProxyClient, type ProxyClientCreated, ProxyClientsAPI, type ProxySecret, ProxySecretBasic, ProxySecretBearer, type ProxySecretType, ProxySecretsAPI, type RemoveProxyAllowByTupleRequest, type Secret, SecretExistsError, SecretsAPI, type ShellSessionOptions, type ShutdownRequest, SlicerAPIError, SlicerClient, type SlicerClientOptions, type SlicerInfo, SlicerShellSession, type UpdateSecretRequest, VM, VMBg, VMFileSystem, type VMInfo, type VMInit, type VMLogs, type VMSnapshot, type VMStat, VMsAPI, type WaitOptions, type XTermLike, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
package/dist/index.js CHANGED
@@ -255,6 +255,7 @@ function createVMReqToWire(r) {
255
255
  if (r.ip !== void 0) o.ip = r.ip;
256
256
  if (r.tags !== void 0) o.tags = r.tags;
257
257
  if (r.secrets !== void 0) o.secrets = r.secrets;
258
+ if (r.network !== void 0) o.network = r.network;
258
259
  return o;
259
260
  }
260
261
  function createVMResFromWire(w) {
@@ -1251,17 +1252,173 @@ function buildListQuery(opts) {
1251
1252
  return s ? `?${s}` : "";
1252
1253
  }
1253
1254
 
1255
+ // src/proxy.ts
1256
+ var ProxySecretBearer = "bearer";
1257
+ var ProxySecretBasic = "basic";
1258
+ function clientFromWire(w) {
1259
+ return { name: w.name, createdAt: w.created_at };
1260
+ }
1261
+ function clientCreatedFromWire(w) {
1262
+ return { name: w.name, token: w.token, createdAt: w.created_at };
1263
+ }
1264
+ function secretFromWire2(w) {
1265
+ const out = { name: w.name, host: w.host, createdAt: w.created_at };
1266
+ if (w.type) out.type = w.type;
1267
+ return out;
1268
+ }
1269
+ function ruleFromWire(w) {
1270
+ const out = { host: w.host };
1271
+ if (w.secret) out.secret = w.secret;
1272
+ if (w.methods && w.methods.length > 0) out.methods = w.methods;
1273
+ if (w.paths && w.paths.length > 0) out.paths = w.paths;
1274
+ if (w.expires && w.expires !== "0001-01-01T00:00:00Z") out.expires = w.expires;
1275
+ if (w.passthrough) out.passthrough = w.passthrough;
1276
+ return out;
1277
+ }
1278
+ var ProxyAPI = class {
1279
+ constructor(transport) {
1280
+ this.transport = transport;
1281
+ this.clients = new ProxyClientsAPI(transport);
1282
+ this.secrets = new ProxySecretsAPI(transport);
1283
+ this.allows = new ProxyAllowsAPI(transport);
1284
+ }
1285
+ transport;
1286
+ clients;
1287
+ secrets;
1288
+ allows;
1289
+ };
1290
+ var ProxyClientsAPI = class {
1291
+ constructor(transport) {
1292
+ this.transport = transport;
1293
+ }
1294
+ transport;
1295
+ /** Mint a new proxy client. The returned token is shown once. */
1296
+ async create(name, opts = {}) {
1297
+ const body = { name };
1298
+ if (opts.token) body.token = opts.token;
1299
+ const wire = await this.transport.request(
1300
+ "POST",
1301
+ "/proxy/v1/clients",
1302
+ body
1303
+ );
1304
+ return clientCreatedFromWire(wire);
1305
+ }
1306
+ async list() {
1307
+ const wire = await this.transport.request("GET", "/proxy/v1/clients");
1308
+ return (wire ?? []).map(clientFromWire);
1309
+ }
1310
+ /**
1311
+ * Revoke the token, drop every allow rule the client owned, and
1312
+ * remove the client.
1313
+ */
1314
+ async delete(name) {
1315
+ await this.transport.request("DELETE", `/proxy/v1/clients/${encodeURIComponent(name)}`);
1316
+ }
1317
+ /** List a client's allow rules in declaration order (first-match-wins). */
1318
+ async rules(name) {
1319
+ const wire = await this.transport.request(
1320
+ "GET",
1321
+ `/proxy/v1/clients/${encodeURIComponent(name)}`
1322
+ );
1323
+ return (wire ?? []).map(ruleFromWire);
1324
+ }
1325
+ };
1326
+ var ProxySecretsAPI = class {
1327
+ constructor(transport) {
1328
+ this.transport = transport;
1329
+ }
1330
+ transport;
1331
+ async create(req) {
1332
+ const body = {
1333
+ name: req.name,
1334
+ host: req.host,
1335
+ value: req.value
1336
+ };
1337
+ if (req.type) body.type = req.type;
1338
+ await this.transport.request("POST", "/proxy/v1/secrets", body);
1339
+ }
1340
+ async list() {
1341
+ const wire = await this.transport.request("GET", "/proxy/v1/secrets");
1342
+ return (wire ?? []).map(secretFromWire2);
1343
+ }
1344
+ /**
1345
+ * Remove a secret. Allow rules that reference it stop matching until
1346
+ * the secret is recreated or the rule is rewritten.
1347
+ */
1348
+ async delete(name) {
1349
+ await this.transport.request("DELETE", `/proxy/v1/secrets/${encodeURIComponent(name)}`);
1350
+ }
1351
+ };
1352
+ var ProxyAllowsAPI = class {
1353
+ constructor(transport) {
1354
+ this.transport = transport;
1355
+ }
1356
+ transport;
1357
+ /** Add an allow rule. Returns the resolved rule with absolute `expires`. */
1358
+ async add(req) {
1359
+ const body = {
1360
+ client: req.client,
1361
+ host: req.host
1362
+ };
1363
+ if (req.secret) body.secret = req.secret;
1364
+ if (req.methods && req.methods.length > 0) body.methods = req.methods;
1365
+ if (req.paths && req.paths.length > 0) body.paths = req.paths;
1366
+ if (req.ttlSeconds && req.ttlSeconds > 0) body.ttl_seconds = req.ttlSeconds;
1367
+ if (req.passthrough) body.passthrough = true;
1368
+ const wire = await this.transport.request(
1369
+ "POST",
1370
+ "/proxy/v1/allows",
1371
+ body
1372
+ );
1373
+ return ruleFromWire(wire);
1374
+ }
1375
+ /**
1376
+ * Host-bulk revoke: removes **every** rule on the client whose host
1377
+ * matches. For surgical removal of one rule among siblings on the
1378
+ * same host (e.g. several path-scoped rules on `github.com`), use
1379
+ * `removeByTuple` instead.
1380
+ */
1381
+ async remove(client, host) {
1382
+ await this.transport.request(
1383
+ "DELETE",
1384
+ `/proxy/v1/allows/${encodeURIComponent(client)}/${encodeURIComponent(host)}`
1385
+ );
1386
+ }
1387
+ /**
1388
+ * Surgical revoke: removes the single rule whose
1389
+ * (host, methods, paths, passthrough) tuple matches the request.
1390
+ * Pass exactly the same fields you used at create time. Method and
1391
+ * host casing are normalised server-side, so `"GET"` / `"get"` and
1392
+ * `"github.com"` / `"GITHUB.COM"` all match the same stored rule.
1393
+ *
1394
+ * Returns 404 (surfaced as a SlicerAPIError) when no rule matches.
1395
+ */
1396
+ async removeByTuple(req) {
1397
+ const body = {
1398
+ client: req.client,
1399
+ host: req.host
1400
+ };
1401
+ if (req.secret) body.secret = req.secret;
1402
+ if (req.methods && req.methods.length > 0) body.methods = req.methods;
1403
+ if (req.paths && req.paths.length > 0) body.paths = req.paths;
1404
+ if (req.passthrough) body.passthrough = true;
1405
+ await this.transport.request("POST", "/proxy/v1/allows/revoke", body);
1406
+ }
1407
+ };
1408
+
1254
1409
  // src/client.ts
1255
1410
  var SlicerClient = class _SlicerClient {
1256
1411
  transport;
1257
1412
  hostGroups;
1258
1413
  vms;
1259
1414
  secrets;
1415
+ proxy;
1260
1416
  constructor(opts) {
1261
1417
  this.transport = new TransportClient(opts);
1262
1418
  this.hostGroups = new HostGroupsAPI(this.transport);
1263
1419
  this.vms = new VMsAPI(this.transport);
1264
1420
  this.secrets = new SecretsAPI(this.transport);
1421
+ this.proxy = new ProxyAPI(this.transport);
1265
1422
  }
1266
1423
  static fromEnv(overrides = {}) {
1267
1424
  const baseURL = overrides.baseURL ?? process.env.SLICER_URL;
@@ -1418,6 +1575,6 @@ var SlicerShellSession = class {
1418
1575
  }
1419
1576
  };
1420
1577
 
1421
- export { ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, Forwarder, GiB, HostGroupsAPI, MiB, NonRootUser, SecretExistsError, SecretsAPI, SlicerAPIError, SlicerClient, SlicerShellSession, VM, VMBg, VMFileSystem, VMsAPI, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
1578
+ export { ExecStdioBase64, ExecStdioText, FRAME_TYPE_DATA, FRAME_TYPE_HEARTBEAT, FRAME_TYPE_SESSION_CLOSE, FRAME_TYPE_SHUTDOWN, FRAME_TYPE_WINDOW_SIZE, Forwarder, GiB, HostGroupsAPI, MiB, NonRootUser, ProxyAPI, ProxyAllowsAPI, ProxyClientsAPI, ProxySecretBasic, ProxySecretBearer, ProxySecretsAPI, SecretExistsError, SecretsAPI, SlicerAPIError, SlicerClient, SlicerShellSession, VM, VMBg, VMFileSystem, VMsAPI, encodeFrame, parseAddressMapping, parseFrame, resolveTransport };
1422
1579
  //# sourceMappingURL=index.js.map
1423
1580
  //# sourceMappingURL=index.js.map