@did-btcr2/cli 0.22.0 → 0.23.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.
Files changed (73) hide show
  1. package/README.md +17 -2
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cjs/index.js +394 -78
  4. package/dist/esm/src/cli.js +2 -1
  5. package/dist/esm/src/cli.js.map +1 -1
  6. package/dist/esm/src/commands/completion.js +1 -1
  7. package/dist/esm/src/commands/completion.js.map +1 -1
  8. package/dist/esm/src/commands/create.js +33 -41
  9. package/dist/esm/src/commands/create.js.map +1 -1
  10. package/dist/esm/src/commands/genesis.js +119 -0
  11. package/dist/esm/src/commands/genesis.js.map +1 -0
  12. package/dist/esm/src/commands/identifier.js +3 -17
  13. package/dist/esm/src/commands/identifier.js.map +1 -1
  14. package/dist/esm/src/commands/index.js +1 -0
  15. package/dist/esm/src/commands/index.js.map +1 -1
  16. package/dist/esm/src/commands/resolve.js +15 -1
  17. package/dist/esm/src/commands/resolve.js.map +1 -1
  18. package/dist/esm/src/commands/write.js +10 -7
  19. package/dist/esm/src/commands/write.js.map +1 -1
  20. package/dist/esm/src/genesis-document-file.js +26 -0
  21. package/dist/esm/src/genesis-document-file.js.map +1 -0
  22. package/dist/esm/src/genesis-spec.js +93 -0
  23. package/dist/esm/src/genesis-spec.js.map +1 -0
  24. package/dist/esm/src/genesis-wizard.js +132 -0
  25. package/dist/esm/src/genesis-wizard.js.map +1 -0
  26. package/dist/esm/src/hints.js +14 -3
  27. package/dist/esm/src/hints.js.map +1 -1
  28. package/dist/esm/src/network-option.js +39 -0
  29. package/dist/esm/src/network-option.js.map +1 -0
  30. package/dist/esm/src/resolution-options.js +19 -2
  31. package/dist/esm/src/resolution-options.js.map +1 -1
  32. package/dist/types/src/cli.d.ts.map +1 -1
  33. package/dist/types/src/commands/create.d.ts +5 -4
  34. package/dist/types/src/commands/create.d.ts.map +1 -1
  35. package/dist/types/src/commands/genesis.d.ts +20 -0
  36. package/dist/types/src/commands/genesis.d.ts.map +1 -0
  37. package/dist/types/src/commands/identifier.d.ts.map +1 -1
  38. package/dist/types/src/commands/index.d.ts +1 -0
  39. package/dist/types/src/commands/index.d.ts.map +1 -1
  40. package/dist/types/src/commands/resolve.d.ts +7 -0
  41. package/dist/types/src/commands/resolve.d.ts.map +1 -1
  42. package/dist/types/src/commands/write.d.ts +2 -1
  43. package/dist/types/src/commands/write.d.ts.map +1 -1
  44. package/dist/types/src/genesis-document-file.d.ts +11 -0
  45. package/dist/types/src/genesis-document-file.d.ts.map +1 -0
  46. package/dist/types/src/genesis-spec.d.ts +70 -0
  47. package/dist/types/src/genesis-spec.d.ts.map +1 -0
  48. package/dist/types/src/genesis-wizard.d.ts +30 -0
  49. package/dist/types/src/genesis-wizard.d.ts.map +1 -0
  50. package/dist/types/src/hints.d.ts +7 -0
  51. package/dist/types/src/hints.d.ts.map +1 -1
  52. package/dist/types/src/network-option.d.ts +15 -0
  53. package/dist/types/src/network-option.d.ts.map +1 -0
  54. package/dist/types/src/resolution-options.d.ts +6 -2
  55. package/dist/types/src/resolution-options.d.ts.map +1 -1
  56. package/dist/types/src/types.d.ts +18 -1
  57. package/dist/types/src/types.d.ts.map +1 -1
  58. package/package.json +5 -5
  59. package/src/cli.ts +2 -0
  60. package/src/commands/completion.ts +1 -1
  61. package/src/commands/create.ts +39 -55
  62. package/src/commands/genesis.ts +149 -0
  63. package/src/commands/identifier.ts +3 -25
  64. package/src/commands/index.ts +1 -0
  65. package/src/commands/resolve.ts +20 -1
  66. package/src/commands/write.ts +10 -7
  67. package/src/genesis-document-file.ts +35 -0
  68. package/src/genesis-spec.ts +149 -0
  69. package/src/genesis-wizard.ts +163 -0
  70. package/src/hints.ts +13 -2
  71. package/src/network-option.ts +50 -0
  72. package/src/resolution-options.ts +21 -2
  73. package/src/types.ts +17 -2
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 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.
9
+ This package provides the `btcr2` CLI for creating, resolving, updating, and deactivating did:btcr2 decentralized identifiers. It decodes and validates identifiers offline, and it builds the genesis document of an external identifier. 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
 
