@did-btcr2/method 0.28.0 → 0.32.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 (193) hide show
  1. package/README.md +13 -5
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.js +34125 -44647
  4. package/dist/browser.mjs +26409 -36931
  5. package/dist/cjs/index.js +2869 -679
  6. package/dist/esm/core/aggregation/beacon-strategy.js +62 -0
  7. package/dist/esm/core/aggregation/beacon-strategy.js.map +1 -0
  8. package/dist/esm/core/aggregation/cohort.js +31 -8
  9. package/dist/esm/core/aggregation/cohort.js.map +1 -1
  10. package/dist/esm/core/aggregation/logger.js +15 -0
  11. package/dist/esm/core/aggregation/logger.js.map +1 -0
  12. package/dist/esm/core/aggregation/messages/base.js +12 -1
  13. package/dist/esm/core/aggregation/messages/base.js.map +1 -1
  14. package/dist/esm/core/aggregation/messages/bodies.js +90 -0
  15. package/dist/esm/core/aggregation/messages/bodies.js.map +1 -0
  16. package/dist/esm/core/aggregation/messages/factories.js.map +1 -1
  17. package/dist/esm/core/aggregation/messages/index.js +1 -0
  18. package/dist/esm/core/aggregation/messages/index.js.map +1 -1
  19. package/dist/esm/core/aggregation/participant.js +39 -46
  20. package/dist/esm/core/aggregation/participant.js.map +1 -1
  21. package/dist/esm/core/aggregation/runner/participant-runner.js +33 -7
  22. package/dist/esm/core/aggregation/runner/participant-runner.js.map +1 -1
  23. package/dist/esm/core/aggregation/runner/service-runner.js +198 -19
  24. package/dist/esm/core/aggregation/runner/service-runner.js.map +1 -1
  25. package/dist/esm/core/aggregation/service.js +143 -15
  26. package/dist/esm/core/aggregation/service.js.map +1 -1
  27. package/dist/esm/core/aggregation/signing-session.js +44 -5
  28. package/dist/esm/core/aggregation/signing-session.js.map +1 -1
  29. package/dist/esm/core/aggregation/transport/didcomm.js +9 -0
  30. package/dist/esm/core/aggregation/transport/didcomm.js.map +1 -1
  31. package/dist/esm/core/aggregation/transport/factory.js +15 -6
  32. package/dist/esm/core/aggregation/transport/factory.js.map +1 -1
  33. package/dist/esm/core/aggregation/transport/http/client.js +350 -0
  34. package/dist/esm/core/aggregation/transport/http/client.js.map +1 -0
  35. package/dist/esm/core/aggregation/transport/http/envelope.js +126 -0
  36. package/dist/esm/core/aggregation/transport/http/envelope.js.map +1 -0
  37. package/dist/esm/core/aggregation/transport/http/errors.js +11 -0
  38. package/dist/esm/core/aggregation/transport/http/errors.js.map +1 -0
  39. package/dist/esm/core/aggregation/transport/http/inbox-buffer.js +45 -0
  40. package/dist/esm/core/aggregation/transport/http/inbox-buffer.js.map +1 -0
  41. package/dist/esm/core/aggregation/transport/http/index.js +12 -0
  42. package/dist/esm/core/aggregation/transport/http/index.js.map +1 -0
  43. package/dist/esm/core/aggregation/transport/http/nonce-cache.js +38 -0
  44. package/dist/esm/core/aggregation/transport/http/nonce-cache.js.map +1 -0
  45. package/dist/esm/core/aggregation/transport/http/protocol.js +28 -0
  46. package/dist/esm/core/aggregation/transport/http/protocol.js.map +1 -0
  47. package/dist/esm/core/aggregation/transport/http/rate-limiter.js +45 -0
  48. package/dist/esm/core/aggregation/transport/http/rate-limiter.js.map +1 -0
  49. package/dist/esm/core/aggregation/transport/http/request-auth.js +100 -0
  50. package/dist/esm/core/aggregation/transport/http/request-auth.js.map +1 -0
  51. package/dist/esm/core/aggregation/transport/http/server.js +481 -0
  52. package/dist/esm/core/aggregation/transport/http/server.js.map +1 -0
  53. package/dist/esm/core/aggregation/transport/http/sse-stream.js +110 -0
  54. package/dist/esm/core/aggregation/transport/http/sse-stream.js.map +1 -0
  55. package/dist/esm/core/aggregation/transport/http/sse-writer.js +25 -0
  56. package/dist/esm/core/aggregation/transport/http/sse-writer.js.map +1 -0
  57. package/dist/esm/core/aggregation/transport/index.js +1 -0
  58. package/dist/esm/core/aggregation/transport/index.js.map +1 -1
  59. package/dist/esm/core/aggregation/transport/nostr.js +245 -16
  60. package/dist/esm/core/aggregation/transport/nostr.js.map +1 -1
  61. package/dist/esm/core/beacon/beacon.js +295 -63
  62. package/dist/esm/core/beacon/beacon.js.map +1 -1
  63. package/dist/esm/core/beacon/cas-beacon.js +3 -3
  64. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  65. package/dist/esm/core/beacon/singleton-beacon.js +3 -3
  66. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  67. package/dist/esm/core/beacon/smt-beacon.js +3 -3
  68. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  69. package/dist/esm/core/beacon/utils.js +14 -9
  70. package/dist/esm/core/beacon/utils.js.map +1 -1
  71. package/dist/esm/core/updater.js +63 -55
  72. package/dist/esm/core/updater.js.map +1 -1
  73. package/dist/esm/did-btcr2.js +0 -4
  74. package/dist/esm/did-btcr2.js.map +1 -1
  75. package/dist/esm/index.js +2 -0
  76. package/dist/esm/index.js.map +1 -1
  77. package/dist/esm/utils/did-document.js +2 -2
  78. package/dist/esm/utils/did-document.js.map +1 -1
  79. package/dist/types/core/aggregation/beacon-strategy.d.ts +52 -0
  80. package/dist/types/core/aggregation/beacon-strategy.d.ts.map +1 -0
  81. package/dist/types/core/aggregation/cohort.d.ts +20 -3
  82. package/dist/types/core/aggregation/cohort.d.ts.map +1 -1
  83. package/dist/types/core/aggregation/logger.d.ts +22 -0
  84. package/dist/types/core/aggregation/logger.d.ts.map +1 -0
  85. package/dist/types/core/aggregation/messages/base.d.ts +13 -1
  86. package/dist/types/core/aggregation/messages/base.d.ts.map +1 -1
  87. package/dist/types/core/aggregation/messages/bodies.d.ts +130 -0
  88. package/dist/types/core/aggregation/messages/bodies.d.ts.map +1 -0
  89. package/dist/types/core/aggregation/messages/factories.d.ts +1 -0
  90. package/dist/types/core/aggregation/messages/factories.d.ts.map +1 -1
  91. package/dist/types/core/aggregation/messages/index.d.ts +1 -0
  92. package/dist/types/core/aggregation/messages/index.d.ts.map +1 -1
  93. package/dist/types/core/aggregation/participant.d.ts +2 -0
  94. package/dist/types/core/aggregation/participant.d.ts.map +1 -1
  95. package/dist/types/core/aggregation/runner/events.d.ts +32 -6
  96. package/dist/types/core/aggregation/runner/events.d.ts.map +1 -1
  97. package/dist/types/core/aggregation/runner/participant-runner.d.ts +7 -5
  98. package/dist/types/core/aggregation/runner/participant-runner.d.ts.map +1 -1
  99. package/dist/types/core/aggregation/runner/service-runner.d.ts +33 -3
  100. package/dist/types/core/aggregation/runner/service-runner.d.ts.map +1 -1
  101. package/dist/types/core/aggregation/service.d.ts +33 -2
  102. package/dist/types/core/aggregation/service.d.ts.map +1 -1
  103. package/dist/types/core/aggregation/signing-session.d.ts +5 -1
  104. package/dist/types/core/aggregation/signing-session.d.ts.map +1 -1
  105. package/dist/types/core/aggregation/transport/didcomm.d.ts +3 -0
  106. package/dist/types/core/aggregation/transport/didcomm.d.ts.map +1 -1
  107. package/dist/types/core/aggregation/transport/factory.d.ts +22 -7
  108. package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -1
  109. package/dist/types/core/aggregation/transport/http/client.d.ts +48 -0
  110. package/dist/types/core/aggregation/transport/http/client.d.ts.map +1 -0
  111. package/dist/types/core/aggregation/transport/http/envelope.d.ts +64 -0
  112. package/dist/types/core/aggregation/transport/http/envelope.d.ts.map +1 -0
  113. package/dist/types/core/aggregation/transport/http/errors.d.ts +9 -0
  114. package/dist/types/core/aggregation/transport/http/errors.d.ts.map +1 -0
  115. package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts +32 -0
  116. package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts.map +1 -0
  117. package/dist/types/core/aggregation/transport/http/index.d.ts +12 -0
  118. package/dist/types/core/aggregation/transport/http/index.d.ts.map +1 -0
  119. package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts +26 -0
  120. package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts.map +1 -0
  121. package/dist/types/core/aggregation/transport/http/protocol.d.ts +53 -0
  122. package/dist/types/core/aggregation/transport/http/protocol.d.ts.map +1 -0
  123. package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts +41 -0
  124. package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts.map +1 -0
  125. package/dist/types/core/aggregation/transport/http/request-auth.d.ts +50 -0
  126. package/dist/types/core/aggregation/transport/http/request-auth.d.ts.map +1 -0
  127. package/dist/types/core/aggregation/transport/http/server.d.ts +110 -0
  128. package/dist/types/core/aggregation/transport/http/server.d.ts.map +1 -0
  129. package/dist/types/core/aggregation/transport/http/sse-stream.d.ts +34 -0
  130. package/dist/types/core/aggregation/transport/http/sse-stream.d.ts.map +1 -0
  131. package/dist/types/core/aggregation/transport/http/sse-writer.d.ts +12 -0
  132. package/dist/types/core/aggregation/transport/http/sse-writer.d.ts.map +1 -0
  133. package/dist/types/core/aggregation/transport/index.d.ts +1 -0
  134. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -1
  135. package/dist/types/core/aggregation/transport/nostr.d.ts +99 -1
  136. package/dist/types/core/aggregation/transport/nostr.d.ts.map +1 -1
  137. package/dist/types/core/aggregation/transport/transport.d.ts +26 -1
  138. package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -1
  139. package/dist/types/core/beacon/beacon.d.ts +149 -22
  140. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  141. package/dist/types/core/beacon/cas-beacon.d.ts +3 -3
  142. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  143. package/dist/types/core/beacon/singleton-beacon.d.ts +3 -3
  144. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  145. package/dist/types/core/beacon/smt-beacon.d.ts +3 -3
  146. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  147. package/dist/types/core/beacon/utils.d.ts +2 -2
  148. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  149. package/dist/types/core/updater.d.ts +27 -12
  150. package/dist/types/core/updater.d.ts.map +1 -1
  151. package/dist/types/did-btcr2.d.ts.map +1 -1
  152. package/dist/types/index.d.ts +2 -0
  153. package/dist/types/index.d.ts.map +1 -1
  154. package/package.json +5 -7
  155. package/src/core/aggregation/beacon-strategy.ts +123 -0
  156. package/src/core/aggregation/cohort.ts +34 -8
  157. package/src/core/aggregation/logger.ts +33 -0
  158. package/src/core/aggregation/messages/base.ts +20 -5
  159. package/src/core/aggregation/messages/bodies.ts +223 -0
  160. package/src/core/aggregation/messages/factories.ts +1 -0
  161. package/src/core/aggregation/messages/index.ts +1 -0
  162. package/src/core/aggregation/participant.ts +40 -46
  163. package/src/core/aggregation/runner/events.ts +27 -3
  164. package/src/core/aggregation/runner/participant-runner.ts +41 -7
  165. package/src/core/aggregation/runner/service-runner.ts +227 -19
  166. package/src/core/aggregation/service.ts +189 -20
  167. package/src/core/aggregation/signing-session.ts +65 -7
  168. package/src/core/aggregation/transport/didcomm.ts +17 -0
  169. package/src/core/aggregation/transport/factory.ts +48 -12
  170. package/src/core/aggregation/transport/http/client.ts +409 -0
  171. package/src/core/aggregation/transport/http/envelope.ts +204 -0
  172. package/src/core/aggregation/transport/http/errors.ts +11 -0
  173. package/src/core/aggregation/transport/http/inbox-buffer.ts +53 -0
  174. package/src/core/aggregation/transport/http/index.ts +11 -0
  175. package/src/core/aggregation/transport/http/nonce-cache.ts +43 -0
  176. package/src/core/aggregation/transport/http/protocol.ts +57 -0
  177. package/src/core/aggregation/transport/http/rate-limiter.ts +75 -0
  178. package/src/core/aggregation/transport/http/request-auth.ts +164 -0
  179. package/src/core/aggregation/transport/http/server.ts +615 -0
  180. package/src/core/aggregation/transport/http/sse-stream.ts +121 -0
  181. package/src/core/aggregation/transport/http/sse-writer.ts +23 -0
  182. package/src/core/aggregation/transport/index.ts +1 -0
  183. package/src/core/aggregation/transport/nostr.ts +266 -23
  184. package/src/core/aggregation/transport/transport.ts +34 -1
  185. package/src/core/beacon/beacon.ts +411 -79
  186. package/src/core/beacon/cas-beacon.ts +4 -4
  187. package/src/core/beacon/singleton-beacon.ts +4 -4
  188. package/src/core/beacon/smt-beacon.ts +4 -4
  189. package/src/core/beacon/utils.ts +16 -11
  190. package/src/core/updater.ts +113 -67
  191. package/src/did-btcr2.ts +0 -5
  192. package/src/index.ts +2 -0
  193. package/src/utils/did-document.ts +2 -2
