@did-btcr2/method 0.23.0 → 0.25.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 +96 -50
- package/dist/browser.js +36332 -37280
- package/dist/browser.mjs +36331 -37279
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +1 -1
- package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/coordinator.js +40 -44
- package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/participant.js +35 -38
- package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/cjs/core/beacon/aggregation/session/index.js +3 -4
- package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/cjs/core/beacon/beacon.js.map +1 -1
- package/dist/cjs/core/beacon/cas-beacon.js +119 -7
- package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
- package/dist/cjs/core/beacon/factory.js +1 -1
- package/dist/cjs/core/beacon/factory.js.map +1 -1
- package/dist/cjs/core/beacon/{singleton.js → singleton-beacon.js} +19 -27
- package/dist/cjs/core/beacon/singleton-beacon.js.map +1 -0
- package/dist/cjs/core/beacon/smt-beacon.js +1 -1
- package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
- package/dist/cjs/core/identifier.js +1 -1
- package/dist/cjs/core/identifier.js.map +1 -1
- package/dist/{esm/core/resolve.js → cjs/core/resolver.js} +244 -92
- package/dist/cjs/core/resolver.js.map +1 -0
- package/dist/cjs/core/update.js +7 -7
- package/dist/cjs/core/update.js.map +1 -1
- package/dist/cjs/did-btcr2.js +34 -94
- package/dist/cjs/did-btcr2.js.map +1 -1
- package/dist/cjs/index.js +2 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/utils/did-document.js +9 -19
- package/dist/cjs/utils/did-document.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/did-comm.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +1 -1
- package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/coordinator.js +40 -44
- package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/participant.js +35 -38
- package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
- package/dist/esm/core/beacon/aggregation/session/index.js +3 -4
- package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +119 -7
- package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
- package/dist/esm/core/beacon/factory.js +1 -1
- package/dist/esm/core/beacon/factory.js.map +1 -1
- package/dist/esm/core/beacon/{singleton.js → singleton-beacon.js} +19 -27
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -0
- package/dist/esm/core/beacon/smt-beacon.js +1 -1
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/identifier.js +1 -1
- package/dist/esm/core/identifier.js.map +1 -1
- package/dist/{cjs/core/resolve.js → esm/core/resolver.js} +244 -92
- package/dist/esm/core/resolver.js.map +1 -0
- package/dist/esm/core/update.js +7 -7
- package/dist/esm/core/update.js.map +1 -1
- package/dist/esm/did-btcr2.js +34 -94
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +2 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/did-document.js +9 -19
- package/dist/esm/utils/did-document.js.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/constants.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/index.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts +2 -2
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/cohort/status.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts +4 -3
- package/dist/types/core/beacon/aggregation/communication/adapter/did-comm.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +5 -3
- package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/communication/error.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/communication/factory.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/communication/service.d.ts +3 -2
- package/dist/types/core/beacon/aggregation/communication/service.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/coordinator.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/participant.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/index.d.ts +1 -0
- package/dist/types/core/beacon/aggregation/session/index.d.ts.map +1 -1
- package/dist/types/core/beacon/aggregation/session/status.d.ts +1 -0
- package/dist/types/core/beacon/beacon.d.ts +10 -4
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +27 -7
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/error.d.ts +1 -0
- package/dist/types/core/beacon/factory.d.ts +1 -0
- package/dist/types/core/beacon/interfaces.d.ts +1 -0
- package/dist/types/core/beacon/signal-discovery.d.ts +1 -0
- package/dist/types/core/beacon/{singleton.d.ts → singleton-beacon.d.ts} +7 -5
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -0
- package/dist/types/core/beacon/smt-beacon.d.ts +5 -3
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/utils.d.ts +1 -0
- package/dist/types/core/identifier.d.ts +1 -0
- package/dist/types/core/interfaces.d.ts +6 -15
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +167 -0
- package/dist/types/core/resolver.d.ts.map +1 -0
- package/dist/types/core/types.d.ts +1 -0
- package/dist/types/core/update.d.ts +4 -3
- package/dist/types/core/update.d.ts.map +1 -1
- package/dist/types/did-btcr2.d.ts +17 -16
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/utils/appendix.d.ts +1 -0
- package/dist/types/utils/did-document-builder.d.ts +1 -0
- package/dist/types/utils/did-document.d.ts +2 -6
- package/dist/types/utils/did-document.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +1 -1
- package/src/core/beacon/aggregation/communication/adapter/did-comm.ts +4 -3
- package/src/core/beacon/aggregation/communication/adapter/nostr.ts +4 -3
- package/src/core/beacon/aggregation/communication/service.ts +2 -2
- package/src/core/beacon/aggregation/coordinator.ts +40 -44
- package/src/core/beacon/aggregation/participant.ts +38 -40
- package/src/core/beacon/aggregation/session/index.ts +3 -4
- package/src/core/beacon/beacon.ts +9 -5
- package/src/core/beacon/cas-beacon.ts +156 -10
- package/src/core/beacon/factory.ts +1 -1
- package/src/core/beacon/{singleton.ts → singleton-beacon.ts} +20 -36
- package/src/core/beacon/smt-beacon.ts +4 -3
- package/src/core/identifier.ts +1 -1
- package/src/core/interfaces.ts +5 -16
- package/src/core/resolver.ts +706 -0
- package/src/core/update.ts +9 -9
- package/src/did-btcr2.ts +37 -130
- package/src/index.ts +2 -3
- package/src/utils/did-document.ts +10 -18
- package/dist/cjs/core/beacon/singleton.js.map +0 -1
- package/dist/cjs/core/resolve.js.map +0 -1
- package/dist/cjs/utils/general.js +0 -195
- package/dist/cjs/utils/general.js.map +0 -1
- package/dist/esm/core/beacon/singleton.js.map +0 -1
- package/dist/esm/core/resolve.js.map +0 -1
- package/dist/esm/utils/general.js +0 -195
- package/dist/esm/utils/general.js.map +0 -1
- package/dist/types/core/beacon/singleton.d.ts.map +0 -1
- package/dist/types/core/resolve.d.ts +0 -92
- package/dist/types/core/resolve.d.ts.map +0 -1
- package/dist/types/utils/general.d.ts +0 -85
- package/dist/types/utils/general.d.ts.map +0 -1
- package/src/core/resolve.ts +0 -474
- package/src/utils/general.ts +0 -204
package/README.md
CHANGED
|
@@ -8,47 +8,70 @@ Visit [btcr2.dev](https://btcr2.dev/impls/ts) to learn more about how to use [@d
|
|
|
8
8
|
|
|
9
9
|
## Test Vector Generator
|
|
10
10
|
|
|
11
|
-
An incremental CLI tool for generating did:btcr2 test vectors
|
|
11
|
+
An incremental CLI tool for generating did:btcr2 test vectors through a stepped workflow: `create` → `update` (offline) → `fund` → `announce` → `resolve`. It produces JSON files under `lib/data/`.
|
|
12
12
|
|
|
13
|
-
The `create`
|
|
13
|
+
The first positional argument is the action. `create` runs offline. All subsequent actions only need `--hash` — the type and network are derived from the DID itself.
|
|
14
14
|
|
|
15
15
|
### Quick Start
|
|
16
16
|
|
|
17
17
|
```bash
|
|
18
18
|
# From packages/method/
|
|
19
19
|
|
|
20
|
-
# 1. Create a new DID (only
|
|
21
|
-
pnpm generate:vector
|
|
20
|
+
# 1. Create a new DID (only action that takes --type and --network)
|
|
21
|
+
pnpm generate:vector create
|
|
22
|
+
pnpm generate:vector create --type external --network mutinynet
|
|
22
23
|
|
|
23
|
-
# 2.
|
|
24
|
-
pnpm generate:vector
|
|
24
|
+
# 2. Construct and sign an update offline (use the hash printed by step 1)
|
|
25
|
+
pnpm generate:vector update --hash <hash> --offline
|
|
25
26
|
|
|
26
|
-
# 3.
|
|
27
|
-
pnpm generate:vector -- --step resolve --hash <hash>
|
|
28
|
-
|
|
29
|
-
# 4. Announce update to Bitcoin (requires live node)
|
|
27
|
+
# 3. Fund the beacon address(es)
|
|
30
28
|
source .env
|
|
31
|
-
pnpm generate:vector
|
|
29
|
+
pnpm generate:vector fund --hash <hash>
|
|
30
|
+
|
|
31
|
+
# 4. Announce the signed update on-chain
|
|
32
|
+
pnpm generate:vector announce --hash <hash>
|
|
32
33
|
|
|
33
|
-
# 5. Resolve against live Bitcoin node
|
|
34
|
-
pnpm generate:vector
|
|
34
|
+
# 5. Resolve the DID against a live Bitcoin node
|
|
35
|
+
pnpm generate:vector resolve --hash <hash>
|
|
36
|
+
|
|
37
|
+
# List existing vectors
|
|
38
|
+
pnpm generate:vector list
|
|
39
|
+
pnpm generate:vector list --network regtest --type key
|
|
35
40
|
```
|
|
36
41
|
|
|
37
|
-
### CLI
|
|
42
|
+
### CLI Reference
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
|
46
|
-
|
|
44
|
+
```
|
|
45
|
+
pnpm generate:vector <action> [options]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
#### Actions
|
|
49
|
+
|
|
50
|
+
| Action | Description |
|
|
51
|
+
|--------|-------------|
|
|
52
|
+
| `create` | Create a new DID and initial test vector files |
|
|
53
|
+
| `update` | Construct and sign an update (optionally announce) |
|
|
54
|
+
| `fund` | Fund beacon address(es) via RPC `sendtoaddress` + mine a block |
|
|
55
|
+
| `announce` | Announce a previously signed update on-chain |
|
|
56
|
+
| `resolve` | Resolve a DID against a live Bitcoin node |
|
|
57
|
+
| `list` | Show existing test vectors |
|
|
58
|
+
|
|
59
|
+
#### Options
|
|
60
|
+
|
|
61
|
+
| Flag | Values | Default | Applies to | Description |
|
|
62
|
+
|------|--------|---------|------------|-------------|
|
|
63
|
+
| `--type` | `key`, `external` | `key` | `create`, `list` | DID identifier type |
|
|
64
|
+
| `--network` | `regtest`, `bitcoin`, `mutinynet`, etc. | `regtest` | `create`, `list` | Bitcoin network |
|
|
65
|
+
| `--genesis` | hex string | prompt / auto-generate | `create` | Genesis bytes hex (see below) |
|
|
66
|
+
| `--hash` | 8-char short hash | — | `update`, `fund`, `announce`, `resolve` | Vector identifier (required) |
|
|
67
|
+
| `--interactive` | flag (no value) | off | `update` | Enable interactive patch builder |
|
|
68
|
+
| `--amount` | BTC amount | `0.001` | `fund` | BTC amount to send to each beacon address |
|
|
69
|
+
| `--offline` | flag (no value) | off | `update`, `resolve` | Skip on-chain announcement or live resolution |
|
|
47
70
|
|
|
48
71
|
> After `create`, the hash uniquely identifies the vector. The script finds the directory
|
|
49
72
|
> automatically and derives the type and network from the stored DID.
|
|
50
73
|
|
|
51
|
-
###
|
|
74
|
+
### Actions
|
|
52
75
|
|
|
53
76
|
#### `create`
|
|
54
77
|
|
|
@@ -59,12 +82,12 @@ Creates a DID and writes the initial vector files. The `--genesis` flag behavior
|
|
|
59
82
|
|
|
60
83
|
```bash
|
|
61
84
|
# Auto-generate everything
|
|
62
|
-
pnpm generate:vector
|
|
63
|
-
pnpm generate:vector
|
|
85
|
+
pnpm generate:vector create
|
|
86
|
+
pnpm generate:vector create --type external --network regtest
|
|
64
87
|
|
|
65
88
|
# Bring your own genesis bytes
|
|
66
|
-
pnpm generate:vector
|
|
67
|
-
pnpm generate:vector
|
|
89
|
+
pnpm generate:vector create --type key --genesis 02abc...def
|
|
90
|
+
pnpm generate:vector create --type external --network regtest --genesis 82830a78...f83a99
|
|
68
91
|
```
|
|
69
92
|
|
|
70
93
|
**Outputs:**
|
|
@@ -85,9 +108,18 @@ Reads back the create output, rebuilds the source document, constructs and signs
|
|
|
85
108
|
|
|
86
109
|
**With `--interactive`:** prompts for JSON Patch operations with smart auto-generation (see below).
|
|
87
110
|
|
|
111
|
+
**With `--offline`:** builds and signs the update but skips the on-chain announcement. This is the typical workflow — use `fund` and `announce` as separate steps afterward.
|
|
112
|
+
|
|
113
|
+
**Without `--offline`:** also announces the update on-chain immediately (requires a funded beacon address and `BITCOIN_NETWORK_CONFIG`).
|
|
114
|
+
|
|
88
115
|
```bash
|
|
89
|
-
|
|
90
|
-
pnpm generate:vector
|
|
116
|
+
# Recommended: sign offline, then fund and announce separately
|
|
117
|
+
pnpm generate:vector update --hash <hash> --offline
|
|
118
|
+
pnpm generate:vector update --hash <hash> --offline --interactive
|
|
119
|
+
|
|
120
|
+
# Or sign and announce in one step (beacon must already be funded)
|
|
121
|
+
source .env
|
|
122
|
+
pnpm generate:vector update --hash <hash>
|
|
91
123
|
```
|
|
92
124
|
|
|
93
125
|
**Outputs:**
|
|
@@ -98,58 +130,71 @@ lib/data/{network}/{type}/{hash}/
|
|
|
98
130
|
other.json # (updated with generated keys)
|
|
99
131
|
```
|
|
100
132
|
|
|
101
|
-
#### `
|
|
133
|
+
#### `fund`
|
|
102
134
|
|
|
103
|
-
|
|
135
|
+
Funds all beacon service addresses in the DID document via RPC `sendtoaddress`, then mines blocks to confirm the funding transaction(s). **Requires a live Bitcoin node with a loaded wallet.**
|
|
104
136
|
|
|
105
137
|
```bash
|
|
106
|
-
|
|
138
|
+
source .env
|
|
139
|
+
pnpm generate:vector fund --hash <hash>
|
|
140
|
+
pnpm generate:vector fund --hash <hash> --amount 0.01
|
|
107
141
|
```
|
|
108
142
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
lib/data/{network}/{type}/{hash}/
|
|
112
|
-
resolve/input.json # { did, resolutionOptions: { sidecar } }
|
|
113
|
-
```
|
|
143
|
+
> Requires `BITCOIN_NETWORK_CONFIG` to be set with connection info
|
|
144
|
+
> for the DID's network. Source your `.env` file or export it directly.
|
|
114
145
|
|
|
115
146
|
#### `announce`
|
|
116
147
|
|
|
117
|
-
|
|
148
|
+
Announces a previously signed update on-chain via the beacon service. Reads the signed update and beacon metadata from the `update` step's persisted files. Useful for retrying a failed announcement without re-running the full update pipeline.
|
|
118
149
|
|
|
119
150
|
```bash
|
|
120
151
|
source .env
|
|
121
|
-
pnpm generate:vector
|
|
152
|
+
pnpm generate:vector announce --hash <hash>
|
|
122
153
|
```
|
|
123
154
|
|
|
124
|
-
|
|
155
|
+
> Requires `BITCOIN_NETWORK_CONFIG` to be set with connection info
|
|
156
|
+
> for the DID's network. Source your `.env` file or export it directly.
|
|
125
157
|
|
|
126
|
-
#### `resolve
|
|
158
|
+
#### `resolve`
|
|
127
159
|
|
|
128
|
-
Resolves
|
|
160
|
+
Resolves a DID against a live Bitcoin node. Assembles a sidecar from the signed update (if the update step has been run) and the genesis document (for x1 types).
|
|
161
|
+
|
|
162
|
+
**With `--offline`:** writes only the sidecar input file without connecting to Bitcoin.
|
|
129
163
|
|
|
130
164
|
```bash
|
|
165
|
+
# Resolve against a live Bitcoin node
|
|
131
166
|
source .env
|
|
132
|
-
pnpm generate:vector
|
|
133
|
-
```
|
|
167
|
+
pnpm generate:vector resolve --hash <hash>
|
|
134
168
|
|
|
135
|
-
|
|
169
|
+
# Offline — build sidecar input only
|
|
170
|
+
pnpm generate:vector resolve --hash <hash> --offline
|
|
171
|
+
```
|
|
136
172
|
|
|
137
173
|
**Outputs:**
|
|
138
174
|
```
|
|
139
175
|
lib/data/{network}/{type}/{hash}/
|
|
140
|
-
resolve/
|
|
176
|
+
resolve/input.json # { did, resolutionOptions: { sidecar } }
|
|
177
|
+
resolve/output.json # { didDocument, didResolutionMetadata, didDocumentMetadata } (live only)
|
|
141
178
|
```
|
|
142
179
|
|
|
143
|
-
>
|
|
144
|
-
>
|
|
145
|
-
|
|
180
|
+
> Live resolution requires `BITCOIN_NETWORK_CONFIG` to be set with connection info
|
|
181
|
+
> for the DID's network. Source your `.env` file or export it directly.
|
|
182
|
+
|
|
183
|
+
#### `list`
|
|
184
|
+
|
|
185
|
+
Displays existing test vectors filtered by network and type. If `--network` or `--type` are not provided, prompts interactively.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
pnpm generate:vector list
|
|
189
|
+
pnpm generate:vector list --network regtest --type key
|
|
190
|
+
```
|
|
146
191
|
|
|
147
192
|
### Interactive Mode
|
|
148
193
|
|
|
149
194
|
Pass `--interactive` to the `update` step to build custom patches. The tool detects common patch targets and auto-generates values.
|
|
150
195
|
|
|
151
196
|
```bash
|
|
152
|
-
pnpm generate:vector
|
|
197
|
+
pnpm generate:vector update --hash <hash> --interactive
|
|
153
198
|
```
|
|
154
199
|
|
|
155
200
|
#### Service patches (`/service/<n>`)
|
|
@@ -225,5 +270,6 @@ lib/data/{network}/{type}/{hash}/
|
|
|
225
270
|
output.json
|
|
226
271
|
resolve/
|
|
227
272
|
input.json
|
|
273
|
+
output.json # (live mode only)
|
|
228
274
|
other.json
|
|
229
275
|
```
|