@did-btcr2/method 0.33.0 → 0.35.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 (88) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/browser.js +371 -119
  3. package/dist/browser.mjs +371 -119
  4. package/dist/cjs/index.js +326 -81
  5. package/dist/esm/core/aggregation/cohort.js +5 -1
  6. package/dist/esm/core/aggregation/cohort.js.map +1 -1
  7. package/dist/esm/core/aggregation/participant.js +25 -8
  8. package/dist/esm/core/aggregation/participant.js.map +1 -1
  9. package/dist/esm/core/aggregation/runner/aggregation-runner.js +66 -0
  10. package/dist/esm/core/aggregation/runner/aggregation-runner.js.map +1 -0
  11. package/dist/esm/core/aggregation/runner/index.js +1 -0
  12. package/dist/esm/core/aggregation/runner/index.js.map +1 -1
  13. package/dist/esm/core/aggregation/runner/participant-runner.js +9 -1
  14. package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
  15. package/dist/esm/core/aggregation/runner/service-runner.js +4 -1
  16. package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -1
  17. package/dist/esm/core/aggregation/service.js +4 -4
  18. package/dist/esm/core/aggregation/service.js.map +1 -1
  19. package/dist/esm/core/aggregation/signer.js +33 -0
  20. package/dist/esm/core/aggregation/signer.js.map +1 -0
  21. package/dist/esm/core/aggregation/signing-session.js +34 -11
  22. package/dist/esm/core/aggregation/signing-session.js.map +1 -1
  23. package/dist/esm/core/aggregation/transport/in-memory.js +149 -0
  24. package/dist/esm/core/aggregation/transport/in-memory.js.map +1 -0
  25. package/dist/esm/core/aggregation/transport/index.js +1 -0
  26. package/dist/esm/core/aggregation/transport/index.js.map +1 -1
  27. package/dist/esm/core/beacon/beacon.js +10 -8
  28. package/dist/esm/core/beacon/beacon.js.map +1 -1
  29. package/dist/esm/core/beacon/cas-beacon.js +4 -4
  30. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  31. package/dist/esm/core/beacon/factory.js +1 -1
  32. package/dist/esm/core/beacon/singleton-beacon.js +4 -4
  33. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  34. package/dist/esm/core/beacon/smt-beacon.js +4 -4
  35. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  36. package/dist/esm/index.js +1 -0
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/types/core/aggregation/cohort.d.ts.map +1 -1
  39. package/dist/types/core/aggregation/participant.d.ts +17 -4
  40. package/dist/types/core/aggregation/participant.d.ts.map +1 -1
  41. package/dist/types/core/aggregation/runner/aggregation-runner.d.ts +56 -0
  42. package/dist/types/core/aggregation/runner/aggregation-runner.d.ts.map +1 -0
  43. package/dist/types/core/aggregation/runner/index.d.ts +1 -0
  44. package/dist/types/core/aggregation/runner/index.d.ts.map +1 -1
  45. package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
  46. package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -1
  47. package/dist/types/core/aggregation/service.d.ts +10 -4
  48. package/dist/types/core/aggregation/service.d.ts.map +1 -1
  49. package/dist/types/core/aggregation/signer.d.ts +50 -0
  50. package/dist/types/core/aggregation/signer.d.ts.map +1 -0
  51. package/dist/types/core/aggregation/signing-session.d.ts +13 -5
  52. package/dist/types/core/aggregation/signing-session.d.ts.map +1 -1
  53. package/dist/types/core/aggregation/transport/in-memory.d.ts +64 -0
  54. package/dist/types/core/aggregation/transport/in-memory.d.ts.map +1 -0
  55. package/dist/types/core/aggregation/transport/index.d.ts +1 -0
  56. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -1
  57. package/dist/types/core/beacon/beacon.d.ts +12 -10
  58. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  59. package/dist/types/core/beacon/cas-beacon.d.ts +4 -4
  60. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  61. package/dist/types/core/beacon/factory.d.ts +3 -3
  62. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  63. package/dist/types/core/beacon/singleton-beacon.d.ts +4 -4
  64. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  65. package/dist/types/core/beacon/smt-beacon.d.ts +4 -4
  66. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  67. package/dist/types/core/resolver.d.ts +1 -1
  68. package/dist/types/index.d.ts +1 -0
  69. package/dist/types/index.d.ts.map +1 -1
  70. package/package.json +5 -5
  71. package/src/core/aggregation/cohort.ts +5 -1
  72. package/src/core/aggregation/participant.ts +38 -12
  73. package/src/core/aggregation/runner/aggregation-runner.ts +96 -0
  74. package/src/core/aggregation/runner/index.ts +1 -0
  75. package/src/core/aggregation/runner/participant-runner.ts +9 -1
  76. package/src/core/aggregation/runner/service-runner.ts +4 -1
  77. package/src/core/aggregation/service.ts +12 -6
  78. package/src/core/aggregation/signer.ts +67 -0
  79. package/src/core/aggregation/signing-session.ts +34 -11
  80. package/src/core/aggregation/transport/in-memory.ts +178 -0
  81. package/src/core/aggregation/transport/index.ts +1 -0
  82. package/src/core/beacon/beacon.ts +12 -10
  83. package/src/core/beacon/cas-beacon.ts +4 -4
  84. package/src/core/beacon/factory.ts +3 -3
  85. package/src/core/beacon/singleton-beacon.ts +4 -4
  86. package/src/core/beacon/smt-beacon.ts +4 -4
  87. package/src/core/resolver.ts +1 -1
  88. package/src/index.ts +1 -0
