@did-btcr2/cli 0.20.0 → 0.22.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 +44 -27
- package/dist/.tsbuildinfo +1 -1
- package/dist/cjs/index.js +237 -175
- package/dist/esm/src/cli.js +3 -2
- package/dist/esm/src/cli.js.map +1 -1
- package/dist/esm/src/commands/completion.js +1 -1
- package/dist/esm/src/commands/completion.js.map +1 -1
- package/dist/esm/src/commands/deactivate.js +11 -88
- package/dist/esm/src/commands/deactivate.js.map +1 -1
- package/dist/esm/src/commands/identifier.js +110 -0
- package/dist/esm/src/commands/identifier.js.map +1 -0
- package/dist/esm/src/commands/index.js +1 -0
- package/dist/esm/src/commands/index.js.map +1 -1
- package/dist/esm/src/commands/resolve.js +4 -37
- package/dist/esm/src/commands/resolve.js.map +1 -1
- package/dist/esm/src/commands/update.js +15 -85
- package/dist/esm/src/commands/update.js.map +1 -1
- package/dist/esm/src/commands/write.js +119 -0
- package/dist/esm/src/commands/write.js.map +1 -0
- package/dist/esm/src/resolution-options.js +47 -0
- package/dist/esm/src/resolution-options.js.map +1 -0
- package/dist/esm/src/types.js.map +1 -1
- package/dist/types/src/cli.d.ts +1 -1
- package/dist/types/src/cli.d.ts.map +1 -1
- package/dist/types/src/commands/deactivate.d.ts +1 -1
- package/dist/types/src/commands/deactivate.d.ts.map +1 -1
- package/dist/types/src/commands/identifier.d.ts +12 -0
- package/dist/types/src/commands/identifier.d.ts.map +1 -0
- 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/resolve.d.ts.map +1 -1
- package/dist/types/src/commands/update.d.ts +1 -1
- package/dist/types/src/commands/update.d.ts.map +1 -1
- package/dist/types/src/commands/write.d.ts +47 -0
- package/dist/types/src/commands/write.d.ts.map +1 -0
- package/dist/types/src/resolution-options.d.ts +21 -0
- package/dist/types/src/resolution-options.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +37 -7
- package/dist/types/src/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/cli.ts +3 -1
- package/src/commands/completion.ts +1 -1
- package/src/commands/deactivate.ts +14 -142
- package/src/commands/identifier.ts +156 -0
- package/src/commands/index.ts +1 -0
- package/src/commands/resolve.ts +8 -64
- package/src/commands/update.ts +19 -139
- package/src/commands/write.ts +198 -0
- package/src/resolution-options.ts +67 -0
- package/src/types.ts +34 -7
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Part of the [`did-btcr2-js`](https://github.com/dcdpr/did-btcr2-js) monorepo.
|
|
|
6
6
|
|
|
7
7
|
## Summary
|
|
8
8
|
|
|
9
|
-
This package provides the `btcr2` CLI for creating, resolving, updating, and deactivating did:btcr2 decentralized identifiers. It also manages an encrypted keystore of keypairs, reads and writes CLI configuration and profiles, and prints shell completion scripts. It wraps the `@did-btcr2/api` SDK via dependency injection, using [commander.js](https://github.com/tj/commander.js/) for argument parsing.
|
|
9
|
+
This package provides the `btcr2` CLI for creating, resolving, updating, and deactivating did:btcr2 decentralized identifiers. It decodes and validates identifiers offline. It also manages an encrypted keystore of keypairs, reads and writes CLI configuration and profiles, and prints shell completion scripts. It wraps the `@did-btcr2/api` SDK via dependency injection, using [commander.js](https://github.com/tj/commander.js/) for argument parsing.
|
|
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
|
|
|
@@ -44,6 +44,7 @@ npx @did-btcr2/cli resolve -i did:btcr2:k1qq...
|
|
|
44
44
|
| `resolve` | `read` | Resolve a DID document |
|
|
45
45
|
| `update` | - | Update a DID document (signs via the keystore) |
|
|
46
46
|
| `deactivate` | `delete` | Deactivate a DID permanently (signs via the keystore) |
|
|
47
|
+
| `identifier` | - | Decode and validate identifiers (offline) |
|
|
47
48
|
| `key` | - | Manage keypairs in the keystore |
|
|
48
49
|
| `keystore` | - | Establish, inspect, and re-key the keystore |
|
|
49
50
|
| `config` | - | Read and write CLI configuration |
|
|
@@ -85,15 +86,19 @@ Required flag: `-i/--identifier`. If both `-r` and `-p` are given, `-r` wins and
|
|
|
85
86
|
|
|
86
87
|
Signs and broadcasts an update to a DID document. The signing key comes from the encrypted keystore (choose one with `--signing-key <ref>` or set an active key with `btcr2 key use`).
|
|
87
88
|
|
|
88
|
-
Required flags: `-s/--source-document
|
|
89
|
+
Required flags: `-i/--identifier`, `-p/--patches`. The command resolves the current document from the network unless you supply the source pair `-s/--source-document` and `--source-version-id` (both or neither). The api derives the verification method and the beacon unless you pass `-m` or `-b`.
|
|
89
90
|
|
|
90
91
|
| Flag | Description |
|
|
91
92
|
|---|---|
|
|
92
|
-
| `-
|
|
93
|
-
|
|
|
94
|
-
| `-
|
|
95
|
-
|
|
|
96
|
-
| `-
|
|
93
|
+
| `-i, --identifier <identifier>` | did:btcr2 identifier to update (required) |
|
|
94
|
+
| `-p, --patches <json>` | JSON Patch operations as a JSON array string (required) |
|
|
95
|
+
| `-s, --source-document <json>` | Source DID document as a JSON string. Requires `--source-version-id`. Omit both to resolve the current document first |
|
|
96
|
+
| `--source-version-id <number>` | Version ID of the source document, a non-negative integer. Requires `--source-document` |
|
|
97
|
+
| `-m, --verification-method-id <id>` | Verification method that signs the update. Default: the one method of the document that publishes the signing key. Pass it when the api names several candidates |
|
|
98
|
+
| `-b, --beacon-id <id>` | Beacon service that announces the update, as a DID URL (`#initialP2WPKH` or absolute). Default: the only beacon of the document, else the one beacon with a spendable UTXO. Pass it when the api names several funded beacons |
|
|
99
|
+
| `-r, --resolution-options <json>` | Resolution options as an inline JSON string, for the resolution of the source document. Supply sidecar data here if the DID's prior updates are not in a CAS. Not allowed with the source pair |
|
|
100
|
+
| `--resolution-options-path <path>` | Path to a JSON file containing resolution options (`-r` wins if both are given). Not allowed with the source pair |
|
|
101
|
+
| `--min-conf <n>` | Minimum block confirmations a beacon signal needs before the source resolution applies it. A positive integer; default `6`, the specification value. Overrides a `minConf` inside `-r`/`--resolution-options-path`. Not allowed with the source pair |
|
|
97
102
|
| `--publish-to-cas <mode>` | Publish update artifacts to a writable CAS before broadcast: `auto`, `always`, or `never` (default: `never`). See [Publishing updates to CAS](#publishing-updates-to-cas) |
|
|
98
103
|
| `--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`) |
|
|
99
104
|
| `--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`) |
|
|
@@ -102,9 +107,20 @@ On a network with a block explorer, text-mode `update` (and `deactivate`) also p
|
|
|
102
107
|
|
|
103
108
|
### deactivate (alias: delete)
|
|
104
109
|
|
|
105
|
-
Permanently deactivates a DID. This is irreversible.
|
|
110
|
+
Permanently deactivates a DID. This is irreversible. The command calls the api's `deactivateDid`, which applies the `{ "op": "add", "path": "/deactivated", "value": true }` patch and refuses a DID that is deactivated already. It signs via the keystore like `update`.
|
|
106
111
|
|
|
107
|
-
Required
|
|
112
|
+
Required flag: `-i/--identifier`. Optional: the same source, derivation, resolution, CAS, fee, and change-address flags as `update`, minus `-p`.
|
|
113
|
+
|
|
114
|
+
### identifier
|
|
115
|
+
|
|
116
|
+
Decodes and validates identifiers. Both subcommands are offline and keystore-free. The identifier is a positional argument.
|
|
117
|
+
|
|
118
|
+
| Subcommand | Description |
|
|
119
|
+
|---|---|
|
|
120
|
+
| `identifier decode <did>` | Print the identifier type, the `hrp`, the version, the network, and the genesis bytes as hex. `--initial-document` adds the initial DID document; an `x` identifier needs `--genesis-document <path>` for it. |
|
|
121
|
+
| `identifier validate <did>` | Run the checks of the identifier decoding algorithm in order and print the report. Exit code `1` if a check fails. `-b, --bytes <hex>` adds the `genesisBytesMatch` check: the identifier must encode these genesis bytes (`k` or `x`). `--genesis-document <path>` adds the `genesisDocument` check for an `x` identifier. |
|
|
122
|
+
|
|
123
|
+
See [`docs/identifier.md`](./docs/identifier.md) for the check list and the output fields.
|
|
108
124
|
|
|
109
125
|
### init
|
|
110
126
|
|
|
@@ -247,24 +263,28 @@ btcr2 -o json resolve -i did:btcr2:k1qq...
|
|
|
247
263
|
### Update a DID
|
|
248
264
|
|
|
249
265
|
```bash
|
|
250
|
-
# Signs with the active keystore key (or one chosen via --signing-key)
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
-p '[{"op":"add","path":"/service/-","value":{"id":"#svc","type":"X","serviceEndpoint":"https://x"}}]'
|
|
255
|
-
|
|
256
|
-
|
|
266
|
+
# Signs with the active keystore key (or one chosen via --signing-key).
|
|
267
|
+
# The command resolves the current document, derives the verification
|
|
268
|
+
# method and the beacon, then signs and broadcasts.
|
|
269
|
+
btcr2 update -i did:btcr2:k1qq... \
|
|
270
|
+
-p '[{"op":"add","path":"/service/-","value":{"id":"#svc","type":"X","serviceEndpoint":"https://x"}}]'
|
|
271
|
+
|
|
272
|
+
# A DID whose prior update is sidecar-only: hand that update to the source resolution
|
|
273
|
+
btcr2 update -i did:btcr2:k1qq... --min-conf 1 -r '{"sidecar":{"updates":[...]}}' \
|
|
274
|
+
-p '[{"op":"remove","path":"/service/1"}]'
|
|
275
|
+
|
|
276
|
+
# Offline source: supply the document and its version, and name the method and the beacon
|
|
277
|
+
btcr2 update -i did:btcr2:k1qq... \
|
|
278
|
+
-s "$(cat did.json)" --source-version-id 1 \
|
|
279
|
+
-p '[{"op":"remove","path":"/service/1"}]' \
|
|
280
|
+
-m '#initialKey' -b '#initialP2WPKH'
|
|
257
281
|
```
|
|
258
282
|
|
|
259
283
|
### Deactivate a DID
|
|
260
284
|
|
|
261
285
|
```bash
|
|
262
|
-
# Irreversible.
|
|
263
|
-
btcr2 deactivate
|
|
264
|
-
-s "$(cat did.json)" \
|
|
265
|
-
--source-version-id 1 \
|
|
266
|
-
-m 'did:btcr2:k1qq...#key-0' \
|
|
267
|
-
-b '{"id":"#beacon-0","type":"SingletonBeacon","serviceEndpoint":"bitcoin:bc1..."}'
|
|
286
|
+
# Irreversible. Resolves the current document, then signs the deactivation via the keystore.
|
|
287
|
+
btcr2 deactivate -i did:btcr2:k1qq... --min-conf 1 -r '{"sidecar":{"updates":[...]}}'
|
|
268
288
|
```
|
|
269
289
|
|
|
270
290
|
### Manage keys
|
|
@@ -418,11 +438,8 @@ A writable CAS is configured with `--cas-rpc-url <url>` (an IPFS HTTP RPC endpoi
|
|
|
418
438
|
btcr2 update \
|
|
419
439
|
--cas-rpc-url http://127.0.0.1:5001 \
|
|
420
440
|
--publish-to-cas auto \
|
|
421
|
-
-
|
|
422
|
-
|
|
423
|
-
-p '[{"op":"add","path":"/service/-","value":{"id":"#svc","type":"X","serviceEndpoint":"https://x"}}]' \
|
|
424
|
-
-m 'did:btcr2:k1qq...#key-0' \
|
|
425
|
-
-b '{"id":"#beacon-0","type":"SingletonBeacon","serviceEndpoint":"bitcoin:bc1..."}'
|
|
441
|
+
-i did:btcr2:k1qq... \
|
|
442
|
+
-p '[{"op":"add","path":"/service/-","value":{"id":"#svc","type":"X","serviceEndpoint":"https://x"}}]'
|
|
426
443
|
```
|
|
427
444
|
|
|
428
445
|
## Links
|