@did-btcr2/method 0.18.1 → 0.20.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 (291) hide show
  1. package/dist/browser.js +4917 -6487
  2. package/dist/browser.mjs +4917 -6487
  3. package/dist/cjs/core/beacon/aggregation/cohort/index.js +3 -3
  4. package/dist/cjs/core/beacon/aggregation/cohort/index.js.map +1 -1
  5. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js +1 -9
  6. package/dist/cjs/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  7. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  8. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  9. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  10. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  11. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  12. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  13. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  14. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  15. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  16. package/dist/cjs/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  17. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  18. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  19. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  20. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  21. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  22. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  23. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  24. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  25. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  26. package/dist/cjs/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  27. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  28. package/dist/cjs/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  29. package/dist/cjs/core/beacon/aggregation/coordinator.js +14 -14
  30. package/dist/cjs/core/beacon/aggregation/coordinator.js.map +1 -1
  31. package/dist/cjs/core/beacon/aggregation/participant.js +4 -3
  32. package/dist/cjs/core/beacon/aggregation/participant.js.map +1 -1
  33. package/dist/cjs/core/beacon/aggregation/session/index.js +1 -1
  34. package/dist/cjs/core/beacon/aggregation/session/index.js.map +1 -1
  35. package/dist/cjs/core/beacon/beacon.js +25 -0
  36. package/dist/cjs/core/beacon/beacon.js.map +1 -0
  37. package/dist/cjs/core/beacon/cas-beacon.js +39 -0
  38. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -0
  39. package/dist/cjs/core/beacon/error.js +4 -4
  40. package/dist/cjs/core/beacon/error.js.map +1 -1
  41. package/dist/cjs/core/beacon/factory.js +10 -11
  42. package/dist/cjs/core/beacon/factory.js.map +1 -1
  43. package/dist/cjs/core/beacon/interfaces.js +2 -0
  44. package/dist/cjs/core/beacon/interfaces.js.map +1 -0
  45. package/dist/cjs/core/beacon/signal-discovery.js +183 -0
  46. package/dist/cjs/core/beacon/signal-discovery.js.map +1 -0
  47. package/dist/cjs/core/beacon/singleton.js +75 -178
  48. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  49. package/dist/cjs/core/beacon/smt-beacon.js +39 -0
  50. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -0
  51. package/dist/cjs/core/beacon/utils.js +71 -114
  52. package/dist/cjs/core/beacon/utils.js.map +1 -1
  53. package/dist/cjs/core/identifier.js +18 -21
  54. package/dist/cjs/core/identifier.js.map +1 -1
  55. package/dist/cjs/core/interfaces.js +2 -0
  56. package/dist/cjs/core/interfaces.js.map +1 -0
  57. package/dist/cjs/core/resolve.js +321 -0
  58. package/dist/cjs/core/resolve.js.map +1 -0
  59. package/dist/cjs/{utils → core}/types.js.map +1 -1
  60. package/dist/cjs/core/update.js +113 -0
  61. package/dist/cjs/core/update.js.map +1 -0
  62. package/dist/cjs/did-btcr2.js +168 -129
  63. package/dist/cjs/did-btcr2.js.map +1 -1
  64. package/dist/cjs/index.js +17 -16
  65. package/dist/cjs/index.js.map +1 -1
  66. package/dist/cjs/utils/appendix.js +16 -33
  67. package/dist/cjs/utils/appendix.js.map +1 -1
  68. package/dist/cjs/utils/did-document-builder.js +5 -0
  69. package/dist/cjs/utils/did-document-builder.js.map +1 -1
  70. package/dist/cjs/utils/did-document.js +62 -72
  71. package/dist/cjs/utils/did-document.js.map +1 -1
  72. package/dist/cjs/utils/general.js +1 -1
  73. package/dist/cjs/utils/general.js.map +1 -1
  74. package/dist/esm/core/beacon/aggregation/cohort/index.js +3 -3
  75. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
  76. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +1 -9
  77. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  78. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  79. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  80. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  81. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  82. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  83. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  84. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  85. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  86. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  87. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  88. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  89. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  90. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  91. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  92. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  93. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  94. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  95. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  96. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  97. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  98. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  99. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  100. package/dist/esm/core/beacon/aggregation/coordinator.js +14 -14
  101. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  102. package/dist/esm/core/beacon/aggregation/participant.js +4 -3
  103. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  104. package/dist/esm/core/beacon/aggregation/session/index.js +1 -1
  105. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
  106. package/dist/esm/core/beacon/beacon.js +25 -0
  107. package/dist/esm/core/beacon/beacon.js.map +1 -0
  108. package/dist/esm/core/beacon/cas-beacon.js +39 -0
  109. package/dist/esm/core/beacon/cas-beacon.js.map +1 -0
  110. package/dist/esm/core/beacon/error.js +4 -4
  111. package/dist/esm/core/beacon/error.js.map +1 -1
  112. package/dist/esm/core/beacon/factory.js +10 -11
  113. package/dist/esm/core/beacon/factory.js.map +1 -1
  114. package/dist/esm/core/beacon/interfaces.js +2 -0
  115. package/dist/esm/core/beacon/interfaces.js.map +1 -0
  116. package/dist/esm/core/beacon/signal-discovery.js +183 -0
  117. package/dist/esm/core/beacon/signal-discovery.js.map +1 -0
  118. package/dist/esm/core/beacon/singleton.js +75 -178
  119. package/dist/esm/core/beacon/singleton.js.map +1 -1
  120. package/dist/esm/core/beacon/smt-beacon.js +39 -0
  121. package/dist/esm/core/beacon/smt-beacon.js.map +1 -0
  122. package/dist/esm/core/beacon/utils.js +71 -114
  123. package/dist/esm/core/beacon/utils.js.map +1 -1
  124. package/dist/esm/core/identifier.js +18 -21
  125. package/dist/esm/core/identifier.js.map +1 -1
  126. package/dist/esm/core/interfaces.js +2 -0
  127. package/dist/esm/core/interfaces.js.map +1 -0
  128. package/dist/esm/core/resolve.js +321 -0
  129. package/dist/esm/core/resolve.js.map +1 -0
  130. package/dist/esm/{utils → core}/types.js.map +1 -1
  131. package/dist/esm/core/update.js +113 -0
  132. package/dist/esm/core/update.js.map +1 -0
  133. package/dist/esm/did-btcr2.js +168 -129
  134. package/dist/esm/did-btcr2.js.map +1 -1
  135. package/dist/esm/index.js +17 -16
  136. package/dist/esm/index.js.map +1 -1
  137. package/dist/esm/utils/appendix.js +16 -33
  138. package/dist/esm/utils/appendix.js.map +1 -1
  139. package/dist/esm/utils/did-document-builder.js +5 -0
  140. package/dist/esm/utils/did-document-builder.js.map +1 -1
  141. package/dist/esm/utils/did-document.js +62 -72
  142. package/dist/esm/utils/did-document.js.map +1 -1
  143. package/dist/esm/utils/general.js +1 -1
  144. package/dist/esm/utils/general.js.map +1 -1
  145. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -1
  146. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +0 -7
  147. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
  148. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
  149. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
  150. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
  151. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
  152. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
  153. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
  154. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
  155. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
  156. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
  157. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
  158. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +13 -5
  159. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
  160. package/dist/types/core/beacon/aggregation/coordinator.d.ts +17 -29
  161. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  162. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  163. package/dist/types/core/beacon/beacon.d.ts +44 -0
  164. package/dist/types/core/beacon/beacon.d.ts.map +1 -0
  165. package/dist/types/core/beacon/cas-beacon.d.ts +36 -0
  166. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -0
  167. package/dist/types/core/beacon/error.d.ts +2 -2
  168. package/dist/types/core/beacon/error.d.ts.map +1 -1
  169. package/dist/types/core/beacon/factory.d.ts +4 -5
  170. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  171. package/dist/types/core/beacon/interfaces.d.ts +59 -0
  172. package/dist/types/core/beacon/interfaces.d.ts.map +1 -0
  173. package/dist/types/core/beacon/signal-discovery.d.ts +25 -0
  174. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -0
  175. package/dist/types/core/beacon/singleton.d.ts +20 -76
  176. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  177. package/dist/types/core/beacon/smt-beacon.d.ts +36 -0
  178. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -0
  179. package/dist/types/core/beacon/utils.d.ts +19 -97
  180. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  181. package/dist/types/core/identifier.d.ts.map +1 -1
  182. package/dist/types/core/interfaces.d.ts +87 -0
  183. package/dist/types/core/interfaces.d.ts.map +1 -0
  184. package/dist/types/core/resolve.d.ts +89 -0
  185. package/dist/types/core/resolve.d.ts.map +1 -0
  186. package/dist/types/core/types.d.ts +84 -0
  187. package/dist/types/core/types.d.ts.map +1 -0
  188. package/dist/types/core/update.d.ts +51 -0
  189. package/dist/types/core/update.d.ts.map +1 -0
  190. package/dist/types/did-btcr2.d.ts +70 -89
  191. package/dist/types/did-btcr2.d.ts.map +1 -1
  192. package/dist/types/index.d.ts +17 -16
  193. package/dist/types/index.d.ts.map +1 -1
  194. package/dist/types/utils/appendix.d.ts +5 -10
  195. package/dist/types/utils/appendix.d.ts.map +1 -1
  196. package/dist/types/utils/did-document-builder.d.ts +6 -1
  197. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  198. package/dist/types/utils/did-document.d.ts +46 -42
  199. package/dist/types/utils/did-document.d.ts.map +1 -1
  200. package/package.json +6 -6
  201. package/src/core/beacon/aggregation/cohort/index.ts +3 -3
  202. package/src/core/beacon/aggregation/cohort/messages/base.ts +1 -12
  203. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -2
  204. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -2
  205. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -2
  206. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -2
  207. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -2
  208. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -2
  209. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -2
  210. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -2
  211. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -2
  212. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -2
  213. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +43 -21
  214. package/src/core/beacon/aggregation/coordinator.ts +41 -29
  215. package/src/core/beacon/aggregation/participant.ts +4 -3
  216. package/src/core/beacon/aggregation/session/index.ts +1 -1
  217. package/src/core/beacon/beacon.ts +58 -0
  218. package/src/core/beacon/cas-beacon.ts +53 -0
  219. package/src/core/beacon/error.ts +5 -6
  220. package/src/core/beacon/factory.ts +12 -16
  221. package/src/core/beacon/interfaces.ts +67 -0
  222. package/src/core/beacon/signal-discovery.ts +237 -0
  223. package/src/core/beacon/singleton.ts +107 -197
  224. package/src/core/beacon/smt-beacon.ts +53 -0
  225. package/src/core/beacon/utils.ts +95 -182
  226. package/src/core/identifier.ts +21 -24
  227. package/src/core/interfaces.ts +93 -0
  228. package/src/core/resolve.ts +463 -0
  229. package/src/core/types.ts +95 -0
  230. package/src/core/update.ts +154 -0
  231. package/src/did-btcr2.ts +255 -159
  232. package/src/index.ts +19 -22
  233. package/src/utils/appendix.ts +26 -44
  234. package/src/utils/did-document-builder.ts +6 -1
  235. package/src/utils/did-document.ts +105 -113
  236. package/src/utils/general.ts +1 -1
  237. package/dist/cjs/core/beacon/cid-aggregate.js +0 -116
  238. package/dist/cjs/core/beacon/cid-aggregate.js.map +0 -1
  239. package/dist/cjs/core/beacon/smt-aggregate.js +0 -126
  240. package/dist/cjs/core/beacon/smt-aggregate.js.map +0 -1
  241. package/dist/cjs/core/crud/deactivate.js +0 -14
  242. package/dist/cjs/core/crud/deactivate.js.map +0 -1
  243. package/dist/cjs/core/crud/read.js +0 -679
  244. package/dist/cjs/core/crud/read.js.map +0 -1
  245. package/dist/cjs/core/crud/update.js +0 -194
  246. package/dist/cjs/core/crud/update.js.map +0 -1
  247. package/dist/cjs/interfaces/beacon.js +0 -41
  248. package/dist/cjs/interfaces/beacon.js.map +0 -1
  249. package/dist/cjs/interfaces/crud.js +0 -2
  250. package/dist/cjs/interfaces/crud.js.map +0 -1
  251. package/dist/esm/core/beacon/cid-aggregate.js +0 -116
  252. package/dist/esm/core/beacon/cid-aggregate.js.map +0 -1
  253. package/dist/esm/core/beacon/smt-aggregate.js +0 -126
  254. package/dist/esm/core/beacon/smt-aggregate.js.map +0 -1
  255. package/dist/esm/core/crud/deactivate.js +0 -14
  256. package/dist/esm/core/crud/deactivate.js.map +0 -1
  257. package/dist/esm/core/crud/read.js +0 -679
  258. package/dist/esm/core/crud/read.js.map +0 -1
  259. package/dist/esm/core/crud/update.js +0 -194
  260. package/dist/esm/core/crud/update.js.map +0 -1
  261. package/dist/esm/interfaces/beacon.js +0 -41
  262. package/dist/esm/interfaces/beacon.js.map +0 -1
  263. package/dist/esm/interfaces/crud.js +0 -2
  264. package/dist/esm/interfaces/crud.js.map +0 -1
  265. package/dist/types/core/beacon/cid-aggregate.d.ts +0 -102
  266. package/dist/types/core/beacon/cid-aggregate.d.ts.map +0 -1
  267. package/dist/types/core/beacon/smt-aggregate.d.ts +0 -111
  268. package/dist/types/core/beacon/smt-aggregate.d.ts.map +0 -1
  269. package/dist/types/core/crud/deactivate.d.ts +0 -13
  270. package/dist/types/core/crud/deactivate.d.ts.map +0 -1
  271. package/dist/types/core/crud/read.d.ts +0 -334
  272. package/dist/types/core/crud/read.d.ts.map +0 -1
  273. package/dist/types/core/crud/update.d.ts +0 -93
  274. package/dist/types/core/crud/update.d.ts.map +0 -1
  275. package/dist/types/interfaces/beacon.d.ts +0 -116
  276. package/dist/types/interfaces/beacon.d.ts.map +0 -1
  277. package/dist/types/interfaces/crud.d.ts +0 -32
  278. package/dist/types/interfaces/crud.d.ts.map +0 -1
  279. package/dist/types/utils/types.d.ts +0 -38
  280. package/dist/types/utils/types.d.ts.map +0 -1
  281. package/src/canonicalize.d.ts +0 -6
  282. package/src/core/beacon/cid-aggregate.ts +0 -153
  283. package/src/core/beacon/smt-aggregate.ts +0 -135
  284. package/src/core/crud/deactivate.ts +0 -13
  285. package/src/core/crud/read.ts +0 -948
  286. package/src/core/crud/update.ts +0 -292
  287. package/src/interfaces/beacon.ts +0 -137
  288. package/src/interfaces/crud.ts +0 -33
  289. package/src/utils/types.ts +0 -41
  290. /package/dist/cjs/{utils → core}/types.js +0 -0
  291. /package/dist/esm/{utils → core}/types.js +0 -0