@@ -89,7 +89,7 @@ export function deriveSingletonAddress(
89
89
  }
90
90
 
91
91
  /**
92
- * Options accepted by {@link Beacon.buildSignAndBroadcast} and related helpers.
92
+ * Options accepted by {@link SinglePartyBeacon.buildSignAndBroadcast} and related helpers.
93
93
  */
94
94
  export interface BroadcastOptions {
95
95
  /** Fee estimator for computing the transaction fee. Defaults to {@link DEFAULT_FEE_ESTIMATOR}. */
@@ -115,14 +115,14 @@ export interface BeaconTxPlan {
115
115
  feeSats: bigint;
116
116
  /**
117
117
  * Singleton beacon script kind, when applicable. Drives the signing dispatch
118
- * in {@link Beacon.signSinglePartyTx}. Aggregation plans set this to `'p2tr'`.
118
+ * in {@link SinglePartyBeacon.signSinglePartyTx}. Aggregation plans set this to `'p2tr'`.
119
119
  */
120
120
  scriptKind: SingletonScriptKind;
121
121
  }
122
122
 
123
123
  /**
124
124
  * Build an OP_RETURN script carrying a 32-byte beacon signal.
125
- * Exported as a utility so callers building txs outside Beacon (e.g., the aggregation
125
+ * Exported as a utility so callers building txs outside SinglePartyBeacon (e.g., the aggregation
126
126
  * `onProvideTxData` callback) can produce identical output.
127
127
  *
128
128
  * Uses the opcode *string* `'RETURN'` rather than the numeric `OP.RETURN`
@@ -168,7 +168,7 @@ async function fetchSpendableUtxo(
168
168
  * Returns the unsigned Transaction + prev-output metadata that an aggregation service's
169
169
  * signing session consumes (via {@link SigningTxData}).
170
170
  *
171
- * This is the reusable counterpart to {@link Beacon.buildSignAndBroadcast}'s internal
171
+ * This is the reusable counterpart to {@link SinglePartyBeacon.buildSignAndBroadcast}'s internal
172
172
  * construction step — the aggregation path must produce an unsigned tx because the
173
173
  * signature comes from a MuSig2 round, not a local secret key.
174
174
  *
@@ -311,9 +311,11 @@ async function signSingletonInput(
311
311
  }
312
312
 
313
313
  /**
314
- * Abstract base class for all BTCR2 Beacon types.
315
- * A Beacon is a service listed in a BTCR2 DID document that informs resolvers
316
- * how to find authentic updates to the DID.
314
+ * Abstract base class providing the single-party broadcast machinery shared by
315
+ * all BTCR2 beacon types: one party holds one key and broadcasts one 32-byte
316
+ * signal (P2PKH / P2WPKH / P2TR key-path). The aggregation (cohort of N >= 1)
317
+ * broadcast mode is the orthogonal axis, handled by the AggregationService and
318
+ * {@link buildAggregationBeaconTx}, not by this class hierarchy. See ADR 037.
317
319
  *
318
320
  * Beacons are lightweight typed wrappers around a {@link BeaconService} configuration.
319
321
  * Dependencies (signals, sidecar data, bitcoin connection) are passed as method
@@ -322,10 +324,10 @@ async function signSingletonInput(
322
324
  * Use {@link BeaconFactory.establish} to create typed instances from service config.
323
325
  *
324
326
  * @abstract
325
- * @class Beacon
326
- * @type {Beacon}
327
+ * @class SinglePartyBeacon
328
+ * @type {SinglePartyBeacon}
327
329
  */
328
- export abstract class Beacon {
330
+ export abstract class SinglePartyBeacon {
329
331
  /**
330
332
  * The Beacon service configuration parsed from the DID Document.
331
333
  */
@@ -5,7 +5,7 @@ import type { Signer } from '@did-btcr2/keypair';
5
5
  import type { BeaconProcessResult, DataNeed } from '../resolver.js';
6
6
  import type { SidecarData } from '../types.js';
7
7
  import type { BroadcastOptions } from './beacon.js';
8
- import { Beacon } from './beacon.js';
8
+ import { SinglePartyBeacon } from './beacon.js';
9
9
  import type { BeaconService, BeaconSignal, BlockMetadata, CasPublishFn } from './interfaces.js';
10
10
 
11
11
  /**
@@ -28,9 +28,9 @@ export interface CASBroadcastOptions extends BroadcastOptions {
28
28
  *
29
29
  * @class CASBeacon
30
30
  * @type {CASBeacon}
31
- * @extends {Beacon}
31
+ * @extends {SinglePartyBeacon}
32
32
  */
33
- export class CASBeacon extends Beacon {
33
+ export class CASBeacon extends SinglePartyBeacon {
34
34
  /**
35
35
  * Creates an instance of CASBeacon.
36
36
  * @param {BeaconService} service The service of the Beacon.
@@ -115,7 +115,7 @@ export class CASBeacon extends Beacon {
115
115
  * Creates a CAS Announcement mapping the DID to the update hash, broadcasts the hash of the
116
116
  * announcement via OP_RETURN, and optionally publishes the announcement off-chain via the
117
117
  * supplied `casPublish` callback. UTXO selection, PSBT construction, fee estimation, signing,
118
- * and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
118
+ * and broadcast are delegated to {@link SinglePartyBeacon.buildSignAndBroadcast}.
119
119
  *
120
120
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
121
121
  * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
@@ -1,5 +1,5 @@
1
1
  import { MethodError } from '@did-btcr2/common';
2
- import type { Beacon } from './beacon.js';
2
+ import type { SinglePartyBeacon } from './beacon.js';
3
3
  import { CASBeacon } from './cas-beacon.js';
4
4
  import type { BeaconService } from './interfaces.js';
5
5
  import { SingletonBeacon } from './singleton-beacon.js';
@@ -14,9 +14,9 @@ export class BeaconFactory {
14
14
  /**
15
15
  * Establish a Beacon instance based on the provided service and optional sidecar data.
16
16
  * @param {BeaconService} service The beacon service configuration.
17
- * @returns {Beacon} The established Beacon instance.
17
+ * @returns {SinglePartyBeacon} The established Beacon instance.
18
18
  */
19
- static establish(service: BeaconService): Beacon {
19
+ static establish(service: BeaconService): SinglePartyBeacon {
20
20
  switch (service.type) {
21
21
  case 'SingletonBeacon':
22
22
  return new SingletonBeacon(service);
@@ -5,16 +5,16 @@ import type { Signer } from '@did-btcr2/keypair';
5
5
  import type { BeaconProcessResult, DataNeed } from '../resolver.js';
6
6
  import type { SidecarData } from '../types.js';
7
7
  import type { BroadcastOptions } from './beacon.js';
8
- import { Beacon } from './beacon.js';
8
+ import { SinglePartyBeacon } from './beacon.js';
9
9
  import type { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
10
10
 
11
11
  /**
12
12
  * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#singleton-beacon | Singleton Beacon}.
13
13
  * @class SingletonBeacon
14
14
  * @type {SingletonBeacon}
15
- * @extends {Beacon}
15
+ * @extends {SinglePartyBeacon}
16
16
  */
17
- export class SingletonBeacon extends Beacon {
17
+ export class SingletonBeacon extends SinglePartyBeacon {
18
18
 
19
19
  /**
20
20
  * Creates an instance of SingletonBeacon.
@@ -64,7 +64,7 @@ export class SingletonBeacon extends Beacon {
64
64
  *
65
65
  * The signal bytes embedded in OP_RETURN are the SHA-256 canonical hash of the signed update.
66
66
  * UTXO selection, PSBT construction, fee estimation, signing, and broadcast are delegated to
67
- * {@link Beacon.buildSignAndBroadcast}.
67
+ * {@link SinglePartyBeacon.buildSignAndBroadcast}.
68
68
  *
69
69
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
70
70
  * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
@@ -7,7 +7,7 @@ import { randomBytes } from '@noble/hashes/utils';
7
7
  import type { BeaconProcessResult, DataNeed } from '../resolver.js';
8
8
  import type { SidecarData } from '../types.js';
9
9
  import type { BroadcastOptions } from './beacon.js';
10
- import { Beacon } from './beacon.js';
10
+ import { SinglePartyBeacon } from './beacon.js';
11
11
  import { SMTBeaconError } from './error.js';
12
12
  import type { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
13
13
 
@@ -21,9 +21,9 @@ import type { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js
21
21
  *
22
22
  * @class SMTBeacon
23
23
  * @type {SMTBeacon}
24
- * @extends {Beacon}
24
+ * @extends {SinglePartyBeacon}
25
25
  */
26
- export class SMTBeacon extends Beacon {
26
+ export class SMTBeacon extends SinglePartyBeacon {
27
27
  /**
28
28
  * Creates an instance of SMTBeacon.
29
29
  * @param {BeaconService} service The Beacon service.
@@ -127,7 +127,7 @@ export class SMTBeacon extends Beacon {
127
127
  * Builds a single-entry Sparse Merkle Tree from the signed update, then broadcasts the tree's
128
128
  * root hash via OP_RETURN. For multi-party aggregation, use the {@link AggregationService}
129
129
  * subsystem directly instead of this method. UTXO selection, PSBT construction, fee estimation,
130
- * signing, and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
130
+ * signing, and broadcast are delegated to {@link SinglePartyBeacon.buildSignAndBroadcast}.
131
131
  *
132
132
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
133
133
  * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
@@ -102,7 +102,7 @@ export type ResolverState =
102
102
  | { status: 'resolved'; result: DidResolutionResponse };
103
103
 
104
104
  /**
105
- * Return type from {@link Beacon.processSignals}.
105
+ * Return type from {@link SinglePartyBeacon.processSignals}.
106
106
  * Contains successfully resolved updates and any data needs that must be
107
107
  * satisfied before the remaining signals can be processed.
108
108
  */
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  // Aggregation
2
2
  export * from './core/aggregation/service.js';
3
3
  export * from './core/aggregation/participant.js';
4
+ export * from './core/aggregation/signer.js';
4
5
  export * from './core/aggregation/cohort.js';
5
6
  export * from './core/aggregation/signing-session.js';
6
7
  export * from './core/aggregation/phases.js';