@did-btcr2/cli 0.6.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.
package/README.md CHANGED
@@ -10,6 +10,8 @@ This package provides the `btcr2` CLI for creating, resolving, updating, and dea
10
10
 
11
11
  Out of the box, `btcr2 resolve` works with zero configuration. The Bitcoin network is derived from the DID itself, and public endpoints (mempool.space, ipfs.io) are used as defaults. Override endpoints via CLI flags, environment variables, or a config file.
12
12
 
13
+ > **Note:** `update` and `deactivate` are parsed and validated but will exit with an error. CLI signing is not yet implemented; use `@did-btcr2/api` with a `Signer` directly until this is wired up.
14
+
13
15
  ## Install
14
16
 
15
17
  ```bash
@@ -24,24 +26,77 @@ pnpm add -g @did-btcr2/cli
24
26
 
25
27
  Requires Node.js >= 22.
26
28
 
29
+ Without installing globally, run directly via npx:
30
+
31
+ ```bash
32
+ npx @did-btcr2/cli resolve -i did:btcr2:k1qq...
33
+ ```
34
+
35
+ ## Commands
36
+
37
+ | Command | Alias | Status | Description |
38
+ |---|---|---|---|
39
+ | `create` | - | Working | Create an identifier and initial DID document |
40
+ | `resolve` | `read` | Working | Resolve a DID document |
41
+ | `update` | - | Not implemented | Update a DID document (CLI signing pending) |
42
+ | `deactivate` | `delete` | Not implemented | Deactivate a DID permanently (CLI signing pending) |
43
+
44
+ ### create
45
+
46
+ Required flags: `-t/--type`, `-n/--network`, `-b/--bytes`.
47
+
48
+ | Flag | Description |
49
+ |---|---|
50
+ | `-t, --type <type>` | Identifier type: `k` (deterministic, 33-byte compressed pubkey) or `x` (external, 32-byte SHA-256 hash) |
51
+ | `-n, --network <network>` | Bitcoin network: `bitcoin`, `testnet3`, `testnet4`, `signet`, `mutinynet`, or `regtest` |
52
+ | `-b, --bytes <bytes>` | Genesis bytes as a hex string |
53
+
54
+ ### resolve (alias: read)
55
+
56
+ Required flag: `-i/--identifier`. At most one of `-r` or `-p` may be given.
57
+
58
+ | Flag | Description |
59
+ |---|---|
60
+ | `-i, --identifier <identifier>` | did:btcr2 identifier to resolve (required) |
61
+ | `-r, --resolution-options <json>` | Resolution options as an inline JSON string |
62
+ | `-p, --resolution-options-path <path>` | Path to a JSON file containing resolution options |
63
+
64
+ ### update (not yet implemented)
65
+
66
+ Parses and validates flags, then exits with `NOT_IMPLEMENTED_ERROR`. Use `@did-btcr2/api` with a `Signer` directly.
67
+
68
+ Required flags: `-s/--source-document`, `--source-version-id`, `-p/--patches`, `-m/--verification-method-id`, `-b/--beacon-id`.
69
+
70
+ ### deactivate (alias: delete, not yet implemented)
71
+
72
+ Parses and validates flags, then exits with `NOT_IMPLEMENTED_ERROR`. Use `@did-btcr2/api` with a `Signer` directly.
73
+
74
+ Required flags: `-s/--source-document`, `--source-version-id`, `-m/--verification-method-id`, `-b/--beacon-id`.
75
+
27
76
  ## Usage
28
77
 
29
78
  ### Create a DID
30
79
 
31
80
  ```bash
32
- # Deterministic (type=k) from a compressed secp256k1 public key (33 bytes hex)
81
+ # Deterministic (type=k): from a compressed secp256k1 public key (33 bytes hex)
33
82
  btcr2 create -t k -n regtest -b 02aa...
34
83
 
35
- # External (type=x) from a SHA-256 hash of a genesis document (32 bytes hex)
84
+ # External (type=x): from a SHA-256 hash of a genesis document (32 bytes hex)
36
85
  btcr2 create -t x -n bitcoin -b bb...
37
86
  ```
38
87
 
39
88
  ### Resolve a DID
40
89
 
41
90
  ```bash
42
- # Zero-config network and endpoints are derived from the DID
91
+ # Zero-config: network and endpoints are derived from the DID
43
92
  btcr2 resolve -i did:btcr2:k1qq...
