@did-btcr2/method 0.29.0 → 0.33.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 (115) hide show
  1. package/README.md +36 -16
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/browser.js +6763 -6170
  4. package/dist/browser.mjs +6763 -6170
  5. package/dist/cjs/index.js +1860 -467
  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/transport/factory.js +15 -6
  9. package/dist/esm/core/aggregation/transport/factory.js.map +1 -1
  10. package/dist/esm/core/aggregation/transport/http/client.js +350 -0
  11. package/dist/esm/core/aggregation/transport/http/client.js.map +1 -0
  12. package/dist/esm/core/aggregation/transport/http/envelope.js +126 -0
  13. package/dist/esm/core/aggregation/transport/http/envelope.js.map +1 -0
  14. package/dist/esm/core/aggregation/transport/http/errors.js +11 -0
  15. package/dist/esm/core/aggregation/transport/http/errors.js.map +1 -0
  16. package/dist/esm/core/aggregation/transport/http/inbox-buffer.js +45 -0
  17. package/dist/esm/core/aggregation/transport/http/inbox-buffer.js.map +1 -0
  18. package/dist/esm/core/aggregation/transport/http/index.js +12 -0
  19. package/dist/esm/core/aggregation/transport/http/index.js.map +1 -0
  20. package/dist/esm/core/aggregation/transport/http/nonce-cache.js +38 -0
  21. package/dist/esm/core/aggregation/transport/http/nonce-cache.js.map +1 -0
  22. package/dist/esm/core/aggregation/transport/http/protocol.js +28 -0
  23. package/dist/esm/core/aggregation/transport/http/protocol.js.map +1 -0
  24. package/dist/esm/core/aggregation/transport/http/rate-limiter.js +45 -0
  25. package/dist/esm/core/aggregation/transport/http/rate-limiter.js.map +1 -0
  26. package/dist/esm/core/aggregation/transport/http/request-auth.js +100 -0
  27. package/dist/esm/core/aggregation/transport/http/request-auth.js.map +1 -0
  28. package/dist/esm/core/aggregation/transport/http/server.js +481 -0
  29. package/dist/esm/core/aggregation/transport/http/server.js.map +1 -0
  30. package/dist/esm/core/aggregation/transport/http/sse-stream.js +110 -0
  31. package/dist/esm/core/aggregation/transport/http/sse-stream.js.map +1 -0
  32. package/dist/esm/core/aggregation/transport/http/sse-writer.js +25 -0
  33. package/dist/esm/core/aggregation/transport/http/sse-writer.js.map +1 -0
  34. package/dist/esm/core/aggregation/transport/index.js +1 -0
  35. package/dist/esm/core/aggregation/transport/index.js.map +1 -1
  36. package/dist/esm/core/beacon/beacon.js +197 -51
  37. package/dist/esm/core/beacon/beacon.js.map +1 -1
  38. package/dist/esm/core/beacon/cas-beacon.js +3 -3
  39. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  40. package/dist/esm/core/beacon/singleton-beacon.js +3 -3
  41. package/dist/esm/core/beacon/singleton-beacon.js.map +1 -1
  42. package/dist/esm/core/beacon/smt-beacon.js +22 -14
  43. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  44. package/dist/esm/core/resolver.js +7 -4
  45. package/dist/esm/core/resolver.js.map +1 -1
  46. package/dist/esm/core/updater.js +63 -55
  47. package/dist/esm/core/updater.js.map +1 -1
  48. package/dist/types/core/aggregation/beacon-strategy.d.ts.map +1 -1
  49. package/dist/types/core/aggregation/transport/factory.d.ts +22 -7
  50. package/dist/types/core/aggregation/transport/factory.d.ts.map +1 -1
  51. package/dist/types/core/aggregation/transport/http/client.d.ts +48 -0
  52. package/dist/types/core/aggregation/transport/http/client.d.ts.map +1 -0
  53. package/dist/types/core/aggregation/transport/http/envelope.d.ts +64 -0
  54. package/dist/types/core/aggregation/transport/http/envelope.d.ts.map +1 -0
  55. package/dist/types/core/aggregation/transport/http/errors.d.ts +9 -0
  56. package/dist/types/core/aggregation/transport/http/errors.d.ts.map +1 -0
  57. package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts +32 -0
  58. package/dist/types/core/aggregation/transport/http/inbox-buffer.d.ts.map +1 -0
  59. package/dist/types/core/aggregation/transport/http/index.d.ts +12 -0
  60. package/dist/types/core/aggregation/transport/http/index.d.ts.map +1 -0
  61. package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts +26 -0
  62. package/dist/types/core/aggregation/transport/http/nonce-cache.d.ts.map +1 -0
  63. package/dist/types/core/aggregation/transport/http/protocol.d.ts +53 -0
  64. package/dist/types/core/aggregation/transport/http/protocol.d.ts.map +1 -0
  65. package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts +41 -0
  66. package/dist/types/core/aggregation/transport/http/rate-limiter.d.ts.map +1 -0
  67. package/dist/types/core/aggregation/transport/http/request-auth.d.ts +50 -0
  68. package/dist/types/core/aggregation/transport/http/request-auth.d.ts.map +1 -0
  69. package/dist/types/core/aggregation/transport/http/server.d.ts +110 -0
  70. package/dist/types/core/aggregation/transport/http/server.d.ts.map +1 -0
  71. package/dist/types/core/aggregation/transport/http/sse-stream.d.ts +34 -0
  72. package/dist/types/core/aggregation/transport/http/sse-stream.d.ts.map +1 -0
  73. package/dist/types/core/aggregation/transport/http/sse-writer.d.ts +12 -0
  74. package/dist/types/core/aggregation/transport/http/sse-writer.d.ts.map +1 -0
  75. package/dist/types/core/aggregation/transport/index.d.ts +1 -0
  76. package/dist/types/core/aggregation/transport/index.d.ts.map +1 -1
  77. package/dist/types/core/aggregation/transport/transport.d.ts +1 -1
  78. package/dist/types/core/aggregation/transport/transport.d.ts.map +1 -1
  79. package/dist/types/core/beacon/beacon.d.ts +72 -12
  80. package/dist/types/core/beacon/beacon.d.ts.map +1 -1
  81. package/dist/types/core/beacon/cas-beacon.d.ts +3 -3
  82. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  83. package/dist/types/core/beacon/singleton-beacon.d.ts +3 -3
  84. package/dist/types/core/beacon/singleton-beacon.d.ts.map +1 -1
  85. package/dist/types/core/beacon/smt-beacon.d.ts +3 -3
  86. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  87. package/dist/types/core/interfaces.d.ts +14 -11
  88. package/dist/types/core/interfaces.d.ts.map +1 -1
  89. package/dist/types/core/resolver.d.ts.map +1 -1
  90. package/dist/types/core/updater.d.ts +27 -12
  91. package/dist/types/core/updater.d.ts.map +1 -1
  92. package/package.json +20 -8
  93. package/src/core/aggregation/beacon-strategy.ts +5 -4
  94. package/src/core/aggregation/transport/factory.ts +48 -12
  95. package/src/core/aggregation/transport/http/client.ts +409 -0
  96. package/src/core/aggregation/transport/http/envelope.ts +204 -0
  97. package/src/core/aggregation/transport/http/errors.ts +11 -0
  98. package/src/core/aggregation/transport/http/inbox-buffer.ts +53 -0
  99. package/src/core/aggregation/transport/http/index.ts +11 -0
  100. package/src/core/aggregation/transport/http/nonce-cache.ts +43 -0
  101. package/src/core/aggregation/transport/http/protocol.ts +57 -0
  102. package/src/core/aggregation/transport/http/rate-limiter.ts +75 -0
  103. package/src/core/aggregation/transport/http/request-auth.ts +164 -0
  104. package/src/core/aggregation/transport/http/server.ts +615 -0
  105. package/src/core/aggregation/transport/http/sse-stream.ts +121 -0
  106. package/src/core/aggregation/transport/http/sse-writer.ts +23 -0
  107. package/src/core/aggregation/transport/index.ts +1 -0
  108. package/src/core/aggregation/transport/transport.ts +1 -1
  109. package/src/core/beacon/beacon.ts +255 -64
  110. package/src/core/beacon/cas-beacon.ts +4 -4
  111. package/src/core/beacon/singleton-beacon.ts +4 -4
  112. package/src/core/beacon/smt-beacon.ts +24 -16
  113. package/src/core/interfaces.ts +14 -11
  114. package/src/core/resolver.ts +8 -5
  115. package/src/core/updater.ts +113 -67