@@ -1,6 +1,7 @@
1
1
  import type { Did } from '@did-btcr2/common';
2
2
  import type { SchnorrKeyPair } from '@did-btcr2/keypair';
3
3
  import { SimplePool } from 'nostr-tools/pool';
4
+ import type { Logger } from '../logger.js';
4
5
  import type { BaseMessage } from '../messages/base.js';
5
6
  import type { MessageHandler, Transport } from './transport.js';
6
7
  /**
@@ -10,7 +11,24 @@ import type { MessageHandler, Transport } from './transport.js';
10
11
  export declare const DEFAULT_NOSTR_RELAYS: string[];
11
12
  export interface NostrTransportConfig {
12
13
  relays?: string[];
14
+ /**
15
+ * Optional logger for transport-level diagnostics (publish/subscribe events,
16
+ * relay rejections, parse failures). Defaults to {@link CONSOLE_LOGGER}.
17
+ */
18
+ logger?: Logger;
19
+ /**
20
+ * How far back (in milliseconds) to set the `since` filter on the broadcast
21
+ * (COHORT_ADVERT) subscription. Some public relays do NOT replay historical
22
+ * events to late subscribers when the filter has no `since`, so the advert
23
+ * gets lost if the subscription lands after the publish. A short lookback
24
+ * window nudges those relays into delivering recent adverts. Set to 0 to
25
+ * disable the filter entirely (unbounded history). Defaults to
26
+ * {@link DEFAULT_BROADCAST_LOOKBACK_MS} (5 minutes).
27
+ */
28
+ broadcastLookbackMs?: number;
13
29
  }
