@did-btcr2/method 0.27.0 → 0.28.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 +38 -9
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +194 -62
- package/dist/browser.mjs +194 -62
- package/dist/cjs/index.js +201 -68
- package/dist/esm/core/aggregation/runner/participant-runner.js +4 -0
- package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
- package/dist/esm/core/updater.js +269 -0
- package/dist/esm/core/updater.js.map +1 -0
- package/dist/esm/did-btcr2.js +30 -42
- package/dist/esm/did-btcr2.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/core/aggregation/runner/participant-runner.d.ts +4 -0
- package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
- package/dist/types/core/updater.d.ts +178 -0
- package/dist/types/core/updater.d.ts.map +1 -0
- package/dist/types/did-btcr2.d.ts +23 -23
- package/dist/types/did-btcr2.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/core/aggregation/runner/participant-runner.ts +4 -0
- package/src/core/updater.ts +415 -0
- package/src/did-btcr2.ts +36 -66
- package/src/index.ts +2 -1
- package/dist/esm/core/update.js +0 -112
- package/dist/esm/core/update.js.map +0 -1
- package/dist/types/core/update.d.ts +0 -52
- package/dist/types/core/update.d.ts.map +0 -1
- package/src/core/update.ts +0 -158
package/README.md
CHANGED
|
@@ -16,7 +16,8 @@ pnpm add @did-btcr2/method
|
|
|
16
16
|
|---|---|
|
|
17
17
|
| Create a DID (offline, deterministic or external) | `DidBtcr2.create()` |
|
|
18
18
|
| Resolve a DID (sans-I/O state machine) | `DidBtcr2.resolve()` |
|
|
19
|
-
|
|
|
19
|
+
| Update a DID (sans-I/O state machine) | `DidBtcr2.update()` → `Updater` |
|
|
20
|
+
| Update utilities (construct, sign, announce) | `Updater.construct()`, `Updater.sign()`, `Updater.announce()` |
|
|
20
21
|
| Beacon types (Singleton, CAS, SMT) | `SingletonBeacon`, `CASBeacon`, `SMTBeacon` |
|
|
21
22
|
| Fee estimation (pluggable) | `FeeEstimator`, `StaticFeeEstimator` |
|
|
22
23
|
| Multi-party aggregation (MuSig2) | `AggregationServiceRunner`, `AggregationParticipantRunner` |
|
|
@@ -63,18 +64,46 @@ const { didDocument, metadata } = state.result;
|
|
|
63
64
|
|
|
64
65
|
See [`src/core/resolver.ts`](./src/core/resolver.ts) for the full `DataNeed` union and phase transitions.
|
|
65
66
|
|
|
66
|
-
###
|
|
67
|
+
### Update a DID
|
|
68
|
+
|
|
69
|
+
`DidBtcr2.update()` returns a sans-I/O state machine — the counterpart to the Resolver. The caller drives the update by fulfilling typed data needs (signing key, funding confirmation, broadcast).
|
|
67
70
|
|
|
68
71
|
```typescript
|
|
69
|
-
import {
|
|
72
|
+
import { DidBtcr2, Updater } from '@did-btcr2/method';
|
|
73
|
+
|
|
74
|
+
const updater = DidBtcr2.update({
|
|
75
|
+
sourceDocument,
|
|
76
|
+
patches : [{ op: 'add', path: '/service/-', value: newService }],
|
|
77
|
+
sourceVersionId : 1,
|
|
78
|
+
verificationMethodId : '#initialKey',
|
|
79
|
+
beaconId : '#beacon-0',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
let state = updater.advance();
|
|
83
|
+
while (state.status === 'action-required') {
|
|
84
|
+
for (const need of state.needs) {
|
|
85
|
+
switch (need.kind) {
|
|
86
|
+
case 'NeedSigningKey':
|
|
87
|
+
updater.provide(need, secretKeyBytes);
|
|
88
|
+
break;
|
|
89
|
+
case 'NeedFunding':
|
|
90
|
+
// Check UTXOs at need.beaconAddress, fund if needed
|
|
91
|
+
updater.provide(need);
|
|
92
|
+
break;
|
|
93
|
+
case 'NeedBroadcast':
|
|
94
|
+
await Updater.announce(need.beaconService, need.signedUpdate, secretKey, bitcoin);
|
|
95
|
+
updater.provide(need);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
state = updater.advance();
|
|
100
|
+
}
|
|
70
101
|
|
|
71
|
-
const
|
|
72
|
-
const unsigned = await Update.construct(doc, [
|
|
73
|
-
{ op: 'add', path: '/service/-', value: { /* new service */ } },
|
|
74
|
-
], 1);
|
|
75
|
-
const signed = Update.sign(did, unsigned, doc.verificationMethod![0], keys.raw.secret!);
|
|
102
|
+
const { signedUpdate } = state.result;
|
|
76
103
|
```
|
|
77
104
|
|
|
105
|
+
See [`src/core/updater.ts`](./src/core/updater.ts) for the full `UpdaterDataNeed` union and phase transitions.
|
|
106
|
+
|
|
78
107
|
### Update Aggregation (Multi-Party MuSig2)
|
|
79
108
|
|
|
80
109
|
Aggregation lets multiple DID controllers coordinate a single Bitcoin transaction that announces all of their updates at once, signed n-of-n with MuSig2. The high-level `Runner` API hides the message routing and decision plumbing:
|
|
@@ -125,4 +154,4 @@ Tests run from compiled JS, so run `pnpm build:tests` before `pnpm test` after a
|
|
|
125
154
|
- **[`docs/beacon-system-overview.md`](./docs/beacon-system-overview.md)** — Beacon architecture, Singleton / CAS / SMT behavior, signal discovery
|
|
126
155
|
- **[`docs/aggregation.md`](./docs/aggregation.md)** — Multi-party aggregation protocol, Runner and state machine APIs, e2e examples
|
|
127
156
|
- **[`docs/test-vectors.md`](./docs/test-vectors.md)** — CLI tool for generating did:btcr2 test vectors via a stepped workflow
|
|
128
|
-
- **Source reference** — See JSDoc comments on public classes; the most important entry points are `DidBtcr2` (facade), `Resolver` (read path), `
|
|
157
|
+
- **Source reference** — See JSDoc comments on public classes; the most important entry points are `DidBtcr2` (facade), `Resolver` (read path), `Updater` (write path), and the aggregation runners.
|