44
93
 
94
+ # Alias: read
95
+ btcr2 read -i did:btcr2:k1qq...
96
+
97
+ # With resolution options as inline JSON
98
+ btcr2 resolve -i did:btcr2:k1qq... -r '{"versionId":"1"}'
99
+
45
100
  # With resolution options from a JSON file
46
101
  btcr2 resolve -i did:btcr2:k1qq... -p resolution-options.json
47
102
 
@@ -49,37 +104,31 @@ btcr2 resolve -i did:btcr2:k1qq... -p resolution-options.json
49
104
  btcr2 -o json resolve -i did:btcr2:k1qq...
50
105
  ```
51
106
 
52
- ### Update a DID
107
+ ### Update a DID (not yet implemented)
53
108
 
54
- ```bash
55
- btcr2 update \
56
- -s '{"id":"did:btcr2:k1qq...","service":[...]}' \
57
- --source-version-id 1 \
58
- -p '[{"op":"add","path":"/service/1","value":{...}}]' \
59
- -m '#initialKey' \
60
- -b '#beacon-0'
109
+ The command is registered and flags are validated, but it will always exit with an error:
110
+
111
+ ```
112
+ CLI signing is not yet implemented. Use @did-btcr2/api with a Signer directly.
61
113
  ```
62
114
 
63
- ### Deactivate a DID
115
+ ### Deactivate a DID (not yet implemented)
64
116
 
65
- ```bash
66
- btcr2 deactivate \
67
- -s '{"id":"did:btcr2:k1qq...","service":[...]}' \
68
- --source-version-id 2 \
69
- -m '#initialKey' \
70
- -b '#beacon-0'
71
- ```
117
+ Same as `update` - flags are parsed but the command exits with `NOT_IMPLEMENTED_ERROR`.
72
118
 
73
119
  ## Configuration
74
120
 
75
- Override precedence (highest wins): CLI flags > environment variables > config file > network defaults.
121
+ Override precedence, highest wins: CLI flags, then environment variables, then config file, then network defaults.
76
122
 
77
- ### CLI flags
123
+ ### Global flags
78
124
 
79
125
  | Flag | Description |
80
126
  |---|---|
127
+ | `-v, --version` | Output the current version |
81
128
  | `-o, --output <format>` | Output format: `json` or `text` (default: `text`) |
82
- | `-c, --config <path>` | Path to config file |
129
+ | `--verbose` | Verbose output |
130
+ | `--quiet` | Suppress non-essential output |
131
+ | `-c, --config <path>` | Path to config file (default: `$XDG_CONFIG_HOME/btcr2/config.json`) |
83
132
  | `--profile <name>` | Config profile name (default: auto-detected from network) |
84
133
  | `--btc-rest <url>` | Override Bitcoin REST endpoint (Esplora API) |
85
134
  | `--btc-rpc-url <url>` | Override Bitcoin Core RPC endpoint |
@@ -126,8 +175,8 @@ Profiles are matched by network name when `--profile` is not specified. For exam
126
175
 
127
176
  When no overrides are configured:
128
177
 
129
- - **Bitcoin REST**: [mempool.space](https://mempool.space) for public networks, `localhost:3000` for regtest
130
- - **Bitcoin RPC**: `localhost:18443` for regtest (credentials required), not configured for public networks
178
+ - **Bitcoin REST**: [mempool.space](https://mempool.space) for `bitcoin`, `testnet3`, `testnet4`, and `signet`; [mutinynet.com](https://mutinynet.com) for `mutinynet`; `http://localhost:3000` for `regtest`
179
+ - **Bitcoin RPC**: `http://localhost:18443` for `regtest` (credentials required), not configured for public networks
131
180
  - **CAS**: [ipfs.io](https://ipfs.io) HTTP gateway (read-only)
132
181
 
133
182
  ## Links
@@ -136,3 +185,7 @@ When no overrides are configured:
136
185
  - [did-btcr2-js monorepo](https://github.com/dcdpr/did-btcr2-js)
137
186
  - [npm: @did-btcr2/cli](https://www.npmjs.com/package/@did-btcr2/cli)
138
187
  - [Implementation docs](https://btcr2.dev/impls/ts)
188
+
189
+ ## License
190
+
191
+ [MPL-2.0](https://github.com/dcdpr/did-btcr2-js/blob/main/LICENSE)