30
+ /** Default `since` lookback for broadcast (COHORT_ADVERT) subscriptions: 5 minutes. */
31
+ export declare const DEFAULT_BROADCAST_LOOKBACK_MS: number;
14
32
  /**
15
33
  * Nostr Transport for did:btcr2 aggregation messages.
16
34
  *
@@ -41,15 +59,95 @@ export declare class NostrTransport implements Transport {
41
59
  * @example
42
60
  * const transport = new NostrTransport();
43
61
  * const keys = SchnorrKeyPair.generate();
44
- * transport.registerActor('did:btcr2:...', keys);
62
+ * const did = DidBtcr2.create(keys.publicKey.compressed, { idType: 'KEY', network: 'mutinynet' });
63
+ * transport.registerActor(did, keys);
45
64
  * transport.start();
46
65
  */
47
66
  registerActor(did: string, keys: SchnorrKeyPair): void;
67
+ /**
68
+ * Detach an actor: drop its handlers, close its relay subscriptions, and remove its keys + peer
69
+ * mapping. Idempotent.
70
+ * @param {string} did - The DID of the actor to unregister.
71
+ * @returns {void}
72
+ * @throws {TransportAdapterError} If the transport is not started or if the pool is unavailable.
73
+ * @example
74
+ * transport.unregisterActor(did);
75
+ */
76
+ unregisterActor(did: string): void;
77
+ /**
78
+ * Remove a single (actor, messageType) handler. Idempotent.
79
+ * @param {string} actorDid - The DID of the actor.
80
+ * @param {string} messageType - The type of message to unregister the handler for.
81
+ * @returns {void}
82
+ * @example
83
+ * transport.unregisterMessageHandler(actorDid, messageType);
84
+ */
85
+ unregisterMessageHandler(actorDid: string, messageType: string): void;
86
+ /**
87
+ * Gets the public key for a registered actor by their DID.
88
+ * @param {string} did - The DID of the registered actor to get the public key for.
89
+ * @returns {Uint8Array | undefined} The compressed public key bytes for the actor's DID, or
90
+ * undefined if the DID is not registered.
91
+ */
48
92
  getActorPk(did: string): Uint8Array | undefined;
93
+ /**
94
+ * Registers a peer's communication public key for encrypted messages.
95
+ * @param {string} did - The DID of the peer to register.
96
+ * @param {Uint8Array} communicationPk - The compressed secp256k1 public key bytes for the peer.
97
+ */
49
98
  registerPeer(did: string, communicationPk: Uint8Array): void;
99
+ /**
100
+ * Gets the registered communication public key for a peer by their DID.
101
+ * @param {string} did - The DID of the peer to get the communication public key for.
102
+ * @returns {Uint8Array | undefined} The compressed secp256k1 public key bytes for the peer, or
103
+ * undefined if the peer is not registered.
104
+ */
50
105
  getPeerPk(did: string): Uint8Array | undefined;
106
+ /**
107
+ * Registers a message handler function for a specific actor and message type. The handler will be called
108
+ * when a message of the specified type is received for the actor's DID. The transport must have been
109
+ * started for handlers to be invoked. If the transport is already started, the handler will be registered
110
+ * immediately; otherwise, it will be registered when the transport starts and the actor's subscription is created.
111
+ * @param {string} actorDid - The DID of the actor to register the message handler for.
112
+ * @param {string} messageType - The type of message to handle.
113
+ * @param {MessageHandler} handler - The function to handle incoming messages of the specified type.
114
+ * @throws {TransportAdapterError} If the actor DID is not registered or if the handler is invalid.
115
+ */
51
116
  registerMessageHandler(actorDid: string, messageType: string, handler: MessageHandler): void;