@@ -0,0 +1,463 @@
1
+ import {
2
+ BitcoinNetworkConnection,
3
+ getNetwork
4
+ } from '@did-btcr2/bitcoin';
5
+ import {
6
+ DateUtils,
7
+ IdentifierHrp,
8
+ INVALID_DID,
9
+ INVALID_DID_DOCUMENT,
10
+ INVALID_DID_UPDATE,
11
+ JSONPatch,
12
+ JSONUtils,
13
+ LATE_PUBLISHING_ERROR,
14
+ MISSING_UPDATE_DATA,
15
+ ResolveError
16
+ } from '@did-btcr2/common';
17
+ import {
18
+ BIP340Cryptosuite,
19
+ BIP340DataIntegrityProof,
20
+ SchnorrMultikey,
21
+ SignedBTCR2Update,
22
+ UnsignedBTCR2Update
23
+ } from '@did-btcr2/cryptosuite';
24
+ import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
25
+ import { bytesToHex } from '@noble/hashes/utils';
26
+ import { canonicalization, DidBtcr2 } from '../did-btcr2.js';
27
+ import { Appendix } from '../utils/appendix.js';
28
+ import { DidDocument, ID_PLACEHOLDER_VALUE } from '../utils/did-document.js';
29
+ import { BeaconFactory } from './beacon/factory.js';
30
+ import { BeaconService, BlockMetadata } from './beacon/interfaces.js';
31
+ import { BeaconSignalDiscovery } from './beacon/signal-discovery.js';
32
+ import { BeaconUtils } from './beacon/utils.js';
33
+ import { DidComponents, Identifier } from './identifier.js';
34
+ import { SMTProof } from './interfaces.js';
35
+ import { CASAnnouncement, Sidecar, SidecarData } from './types.js';
36
+
37
+ /**
38
+ * The response object for DID Resolution.
39
+ */
40
+ export interface DidResolutionResponse {
41
+ currentDocument: DidDocument;
42
+ confirmations: number;
43
+ versionId: string;
44
+ updated: string;
45
+ }
46
+
47
+ /**
48
+ * Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
49
+ * Resolving a did:btcr2 identifier iteratively builds a DID document by applying BTCR2 Updates
50
+ * to an Initial DID Document that have been committed to the Bitcoin blockchain by Authorized
51
+ * Beacon Signals. The Initial DID Document is either deterministically created from the DID or
52
+ * provided by Sidecar Data.
53
+ * @class Resolve
54
+ * @type {Resolve}
55
+ */
56
+ export class Resolve {
57
+ /**
58
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-secp256k1-public-key | 7.2.d.1 if genesis bytes is a secp256k1 Public Key}.
59
+ * @param {DidComponents} didComponents The decoded components of the did.
60
+ * @returns {DidDocument} The resolved DID Document object.
61
+ */
62
+ static deterministic(didComponents: DidComponents): DidDocument {
63
+ // Encode the did from the didComponents
64
+ const did = Identifier.encode(didComponents);
65
+
66
+ // Deconstruct the bytes from the given components
67
+ const { genesisBytes } = didComponents;
68
+
69
+ // Construct a new CompressedSecp256k1PublicKey and deconstruct the publicKey and publicKeyMultibase
70
+ const { multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(genesisBytes);
71
+
72
+ // Generate the service field for the DID Document
73
+ const service = BeaconUtils.generateBeaconServices({
74
+ id : did,
75
+ publicKey : genesisBytes,
76
+ network : getNetwork(didComponents.network),
77
+ beaconType : 'SingletonBeacon'
78
+ });
79
+
80
+ return new DidDocument({
81
+ id : did,
82
+ controller : [did],
83
+ verificationMethod : [{
84
+ id : `${did}#initialKey`,
85
+ type : 'Multikey',
86
+ controller : did,
87
+ publicKeyMultibase : publicKeyMultibase.encoded
88
+ }],
89
+ service
90
+ });
91
+ }
92
+
93
+ /**
94
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#if-genesis_bytes-is-a-sha-256-hash | 7.2.d.2 if genesis_bytes is a SHA-256 Hash}.
95
+ * @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
96
+ * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
97
+ * @returns {Promise<DidDocument>} The resolved DID Document object
98
+ * @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
99
+ */
100
+ static async external(
101
+ didComponents: DidComponents,
102
+ genesisDocument: object,
103
+ ): Promise<DidDocument> {
104
+ // Canonicalize and sha256 hash the currentDocument
105
+ const hashBytes = canonicalization.process(genesisDocument, { encoding: 'hex' });
106
+
107
+ // Compare the genesisBytes to the hashBytes
108
+ const genesisBytes = bytesToHex(didComponents.genesisBytes);
109
+
110
+ // If the genesisBytes do not match the hashBytes, throw an error
111
+ if (genesisBytes !== hashBytes) {
112
+ throw new ResolveError(
113
+ `Initial document mismatch: genesisBytes ${genesisBytes} !== hashBytes ${hashBytes}`,
114
+ INVALID_DID_DOCUMENT, { genesisBytes, hashBytes }
115
+ );
116
+ }
117
+
118
+ // Encode the did from the didComponents
119
+ const did = Identifier.encode(didComponents);
120
+
121
+ // Replace the placeholder did with the did throughout the currentDocument.
122
+ const currentDocument = JSON.parse(
123
+ JSON.stringify(genesisDocument).replaceAll(ID_PLACEHOLDER_VALUE, did)
124
+ );
125
+
126
+ // Return a W3C conformant DID Document
127
+ return new DidDocument(currentDocument);
128
+ }
129
+
130
+ /**
131
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
132
+ * @param {Sidecar} sidecar The sidecar data to process.
133
+ * @returns {ProcessedSidecar} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
134
+ */
135
+ static sidecarData(sidecar: Sidecar = {} as Sidecar): SidecarData {
136
+ // BTCR2 Signed Updates map
137
+ const updateMap = new Map<string, SignedBTCR2Update>();
138
+ if(sidecar.updates?.length)
139
+ for(const update of sidecar.updates) {
140
+ updateMap.set(canonicalization.process(update, { encoding: 'hex' }), update);
141
+ }
142
+
143
+ // CAS Announcements map
144
+ const casMap = new Map<string, CASAnnouncement>();
145
+ if(sidecar.casUpdates?.length)
146
+ for(const update of sidecar.casUpdates) {
147
+ casMap.set(canonicalization.process(update, { encoding: 'hex' }), update);
148
+ }
149
+
150
+ // SMT Proofs map
151
+ const smtMap = new Map<string, SMTProof>();
152
+ if(sidecar.smtProofs?.length)
153
+ for(const proof of sidecar.smtProofs) {
154
+ smtMap.set(proof.id, proof);
155
+ }
156
+
157
+ return { updateMap, casMap, smtMap };
158
+ }
159
+
160
+ /**
161
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
162
+ * Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
163
+ * The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
164
+ * @param {DidComponents} didComponents The decoded components of the did.
165
+ * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
166
+ * @returns {Promise<DidDocument>} The resolved DID Document object.
167
+ * @throws {ResolveError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
168
+ */
169
+
170
+ static async currentDocument(
171
+ didComponents: DidComponents,
172
+ genesisDocument?: object,
173
+ ): Promise<DidDocument> {
174
+ // Deconstruct the hrp from the components
175
+ const { hrp, genesisBytes } = didComponents;
176
+
177
+ // If hrp `x`, perform external resolution
178
+ if (hrp === IdentifierHrp.x) {
179
+ if(!genesisDocument)
180
+ throw new ResolveError(
181
+ 'External resolution requires genesisDocument',
182
+ MISSING_UPDATE_DATA, { didComponents }
183
+ );
184
+ return await this.external(didComponents, genesisDocument);
185
+ }
186
+
187
+ // Check for hrp `k`
188
+ if(hrp === IdentifierHrp.k){
189
+ // Validate genesis bytes as a compressed secp256k1 public key
190
+ if(!CompressedSecp256k1PublicKey.isValid(genesisBytes)) {
191
+ throw new ResolveError(
192
+ 'Deterministic resolution requires valid secp256k1 public key',
193
+ INVALID_DID, { genesisBytes }
194
+ );
195
+ }
196
+ // Perform deterministic resolution
197
+ return this.deterministic(didComponents);
198
+ }
199
+
200
+ // Else, throw an error for unsupported hrp
201
+ throw new ResolveError(`Unsupported DID hrp ${hrp}`, INVALID_DID, { hrp });
202
+ }
203
+
204
+ /**
205
+ * Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
206
+ * Signal Bytes (last output in OP_RETURN transaction).
207
+ * @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
208
+ * @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
209
+ * @param {BitcoinNetworkConnection} bitcoin The bitcoin network connection used to fetch beacon signals
210
+ * @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
211
+ */
212
+ static async beaconSignals(
213
+ beaconServices: Array<BeaconService>,
214
+ sidecarData: SidecarData,
215
+ bitcoin: BitcoinNetworkConnection
216
+ ): Promise<Array<[SignedBTCR2Update, BlockMetadata]>> {
217
+ // Discover Beacon Signals via indexer server (esplora/electrs) or full node
218
+ const beaconServicesSignals = bitcoin.network.rest
219
+ ? await BeaconSignalDiscovery.indexer(beaconServices, bitcoin)
220
+ : await BeaconSignalDiscovery.fullnode(beaconServices, bitcoin);
221
+
222
+ // Process each beacon's signals in parallel
223
+ const promises = Array.from(beaconServicesSignals.entries()).map(
224
+ async ([service, signals]) => {
225
+ // Skip beacons with no signals
226
+ if (!signals.length) return [];
227
+ // Establish a typed beacon and process its signals
228
+ return BeaconFactory.establish(service).processSignals(signals, sidecarData);
229
+ }
230
+ );
231
+
232
+ return (await Promise.all(promises)).flat();
233
+ }
234
+
235
+ /**
236
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
237
+ * @param {DidDocument} currentDocument The current DID Document to apply the updates to.
238
+ * @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
239
+ * @param {string} [versionTime] The optional version time to limit updates to.
240
+ * @param {string} [versionId] The optional version id to limit updates to.
241
+ * @returns {Promise<DidResolutionResponse>} The updated DID Document, number of confirmations, and version id.
242
+ */
243
+ static async updates(
244
+ currentDocument: DidDocument,
245
+ unsortedUpdates: Array<[SignedBTCR2Update, BlockMetadata]>,
246
+ versionTime?: string,
247
+ versionId?: string
248
+ ): Promise<DidResolutionResponse> {
249
+ // Start the version number being processed at 1
250
+ let currentVersionId = 1;
251
+
252
+ // Initialize an empty array to hold the update hashes
253
+ const updateHashHistory: string[] = [];
254
+
255
+ // 1. Sort updates by targetVersionId (ascending), using blockheight as tie-breaker
256
+ const updates = unsortedUpdates.sort(([upd0, blk0], [upd1, blk1]) =>
257
+ upd0.targetVersionId - upd1.targetVersionId || blk0.height - blk1.height
258
+ );
259
+
260
+ // Create a default response object
261
+ const response = {
262
+ currentDocument,
263
+ versionId : `${currentVersionId}`,
264
+ confirmations : 0,
265
+ updated : ''
266
+ };
267
+
268
+ // Iterate over each (update block) pair
269
+ for(const [update, block] of updates) {
270
+ // Get the hash of the current document
271
+ const currentDocumentHash = canonicalization.process(response.currentDocument, { encoding: 'base58' });
272
+
273
+ // Set confirmations to the block confirmations
274
+ response.confirmations = block.confirmations;
275
+
276
+ // Safely convert versionTime to timestamp
277
+ const vTime = DateUtils.dateStringToTimestamp(versionTime || '');
278
+ // Safely convert block.blocktime to timestamp
279
+ const bTime = DateUtils.blocktimeToTimestamp(block.time);
280
+ // Set the updated field to the blocktime of the current update
281
+ response.updated = DateUtils.toISOStringNonFractional(bTime);
282
+
283
+ // if resolutionOptions.versionTime is defined and the blocktime is more recent, return currentDocument
284
+ if(vTime < bTime) {
285
+ return response;
286
+ }
287
+
288
+ // Check update.targetVersionId against currentVersionId
289
+ // If update.targetVersionId <= currentVersionId, confirm duplicate update
290
+ if(update.targetVersionId <= currentVersionId) {
291
+ updateHashHistory.push(currentDocumentHash);
292
+ this.confirmDuplicate(update, updateHashHistory);
293
+ }
294
+
295
+ // If update.targetVersionId == currentVersionId + 1, apply the update
296
+ else if (update.targetVersionId === currentVersionId + 1) {
297
+ // Prepend `z` to the sourceHash if it does not start with it
298
+ const sourceHash = update.sourceHash.startsWith('z') ? update.sourceHash : `z${update.sourceHash}`;
299
+
300
+ // Check if update.sourceHash !== currentDocumentHash
301
+ if (sourceHash !== currentDocumentHash) {
302
+ // Raise an INVALID_DID_UPDATE error if they do not match
303
+ throw new ResolveError(
304
+ `Hash mismatch: update.sourceHash !== currentDocumentHash`,
305
+ INVALID_DID_UPDATE, { sourceHash, currentDocumentHash }
306
+ );
307
+ }
308
+ // Apply the update to the currentDocument and set it in the response
309
+ response.currentDocument = await this.applyUpdate(response.currentDocument, update);
310
+ // Create unsigned_update by removing the proof property from update.
311
+ const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']) as UnsignedBTCR2Update;
312
+ // Push the canonicalized unsigned update hash to the updateHashHistory
313
+ updateHashHistory.push(canonicalization.process(unsignedUpdate, { encoding: 'base58' }));
314
+ }
315
+
316
+ // If update.targetVersionId > currentVersionId + 1, throw LATE_PUBLISHING error
317
+ else if(update.targetVersionId > currentVersionId + 1) {
318
+ throw new ResolveError(
319
+ `Version Id Mismatch: targetVersionId cannot be > currentVersionId + 1`,
320
+ 'LATE_PUBLISHING_ERROR', {
321
+ targetVersionId : update.targetVersionId,
322
+ currentVersionId : String(currentVersionId + 1)
323
+ }
324
+ );
325
+ }
326
+
327
+ // Increment currentVersionId
328
+ currentVersionId++;
329
+ // Set currentVersionId in response
330
+ response.versionId = `${currentVersionId}`;
331
+
332
+ // If resolutionOptions.versionId is defined and <= currentVersionId, return currentDocument
333
+ if(currentVersionId >= Number(versionId)) {
334
+ return response;
335
+ }
336
+
337
+ // Check if the current document is deactivated before further processing
338
+ if(currentDocument.deactivated) {
339
+ return response;
340
+ }
341
+ }
342
+
343
+ // Return response data
344
+ return response;
345
+ }
346
+
347
+ /**
348
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
349
+ * This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
350
+ * @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
351
+ * @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
352
+ */
353
+ static confirmDuplicate(update: SignedBTCR2Update, updateHashHistory: string[]): void {
354
+ // Create unsigned_update by removing the proof property from update.
355
+ const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']) as UnsignedBTCR2Update;
356
+
357
+ // Hash unsignedUpdate with JSON Document Hashing algorithm
358
+ const unsignedUpdateHash = canonicalization.process(unsignedUpdate);
359
+
360
+ // 5. Let historicalUpdateHash equal updateHashHistory[updateHashIndex].
361
+ const historicalUpdateHash = updateHashHistory[update.targetVersionId - 2];
362
+
363
+ // Check if the updateHash matches the historical hash
364
+ if (updateHashHistory[update.targetVersionId - 2] !== unsignedUpdateHash) {
365
+ throw new ResolveError(
366
+ `Invalid duplicate: ${unsignedUpdateHash} does not match ${historicalUpdateHash}`,
367
+ LATE_PUBLISHING_ERROR, { unsignedUpdateHash, updateHashHistory }
368
+ );
369
+ }
370
+ }
371
+
372
+ /**
373
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
374
+ * @param {DidDocument} currentDocument The current DID Document to apply the update to.
375
+ * @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
376
+ * @returns {Promise<DidDocument>} The updated DID Document after applying the update.
377
+ * @throws {ResolveError} If the update is invalid or cannot be applied.
378
+ */
379
+ static async applyUpdate(
380
+ currentDocument: DidDocument,
381
+ update: SignedBTCR2Update
382
+ ): Promise<DidDocument> {
383
+ // Get the capability id from the to update proof.
384
+ const capabilityId = update.proof?.capability;
385
+ // Since this field is optional, check that it exists
386
+ if (!capabilityId) {
387
+ // If it does not exist, throw INVALID_DID_UPDATE error
388
+ throw new ResolveError('No root capability found in update', INVALID_DID_UPDATE, update);
389
+ }
390
+
391
+ // Get the root capability object by dereferencing the capabilityId
392
+ const rootCapability = Appendix.dereferenceZcapId(capabilityId);
393
+
394
+ // Deconstruct the invocationTarget and controller from the root capability
395
+ const { invocationTarget, controller: rootController } = rootCapability;
396
+ // Check that both invocationTarget and rootController equal currentDocument.id
397
+ if (![invocationTarget, rootController].every((id) => id === currentDocument.id)) {
398
+ // If they do not all match, throw INVALID_DID_UPDATE error
399
+ throw new ResolveError(
400
+ 'Invalid root capability',
401
+ INVALID_DID_UPDATE, { rootCapability, currentDocument }
402
+ );
403
+ }
404
+
405
+ // Get the verificationMethod field from the update proof as verificationMethodId.
406
+ const verificationMethodId = update.proof?.verificationMethod;
407
+ // Since this field is optional, check that it exists
408
+ if(!verificationMethodId) {
409
+ // If it does not exist, throw INVALID_DID_UPDATE error
410
+ throw new ResolveError('No verificationMethod found in update', INVALID_DID_UPDATE, update);
411
+ }
412
+
413
+ // Get the verificationMethod from the DID Document using the verificationMethodId.
414
+ const vm = DidBtcr2.getSigningMethod(currentDocument, verificationMethodId);
415
+
416
+ // Construct a new SchnorrMultikey.
417
+ const multikey = SchnorrMultikey.fromVerificationMethod(vm);
418
+
419
+ // Construct a new BIP340Cryptosuite with the SchnorrMultikey.
420
+ const cryptosuite = new BIP340Cryptosuite(multikey);
421
+
422
+ // Canonicalize the update
423
+ const canonicalUpdate = canonicalization.canonicalize(update);
424
+
425
+ // Construct a DataIntegrityProof with the cryptosuite
426
+ const diProof = new BIP340DataIntegrityProof(cryptosuite);
427
+
428
+ // Call the verifyProof method
429
+ const verificationResult = diProof.verifyProof(canonicalUpdate, 'capabilityInvocation');
430
+
431
+ // If the result is not verified, throw INVALID_DID_UPDATE error
432
+ if (!verificationResult.verified) {
433
+ throw new ResolveError(
434
+ 'Invalid update: proof not verified',
435
+ INVALID_DID_UPDATE, verificationResult
436
+ );
437
+ }
438
+
439
+ // Apply the update.patch to the currentDocument to get the updatedDocument.
440
+ const updatedDocument = JSONPatch.apply(currentDocument, update.patch) as DidDocument;
441
+
442
+ // Verify that updatedDocument is conformant to DID Core v1.1.
443
+ DidDocument.validate(updatedDocument);
444
+
445
+ // Canonicalize and hash the updatedDocument to get the currentDocumentHash.
446
+ const currentDocumentHash = canonicalization.process(currentDocument, { encoding: 'base58' });
447
+
448
+ // Prepare the update targetHash for comparison with currentDocumentHash.
449
+ const updateTargetHash = update.targetHash.startsWith('z') ? update.targetHash : `z${update.targetHash}`;
450
+
451
+ // Make sure the update.targetHash equals currentDocumentHash.
452
+ if (updateTargetHash !== currentDocumentHash) {
453
+ // If they do not match, throw INVALID_DID_UPDATE error.
454
+ throw new ResolveError(
455
+ `Invalid update: updateTargetHash !== currentDocumentHash`,
456
+ INVALID_DID_UPDATE, { updateTargetHash, currentDocumentHash }
457
+ );
458
+ }
459
+
460
+ // Return final updatedDocument.
461
+ return updatedDocument;
462
+ }
463
+ }
@@ -0,0 +1,95 @@
1
+ import { HexString } from '@did-btcr2/common';
2
+ import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
+ import { SMTProof } from './interfaces.js';
4
+
5
+ /**
6
+ * {@link https://dcdpr.github.io/did-btcr2/data-structures.html#cas-announcement | CAS Announcement }
7
+ * a data structure that maps DIDs to BTCR2 Signed Update hashes. All BTCR2 Signed
8
+ * Updates (data structure) MUST be hashed with the JSON Document Hashing algorithm.
9
+ * The concrete representation of this data structure will be published to a CAS.
10
+ * @example
11
+ * ```json
12
+ * {
13
+ * "did:btcr2:k1q5pa5tq86fzrl0ez32nh8e0ks4tzzkxnnmn8tdvxk04ahzt70u09dag02h0cp": "a4ayc_80_OGda4BO_1o_V0etpOqiLx1JwB5S3beHW0s",
14
+ * "did:btcr2:x1qhjw6jnhwcyu5wau4x0cpwvz74c3g82c3uaehqpaf7lzfgmnwsd7spmmf54": "1HNeOiZeFu7gP1lxi5tdAwGcB9i2xR-Q2jpmbuwTqzU",
15
+ * "did:btcr2:k1qgp5h79scv4sfqkzak5g6y89dsy3cq0pd2nussu2cm3zjfhn4ekwrucc4q7t7": "TgdAhWK-24tgzgXB3s_jrRa3IjCWfeAfZAt-Rym0n84"
16
+ * }
17
+ * ```
18
+ */
19
+ export type CASAnnouncement = {
20
+ [key: string]: string
21
+ }
22
+
23
+ /**
24
+ * See {@link https://dcdpr.github.io/did-btcr2/terminology.html#sidecar | Sidecar }
25
+ * for more details about the sidecar mechanism. See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#sidecar-data | Sidecar Data}
26
+ * for more details about the data structure.
27
+ */
28
+ export type Sidecar = {
29
+ /**
30
+ * The context string "https://btcr2.dev/context/v1"
31
+ */
32
+ '@context'?: string,
33
+
34
+ /**
35
+ * Optional Genesis Did Document. Required when resolving did:btcr2 identifiers
36
+ * with `x` HRP.D
37
+ */
38
+ genesisDocument?: object;
39
+
40
+ /**
41
+ * Optional array of BTCR2 Signed Updates. Required if the DID being resolved
42
+ * has ever had a published BTCR2 Update.
43
+ */
44
+ updates?: Array<SignedBTCR2Update>
45
+
46
+ /**
47
+ * Optional array of CAS Announcements. Required if the DID being reslved has
48
+ * used a CAS Beacon to publish a BTCR2 Update.
49
+ */
50
+ casUpdates?: Array<CASAnnouncement>;
51
+
52
+ /**
53
+ * Optional array of SMT Proofs. Required if the DID being resolved has used
54
+ * an SMT Beacon to publish a BTCR2 Update.
55
+ */
56
+ smtProofs?: Array<SMTProof>;
57
+ };
58
+
59
+ /**
60
+ * The Sidecar data structure used for Singleton Beacons.
61
+ */
62
+ export type SingletonBeaconSidecarData = Map<HexString, SignedBTCR2Update>;
63
+ /**
64
+ * The Sidecar data structure used for CAS Beacons.
65
+ */
66
+ export type CASBeaconSidecarData = Map<HexString, CASAnnouncement>;
67
+ /**
68
+ * The Sidecar data structure used for SMT Beacons.
69
+ */
70
+ export type SMTBeaconSidecarData = Map<string, SMTProof>;
71
+
72
+ /**
73
+ * The Sidecar data structure post-processing used for resolution.
74
+ */
75
+ export type SidecarData = {
76
+ /**
77
+ * Map of BTCR2 Signed Updates by their hash bytes.
78
+ */
79
+ updateMap: SingletonBeaconSidecarData;
80
+
81
+ /**
82
+ * Map of CAS Announcements by their hash bytes.
83
+ */
84
+ casMap: CASBeaconSidecarData;
85
+
86
+ /**
87
+ * Map of SMT Proofs by their ID.
88
+ */
89
+ smtMap: SMTBeaconSidecarData;
90
+ }
91
+
92
+ /**
93
+ * Union type for all Beacon Sidecar data structures.
94
+ */
95
+ export type BeaconSidecarData = SingletonBeaconSidecarData | CASBeaconSidecarData | SMTBeaconSidecarData;