@krovacloud/sdk 0.4.11 → 0.4.12

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/CHANGELOG.md CHANGED
@@ -7,8 +7,19 @@ All notable changes to `@krovacloud/sdk` are documented here. This project adher
7
7
 
8
8
  ## Unreleased
9
9
 
10
+ ### Added
11
+
12
+ - `proxyProtocol` (`"v1"`, `"v2"` or `null`) on `domains.create()` and
13
+ `domains.update()`, and on every returned `Domain`, which now also carries
14
+ `originScheme`. `confirmMixedProxyProtocol: true` saves a setting that differs
15
+ from other domains on the same Cube port; without it that save is a `409`
16
+ naming them. Types regenerated from the API's spec.
17
+
10
18
  ### Changed
11
19
 
20
+ - The README no longer says HTTPS to the Cube is verified before it applies: the
21
+ API now applies it as saved.
22
+
12
23
  - **BREAKING** — `KrovaErrorBody` no longer has an open `[key: string]: unknown`
13
24
  index signature; only `error?: string` is part of the public shape. The
14
25
  documented API contract (`components.schemas.Error` in the bundled OpenAPI
package/README.md CHANGED
@@ -373,9 +373,28 @@ await krova.domains.update(spaceId, cubeId, mappingId, {
373
373
  ```
374
374
 
375
375
  The dial port is derived: `https` on the default port 80 connects on 443, and a
376
- deliberate custom port is honoured exactly. The setting is verified against the
377
- Cube before it is applied — if the domain does not serve, the route is left on
378
- `http`.
376
+ deliberate custom port is honored exactly. The setting applies as saved, with no
377
+ check: if nothing in the Cube answers HTTPS for the domain, visitors get an
378
+ error page until you set it back to `http`.
379
+
380
+ ## Custom domains: the visitor's address on the connection
381
+
382
+ The edge always passes the visitor's address in the `X-Real-IP` and
383
+ `X-Forwarded-For` headers. For software that reads it from the TCP connection
384
+ instead, set `proxyProtocol` to `"v1"` (a line of text) or `"v2"` (binary): the
385
+ edge then sends a PROXY protocol header naming the visitor at the start of every
386
+ connection to the Cube. `null` turns it off.
387
+
388
+ ```ts
389
+ await krova.domains.update(spaceId, cubeId, mappingId, { proxyProtocol: "v2" });
390
+ ```
391
+
392
+ The app must accept the PROXY protocol on that port before you turn it on, or
393
+ every request to the domain fails. An app accepts it per port, so every domain
394
+ mapped to the same Cube port needs the same setting: a create or update that
395
+ would mix them is rejected with a `409` whose message names the other domains.
396
+ Send `confirmMixedProxyProtocol: true` to save anyway, when the app handles both
397
+ on that port.
379
398
 
380
399
  ## License
381
400
 
package/dist/index.d.cts CHANGED
@@ -918,6 +918,8 @@ interface paths {
918
918
  basicAuthPassword?: string;
919
919
  /** @description HTTP Basic Auth username. Null/empty clears Basic Auth. Setting it requires basicAuthPassword. */
920
920
  basicAuthUser?: string | null;
921
+ /** @description Accept a save that leaves domains on the same cube port with different proxyProtocol settings (for an app that handles both on one port, or mid-migration). Not stored. */
922
+ confirmMixedProxyProtocol?: boolean;
921
923
  /** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or stopped cube is never CORS-masked. */
922
924
  corsConfig?: {
923
925
  /** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
@@ -942,12 +944,17 @@ interface paths {
942
944
  /** @description Max request body size (MB). Null = unlimited (default). */
943
945
  maxRequestBodyMb?: number | null;
944
946
  /**
945
- * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
947
+ * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honored exactly. Applied as saved: if the cube does not serve this hostname over HTTPS, requests to the domain fail until you set it back to http.
946
948
  * @enum {string}
947
949
  */
948
950
  originScheme?: "http" | "https";
949
951
  /** @description Cube port the domain proxies to. */
950
952
  port: number;
953
+ /**
954
+ * @description Send a PROXY protocol header (v1 text or v2 binary) at the start of every connection to the cube, so the app reads the visitor's address from the connection itself, as on a plain VPS. Null (default) = off. The app must accept PROXY protocol on this port, or every request to the domain fails; it is applied as saved. Every domain on the same cube port must use the same setting: a save that would mix them is refused with 409 unless confirmMixedProxyProtocol is true.
955
+ * @enum {string|null}
956
+ */
957
+ proxyProtocol?: "v1" | "v2" | null;
951
958
  /** @description Header rewrites: `set` adds/overwrites, `remove` deletes. Null clears all. */
952
959
  requestHeaderOverrides?: {
953
960
  remove?: string[];
@@ -988,6 +995,13 @@ interface paths {
988
995
  };
989
996
  };
990
997
  400: components["responses"]["BadRequest"];
998
+ /** @description Refused. Among other reasons (the domain is in use, or is being removed): the save would leave domains on the same cube port with different proxyProtocol settings. Then `errorMeta.code` is `proxy_protocol_port_mismatch`, with `errorMeta.port` and `errorMeta.domains` naming the other domains. Change them together, or resend with confirmMixedProxyProtocol: true. */
999
+ 409: {
1000
+ headers: {
1001
+ [name: string]: unknown;
1002
+ };
1003
+ content?: never;
1004
+ };
991
1005
  429: components["responses"]["RateLimited"];
992
1006
  };
993
1007
  };
@@ -1059,6 +1073,8 @@ interface paths {
1059
1073
  basicAuthPassword?: string;
1060
1074
  /** @description HTTP Basic Auth username. Null/empty clears Basic Auth. Setting it requires basicAuthPassword. */
1061
1075
  basicAuthUser?: string | null;
1076
+ /** @description Accept a save that leaves domains on the same cube port with different proxyProtocol settings (for an app that handles both on one port, or mid-migration). Not stored. */
1077
+ confirmMixedProxyProtocol?: boolean;
1062
1078
  /** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or stopped cube is never CORS-masked. */
1063
1079
  corsConfig?: {
1064
1080
  /** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
@@ -1081,10 +1097,15 @@ interface paths {
1081
1097
  /** @description Max request body size (MB). Null = unlimited (default). */
1082
1098
  maxRequestBodyMb?: number | null;
1083
1099
  /**
1084
- * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
1100
+ * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honored exactly. Applied as saved: if the cube does not serve this hostname over HTTPS, requests to the domain fail until you set it back to http.
1085
1101
  * @enum {string}
1086
1102
  */
1087
1103
  originScheme?: "http" | "https";
1104
+ /**
1105
+ * @description Send a PROXY protocol header (v1 text or v2 binary) at the start of every connection to the cube, so the app reads the visitor's address from the connection itself, as on a plain VPS. Null (default) = off. The app must accept PROXY protocol on this port, or every request to the domain fails; it is applied as saved. Every domain on the same cube port must use the same setting: a save that would mix them is refused with 409 unless confirmMixedProxyProtocol is true.
1106
+ * @enum {string|null}
1107
+ */
1108
+ proxyProtocol?: "v1" | "v2" | null;
1088
1109
  /** @description Header rewrites: `set` adds/overwrites, `remove` deletes. Null clears all. */
1089
1110
  requestHeaderOverrides?: {
1090
1111
  remove?: string[];
@@ -1125,6 +1146,13 @@ interface paths {
1125
1146
  };
1126
1147
  400: components["responses"]["BadRequest"];
1127
1148
  404: components["responses"]["NotFound"];
1149
+ /** @description Refused. Among other reasons (the domain is in use, or is being removed): the save would leave domains on the same cube port with different proxyProtocol settings. Then `errorMeta.code` is `proxy_protocol_port_mismatch`, with `errorMeta.port` and `errorMeta.domains` naming the other domains. Change them together, or resend with confirmMixedProxyProtocol: true. */
1150
+ 409: {
1151
+ headers: {
1152
+ [name: string]: unknown;
1153
+ };
1154
+ content?: never;
1155
+ };
1128
1156
  429: components["responses"]["RateLimited"];
1129
1157
  };
1130
1158
  };
@@ -1960,7 +1988,11 @@ interface components {
1960
1988
  ipDenyList: string[] | null;
1961
1989
  isWildcard: boolean;
1962
1990
  maxRequestBodyMb: number | null;
1991
+ /** @enum {string} */
1992
+ originScheme: "http" | "https";
1963
1993
  port: number | null;
1994
+ /** @enum {string|null} */
1995
+ proxyProtocol: "v1" | "v2" | null;
1964
1996
  /** @description Header rewrites: `set` adds/overwrites, `remove` deletes. Null clears all. */
1965
1997
  requestHeaderOverrides: {
1966
1998
  remove?: string[];
package/dist/index.d.ts CHANGED
@@ -918,6 +918,8 @@ interface paths {
918
918
  basicAuthPassword?: string;
919
919
  /** @description HTTP Basic Auth username. Null/empty clears Basic Auth. Setting it requires basicAuthPassword. */
920
920
  basicAuthUser?: string | null;
921
+ /** @description Accept a save that leaves domains on the same cube port with different proxyProtocol settings (for an app that handles both on one port, or mid-migration). Not stored. */
922
+ confirmMixedProxyProtocol?: boolean;
921
923
  /** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or stopped cube is never CORS-masked. */
922
924
  corsConfig?: {
923
925
  /** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
@@ -942,12 +944,17 @@ interface paths {
942
944
  /** @description Max request body size (MB). Null = unlimited (default). */
943
945
  maxRequestBodyMb?: number | null;
944
946
  /**
945
- * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
947
+ * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honored exactly. Applied as saved: if the cube does not serve this hostname over HTTPS, requests to the domain fail until you set it back to http.
946
948
  * @enum {string}
947
949
  */
948
950
  originScheme?: "http" | "https";
949
951
  /** @description Cube port the domain proxies to. */
950
952
  port: number;
953
+ /**
954
+ * @description Send a PROXY protocol header (v1 text or v2 binary) at the start of every connection to the cube, so the app reads the visitor's address from the connection itself, as on a plain VPS. Null (default) = off. The app must accept PROXY protocol on this port, or every request to the domain fails; it is applied as saved. Every domain on the same cube port must use the same setting: a save that would mix them is refused with 409 unless confirmMixedProxyProtocol is true.
955
+ * @enum {string|null}
956
+ */
957
+ proxyProtocol?: "v1" | "v2" | null;
951
958
  /** @description Header rewrites: `set` adds/overwrites, `remove` deletes. Null clears all. */
952
959
  requestHeaderOverrides?: {
953
960
  remove?: string[];
@@ -988,6 +995,13 @@ interface paths {
988
995
  };
989
996
  };
990
997
  400: components["responses"]["BadRequest"];
998
+ /** @description Refused. Among other reasons (the domain is in use, or is being removed): the save would leave domains on the same cube port with different proxyProtocol settings. Then `errorMeta.code` is `proxy_protocol_port_mismatch`, with `errorMeta.port` and `errorMeta.domains` naming the other domains. Change them together, or resend with confirmMixedProxyProtocol: true. */
999
+ 409: {
1000
+ headers: {
1001
+ [name: string]: unknown;
1002
+ };
1003
+ content?: never;
1004
+ };
991
1005
  429: components["responses"]["RateLimited"];
992
1006
  };
993
1007
  };
@@ -1059,6 +1073,8 @@ interface paths {
1059
1073
  basicAuthPassword?: string;
1060
1074
  /** @description HTTP Basic Auth username. Null/empty clears Basic Auth. Setting it requires basicAuthPassword. */
1061
1075
  basicAuthUser?: string | null;
1076
+ /** @description Accept a save that leaves domains on the same cube port with different proxyProtocol settings (for an app that handles both on one port, or mid-migration). Not stored. */
1077
+ confirmMixedProxyProtocol?: boolean;
1062
1078
  /** @description Per-domain CORS policy, applied at the edge. Null (default) = CORS disabled and no Access-Control-* header is emitted anywhere. When set, the proxy answers OPTIONS preflight itself (204, the cube is never involved) and adds the headers to normal AND error responses, so a cross-origin request to a failing or stopped cube is never CORS-masked. */
1063
1079
  corsConfig?: {
1064
1080
  /** @description Send Access-Control-Allow-Credentials: true. Rejected together with the "*" origin. */
@@ -1081,10 +1097,15 @@ interface paths {
1081
1097
  /** @description Max request body size (MB). Null = unlimited (default). */
1082
1098
  maxRequestBodyMb?: number | null;
1083
1099
  /**
1084
- * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honoured exactly. Verified against the cube before it is applied — if the domain does not serve, the route is left on http.
1100
+ * @description Scheme the edge speaks to the CUBE on the backend hop. http (default) = cleartext. https = the cube terminates TLS itself (a control panel holding its own certificate, or an app listening on HTTPS) and answers plain HTTP with a redirect, so it cannot be reached over cleartext at all. Visitors are on HTTPS either way. The dial port is derived: https on the default port 80 connects on 443; a deliberate custom port is honored exactly. Applied as saved: if the cube does not serve this hostname over HTTPS, requests to the domain fail until you set it back to http.
1085
1101
  * @enum {string}
1086
1102
  */
1087
1103
  originScheme?: "http" | "https";
1104
+ /**
1105
+ * @description Send a PROXY protocol header (v1 text or v2 binary) at the start of every connection to the cube, so the app reads the visitor's address from the connection itself, as on a plain VPS. Null (default) = off. The app must accept PROXY protocol on this port, or every request to the domain fails; it is applied as saved. Every domain on the same cube port must use the same setting: a save that would mix them is refused with 409 unless confirmMixedProxyProtocol is true.
1106
+ * @enum {string|null}
1107
+ */
1108
+ proxyProtocol?: "v1" | "v2" | null;
1088
1109
  /** @description Header rewrites: `set` adds/overwrites, `remove` deletes. Null clears all. */
1089
1110
  requestHeaderOverrides?: {
1090
1111
  remove?: string[];
@@ -1125,6 +1146,13 @@ interface paths {
1125
1146
  };
1126
1147
  400: components["responses"]["BadRequest"];
1127
1148
  404: components["responses"]["NotFound"];
1149
+ /** @description Refused. Among other reasons (the domain is in use, or is being removed): the save would leave domains on the same cube port with different proxyProtocol settings. Then `errorMeta.code` is `proxy_protocol_port_mismatch`, with `errorMeta.port` and `errorMeta.domains` naming the other domains. Change them together, or resend with confirmMixedProxyProtocol: true. */
1150
+ 409: {
1151
+ headers: {
1152
+ [name: string]: unknown;
1153
+ };
1154
+ content?: never;
1155
+ };
1128
1156
  429: components["responses"]["RateLimited"];
1129
1157
  };
1130
1158
  };
@@ -1960,7 +1988,11 @@ interface components {
1960
1988
  ipDenyList: string[] | null;
1961
1989
  isWildcard: boolean;
1962
1990
  maxRequestBodyMb: number | null;
1991
+ /** @enum {string} */
1992
+ originScheme: "http" | "https";
1963
1993
  port: number | null;
1994
+ /** @enum {string|null} */
1995
+ proxyProtocol: "v1" | "v2" | null;
1964
1996
  /** @description Header rewrites: `set` adds/overwrites, `remove` deletes. Null clears all. */
1965
1997
  requestHeaderOverrides: {
1966
1998
  remove?: string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krovacloud/sdk",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
4
4
  "description": "Official TypeScript SDK for Krova Cloud — a typed client for provisioning and managing Cubes (Firecracker microVMs) with dedicated resources.",
5
5
  "license": "MIT",
6
6
  "type": "module",