117
+ /**
118
+ * Starts the transport by connecting to the configured Nostr relays and setting up subscriptions
119
+ * for all registered actors. This method must be called after registering actors via registerActor()
120
+ * and before sending or receiving messages. The transport will subscribe to broadcast events (kind 1)
121
+ * for cohort adverts and directed events (kinds 1 and 1059) for each registered actor based on their
122
+ * public keys. Incoming events are processed and dispatched to the appropriate handlers based on
123
+ * message type. If the transport is already started, this method has no effect.
124
+ * @returns {NostrTransport}
125
+ */
52
126
  start(): NostrTransport;
127
+ /**
128
+ * Sends a message by publishing a Nostr event to the configured relays. The message is serialized
129
+ * as JSON and included in the event content.
130
+ * @param {BaseMessage} message - The aggregation message to send. Must include a valid `type` property.
131
+ * @param {Did} sender - The DID of the registered actor sending the message. Must have been
132
+ * registered via registerActor().
133
+ * @param {Did} [to] - Optional recipient DID for directed messages. Required for encrypted message
134
+ * types. If provided, must have been registered via registerPeer().
135
+ * @returns {Promise<void>} Resolves when the message has been published to the relays. Note that
136
+ * publication is best-effort: the method will resolve as long as at least one relay accepts the
137
+ * event, even if others reject it.
138
+ */
53
139
  sendMessage(message: BaseMessage, sender: Did, to?: Did): Promise<void>;
140
+ /**
141
+ * Publish the message once immediately and then re-publish on an interval
142
+ * until the returned stop function is invoked.
143
+ *
144
+ * Useful for broadcast messages (COHORT_ADVERT) on relays that don't
145
+ * backfill historical events to late subscribers: republishing gives late
146
+ * joiners a window to discover the message without requiring protocol
147
+ * changes. Relay rate-limit / publish failures inside the interval are
148
+ * caught and logged rather than propagated — the caller should stop the
149
+ * repeater once the protocol condition is satisfied.
150
+ */
151
+ publishRepeating(message: BaseMessage, sender: Did, intervalMs: number, recipient?: Did): () => void;
54
152
  }
55
153
  //# sourceMappingURL=nostr.d.ts.map
@@ -1 +1 @@
1
-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ACH,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,GAAG,IAAI;IAY5D;;;;;OAKG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI9C;;;;;;;;;OASG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI;IAW5F;;;;;;;;OAQG;IACH,KAAK,IAAI,cAAc;IAsCvB;;;;;;;;;;;OAWG;IACG,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC;IAmF7E;;;;;;;;;;OAUG;IACH,gBAAgB,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,GAAG,GAAG,MAAM,IAAI;CAwNrG"}
@@ -3,7 +3,7 @@ import type { BaseMessage } from '../messages/base.js';
3
3
  export type SyncMessageHandler = (msg: any) => void;
4
4
  export type AsyncMessageHandler = (msg: any) => Promise<void>;
5
5
  export type MessageHandler = SyncMessageHandler | AsyncMessageHandler;
6
- export type TransportType = 'nostr' | 'didcomm';
6
+ export type TransportType = 'nostr' | 'didcomm' | 'http';
7
7
  /**
8
8
  * Multi-actor message transport.
9
9
  *
@@ -31,7 +31,32 @@ export interface Transport {
31
31
  getPeerPk(did: string): Uint8Array | undefined;
32
32
  /** Register a message handler scoped to a specific actor. */
33
33
  registerMessageHandler(actorDid: string, messageType: string, handler: MessageHandler): void;
34
+ /** Remove a previously-registered handler. No-op if not registered. */
35
+ unregisterMessageHandler(actorDid: string, messageType: string): void;
36
+ /**
37
+ * Detach an actor: unregister all its handlers, drop its keys, and close any
38
+ * transport-level subscriptions created for it. No-op if the actor is not
39
+ * registered.
40
+ */
41
+ unregisterActor(did: string): void;
34
42
  /** Send a message. The transport looks up sender to resolve signing keys. */
35
43
  sendMessage(message: BaseMessage, sender: string, recipient?: string): Promise<void>;
44
+ /**
45
+ * Publish the message once immediately and then repeat it on a fixed
46
+ * interval. Returns a stop function the caller MUST invoke when the repeat
47
+ * is no longer needed (e.g. once the protocol state that required the
48
+ * message is satisfied).
49
+ *
50
+ * Useful for broadcasts on transports that don't reliably backfill
51
+ * historical events to late subscribers (many Nostr relays) — republishing
52
+ * gives late joiners a window in which to discover the message. The first
53
+ * publish is synchronous-ish (fired before the method returns).
54
+ *
55
+ * Callers specify `recipient` only for directed messages; for broadcasts
56
+ * it is omitted.
57
+ *
58
+ * @returns A stop function. Idempotent — safe to call more than once.
59
+ */
60
+ publishRepeating(message: BaseMessage, sender: string, intervalMs: number, recipient?: string): () => void;
36
61
  }
37
62
  //# sourceMappingURL=transport.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../../../src/core/aggregation/transport/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,IAAI,CAAC;AACpD,MAAM,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9D,MAAM,MAAM,cAAc,GAAG,kBAAkB,GAAG,mBAAmB,CAAC;AAEtE,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IAEb,sEAAsE;IACtE,KAAK,IAAI,IAAI,CAAC;IAEd,sEAAsE;IACtE,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,GAAG,IA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c,GAAG,IAAI,CAAC;IAEvD,uEAAuE;IACvE,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAEhD,4EAA4E;IAC5E,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,eAAe,EAAE,UAAU,GAAG,IAAI,CAAC;IAE7D,yDAAyD;IACzD,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IAE/C,6DAA6D;IAC7D,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAE7F,uEAAuE;IACvE,wBAAwB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAEtE;;;;OAIG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAEnC,6EAA6E;IAC7E,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErF;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CACd,OAAO,EAAE,WAAW,EACpB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,IAAI,CAAC;CACf"}
@@ -1,17 +1,122 @@
1
- import type { BitcoinConnection } from '@did-btcr2/bitcoin';
1
+ import type { AddressUtxo, BitcoinConnection, BTCNetwork } from '@did-btcr2/bitcoin';
2
2
  import type { KeyBytes } from '@did-btcr2/common';
3
3
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
+ import type { Signer } from '@did-btcr2/keypair';
5
+ import { Transaction } from '@scure/btc-signer';
4
6
  import type { BeaconProcessResult } from '../resolver.js';
