@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.
Files changed (62) hide show
  1. package/README.md +25 -13
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.js +332 -582
  4. package/dist/browser.mjs +332 -582
  5. package/dist/cjs/index.js +213 -35
  6. package/dist/esm/core/aggregation/beacon-strategy.js +5 -4
  7. package/dist/esm/core/aggregation/beacon-strategy.js.map +1 -1
  8. package/dist/esm/core/aggregation/runner/aggregation-runner.js +66 -0
  9. package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +1 -0
  10. package/dist/esm/core/aggregation/runner/index.js +1 -0
  11. package/dist/esm/core/aggregation/runner/index.js.map +1 -1
  12. package/dist/esm/core/aggregation/transport/in-memory.js +146 -0
  13. package/dist/esm/core/aggregation/transport/in-memory.js.map +1 -0
  14. package/dist/esm/core/aggregation/transport/index.js +1 -0
  15. package/dist/esm/core/aggregation/transport/index.js.map +1 -1
  16. package/dist/esm/core/beacon/beacon.js +10 -8
  17. package/dist/esm/core/beacon/beacon.js.map +1 -1
  18. package/dist/esm/core/beacon/cas-beacon.js +4 -4
  19. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  20. package/dist/esm/core/beacon/factory.js +1 -1
  21. package/dist/esm/core/beacon/singleton-beacon.js +4 -4
  22. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  23. package/dist/esm/core/beacon/smt-beacon.js +23 -15
  24. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  25. package/dist/esm/core/resolver.js +7 -4
  26. package/dist/esm/core/resolver.js.map +1 -1
  27. package/dist/types/core/aggregation/beacon-strategy.d.ts.map +1 -1
  28. package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +56 -0
  29. package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +1 -0
  30. package/dist/types/core/aggregation/runner/index.d.ts +1 -0
  31. package/dist/types/core/aggregation/runner/index.d.ts.map +1 -1
  32. package/dist/types/core/aggregation/transport/in-memory.d.ts +64 -0
  33. package/dist/types/core/aggregation/transport/in-memory.d.ts.map +1 -0
  34. package/dist/types/core/aggregation/transport/index.d.ts +1 -0
  35. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -1
  36. package/dist/types/core/beacon/beacon.d.ts +12 -10
  37. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  38. package/dist/types/core/beacon/cas-beacon.d.ts +4 -4
  39. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  40. package/dist/types/core/beacon/factory.d.ts +3 -3
  41. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  42. package/dist/types/core/beacon/singleton-beacon.d.ts +4 -4
  43. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  44. package/dist/types/core/beacon/smt-beacon.d.ts +4 -4
  45. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  46. package/dist/types/core/interfaces.d.ts +14 -11
  47. package/dist/types/core/interfaces.d.ts.map +1 -1
  48. package/dist/types/core/resolver.d.ts +1 -1
  49. package/dist/types/core/resolver.d.ts.map +1 -1
  50. package/package.json +20 -8
  51. package/src/core/aggregation/beacon-strategy.ts +5 -4
  52. package/src/core/aggregation/runner/aggregation-runner.ts +96 -0
  53. package/src/core/aggregation/runner/index.ts +1 -0
  54. package/src/core/aggregation/transport/in-memory.ts +174 -0
  55. package/src/core/aggregation/transport/index.ts +1 -0
  56. package/src/core/beacon/beacon.ts +12 -10
  57. package/src/core/beacon/cas-beacon.ts +4 -4
  58. package/src/core/beacon/factory.ts +3 -3
  59. package/src/core/beacon/singleton-beacon.ts +4 -4
  60. package/src/core/beacon/smt-beacon.ts +24 -16
  61. package/src/core/interfaces.ts +14 -11
  62. 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/) a censorship-resistant Decentralized Identifier method using Bitcoin as a verifiable data registry.
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()` `Updater` |
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) the identifier IS the public key
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 the counterpart to the Resolver. The caller drives the update by fulfilling typed data needs (signing key, funding confirmation, broadcast).
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, secretKeyBytes);
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, secretKey, bitcoin);
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 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).
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** [btcr2.dev/impls/ts](https://btcr2.dev/impls/ts)
161
- - **[`docs/beacon-system-overview.md`](./docs/beacon-system-overview.md)** Beacon architecture, Singleton / CAS / SMT behavior, signal discovery
162
- - **[`docs/aggregation.md`](./docs/aggregation.md)** Multi-party aggregation protocol, Runner and state machine APIs, e2e examples
163
- - **[`docs/http-transport.md`](./docs/http-transport.md)** HTTP/REST transport: wire protocol, signed envelopes, SSE subscriptions, Hono/Node framework mount example, permissive CORS
164
- - **[`docs/test-vectors.md`](./docs/test-vectors.md)** CLI tool for generating did:btcr2 test vectors via a stepped workflow
165
- - **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.
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)