@did-btcr2/method 0.32.0 → 0.34.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 +25 -13
- package/dist/.tsbuildinfo +1 -1
- package/dist/browser.js +332 -582
- package/dist/browser.mjs +332 -582
- package/dist/cjs/index.js +213 -35
- package/dist/esm/core/aggregation/beacon-strategy.js +5 -4
- package/dist/esm/core/aggregation/beacon-strategy.js.map +1 -1
- package/dist/esm/core/aggregation/runner/aggregation-runner.js +66 -0
- package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +1 -0
- package/dist/esm/core/aggregation/runner/index.js +1 -0
- package/dist/esm/core/aggregation/runner/index.js.map +1 -1
- package/dist/esm/core/aggregation/transport/in-memory.js +146 -0
- package/dist/esm/core/aggregation/transport/in-memory.js.map +1 -0
- package/dist/esm/core/aggregation/transport/index.js +1 -0
- package/dist/esm/core/aggregation/transport/index.js.map +1 -1
- package/dist/esm/core/beacon/beacon.js +10 -8
- package/dist/esm/core/beacon/beacon.js.map +1 -1
- package/dist/esm/core/beacon/cas-beacon.js +4 -4
- 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/singleton-beacon.js +4 -4
- package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
- package/dist/esm/core/beacon/smt-beacon.js +23 -15
- package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
- package/dist/esm/core/resolver.js +7 -4
- package/dist/esm/core/resolver.js.map +1 -1
- package/dist/types/core/aggregation/beacon-strategy.d.ts.map +1 -1
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +56 -0
- package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +1 -0
- package/dist/types/core/aggregation/runner/index.d.ts +1 -0
- package/dist/types/core/aggregation/runner/index.d.ts.map +1 -1
- package/dist/types/core/aggregation/transport/in-memory.d.ts +64 -0
- package/dist/types/core/aggregation/transport/in-memory.d.ts.map +1 -0
- package/dist/types/core/aggregation/transport/index.d.ts +1 -0
- package/dist/types/core/aggregation/transport/index.d.ts.map +1 -1
- package/dist/types/core/beacon/beacon.d.ts +12 -10
- package/dist/types/core/beacon/beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/cas-beacon.d.ts +4 -4
- package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/factory.d.ts +3 -3
- package/dist/types/core/beacon/factory.d.ts.map +1 -1
- package/dist/types/core/beacon/singleton-beacon.d.ts +4 -4
- package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
- package/dist/types/core/beacon/smt-beacon.d.ts +4 -4
- package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
- package/dist/types/core/interfaces.d.ts +14 -11
- package/dist/types/core/interfaces.d.ts.map +1 -1
- package/dist/types/core/resolver.d.ts +1 -1
- package/dist/types/core/resolver.d.ts.map +1 -1
- package/package.json +20 -8
- package/src/core/aggregation/beacon-strategy.ts +5 -4
- package/src/core/aggregation/runner/aggregation-runner.ts +96 -0
- package/src/core/aggregation/runner/index.ts +1 -0
- package/src/core/aggregation/transport/in-memory.ts +174 -0
- package/src/core/aggregation/transport/index.ts +1 -0
- package/src/core/beacon/beacon.ts +12 -10
- package/src/core/beacon/cas-beacon.ts +4 -4
- package/src/core/beacon/factory.ts +3 -3
- package/src/core/beacon/singleton-beacon.ts +4 -4
- package/src/core/beacon/smt-beacon.ts +24 -16
- package/src/core/interfaces.ts +14 -11
- package/src/core/resolver.ts +9 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @did-btcr2/method
|
|
2
2
|
|
|
3
|
-
TypeScript reference implementation of the [did:btcr2 DID Method](https://dcdpr.github.io/did-btcr2/)
|
|
3
|
+
TypeScript reference implementation of the [did:btcr2 DID Method](https://dcdpr.github.io/did-btcr2/): a censorship-resistant Decentralized Identifier method using Bitcoin as a verifiable data registry.
|
|
4
4
|
|
|
5
5
|
This package is the core of the `did-btcr2-js` monorepo. It implements DID create/resolve/update operations, the three beacon types (Singleton, CAS, SMT), multi-party aggregation over MuSig2, and a pluggable transport layer for peer-to-peer coordination.
|
|
6
6
|
|
|
@@ -16,12 +16,13 @@ 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
|
-
| Update a DID (sans-I/O state machine) | `DidBtcr2.update()`
|
|
19
|
+
| Update a DID (sans-I/O state machine) | `DidBtcr2.update()` returns an `Updater` |
|
|
20
20
|
| Update utilities (construct, sign, announce) | `Updater.construct()`, `Updater.sign()`, `Updater.announce()` |
|
|
21
21
|
| Beacon types (Singleton, CAS, SMT) | `SingletonBeacon`, `CASBeacon`, `SMTBeacon` |
|
|
22
22
|
| Fee estimation (pluggable) | `FeeEstimator`, `StaticFeeEstimator` |
|
|
23
23
|
| Multi-party aggregation (MuSig2) | `AggregationServiceRunner`, `AggregationParticipantRunner` |
|
|
24
24
|
| Transport abstraction (Nostr, HTTP/REST, DIDComm stub) | `Transport`, `NostrTransport`, `HttpClientTransport`, `HttpServerTransport` |
|
|
25
|
+
| Signer abstraction (local key, KMS, custom) | `Signer` / `LocalSigner` from `@did-btcr2/keypair`; `KeyManagerSigner` from `@did-btcr2/key-manager` |
|
|
25
26
|
| DID document types and builders | `Btcr2DidDocument`, `DidDocumentBuilder` |
|
|
26
27
|
|
|
27
28
|
## Quick Start
|
|
@@ -32,7 +33,7 @@ pnpm add @did-btcr2/method
|
|
|
32
33
|
import { DidBtcr2 } from '@did-btcr2/method';
|
|
33
34
|
import { SchnorrKeyPair } from '@did-btcr2/keypair';
|
|
34
35
|
|
|
35
|
-
// Deterministic (k-type)
|
|
36
|
+
// Deterministic (k-type): the identifier IS the public key
|
|
36
37
|
const keys = SchnorrKeyPair.generate();
|
|
37
38
|
const did = DidBtcr2.create(keys.publicKey.compressed, {
|
|
38
39
|
idType : 'KEY',
|
|
@@ -66,10 +67,17 @@ See [`src/core/resolver.ts`](./src/core/resolver.ts) for the full `DataNeed` uni
|
|
|
66
67
|
|
|
67
68
|
### Update a DID
|
|
68
69
|
|
|
69
|
-
`DidBtcr2.update()` returns a sans-I/O state machine
|
|
70
|
+
`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).
|
|
70
71
|
|
|
71
72
|
```typescript
|
|
72
73
|
import { DidBtcr2, Updater } from '@did-btcr2/method';
|
|
74
|
+
import { LocalSigner } from '@did-btcr2/keypair';
|
|
75
|
+
import { BitcoinConnection } from '@did-btcr2/bitcoin';
|
|
76
|
+
|
|
77
|
+
// Build a Signer from a raw secret key. For KMS-backed keys use KeyManagerSigner
|
|
78
|
+
// from '@did-btcr2/key-manager' instead.
|
|
79
|
+
const signer = new LocalSigner(secretKeyBytes);
|
|
80
|
+
const bitcoin = BitcoinConnection.forNetwork('mutinynet');
|
|
73
81
|
|
|
74
82
|
const updater = DidBtcr2.update({
|
|
75
83
|
sourceDocument,
|
|
@@ -84,14 +92,14 @@ while (state.status === 'action-required') {
|
|
|
84
92
|
for (const need of state.needs) {
|
|
85
93
|
switch (need.kind) {
|
|
86
94
|
case 'NeedSigningKey':
|
|
87
|
-
updater.provide(need,
|
|
95
|
+
updater.provide(need, signer);
|
|
88
96
|
break;
|
|
89
97
|
case 'NeedFunding':
|
|
90
98
|
// Check UTXOs at need.beaconAddress, fund if needed
|
|
91
99
|
updater.provide(need);
|
|
92
100
|
break;
|
|
93
101
|
case 'NeedBroadcast':
|
|
94
|
-
await Updater.announce(need.beaconService, need.signedUpdate,
|
|
102
|
+
await Updater.announce(need.beaconService, need.signedUpdate, signer, bitcoin);
|
|
95
103
|
updater.provide(need);
|
|
96
104
|
break;
|
|
97
105
|
}
|
|
@@ -134,7 +142,7 @@ runner.on('signing-complete', (result) => console.log('done'));
|
|
|
134
142
|
const result = await runner.run();
|
|
135
143
|
```
|
|
136
144
|
|
|
137
|
-
The full step-by-step protocol walkthrough
|
|
145
|
+
The full step-by-step protocol walkthrough (service flow, participant flow, decision callbacks, events, the low-level state machine API, and production deployment notes) is in [`docs/aggregation.md`](./docs/aggregation.md). The HTTP/REST transport has its own walkthrough in [`docs/http-transport.md`](./docs/http-transport.md).
|
|
138
146
|
|
|
139
147
|
## Architecture Principles
|
|
140
148
|
|
|
@@ -157,9 +165,13 @@ Tests run from compiled JS, so run `pnpm build:tests` before `pnpm test` after a
|
|
|
157
165
|
|
|
158
166
|
## Documentation
|
|
159
167
|
|
|
160
|
-
- **Package docs on btcr2.dev**
|
|
161
|
-
- **[`docs/beacon-system-overview.md`](./docs/beacon-system-overview.md)**
|
|
162
|
-
- **[`docs/aggregation.md`](./docs/aggregation.md)**
|
|
163
|
-
- **[`docs/http-transport.md`](./docs/http-transport.md)**
|
|
164
|
-
- **[`docs/test-vectors.md`](./docs/test-vectors.md)**
|
|
165
|
-
- **Source reference**
|
|
168
|
+
- **Package docs on btcr2.dev** [btcr2.dev/impls/ts](https://btcr2.dev/impls/ts)
|
|
169
|
+
- **[`docs/beacon-system-overview.md`](./docs/beacon-system-overview.md)** Beacon architecture, Singleton / CAS / SMT behavior, signal discovery
|
|
170
|
+
- **[`docs/aggregation.md`](./docs/aggregation.md)** Multi-party aggregation protocol, Runner and state machine APIs, e2e examples
|
|
171
|
+
- **[`docs/http-transport.md`](./docs/http-transport.md)** HTTP/REST transport: wire protocol, signed envelopes, SSE subscriptions, Hono/Node framework mount example, permissive CORS
|
|
172
|
+
- **[`docs/test-vectors.md`](./docs/test-vectors.md)** CLI tool for generating did:btcr2 test vectors via a stepped workflow
|
|
173
|
+
- **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.
|
|
174
|
+
|
|
175
|
+
## License
|
|
176
|
+
|
|
177
|
+
[MPL-2.0](https://github.com/dcdpr/did-btcr2-js/blob/main/LICENSE)
|