5
7
  import type { SidecarData } from '../types.js';
6
8
  import type { FeeEstimator } from './fee-estimator.js';
7
9
  import type { BeaconService, BeaconSignal } from './interfaces.js';
8
10
  /**
9
- * Options accepted by {@link Beacon.buildSignAndBroadcast}.
11
+ * Singleton beacon script kinds. Per the did:btcr2 spec, deterministic DID documents
12
+ * include three beacon services: P2PKH, P2WPKH, and P2TR (taproot key-path) — all
13
+ * derived from the genesis secp256k1 public key. The singleton broadcast path must
14
+ * support signing for all three.
15
+ */
16
+ export type SingletonScriptKind = 'p2pkh' | 'p2wpkh' | 'p2tr';
17
+ /**
18
+ * Conservative vsize estimate for a 1-input P2TR key-path → 1 P2TR change + 1 OP_RETURN(32) tx.
19
+ * Stripped 137 + witness ≈ 68 (marker + flag + stack-count + sig-len + 64 BIP-340 sig).
20
+ * Weight = 137*4 + 68 = 616, vsize ≈ 154, rounded to 160 for headroom.
21
+ */
22
+ export declare const P2TR_BEACON_TX_VSIZE = 160;
23
+ /**
24
+ * Conservative vsize estimate for a 1-input P2WPKH → 1 P2WPKH change + 1 OP_RETURN(32) tx.
25
+ * Stripped 125 + witness ≈ 110 (worst-case DER ECDSA sig 72 + sighash byte + 33 pubkey + framing).
26
+ * vsize = ceil((125*4 + 110) / 4) ≈ 153, rounded to 155.
27
+ */
28
+ export declare const P2WPKH_BEACON_TX_VSIZE = 155;
29
+ /**
30
+ * Conservative vsize estimate for a 1-input P2PKH → 1 P2PKH change + 1 OP_RETURN(32) tx.
31
+ * Legacy (non-segwit): scriptSig carries the full sig+pubkey (~108 bytes), no witness
32
+ * discount. Stripped ≈ 4 nVer + 1 vin-count + (32+4+1+108+4) input + 1 vout-count +
33
+ * 34 P2PKH-change + 43 OP_RETURN + 4 nLockTime ≈ 236 bytes. vsize = 236, rounded to 240.
34
+ */
35
+ export declare const P2PKH_BEACON_TX_VSIZE = 240;
36
+ /** Per-kind vsize lookup for singleton beacon fee estimation. */
37
+ export declare const SINGLETON_BEACON_TX_VSIZE: Readonly<Record<SingletonScriptKind, number>>;
38
+ /**
39
+ * Detect the singleton script kind of a Bitcoin address (P2PKH / P2WPKH / P2TR).
40
+ * The deterministic-DID document emits all three kinds; the broadcast path needs
41
+ * to know which is in use to construct the input and dispatch the signing primitive.
42
+ */
43
+ export declare function detectSingletonScriptKind(bitcoinAddress: string, network: BTCNetwork): SingletonScriptKind;
44
+ /**
45
+ * Derive the address that `pubkey` produces under the given script kind. Used to
46
+ * fail-fast when a caller wires a signer to a beacon address that the signer's
47
+ * pubkey cannot actually spend.
48
+ */
49
+ export declare function deriveSingletonAddress(kind: SingletonScriptKind, pubkey: KeyBytes, network: BTCNetwork): string;
50
+ /**
51
+ * Options accepted by {@link Beacon.buildSignAndBroadcast} and related helpers.
10
52
  */
11
53
  export interface BroadcastOptions {
12
54
  /** Fee estimator for computing the transaction fee. Defaults to {@link DEFAULT_FEE_ESTIMATOR}. */
13
55
  feeEstimator?: FeeEstimator;
14
56
  }
57
+ /**
58
+ * Unsigned beacon transaction + the prev-output metadata needed for downstream
59
+ * signing (single-party ECDSA or multi-party MuSig2 Taproot).
60
+ */
61
+ export interface BeaconTxPlan {
62
+ /** The unsigned scure @scure/btc-signer Transaction. */
63
+ tx: Transaction;
64
+ /** Scripts of the consumed previous outputs (needed for Taproot sighash). */
65
+ prevOutScripts: Uint8Array[];
66
+ /** Amounts (sats) of the consumed previous outputs. */
67
+ prevOutValues: bigint[];
68
+ /** Address change was sent back to (same as the beacon address). */
69
+ beaconAddress: string;
70
+ /** The UTXO this tx consumes. */
71
+ utxo: AddressUtxo;
72
+ /** The fee (sats) already deducted from the change output. */
73
+ feeSats: bigint;
74
+ /**
75
+ * Singleton beacon script kind, when applicable. Drives the signing dispatch
76
+ * in {@link Beacon.signSinglePartyTx}. Aggregation plans set this to `'p2tr'`.
77
+ */
78
+ scriptKind: SingletonScriptKind;
79
+ }
80
+ /**
81
+ * Build an OP_RETURN script carrying a 32-byte beacon signal.
82
+ * Exported as a utility so callers building txs outside Beacon (e.g., the aggregation
83
+ * `onProvideTxData` callback) can produce identical output.
84
+ *
85
+ * Uses the opcode *string* `'RETURN'` rather than the numeric `OP.RETURN`
86
+ * constant because scure's `Script.encode` interprets a number as a byte to
87
+ * push, not as the opcode. The string form emits the bare opcode (0x6a)
88
+ * followed by an `OP_PUSHBYTES_32` push, producing the standard NULL_DATA
89
+ * shape Bitcoin Core's `IsStandard` accepts. The numeric form silently
90
+ * produces `OP_PUSHBYTES_1 0x6a OP_PUSHBYTES_32 <32 bytes>`, which is
91
+ * non-standard and rejected at broadcast with `RPC error -26: scriptpubkey`.
92
+ */
93
+ export declare function opReturnScript(signalBytes: Uint8Array): Uint8Array;
94
+ /**
95
+ * Build an aggregation beacon transaction (P2TR key-path spend) ready for MuSig2 signing.
96
+ * Returns the unsigned Transaction + prev-output metadata that an aggregation service's
97
+ * signing session consumes (via {@link SigningTxData}).
98
+ *
99
+ * This is the reusable counterpart to {@link Beacon.buildSignAndBroadcast}'s internal
100
+ * construction step — the aggregation path must produce an unsigned tx because the
101
+ * signature comes from a MuSig2 round, not a local secret key.
102
+ *
103
+ * @param opts Parameters including the cohort's aggregate internal pubkey.
104
+ * @returns A {@link BeaconTxPlan} with the unsigned tx and sighash inputs.
105
+ */
106
+ export declare function buildAggregationBeaconTx(opts: {
107
+ /** The beacon (cohort) address where UTXOs live and change returns to. */
108
+ beaconAddress: string;
109
+ /** The cohort's MuSig2-aggregated x-only internal pubkey (32 bytes). */
110
+ internalPubkey: Uint8Array;
111
+ /** 32-byte beacon signal embedded in the OP_RETURN output. */
112
+ signalBytes: Uint8Array;
113
+ /** Bitcoin REST connection for UTXO / prev-tx lookup. */
114
+ bitcoin: BitcoinConnection;
115
+ /** Network params used to derive the P2TR witnessUtxo script. */
116
+ network: BTCNetwork;
117
+ /** Optional fee estimator (defaults to 5 sat/vB). */
118
+ feeEstimator?: FeeEstimator;
119
+ }): Promise<BeaconTxPlan>;
15
120
  /**
16
121
  * Abstract base class for all BTCR2 Beacon types.
17
122
  * A Beacon is a service listed in a BTCR2 DID document that informs resolvers
@@ -49,37 +154,59 @@ export declare abstract class Beacon {
49
154
  * Broadcasts a signed update as a Beacon Signal to the Bitcoin network.
50
155
  * Used during the update path.
51
156
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
52
- * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
157
+ * @param {Signer} signer Signer that produces the signature for the spending input.
158
+ * ECDSA for P2PKH / P2WPKH singletons, Schnorr (BIP-340) for P2TR key-path.
53
159
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
54
160
  * @param {BroadcastOptions} [options] Optional broadcast configuration (e.g. fee estimator).
55
161
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
56
162
  */