@@ -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,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GAWG;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;IAyEtB;;;;;;;;;;;;;;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"}
@@ -38,36 +38,39 @@ export interface ResolutionOptions extends DidResolutionOptions {
38
38
  * a path from a leaf in the tree to the Merkle root, proving that the leaf is in the tree.
39
39
  * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#smt-proof | SMT Proof (data structure)}.
40
40
  *
41
+ * All SHA-256 hash fields (`id`, `nonce`, `updateId`, `hashes`) are "base64url"
42
+ * [RFC4648] encoded without padding (43 chars each). `collapsed` is the 256-bit
43
+ * zero-node bitmap, also base64url no-pad (43 chars).
44
+ *
41
45
  * @example
42
46
  * ```json
43
47
  * {
44
- * "id": "<< Hexadecimal of Root Hash >>",
45
- * "nonce": "<< Hexadecimal of Nonce 1101 >>",
46
- * "updateId": "<< Hexadecimal of hash(Data Block 1101) >>",
47
- * "collapsed": "<< Hexadecimal of 0001 >>",
48
+ * "id": "q1H_iaYG0Oq6gbrycYL-r7FjUsJLnIpHDn49TLeONNA",
49
+ * "nonce": "99jndCBWHpZfmObXlIvRGHaPMgoQKXIETdD4H-XqryE",
50
+ * "updateId": "njYNViJq2OmhSw1fLfARPCj12RY3VXKGWdS3-7OQ2BE",
51
+ * "collapsed": "v_________________________________________8",
48
52
  * "hashes": [
49
- * "<< Hexadecimal of Hash 1110 >>",
50
- * "<< Hexadecimal of Hash 1001 >>",
51
- * "<< Hexadecimal of Hash 0 >>"
53
+ * "8JWXL7chPKJXwg-i9O1EFTHan_oOO_RmglDpu_ugax0"
52
54
  * ]
53
55
  * }
54
56
  * ```
55
57
  */
56
58
  export interface SMTProof {
57
59
  /**
58
- * The SHA-256 hash of the root node of the Sparse Merkle Tree.
60
+ * base64url (no padding) SHA-256 hash of the root node of the Sparse Merkle Tree.
59
61
  */
60
62
  id: string;
61
63
  /**
62
- * Optional 256-bit nonce generated for each update. Hex-encoded (64 chars).
64
+ * Optional 256-bit nonce generated for each update. base64url, no padding (43 chars).
63
65
  */
64
66
  nonce?: string;
65
67
  /**
66
- * Optional hex-encoded canonical hash of the BTCR2 Signed Update.
68
+ * Optional base64url (no padding) canonical hash of the BTCR2 Signed Update.
67
69
  */
68
70
  updateId?: string;
69
71
  /**
70
- * Bitmap of zero nodes within the path (see: collapsed leaves).
72
+ * base64url (no padding) bitmap of zero nodes within the path (see: collapsed
73
+ * leaves). Bit set = empty/zero sibling; bit clear = a sibling hash is present.
71
74
  */
72
75
  collapsed: string;
73
76
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
1
+ {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAkB,SAAQ,oBAAoB;IAC7D;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/core/resolver.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,iBAAiB,EAElB,MAAM,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AAM,CAAC,OAAO,CACZ,eAAe,EAAE,WAAW,EAC5B,eAAe,EAAE,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,EAC1D,WAAW,CAAC,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,MAAM,GACjB,qBAAqB;IAgHxB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAsB/B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAqF1B;;;;;;OAMG;IACH,OAAO,IAAI,aAAa;IAuIxB;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IACtD,OAAO,CAAC,IAAI,EAAE,iBAAiB,EAAE,IAAI,EAAE,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,GAAG,IAAI;IACrF,OAAO,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,eAAe,GAAG,IAAI;IAC/D,OAAO,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,GAAG,IAAI;IAC9D,OAAO,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI;CA4ClD"}
@@ -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
@@ -1 +1 @@
1
- {"version":3,"file":"updater.d.ts","sourceRoot":"","sources":["../../../src/core/updater.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElE,OAAO,EAA6C,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AACrI,OAAO,EAAe,KAAK,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAE1G,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAI5D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,EAAE,mBAAmB,CAAC;CAC9C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;CACvC;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,gGAAgG;IAChG,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC;IACtC,6CAA6C;IAC7C,QAAQ,CAAC,YAAY,EAAE,iBAAiB,CAAC;CAC1C;AAED,qFAAqF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AQ,CACnB,aAAa,EAAE,aAAa,EAC5B,MAAM,EAAE,iBAAiB,EACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,iBAAiB,GACzB,OAAO,CAAC,iBAAiB,CAAC;IAa7B;;;;OAIG;IACH,OAAO,IAAI,YAAY;IAiEvB;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IACjD,OAAO,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI;IACtD,OAAO,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI;CAkEnC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@did-btcr2/method",
3
- "version": "0.29.0",
3
+ "version": "0.33.0",
4
4
  "type": "module",
5
5
  "description": "Reference implementation for the did:btcr2 DID method written in TypeScript and JavaScript. did:btcr2 is a censorship resistant DID Method using the Bitcoin blockchain as a Verifiable Data Registry to announce changes to the DID document. This is the core method implementation for the did-btcr2-js monorepo.",
6
6
  "main": "./dist/cjs/index.js",
@@ -80,11 +80,11 @@
80
80
  "helia": "^5.5.1",
81
81
  "multiformats": "^13.4.2",
82
82
  "nostr-tools": "^2.23.3",
83
- "@did-btcr2/smt": "^0.2.4",
84
- "@did-btcr2/cryptosuite": "^6.0.6",
83
+ "@did-btcr2/smt": "^0.3.0",
84
+ "@did-btcr2/keypair": "^0.13.0",
85
+ "@did-btcr2/cryptosuite": "^8.0.0",
85
86
  "@did-btcr2/bitcoin": "^0.6.0",
86
- "@did-btcr2/common": "^9.0.0",
87
- "@did-btcr2/keypair": "^0.11.4"
87
+ "@did-btcr2/common": "^9.1.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@eslint/js": "^9.39.4",
@@ -98,6 +98,7 @@
98
98
  "c8": "^10.1.3",
99
99
  "chai": "^5.3.3",
100
100
  "chai-as-promised": "^8.0.2",
101
+ "commander": "^13.1.0",
101
102
  "esbuild": "^0.24.2",
102
103
  "eslint": "^9.39.4",
103
104
  "eslint-plugin-mocha": "^10.5.0",
@@ -132,12 +133,23 @@
132
133
  "lint": "eslint . --max-warnings 0",
133
134
  "lint:fix": "eslint . --fix",
134
135
  "test": "pnpm c8 mocha",
135
- "test:unit": "[ -z \"$FILE_NAME\" ] && echo 'ERROR: FILE_NAME is not set' || pnpm tsx lib/test-$FILE_NAME.ts",
136
+ "test:unit": "[ -z \"$FILE_NAME\" ] && echo 'ERROR: FILE_NAME is not set' || bun lib/test-$FILE_NAME.ts",
136
137
  "build:test": "pnpm build && pnpm build:tests && pnpm c8 mocha",
137
138
  "build:lint:test": "pnpm build && pnpm build:tests && pnpm lint:fix",
138
139
  "prepublish": "pnpm build",
139
- "generate:vector": "pnpm tsx lib/generate-vector.ts",
140
- "do": "pnpm tsx",
140
+ "generate:vector": "bun lib/generate-vector.ts",
141
+ "generate:scenario": "bun lib/generate-scenario.ts",
142
+ "scenario:keys": "bun lib/scenario-keys.ts",
143
+ "scenario:artifacts": "bun lib/build-artifacts.ts",
144
+ "scenario:route": "bun lib/route-delivery.ts",
145
+ "scenario:publish": "bun lib/publish-scenarios.ts",
146
+ "scenario:funding": "bun lib/aggregate-funding.ts",
147
+ "scenario:fund": "bun lib/fund-scenarios.ts",
148
+ "scenario:anchor": "bun lib/anchor-scenarios.ts",
149
+ "scenario:verify": "bun lib/verify-scenarios.ts",
150
+ "scenario:verify:live": "bun lib/verify-live.ts",
151
+ "wallet": "bun lib/wallet/cli.ts",
152
+ "do": "bun",
141
153
  "do:lib": "${PWD}/lib/run-lib.sh",
142
154
  "pack:local": "pnpm pack && mv *.tgz ./release"
143
155
  }
@@ -1,7 +1,7 @@
1
1
  import { canonicalize } from '@did-btcr2/common';
2
2
  import type { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
3
  import type { SerializedSMTProof } from '@did-btcr2/smt';
4
- import { blockHash, didToIndex, hashToHex, hexToHash, verifySerializedProof } from '@did-btcr2/smt';
4
+ import { base64UrlToHash, blockHash, didToIndex, hashToBase64Url, verifySerializedProof } from '@did-btcr2/smt';
5
5
  import type { AggregationCohort } from './cohort.js';
6
6
  import type { BaseBody } from './messages/base.js';
7
7
 
@@ -90,15 +90,16 @@ const SMT_STRATEGY: AggregateBeaconStrategy = {
90
90
  validateParticipantView({ participantDid, submittedUpdate, body }) {
91
91
  const smtProof = body.smtProof as unknown as SerializedSMTProof | undefined;
92
92
  if(!smtProof?.updateId || !smtProof?.nonce) return { matches: false };
93
- // Verify updateId matches the canonicalized update hash
93
+ // Verify updateId matches the canonicalized update hash. Proof hash fields
94
+ // are base64url (no padding) per the SMT Proof spec.
94
95
  const canonicalBytes = new TextEncoder().encode(canonicalize(submittedUpdate as unknown as Record<string, unknown>));
95
- const expectedUpdateId = hashToHex(blockHash(canonicalBytes));
96
+ const expectedUpdateId = hashToBase64Url(blockHash(canonicalBytes));
96
97
  if(smtProof.updateId !== expectedUpdateId) {
97
98
  return { matches: false, smtProof };
98
99
  }
99
100
  // Verify Merkle inclusion
100
101
  const index = didToIndex(participantDid);
101
- const candidateHash = blockHash(blockHash(hexToHash(smtProof.nonce)), hexToHash(smtProof.updateId));
102
+ const candidateHash = blockHash(blockHash(base64UrlToHash(smtProof.nonce)), base64UrlToHash(smtProof.updateId));
102
103
  return {
103
104
  matches : verifySerializedProof(smtProof, index, candidateHash),
104
105
  smtProof,
@@ -1,28 +1,64 @@
1
1
  import { NotImplementedError } from '@did-btcr2/common';
2
- import { NostrTransport } from './nostr.js';
2
+ import type { Logger } from '../logger.js';
3
3
  import { TransportError } from './error.js';
4
- import type { Transport, TransportType } from './transport.js';
4
+ import type { HttpClientTransportConfig } from './http/client.js';
5
+ import { HttpClientTransport } from './http/client.js';
6
+ import type { HttpServerTransportConfig } from './http/server.js';
7
+ import { HttpServerTransport } from './http/server.js';
8
+ import { NostrTransport } from './nostr.js';
9
+ import type { Transport } from './transport.js';
10
+
11
+ /** Discriminated-union config for {@link TransportFactory.establish}. */
12
+ export type TransportConfig =
13
+ | NostrTransportConfigOption
14
+ | DidCommTransportConfigOption
15
+ | HttpClientTransportConfigOption
16
+ | HttpServerTransportConfigOption;
5
17
 
6
- export interface TransportConfig {
7
- type: TransportType;
18
+ export interface NostrTransportConfigOption {
19
+ type: 'nostr';
8
20
  relays?: string[];
21
+ logger?: Logger;
22
+ broadcastLookbackMs?: number;
23
+ }
24
+
25
+ export interface DidCommTransportConfigOption {
26
+ type: 'didcomm';
9
27
  }
10
28
 
11
- /**
12
- * Factory for creating Transport instances.
13
- * @class TransportFactory
14
- */
29
+ export interface HttpClientTransportConfigOption extends HttpClientTransportConfig {
30
+ type: 'http';
31
+ role: 'client';
32
+ }
33
+
34
+ export interface HttpServerTransportConfigOption extends HttpServerTransportConfig {
35
+ type: 'http';
36
+ role: 'server';
37
+ }
38
+
39
+ /** Factory for creating Transport instances. */
15
40
  export class TransportFactory {
16
41
  static establish(config: TransportConfig): Transport {
17
- switch (config.type) {
42
+ switch(config.type) {
18
43
  case 'nostr':
19
- return new NostrTransport({ relays: config.relays });
44
+ return new NostrTransport({
45
+ relays : config.relays,
46
+ logger : config.logger,
47
+ broadcastLookbackMs : config.broadcastLookbackMs,
48
+ });
20
49
  case 'didcomm':
21
50
  throw new NotImplementedError('DIDComm transport not implemented yet.');
51
+ case 'http':
52
+ if(config.role === 'client') return new HttpClientTransport(config);
53
+ if(config.role === 'server') return new HttpServerTransport(config);
54
+ throw new NotImplementedError(
55
+ `HTTP transport role not implemented: ${(config as { role: string }).role}`,
56
+ );
22
57
  default:
23
58
  throw new TransportError(
24
- `Invalid transport type: ${config.type}`,
25
- 'INVALID_TRANSPORT_TYPE', { config }
59
+ `Invalid transport type: ${(config as { type: string }).type}`,
60
+ 'INVALID_TRANSPORT_TYPE',
61
+ { config },
26
62
  );
27
63
  }
28
64
  }