disk 0.8.0 → 0.8.8

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,6 @@
1
- # The MIT License (MIT)
2
- Copyright (c) 2013 Jonas Hermsmeier
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Archil, Inc.
3
4
 
4
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
6
  of this software and associated documentation files (the "Software"), to deal
@@ -11,10 +12,10 @@ furnished to do so, subject to the following conditions:
11
12
  The above copyright notice and this permission notice shall be included in all
12
13
  copies or substantial portions of the Software.
13
14
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18
- DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
- OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
20
- OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,119 +1,152 @@
1
- # Disk
2
- [![npm](https://img.shields.io/npm/v/disk.svg?style=flat-square)](https://npmjs.com/package/disk)
3
- [![npm license](https://img.shields.io/npm/l/disk.svg?style=flat-square)](https://npmjs.com/package/disk)
4
- [![npm downloads](https://img.shields.io/npm/dm/disk.svg?style=flat-square)](https://npmjs.com/package/disk)
5
- [![build status](https://img.shields.io/travis/jhermsmeier/node-disk/master.svg?style=flat-square)](https://travis-ci.org/jhermsmeier/node-disk)
6
- [![stability](https://img.shields.io/badge/stability-experimental-orange.svg?style=flat-square)](https://nodejs.org/api/documentation.html#documentation_stability_index)
1
+ # disk
7
2
 
8
- ## Install via [npm](https://npmjs.com)
3
+ Node.js client and CLI for [Archil](https://archil.com) disks. Create disks, list and inspect them, manage who can mount them, and run commands against them — all from scripts, CI, or an interactive terminal.
9
4
 
10
- ```sh
11
- $ npm install --save disk
12
- ```
5
+ `disk` talks to the Archil control plane over HTTPS and has no native dependencies. If you also want to mount a disk's data plane from Node (rare — most users want `disk exec` or the `archil` CLI), install [`@archildata/native`](https://www.npmjs.com/package/@archildata/native) alongside `disk`.
13
6
 
14
- ## Related Modules
7
+ ## Install
15
8
 
16
- **Internals:**
9
+ ```bash
10
+ npm install disk
11
+ ```
17
12
 
18
- - [MBR](https://github.com/jhermsmeier/node-mbr) – Master Boot Record
19
- - [GPT](https://github.com/jhermsmeier/node-gpt) – GUID Partition Table
20
- - [CHS](https://github.com/jhermsmeier/node-chs) – Cylinder-Head-Sector Addressing
21
- - [apple-partition-map](https://github.com/jhermsmeier/node-apple-partition-map) – Apple Partition Map
22
- - [BlockDevice](https://github.com/jhermsmeier/node-blockdevice) – Block device handling
23
- - [RamDisk](https://github.com/jhermsmeier/node-ramdisk) – In-memory block device
13
+ ## CLI
24
14
 
25
- **Block Devices:**
15
+ ```bash
16
+ # Authenticate
17
+ export ARCHIL_API_KEY=key-...
18
+ export ARCHIL_REGION=aws-us-east-1
26
19
 
27
- - [VHD](https://github.com/jhermsmeier/node-vhd) Microsoft Virtual Hard Disk format
28
- - [UDIF](https://github.com/jhermsmeier/node-udif) Apple's DMG / UDIF (Universal Disk Image Format)
29
- - [UDF](https://github.com/jhermsmeier/node-udf) – OSTA Universal Disk Format
20
+ # Create a disk — the response includes a one-time disk token you'll need to mount it
21
+ npx disk create my-disk
30
22
 
31
- **File Systems:**
23
+ # List and inspect
24
+ npx disk list
25
+ npx disk get dsk-abc123
32
26
 
33
- - [FAT32](https://github.com/jhermsmeier/node-fat32) FAT32/16/12 file system driver
34
- - [ExFAT](https://github.com/jhermsmeier/node-exfat) ExFAT file system driver
35
- - [HFSX](https://github.com/jhermsmeier/node-hsfx) Apple HFS+ file system driver
36
- - [NTFS](https://github.com/jhermsmeier/node-ntfs) – NTFS file system driver
27
+ # Run a command against the disk's contents — Archil spins up a container with the disk
28
+ # mounted, runs the command, and returns stdout/stderr/exit code.
29
+ npx disk dsk-abc123 exec "ls -la /mnt"
37
30
 
38
- ## Usage
31
+ # Delete
32
+ npx disk delete dsk-abc123
39
33
 
40
- ```js
41
- var Disk = require( 'disk' )
34
+ # Manage account-level API keys
35
+ npx disk api-keys list
36
+ npx disk api-keys create ci-bot
37
+ npx disk api-keys delete key-abc123
42
38
  ```
43
39
 
44
- Set up a device to work with.
45
- This can be anything with a [blockdevice](https://github.com/jhermsmeier/node-blockdevice) compatible API.
40
+ `list` and `get` pretty-print tables by default; pass `-o json` to pipe into `jq`. Credentials come from `ARCHIL_API_KEY` / `ARCHIL_REGION`, or `--api-key` / `--region` / `--base-url` flags.
41
+
42
+ ## Library
43
+
44
+ The recommended pattern is a module-namespace import:
45
+
46
+ ```ts
47
+ import * as archil from "disk";
46
48
 
47
- ```js
48
- var device = new BlockDevice({
49
- path: BlockDevice.getPath( 0 )
50
- })
49
+ // Configure once per process — falls back to ARCHIL_API_KEY / ARCHIL_REGION env vars.
50
+ archil.configure({ apiKey: process.env.ARCHIL_API_KEY, region: "aws-us-east-1" });
51
+
52
+ // Create a disk. `token` here is the disk token — the one-time credential for mounting.
53
+ const { disk, token } = await archil.createDisk({ name: "my-disk" });
54
+ console.log(`Created ${disk.id}, disk token: ${token}`);
55
+
56
+ // List and look up disks
57
+ const all = await archil.listDisks();
58
+ const d = await archil.getDisk(disk.id);
51
59
  ```
52
60
 
53
- Create a disk:
61
+ Per-disk operations are methods on the `Disk` object itself, not top-level functions:
62
+
63
+ ```ts
64
+ const d = await archil.getDisk("dsk-abc123");
65
+
66
+ // Run a command in a container with the disk mounted
67
+ const { stdout, stderr, exitCode } = await d.exec("ls -la /mnt && cat /mnt/config.json");
68
+
69
+ // Manage who can mount the disk
70
+ const user = await d.addUser({ type: "token", nickname: "ci" });
71
+ await d.removeUser("token", user.identifier!);
54
72
 
55
- ```js
56
- var disk = new Disk( device )
73
+ // Delete
74
+ await d.delete();
57
75
  ```
58
76
 
59
- Open the device:
77
+ API keys live at the account level, so those helpers are top-level:
60
78
 
61
- ```js
62
- // This also attempts to detect it's block size if unspecified,
63
- // as well as reading the MBR & GPT on the device
64
- disk.open( function( error ) {})
79
+ ```ts
80
+ await archil.listApiKeys();
81
+ await archil.createApiKey({ name: "ci-bot", description: "GitHub Actions" });
82
+ await archil.deleteApiKey("key-abc123");
65
83
  ```
66
84
 
67
- Read or write the MBR (`disk.mbr`) from or to the device:
85
+ ### Named imports
68
86
 
69
- ```js
70
- disk.readMBR( function( error, mbr ) {})
71
- disk.writeMBR( function( error ) {})
87
+ If you prefer named imports over the namespace style, they work the same way:
88
+
89
+ ```ts
90
+ import { createDisk, getDisk, listDisks, configure } from "disk";
72
91
  ```
73
92
 
74
- Read or write the GPT (`disk.gpt`) from or to the device:
93
+ ### Multiple accounts or regions
94
+
95
+ For multi-tenant scripts, instantiate `Archil` directly instead of using the module-level `configure`:
96
+
97
+ ```ts
98
+ import { Archil } from "disk";
75
99
 
76
- ```js
77
- disk.readGPT( function( error, gpt ) {})
78
- disk.writeGPT( function( error ) {})
100
+ const prod = new Archil({ apiKey: prodKey, region: "aws-us-east-1" });
101
+ const staging = new Archil({ apiKey: stagingKey, region: "aws-us-east-1" });
102
+
103
+ const prodDisks = await prod.disks.list();
104
+ const stagingDisks = await staging.disks.list();
79
105
  ```
80
106
 
81
- Verify the backup GPT;
82
- NOTE: The callback will be called with an error *and*
83
- the backup GPT if it doesn't verify.
107
+ ## Connecting to a disk's data plane
108
+
109
+ To run a command against a disk, use `Disk.exec()` — it returns stdout, stderr, and an exit code from an Archil-managed container with the disk pre-mounted. No local filesystem involved.
84
110
 
85
- ```js
86
- disk.verifyGPT( function( error, backupGPT ) {})
111
+ To mount a disk as a real filesystem on your machine, use the [`archil`](https://archil.com) CLI — it mounts through the OS kernel via FUSE, so any program can read and write files with standard APIs.
112
+
113
+ For the rare case where you need raw Archil protocol access from Node.js (inodes, delegations, byte-level reads), install [`@archildata/native`](https://www.npmjs.com/package/@archildata/native) alongside `disk`:
114
+
115
+ ```bash
116
+ npm install disk @archildata/native
87
117
  ```
88
118
 
89
- Close the device:
119
+ Then `Disk.mount()` lazy-loads the native client:
90
120
 
91
- ```js
92
- disk.close( function( error ) {})
121
+ ```ts
122
+ import { getDisk } from "disk";
123
+
124
+ const d = await getDisk("dsk-abc123");
125
+ const client = await d.mount({ authToken: "<disk-token>" });
126
+ // `client` is an ArchilClient from @archildata/native — see that package's README.
127
+ await client.close();
93
128
  ```
94
129
 
95
- ## API
130
+ `@archildata/native` supports Linux (x64 / arm64, glibc) and macOS (arm64). On other platforms, `mount()` throws; the rest of `disk` still works.
131
+
132
+ ## Supported regions
96
133
 
97
- #### Disk
134
+ | Region | Provider |
135
+ | ----------------- | -------- |
136
+ | `aws-us-east-1` | AWS |
137
+ | `aws-us-west-2` | AWS |
138
+ | `aws-eu-west-1` | AWS |
139
+ | `gcp-us-central1` | GCP |
98
140
 
99
- - Disk.MBR: See [mbr](https://github.com/jhermsmeier/node-mbr)
100
- - Disk.GPT: See [gpt](https://github.com/jhermsmeier/node-gpt)
141
+ ## FAQ
101
142
 
102
- #### new Disk( device )
143
+ ### What's the difference between an API key and a disk token?
103
144
 
104
- **Properties:**
145
+ Archil has two credential types, and the examples above use both:
105
146
 
106
- - **device**
107
- - **mbr**
108
- - **gpt**
147
+ - **API key** — account-level credential for the control plane. You use one whenever you call `disk` (CLI or library). Create and manage them at [console.archil.com](https://console.archil.com) or with `disk api-keys create`. Goes in the `ARCHIL_API_KEY` env var or the `--api-key` flag.
148
+ - **Disk token** — per-disk credential that lets a client mount a specific disk. Created automatically when you `disk create <name>` (the value is shown once; save it). You don't need one to run `disk` itself — only when something is actually mounting a disk.
109
149
 
110
- **Methods:**
150
+ ## Support
111
151
 
112
- - **open( callback )**
113
- - **close( callback )**
114
- - **getEFIPart()**
115
- - **readMBR( callback )**
116
- - **writeMBR( callback )**
117
- - **readGPT( callback )**
118
- - **writeGPT( callback )**
119
- - **writeGPT( callback )**: Not implemented
152
+ Questions, feature requests, or issues? Reach us at **support@archil.com**.