@@ -45,6 +45,7 @@ npx @did-btcr2/cli resolve -i did:btcr2:k1qq...
45
45
  | `update` | - | Update a DID document (signs via the keystore) |
46
46
  | `deactivate` | `delete` | Deactivate a DID permanently (signs via the keystore) |
47
47
  | `identifier` | - | Decode and validate identifiers (offline) |
48
+ | `genesis` | - | Build the genesis document of an external identifier (offline) |
48
49
  | `key` | - | Manage keypairs in the keystore |
49
50
  | `keystore` | - | Establish, inspect, and re-key the keystore |
50
51
  | `config` | - | Read and write CLI configuration |
@@ -59,13 +60,14 @@ Creates an identifier and initial DID document. Two identifier types, selected b
59
60
  - **generate** (neither `--bytes` nor `--signing-key`): mint a fresh key, persist it to the keystore, set it active, and print the identifier. Sealing the secret prompts for the keystore passphrase.
60
61
  - **existing** (`--signing-key <ref>`): use a stored key's public key as the genesis bytes. Reading a public key never decrypts, so this never prompts.
61
62
  - **raw** (`--bytes <hex>`): a 33-byte public key as hex. Offline and keystore-free.
62
- - **`x`** (external): raw-bytes only, the 32-byte SHA-256 hash of a genesis document via `--bytes`.
63
+ - **`x`** (external): the genesis document file via `--document <path>` (the api hashes it; see `genesis build`), or the 32-byte SHA-256 hash via `--bytes`.
63
64
 
64
65
  | Flag | Description |
65
66
  |---|---|
66
67
  | `-t, --type <type>` | Identifier type: `k` (deterministic) or `x` (external). Default: `k` |
67
68
  | `-n, --network <network>` | Bitcoin network: `bitcoin`, `testnet3`, `testnet4`, `signet`, `mutinynet`, or `regtest`. Default: config `defaults.network`, else the active profile's network, else `regtest` |
68
69
  | `-b, --bytes <bytes>` | Genesis bytes as a hex string. For type=k, a 33-byte public key (omit to generate a key); for type=x, the 32-byte genesis-document hash |
70
+ | `--document <path>` | For type=x, the JSON genesis document to hash. Exclusive with `--bytes`. The result adds `genesisBytes` |
69
71
 
70
72
  `--signing-key <ref>` (global) selects a stored key for the existing-key mode; it applies only to `-t k`.
71
73
 
@@ -81,6 +83,7 @@ Required flag: `-i/--identifier`. If both `-r` and `-p` are given, `-r` wins and
81
83
  | `-r, --resolution-options <json>` | Resolution options as an inline JSON string |
82
84
  | `-p, --resolution-options-path <path>` | Path to a JSON file containing resolution options |
83
85
  | `--min-conf <n>` | Minimum block confirmations a beacon signal needs before resolution applies it. A positive integer; default `6`, the specification value. Overrides a `minConf` inside `-r`/`-p`. Pass `1` to see a fresh update after one block |
86
+ | `--genesis-document <path>` | The JSON genesis document of an external (`x`) identifier. Fills `sidecar.genesisDocument`; wins over a value inside `-r`/`-p`. Refused for a `k` identifier |
84
87
 
85
88
  ### update
86
89
 
@@ -122,6 +125,18 @@ Decodes and validates identifiers. Both subcommands are offline and keystore-fre
122
125
 
123
126
  See [`docs/identifier.md`](./docs/identifier.md) for the check list and the output fields.
124
127
 
128
+ ### genesis
129
+
130
+ Builds the genesis document of an external (`x`) identifier, writes it to a file, and prints the identifier. Offline: the beacon addresses are derived from the keys. The keystore opens only for public reads of a key reference.
131
+
132
+ | Subcommand | Description |
133
+ |---|---|
134
+ | `genesis build` | On a terminal, ask for the keys, the relationships, the beacons, and the services (defaults: the active key, all four relationships, one P2WPKH Singleton beacon). `--spec <path>` reads a JSON spec instead and asks nothing. `-n <network>` as in `create`. `--out <path>` names the file (default `genesis.json`); `--force` overwrites. Prints `{ did, network, genesisBytes, path, beacons }`. |
135
+
136
+ Then: `create -t x --document <path>` mints the identifier again from the file, `identifier validate <did> --genesis-document <path>` confirms the pair, and `resolve`, `update`, and `deactivate` take the file with `--genesis-document <path>`.
137
+
138
+ See [`docs/genesis.md`](./docs/genesis.md) for the wizard questions, the spec file, and the output fields.
139
+
125
140
  ### init
126
141
 
127
142
  `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).