@did-btcr2/cli 0.17.0 → 0.18.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 +33 -8
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +421 -177
- package/dist/esm/src/cli.js +2 -1
- package/dist/esm/src/cli.js.map +1 -1
- package/dist/esm/src/commands/create.js +4 -0
- package/dist/esm/src/commands/create.js.map +1 -1
- package/dist/esm/src/commands/deactivate.js +2 -0
- package/dist/esm/src/commands/deactivate.js.map +1 -1
- package/dist/esm/src/commands/index.js +1 -0
- package/dist/esm/src/commands/index.js.map +1 -1
- package/dist/esm/src/commands/init.js +87 -44
- package/dist/esm/src/commands/init.js.map +1 -1
- package/dist/esm/src/commands/keystore.js +61 -42
- package/dist/esm/src/commands/keystore.js.map +1 -1
- package/dist/esm/src/commands/quickstart.js +158 -0
- package/dist/esm/src/commands/quickstart.js.map +1 -0
- package/dist/esm/src/commands/update.js +2 -0
- package/dist/esm/src/commands/update.js.map +1 -1
- package/dist/esm/src/config.js +66 -0
- package/dist/esm/src/config.js.map +1 -1
- package/dist/esm/src/hints.js +54 -0
- package/dist/esm/src/hints.js.map +1 -0
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/commands/create.d.ts.map +1 -1
- package/dist/types/src/commands/deactivate.d.ts.map +1 -1
- package/dist/types/src/commands/index.d.ts +1 -0
- package/dist/types/src/commands/index.d.ts.map +1 -1
- package/dist/types/src/commands/init.d.ts +52 -5
- package/dist/types/src/commands/init.d.ts.map +1 -1
- package/dist/types/src/commands/keystore.d.ts +37 -1
- package/dist/types/src/commands/keystore.d.ts.map +1 -1
- package/dist/types/src/commands/quickstart.d.ts +12 -0
- package/dist/types/src/commands/quickstart.d.ts.map +1 -0
- package/dist/types/src/commands/update.d.ts.map +1 -1
- package/dist/types/src/config.d.ts +35 -0
- package/dist/types/src/config.d.ts.map +1 -1
- package/dist/types/src/hints.d.ts +24 -0
- package/dist/types/src/hints.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +17 -0
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +2 -0
- package/src/commands/create.ts +4 -0
- package/src/commands/deactivate.ts +2 -0
- package/src/commands/index.ts +1 -0
- package/src/commands/init.ts +146 -54
- package/src/commands/keystore.ts +95 -55
- package/src/commands/quickstart.ts +209 -0
- package/src/commands/update.ts +2 -0
- package/src/config.ts +75 -0
- package/src/hints.ts +51 -0
- package/src/types.ts +12 -1
package/README.md
CHANGED
|
@@ -37,6 +37,7 @@ npx @did-btcr2/cli resolve -i did:btcr2:k1qq...
|
|
|
37
37
|
| Command | Alias | Description |
|
|
38
38
|
|---|---|---|
|
|
39
39
|
| `init` | - | Set up the btcr2 home: create the directory, a default config, and establish the keystore |
|
|
40
|
+
| `quickstart` | - | One-command onboarding: `init` + record the network + (optionally) cache the session and probe endpoints |
|
|
40
41
|
| `create` | - | Create an identifier and initial DID document |
|
|
41
42
|
| `resolve` | `read` | Resolve a DID document |
|
|
42
43
|
| `update` | - | Update a DID document (signs via the keystore) |
|
|
@@ -65,6 +66,8 @@ Creates an identifier and initial DID document. Two identifier types, selected b
|
|
|
65
66
|
|
|
66
67
|
`--signing-key <ref>` (global) selects a stored key for the existing-key mode; it applies only to `-t k`.
|
|
67
68
|
|
|
69
|
+
On a testnet with a public faucet, text-mode `create` (for a `-t k` identifier) also prints a **funding hint** on stderr: the initial P2WPKH beacon address next to its faucet and explorer links, from the per-network preset. It is suppressed under `--quiet` and `-o json`, and absent on regtest and mainnet.
|
|
70
|
+
|
|
68
71
|
### resolve (alias: read)
|
|
69
72
|
|
|
70
73
|
Required flag: `-i/--identifier`. At most one of `-r` or `-p` may be given.
|
|
@@ -92,6 +95,8 @@ Required flags: `-s/--source-document`, `--source-version-id`, `-p/--patches`, `
|
|
|
92
95
|
| `--fee-rate <satsPerVByte>` | Fee rate in sats/vByte for the beacon transaction (default: `5`). Raise it under congestion so the transaction confirms (also `BTCR2_FEE_RATE`, profile `btc.feeRate`) |
|
|
93
96
|
| `--change-address <address>` | Send transaction change to this address instead of the beacon address, so a DID's announcements are not linked on-chain (profile `btc.changeAddress`) |
|
|
94
97
|
|
|
98
|
+
On a network with a block explorer, text-mode `update` (and `deactivate`) also prints a `Watch:` link on stderr for the broadcast txid, suppressed under `--quiet` and `-o json`.
|
|
99
|
+
|
|
95
100
|
### deactivate (alias: delete)
|
|
96
101
|
|
|
97
102
|
Permanently deactivates a DID. This is irreversible. Deactivation applies the `{ "op": "add", "path": "/deactivated", "value": true }` patch and routes through the same signed-update path as `update`, so it also signs via the keystore.
|
|
@@ -100,22 +105,37 @@ Required flags: `-s/--source-document`, `--source-version-id`, `-m/--verificatio
|
|
|
100
105
|
|
|
101
106
|
### init
|
|
102
107
|
|
|
103
|
-
`btcr2 init` is the one-command setup: it creates the btcr2 home directory, writes a default config if none exists, and establishes the keystore if none exists. It is idempotent (existing files are left untouched unless `--force`).
|
|
108
|
+
`btcr2 init` is the one-command setup: it creates the btcr2 home directory, writes a default config if none exists, and establishes the keystore if none exists. It is idempotent (existing files are left untouched unless `--force`). For a single command that also records the network and (optionally) caches the session and probes the endpoints, see [`quickstart`](#quickstart).
|
|
104
109
|
|
|
105
110
|
| Flag | Description |
|
|
106
111
|
|---|---|
|
|
112
|
+
| `-n, --network <network>` | Bitcoin network to record as `defaults.network` so later commands can drop `-n`. Written idempotently: it never clobbers a network you set earlier |
|
|
107
113
|
| `--dev` | Establish an **unencrypted** dev keystore (plaintext keys, no passphrase). Testnet/regtest only; mainnet operations are refused |
|
|
108
|
-
| `--force` | Re-create the config
|
|
114
|
+
| `--force` | Re-create the config even if it exists. **Never** re-creates the keystore (re-establishing one is the explicit `keystore init --force`) |
|
|
115
|
+
|
|
116
|
+
By default `init` establishes an **encrypted** keystore and prompts (with confirmation) for a passphrase up front, so the first `key generate` never seals the keystore under an unconfirmed, mistyped passphrase. Supply the passphrase non-interactively with `BTCR2_KEYSTORE_PASSPHRASE` or `--passphrase-file` for scripted setup. The output envelope reports the resolved `network` alongside the paths and `protection`.
|
|
117
|
+
|
|
118
|
+
### quickstart
|
|
109
119
|
|
|
110
|
-
|
|
120
|
+
`btcr2 quickstart` collapses onboarding into one step: it runs `init`'s scaffold, records the network (default **mutinynet**), and optionally caches the session and probes the endpoints. It reimplements nothing - it composes `init`, `keystore unlock`, and `config doctor` - so the keystore and session guarantees hold unchanged.
|
|
121
|
+
|
|
122
|
+
| Flag | Description |
|
|
123
|
+
|---|---|
|
|
124
|
+
| `-n, --network <network>` | Bitcoin network to set up. Default: `mutinynet` |
|
|
125
|
+
| `--dev` | Establish an unencrypted dev keystore (testnet only) |
|
|
126
|
+
| `--unlock` | Cache the passphrase for the session so later commands do not re-prompt. Opt-in; on a fresh encrypted keystore it reuses the establish-time passphrase with no second prompt |
|
|
127
|
+
| `--ttl <duration>` | Session lifetime with `--unlock`: bare seconds or an `s`/`m`/`h` suffix (default `1h`, max `24h`; also `BTCR2_KEYSTORE_TTL`) |
|
|
128
|
+
| `--no-doctor` | Skip the endpoint reachability probe (which is on by default and **advisory**: a failed probe warns but `quickstart` still exits 0) |
|
|
129
|
+
| `--allow-mainnet` | Permit `-n bitcoin` (records mainnet as the default; dev keystores are still refused). Guarded before any writes |
|
|
130
|
+
| `--force` | Re-create the config even if it exists (never the keystore) |
|
|
111
131
|
|
|
112
132
|
The workshop happy path:
|
|
113
133
|
|
|
114
134
|
```bash
|
|
115
|
-
btcr2
|
|
135
|
+
btcr2 quickstart -n mutinynet --unlock --ttl 2h # (or: --dev for an unencrypted dev keystore)
|
|
116
136
|
btcr2 key generate --set-active
|
|
117
|
-
btcr2 create
|
|
118
|
-
# ...fund the beacon, resolve, update, deactivate...
|
|
137
|
+
btcr2 create # network comes from defaults.network
|
|
138
|
+
# ...fund the beacon (create prints the faucet + explorer links), resolve, update, deactivate...
|
|
119
139
|
```
|
|
120
140
|
|
|
121
141
|
### key
|
|
@@ -141,11 +161,15 @@ Establish, inspect, and re-key the keystore. These operate on the keystore file
|
|
|
141
161
|
| Subcommand | Alias | Description |
|
|
142
162
|
|---|---|---|
|
|
143
163
|
| `keystore init` | - | Establish the keystore (encrypted by default; prompts and confirms the passphrase). `--dev` creates an unencrypted dev keystore; `--force` re-establishes an existing one (discards its keys) |
|
|
144
|
-
| `keystore status` | - | Show the resolved path, protection mode (`encrypted`/`dev`/`absent`), whether a passphrase is established, and the
|
|
145
|
-
| `keystore change-passphrase` | `passwd` | Re-seal every key under a new passphrase (encrypted keystores only). Prompts for the current passphrase, then a new one (with confirmation) |
|
|
164
|
+
| `keystore status` | - | Show the resolved path, protection mode (`encrypted`/`dev`/`absent`), whether a passphrase is established, the key count, and the `session` state (whether one is live and its remaining lifetime). Never decrypts or prompts |
|
|
165
|
+
| `keystore change-passphrase` | `passwd` | Re-seal every key under a new passphrase (encrypted keystores only). Prompts for the current passphrase, then a new one (with confirmation). Clears any cached session |
|
|
166
|
+
| `keystore unlock` | - | Cache the verified passphrase for the session so later commands do not re-prompt. `--ttl <duration>` sets the lifetime (default `1h`, max `24h`; also `BTCR2_KEYSTORE_TTL`); `--allow-mainnet` permits unlocking a `bitcoin`-default context |
|
|
167
|
+
| `keystore lock` | - | Revoke the cached session so later commands prompt again. Idempotent; needs no passphrase |
|
|
146
168
|
|
|
147
169
|
**Encrypted vs dev keystores.** An encrypted keystore seals each secret with argon2id + XChaCha20-Poly1305 under one passphrase, and records a verifier so a mistyped passphrase fails loudly (with `Incorrect passphrase`) instead of sealing a key under an unknown or divergent passphrase. A **dev keystore** (`--dev`) stores secrets in plaintext and never prompts: it is for disposable testnet/regtest keys only, and the CLI **hard-refuses** to sign or generate a mainnet (`bitcoin`) key with one.
|
|
148
170
|
|
|
171
|
+
**Session unlock.** `keystore unlock` caches the verified passphrase in `<home>/session.json` (`0600`) so a returning operator authenticates once instead of on every signing command. A cached session sits below `BTCR2_KEYSTORE_PASSPHRASE` / `--passphrase-file` and above the interactive prompt, so unattended and CI paths still win. Mainnet keeps per-use authentication: a `bitcoin` operation is withheld from a session that was not unlocked with `--allow-mainnet`. The cached passphrase is base64url-encoded, not encrypted; its only protection at rest is the `0600` file mode.
|
|
172
|
+
|
|
149
173
|
### config
|
|
150
174
|
|
|
151
175
|
Read and write CLI configuration.
|
|
@@ -292,6 +316,7 @@ Override precedence, highest wins: CLI flags, then environment variables, then c
|
|
|
292
316
|
| `BTCR2_OUTPUT` | `-o, --output` |
|
|
293
317
|
| `BTCR2_HOME` | `--home` |
|
|
294
318
|
| `BTCR2_KEYSTORE_PASSPHRASE` | keystore passphrase (unattended use) |
|
|
319
|
+
| `BTCR2_KEYSTORE_TTL` | session lifetime for `keystore unlock` / `quickstart --unlock` (default `1h`, max `24h`) |
|
|
295
320
|
|
|
296
321
|
### Home directory
|
|
297
322
|
|