57
- abstract broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
163
+ abstract broadcastSignal(signedUpdate: SignedBTCR2Update, signer: Signer, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
58
164
  /**
59
- * Shared PSBT construction + signing + broadcast helper used by all beacon types.
165
+ * Build + sign + broadcast a singleton beacon signal transaction. The beacon
166
+ * address's script kind (P2PKH / P2WPKH / P2TR) is detected automatically
167
+ * and the input is constructed and signed accordingly.
60
168
  *
61
- * Steps:
62
- * 1. Parse the beacon's `serviceEndpoint` (stripping `bitcoin:` prefix) into a Bitcoin address.
63
- * 2. Query the address for unconfirmed/confirmed UTXOs.
64
- * 3. Select the most recent confirmed UTXO.
65
- * 4. Fetch the previous transaction hex for `nonWitnessUtxo`.
66
- * 5. Build a PSBT: input (UTXO) → change output + OP_RETURN(signalBytes).
67
- * 6. Compute the fee via the supplied (or default) {@link FeeEstimator} against the tx vsize.
68
- * 7. Sign input 0 with an ECDSA signer derived from `secretKey`.
69
- * 8. Finalize, extract, and broadcast via the REST transaction endpoint.
70
- *
71
- * Fee handling: the PSBT is constructed with a placeholder change amount, signed to measure
72
- * vsize, then the change is adjusted to pay the actual fee and the input re-signed. This
73
- * two-pass approach avoids hardcoded fee constants and produces a tx that matches the
74
- * estimator's rate.
169
+ * Composed from the three extracted phases ({@link buildSinglePartyTx},
170
+ * {@link signSinglePartyTx}, {@link broadcastRawTx}) so each piece can be exercised
171
+ * in isolation. Aggregation beacons use {@link buildAggregationBeaconTx} instead —
172
+ * the multi-party path can't share the signing phase, but the tx-construction
173
+ * plumbing (UTXO fetch + OP_RETURN output + change output) is shared.
75
174
  *
76
175
  * @param signalBytes 32-byte payload to embed in OP_RETURN.
77
- * @param secretKey Secret key used to sign the spending input.
176
+ * @param signer Signer used to sign the spending input.
78
177
  * @param bitcoin Bitcoin network connection.
79
178
  * @param options Broadcast options (fee estimator, etc.).
80
179
  * @returns The txid of the broadcast transaction.
81
- * @throws {BeaconError} if the address is unfunded or no UTXO is available.
180
+ * @throws {BeaconError} if the address is unfunded, no UTXO is available, or fee exceeds value.
181
+ */
182
+ protected buildSignAndBroadcast(signalBytes: Uint8Array, signer: Signer, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<string>;
183
+ /**
184
+ * Build an unsigned singleton beacon tx ready for {@link signSinglePartyTx}.
185
+ *
186
+ * Detects the beacon address script kind (P2PKH / P2WPKH / P2TR) and configures
187
+ * the input accordingly. Validates that the signer's pubkey produces the beacon
188
+ * address under that script kind — without this check, a misconfigured caller
189
+ * would burn a real UTXO on a tx that fails at broadcast. Fees are computed from
190
+ * the per-kind {@link SINGLETON_BEACON_TX_VSIZE} constant, avoiding any probe-sign
191
+ * round-trip.
192
+ */
193
+ protected buildSinglePartyTx(opts: {
194
+ signalBytes: Uint8Array;
195
+ beaconAddress: string;
196
+ utxo: AddressUtxo;
197
+ prevTxBytes: Uint8Array;
198
+ signer: Signer;
199
+ bitcoin: BitcoinConnection;
200
+ feeEstimator: FeeEstimator;
201
+ }): Promise<BeaconTxPlan>;
202
+ /**
203
+ * Sign + finalize the unsigned single-party tx and return its raw hex.
204
+ * Dispatches to the correct signing primitive based on `plan.scriptKind`.
205
+ */
206
+ protected signSinglePartyTx(plan: BeaconTxPlan, signer: Signer): Promise<string>;
207
+ /**
208
+ * Broadcast raw transaction hex via the Bitcoin REST endpoint. Returns the txid.
82
209
  */
83
- protected buildSignAndBroadcast(signalBytes: Uint8Array, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<string>;
210
+ protected broadcastRawTx(bitcoin: BitcoinConnection, rawHex: string): Promise<string>;
84
211
  }
85
212
  //# sourceMappingURL=beacon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAKnE;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kGAAkG;IAClG,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,8BAAsB,MAAM;IAC1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;gBAEpB,OAAO,EAAE,aAAa;IAIlC;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,cAAc,CACrB,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,mBAAmB;IAEtB;;;;;;;;OAQG;IACH,QAAQ,CAAC,eAAe,CACtB,YAAY,EAAE,iBAAi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inConnection } from '@did-btcr2/bitcoin';
2
- import type { KeyBytes } from '@did-btcr2/common';
3
2
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
+ import type { Signer } from '@did-btcr2/keypair';
4
4
  import type { BeaconProcessResult } from '../resolver.js';
5
5
  import type { SidecarData } from '../types.js';
6
6
  import type { BroadcastOptions } from './beacon.js';
@@ -56,13 +56,13 @@ export declare class CASBeacon extends Beacon {
56
56
  * and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
57
57
  *
58
58
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
59
- * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
59
+ * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
60
60
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
61
61
  * @param {CASBroadcastOptions} [options] Optional broadcast configuration, including a
62
62
  * `casPublish` callback to publish the announcement off-chain and a `feeEstimator`.
63
63
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
64
64
  * @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
65
65
  */
66
- broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: CASBroadcastOptions): Promise<SignedBTCR2Update>;
66
+ broadcastSignal(signedUpdate: SignedBTCR2Update, signer: Signer, bitcoin: BitcoinConnection, options?: CASBroadcastOptions): Promise<SignedBTCR2Update>;
67
67
  }
68
68
  //# sourceMappingURL=cas-beacon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cas-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/cas-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,C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AAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAiB,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEhG;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;IAC3D,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,SAAU,SAAQ,MAAM;IACnC;;;OAGG;gBACS,OAAO,EAAE,aAAa;IAIlC;;;;;;;;;;;;OAYG;IACH,cAAc,CACZ,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,mBAAmB;IAsDtB;;;;;;;;;;;;;;;OAeG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,iBAAiB,CAAC;CAuB9B"}
@@ -1,6 +1,6 @@
1
1
  import type { BitcoinConnection } from '@did-btcr2/bitcoin';
2
- import type { KeyBytes } from '@did-btcr2/common';
3
2
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
+ import type { Signer } from '@did-btcr2/keypair';
4
4
  import type { BeaconProcessResult } from '../resolver.js';
5
5
  import type { SidecarData } from '../types.js';
6
6
  import type { BroadcastOptions } from './beacon.js';
@@ -33,12 +33,12 @@ export declare class SingletonBeacon extends Beacon {
33
33
  * {@link Beacon.buildSignAndBroadcast}.
34
34
  *
35
35
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
36
- * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
36
+ * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
37
37
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
38
38
  * @param {BroadcastOptions} [options] Optional broadcast configuration (e.g. fee estimator).
39
39
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
40
40
  * @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
41
41
  */
42
- broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
42
+ broadcastSignal(signedUpdate: SignedBTCR2Update, signer: Signer, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
43
43
  }
44
44
  //# sourceMappingURL=singleton-beacon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"singleton-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/singleton-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAY,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAElF;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,MAAM;IAEzC;;;OAGG;gBACS,OAAO,EAAE,aAAa;IAIlC;;;;;OAKG;IACH,cAAc,CACZ,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,mBAAmB;IA0BtB;;;;;;;;;;;;;OAaG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC;CAK9B"}
1
+ {"version":3,"file":"singleton-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/singleton-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,KAAK,EAAE,mBAAmB,EAAY,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAElF;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,MAAM;IAEzC;;;OAGG;gBACS,OAAO,EAAE,aAAa;IAIlC;;;;;OAKG;IACH,cAAc,CACZ,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,mBAAmB;IA0BtB;;;;;;;;;;;;;OAaG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC;CAK9B"}
@@ -1,6 +1,6 @@
1
1
  import type { BitcoinConnection } from '@did-btcr2/bitcoin';
2
- import type { KeyBytes } from '@did-btcr2/common';
3
2
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
+ import type { Signer } from '@did-btcr2/keypair';
4
4
  import type { BeaconProcessResult } from '../resolver.js';
5
5
  import type { SidecarData } from '../types.js';
6
6
  import type { BroadcastOptions } from './beacon.js';
@@ -47,12 +47,12 @@ export declare class SMTBeacon extends Beacon {
47
47
  * signing, and broadcast are delegated to {@link Beacon.buildSignAndBroadcast}.
48
48
  *
49
49
  * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
50
- * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
50
+ * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
51
51
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
52
52
  * @param {BroadcastOptions} [options] Optional broadcast configuration (e.g. fee estimator).
53
53
  * @return {Promise<SignedBTCR2Update>} The signed update that was broadcast.
54
54
  * @throws {BeaconError} if the bitcoin address is invalid, unfunded, or UTXO cannot cover the fee.
55
55
  */
56
- broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
56
+ broadcastSignal(signedUpdate: SignedBTCR2Update, signer: Signer, bitcoin: BitcoinConnection, options?: BroadcastOptions): Promise<SignedBTCR2Update>;
57
57
  }
58
58
  //# sourceMappingURL=smt-beacon.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"smt-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE,OAAO,KAAK,EAAE,mBAAmB,EAAY,MAAM,gBAAgB,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,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AAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,mBAAmB;IAiEtB;;;;;;;;;;;;;;OAcG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,EAC1B,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,iBAAiB,CAAC;CAgB9B"}
@@ -1,5 +1,5 @@
1
+ import type { BTCNetwork } from '@did-btcr2/bitcoin';
1
2
  import type { KeyBytes, Maybe } from '@did-btcr2/common';
2
- import type { networks } from 'bitcoinjs-lib';
3
3
  import type { DidDocument } from '../../utils/did-document.js';
4
4
  import type { BeaconService } from './interfaces.js';
5
5
  /**
@@ -53,7 +53,7 @@ export declare class BeaconUtils {
53
53
  static generateBeaconServices({ id, publicKey, network, beaconType }: {
54
54
  id: string;
55
55
  publicKey: KeyBytes;
56
- network: networks.Network;
56
+ network: BTCNetwork;
57
57
  beaconType: string;
58
58
  }): Array<BeaconService>;
59
59
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAC,MAAM,mBAAmB,CAAC;AAExD,OAAO,KAAK,EAAE,QAAQ,EAAC,MAAM,eAAe,CAAC;AAG7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAGrD;;;;GAIG;AACH,qBAAa,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAO/C;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO;IAc1D;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,WAAW,E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AAa,WAAW;IACtB;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAO/C;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,OAAO;IAc1D;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,WAAW,EAAE,WAAW,GAAG,aAAa,EAAE;IAKnE;;;;;OAKG;IACH,MAAM,CAAC,oBAAoB,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC;IAiBlF;;;;;;;OAOG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa;IA2BpH;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;QACpE,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,QAAQ,CAAC;QACpB,OAAO,EAAE,UAAU,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,KAAK,CAAC,aAAa,CAAC;IAoCxB;;;;OAIG;IACH,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;IAIvE;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;IAQtF;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE;CAG/D"}
@@ -1,12 +1,14 @@
1
1
  import type { BitcoinConnection } from '@did-btcr2/bitcoin';
2
- import type { KeyBytes, PatchOperation } from '@did-btcr2/common';
2
+ import type { PatchOperation } from '@did-btcr2/common';
3
3
  import { type SignedBTCR2Update, type UnsignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
+ import type { Signer } from '@did-btcr2/keypair';
4
5
  import { type Btcr2DidDocument, type DidVerificationMethod } from '../utils/did-document.js';
5
6
  import type { BeaconService } from './beacon/interfaces.js';
6
7
  /**
7
- * The updater needs the caller to supply a signing key (or a KMS-backed signature)
8
- * for the given verification method. The unsigned update is attached so the caller
9
- * can inspect it before producing a signature.
8
+ * The updater needs the caller to supply a {@link Signer} for the given
9
+ * verification method. The unsigned update is attached so the caller can
10
+ * inspect it before producing a signature. The signer can wrap a local secret
11
+ * key (`LocalSigner`), a KMS-managed key (`KeyManagerSigner`), or any custom backend.
10
12
  */
11
13
  export interface NeedSigningKey {
12
14
  readonly kind: 'NeedSigningKey';
@@ -29,6 +31,18 @@ export interface NeedFunding {
29
31
  /** The beacon service this address belongs to. */
30
32
  readonly beaconService: BeaconService;
31
33
  }
34
+ /**
35
+ * Optional proof the caller passes when fulfilling {@link NeedFunding}. The
36
+ * state machine asserts the proof before transitioning to Broadcast. Sans-I/O
37
+ * is preserved: the caller still performs the UTXO lookup; this is just a
38
+ * contract-level handshake.
39
+ */
40
+ export interface FundingProof {
41
+ /** Number of spendable UTXOs the caller observed at the beacon address. Must be >= 1. */
42
+ utxoCount: number;
43
+ /** Optional txid the caller funded with, for diagnostics. */
44
+ txid?: string;
45
+ }
32
46
  /**
33
47
  * The updater needs the caller to broadcast the signed update via the beacon.
34
48
  *
@@ -86,20 +100,21 @@ export interface UpdaterParams {
86
100
  *
87
101
  * ```typescript
88
102
  * const updater = DidBtcr2.update({ sourceDocument, patches, ... });
103
+ * const signer = new LocalSigner(secretKeyBytes); // or KeyManagerSigner / custom
89
104
  * let state = updater.advance();
90
105
  *
91
106
  * while(state.status === 'action-required') {
92
107
  * for(const need of state.needs) {
93
108
  * switch(need.kind) {
94
109
  * case 'NeedSigningKey':
95
- * updater.provide(need, secretKeyBytes);
110
+ * updater.provide(need, signer);
96
111
  * break;
97
112
  * case 'NeedFunding':
98
113
  * // Check UTXOs at need.beaconAddress, fund if needed
99
114
  * updater.provide(need);
100
115
  * break;
101
116
  * case 'NeedBroadcast':
102
- * await Updater.announce(need.beaconService, need.signedUpdate, secretKey, bitcoin);
117
+ * await Updater.announce(need.beaconService, need.signedUpdate, signer, bitcoin);
103
118
  * updater.provide(need);
104
119
  * break;
105
120
  * }
@@ -143,21 +158,21 @@ export declare class Updater {
143
158
  * @param {string} did The did-btcr2 identifier to derive the root capability from.
144
159
  * @param {UnsignedBTCR2Update} unsignedUpdate The unsigned update to sign.
145
160
  * @param {DidVerificationMethod} verificationMethod The verification method for signing.
146
- * @param {KeyBytes} secretKey The secret key bytes.
161
+ * @param {Signer} signer Signer that produces the BIP-340 Schnorr signature.
147
162
  * @returns {SignedBTCR2Update} The signed update with a Data Integrity proof.
148
163
  */
149
- static sign(did: string, unsignedUpdate: UnsignedBTCR2Update, verificationMethod: DidVerificationMethod, secretKey: KeyBytes): SignedBTCR2Update;
164
+ static sign(did: string, unsignedUpdate: UnsignedBTCR2Update, verificationMethod: DidVerificationMethod, signer: Signer): SignedBTCR2Update;
150
165
  /**
151
166
  * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#announce-did-update | 7.3.d Announce DID Update}.
152
167
  * Announces a signed update to the Bitcoin blockchain via the specified beacon.
153
168
  *
154
169
  * @param {BeaconService} beaconService The beacon service to broadcast through.
155
170
  * @param {SignedBTCR2Update} update The signed update to announce.
156
- * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
171
+ * @param {Signer} signer Signer that produces the ECDSA signature for the Bitcoin transaction.
157
172
  * @param {BitcoinConnection} bitcoin The Bitcoin network connection.
158
173
  * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
159
174
  */
160
- static announce(beaconService: BeaconService, update: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinConnection): Promise<SignedBTCR2Update>;
175
+ static announce(beaconService: BeaconService, update: SignedBTCR2Update, signer: Signer, bitcoin: BitcoinConnection): Promise<SignedBTCR2Update>;
161
176
  /**
162
177
  * Advance the state machine. Returns either:
163
178
  * - `{ status: 'action-required', needs }` — caller must provide data via {@link provide}
@@ -171,8 +186,8 @@ export declare class Updater {
171
186
  * @param need The DataNeed being fulfilled (from the `needs` array).
172
187
  * @param data The data payload corresponding to the need kind (omit for NeedFunding/NeedBroadcast).
173
188
  */
174
- provide(need: NeedSigningKey, data: KeyBytes): void;
175
- provide(need: NeedFunding): void;
189
+ provide(need: NeedSigningKey, data: Signer): void;
190
+ provide(need: NeedFunding, proof?: FundingProof): void;
176
191
  provide(need: NeedBroadcast): void;
177
192
  }
178
193
  //# sourceMappingURL=updater.d.ts.map