@krovacloud/sdk 0.5.0 → 0.5.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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,8 @@ All notable changes to `@krovacloud/sdk` are documented here. This project adher
9
9
 
10
10
  ### Added
11
11
 
12
+ - `@krovacloud/sdk/ssh`, a Node-only entry for running commands and moving files on a Cube over its own SSH with a private key you supply: `connectCube(krova, spaceId, cubeId, { privateKey, passphrase?, readyTimeoutMs?, hostKeys? })` returns a shell with `run()`, `files.write/read/upload/download` and `close()`. The host key is checked against the keys from `cubes.ssh()` and a mismatch throws `HostKeyMismatchError`; there is no way to skip the check. Also exports `shellQuote`, `RunTimeoutError` and `SshError`. Adds the `ssh2` dependency; the main entry does not load it.
13
+
12
14
  - Backups and sharing them between spaces: `backups.list()`, `backups.get()` and `backups.share()` (with an optional `idempotencyKey`), and a new `backupShares` group with `list()`, `accept()`, `decline()` and `cancel()`. New exported types `Backup`, `BackupShare`, `BackupShareList` and `AcceptedBackupShare`. These endpoints read the Backups permissions (`backup.view`, `backup.manage`), not the Cube ones. The OpenAPI snapshot is refreshed from the live API and the types regenerated.
13
15
 
14
16
  - `proxyProtocol` (`"v1"`, `"v2"` or `null`) on `domains.create()` and
package/README.md CHANGED
@@ -368,6 +368,36 @@ try {
368
368
 
369
369
  Mutating `POST` / `DELETE` endpoints are rate-limited (10 requests / 60s per client IP). The client automatically retries `429` and `503` up to `maxRetries` times, honoring the `Retry-After` header.
370
370
 
371
+ ## Run commands and move files
372
+
373
+ Krova has no exec or files API. Commands and files go over the Cube's own SSH, with a private key you supply, through the Node-only `@krovacloud/sdk/ssh` entry. The main entry never loads it, so browser and edge code is unaffected.
374
+
375
+ ```ts
376
+ import { KrovaClient } from "@krovacloud/sdk";
377
+ import { connectCube } from "@krovacloud/sdk/ssh";
378
+
379
+ const krova = new KrovaClient({ apiKey: process.env.KROVA_API_KEY! });
380
+ const shell = await connectCube(krova, spaceId, cubeId, {
381
+ privateKey: process.env.CUBE_SSH_KEY!, // the private half of a key on the Cube
382
+ });
383
+
384
+ try {
385
+ const { stdout, stderr, exitCode } = await shell.run(["ls", "-la"], { cwd: "/srv" });
386
+ await shell.files.write("/srv/hello.txt", "hello");
387
+ const bytes = await shell.files.read("/srv/hello.txt");
388
+ await shell.files.upload("./build.tar.gz", "/srv/build.tar.gz");
389
+ await shell.files.download("/var/log/app.log", "./app.log");
390
+ } finally {
391
+ await shell.close();
392
+ }
393
+ ```
394
+
395
+ - `run(command, { cwd?, env?, timeoutMs?, stdin? })` returns `{ stdout, stderr, exitCode, signal? }`. A string runs as written in the Cube's shell. A string array has each argument quoted for you (`shellQuote` is exported), as are `cwd` and the `env` values. A timeout closes the channel and rejects with `RunTimeoutError`.
396
+ - The connection is verified against the Cube's host keys from `krova.cubes.ssh()`. A key that does not match, or a Cube with no keys captured yet, throws `HostKeyMismatchError`. If you keep your own pinned keys, pass them as `hostKeys`. There is no option to skip the check.
397
+ - Your key is used for the connection and never logged or stored by the SDK. An encrypted key takes `passphrase`.
398
+ - `ssh2` has an optional native addon (`cpu-features`) with an install script. The SDK works without it, so pnpm users can leave that script disabled.
399
+ - File paths are literal: `~` and `$VAR` are not expanded. `files.read` and `files.write` hold the whole file in memory; use `upload` and `download` for large files.
400
+
371
401
  ## Configuration
372
402
 
373
403
  Point the client at a different base URL (self-hosted gateway, staging, a proxy):