@did-btcr2/cli 0.5.3 → 0.8.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 +137 -2
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +163 -30
- package/dist/esm/src/cli.js +22 -11
- package/dist/esm/src/cli.js.map +1 -1
- package/dist/esm/src/commands/create.js +2 -1
- package/dist/esm/src/commands/create.js.map +1 -1
- package/dist/esm/src/commands/deactivate.js +14 -5
- package/dist/esm/src/commands/deactivate.js.map +1 -1
- package/dist/esm/src/commands/resolve.js +4 -3
- package/dist/esm/src/commands/resolve.js.map +1 -1
- package/dist/esm/src/commands/update.js +15 -5
- package/dist/esm/src/commands/update.js.map +1 -1
- package/dist/esm/src/config.js +142 -0
- package/dist/esm/src/config.js.map +1 -0
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/index.js.map +1 -1
- package/dist/types/src/cli.d.ts +10 -5
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/commands/create.d.ts +2 -2
- package/dist/types/src/commands/create.d.ts.map +1 -1
- package/dist/types/src/commands/deactivate.d.ts +2 -2
- package/dist/types/src/commands/deactivate.d.ts.map +1 -1
- package/dist/types/src/commands/resolve.d.ts +2 -2
- package/dist/types/src/commands/resolve.d.ts.map +1 -1
- package/dist/types/src/commands/update.d.ts +2 -2
- package/dist/types/src/commands/update.d.ts.map +1 -1
- package/dist/types/src/config.d.ts +131 -0
- package/dist/types/src/config.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +7 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/cli.ts +22 -12
- package/src/commands/create.ts +3 -2
- package/src/commands/deactivate.ts +22 -6
- package/src/commands/resolve.ts +4 -4
- package/src/commands/update.ts +23 -6
- package/src/config.ts +226 -0
- package/src/index.ts +1 -0
- package/src/types.ts +10 -3
package/README.md
CHANGED
|
@@ -1,3 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @did-btcr2/cli
|
|
2
2
|
|
|
3
|
-
Command
|
|
3
|
+
Command-line interface for the [did:btcr2](https://dcdpr.github.io/did-btcr2/) DID method.
|
|
4
|
+
|
|
5
|
+
Part of the [`did-btcr2-js`](https://github.com/dcdpr/did-btcr2-js) monorepo.
|
|
6
|
+
|
|
7
|
+
## Summary
|
|
8
|
+
|
|
9
|
+
This package provides the `btcr2` CLI for creating, resolving, updating, and deactivating did:btcr2 decentralized identifiers. It wraps the `@did-btcr2/api` SDK via dependency injection, using [commander.js](https://github.com/tj/commander.js/) for argument parsing.
|
|
10
|
+
|
|
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
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @did-btcr2/cli
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Or with pnpm:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add -g @did-btcr2/cli
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Requires Node.js >= 22.
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Create a DID
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Deterministic (type=k) — from a compressed secp256k1 public key (33 bytes hex)
|
|
33
|
+
btcr2 create -t k -n regtest -b 02aa...
|
|
34
|
+
|
|
35
|
+
# External (type=x) — from a SHA-256 hash of a genesis document (32 bytes hex)
|
|
36
|
+
btcr2 create -t x -n bitcoin -b bb...
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Resolve a DID
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Zero-config — network and endpoints are derived from the DID
|
|
43
|
+
btcr2 resolve -i did:btcr2:k1qq...
|
|
44
|
+
|
|
45
|
+
# With resolution options from a JSON file
|
|
46
|
+
btcr2 resolve -i did:btcr2:k1qq... -p resolution-options.json
|
|
47
|
+
|
|
48
|
+
# JSON output
|
|
49
|
+
btcr2 -o json resolve -i did:btcr2:k1qq...
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Update a DID
|
|
53
|
+
|
|
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'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Deactivate a DID
|
|
64
|
+
|
|
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
|
+
```
|
|
72
|
+
|
|
73
|
+
## Configuration
|
|
74
|
+
|
|
75
|
+
Override precedence (highest wins): CLI flags > environment variables > config file > network defaults.
|
|
76
|
+
|
|
77
|
+
### CLI flags
|
|
78
|
+
|
|
79
|
+
| Flag | Description |
|
|
80
|
+
|---|---|
|
|
81
|
+
| `-o, --output <format>` | Output format: `json` or `text` (default: `text`) |
|
|
82
|
+
| `-c, --config <path>` | Path to config file |
|
|
83
|
+
| `--profile <name>` | Config profile name (default: auto-detected from network) |
|
|
84
|
+
| `--btc-rest <url>` | Override Bitcoin REST endpoint (Esplora API) |
|
|
85
|
+
| `--btc-rpc-url <url>` | Override Bitcoin Core RPC endpoint |
|
|
86
|
+
| `--btc-rpc-user <user>` | Bitcoin Core RPC username |
|
|
87
|
+
| `--btc-rpc-pass <pass>` | Bitcoin Core RPC password |
|
|
88
|
+
| `--cas-gateway <url>` | IPFS HTTP gateway for CAS reads |
|
|
89
|
+
|
|
90
|
+
### Environment variables
|
|
91
|
+
|
|
92
|
+
| Variable | Equivalent flag |
|
|
93
|
+
|---|---|
|
|
94
|
+
| `BTCR2_BTC_REST` | `--btc-rest` |
|
|
95
|
+
| `BTCR2_BTC_RPC_URL` | `--btc-rpc-url` |
|
|
96
|
+
| `BTCR2_BTC_RPC_USER` | `--btc-rpc-user` |
|
|
97
|
+
| `BTCR2_BTC_RPC_PASS` | `--btc-rpc-pass` |
|
|
98
|
+
| `BTCR2_CAS_GATEWAY` | `--cas-gateway` |
|
|
99
|
+
|
|
100
|
+
### Config file
|
|
101
|
+
|
|
102
|
+
Default location: `$XDG_CONFIG_HOME/btcr2/config.json` (falls back to `~/.config/btcr2/config.json`).
|
|
103
|
+
|
|
104
|
+
Profiles are matched by network name when `--profile` is not specified. For example, resolving a regtest DID automatically selects the `"regtest"` profile.
|
|
105
|
+
|
|
106
|
+
```json
|
|
107
|
+
{
|
|
108
|
+
"profiles": {
|
|
109
|
+
"regtest": {
|
|
110
|
+
"btc": {
|
|
111
|
+
"rest": "http://localhost:3000",
|
|
112
|
+
"rpcUrl": "http://localhost:18443",
|
|
113
|
+
"rpcUser": "polaruser",
|
|
114
|
+
"rpcPass": "polarpass"
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"bitcoin": {
|
|
118
|
+
"btc": { "rest": "https://my-mempool/api" },
|
|
119
|
+
"cas": { "gateway": "https://ipfs.io" }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Defaults
|
|
126
|
+
|
|
127
|
+
When no overrides are configured:
|
|
128
|
+
|
|
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
|
|
131
|
+
- **CAS**: [ipfs.io](https://ipfs.io) HTTP gateway (read-only)
|
|
132
|
+
|
|
133
|
+
## Links
|
|
134
|
+
|
|
135
|
+
- [did:btcr2 specification](https://dcdpr.github.io/did-btcr2/)
|
|
136
|
+
- [did-btcr2-js monorepo](https://github.com/dcdpr/did-btcr2-js)
|
|
137
|
+
- [npm: @did-btcr2/cli](https://www.npmjs.com/package/@did-btcr2/cli)
|
|
138
|
+
- [Implementation docs](https://btcr2.dev/impls/ts)
|