@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,321 @@
1
+ import { getNetwork } from '@did-btcr2/bitcoin';
2
+ import { DateUtils, IdentifierHrp, INVALID_DID, INVALID_DID_DOCUMENT, INVALID_DID_UPDATE, JSONPatch, JSONUtils, LATE_PUBLISHING_ERROR, MISSING_UPDATE_DATA, ResolveError } from '@did-btcr2/common';
3
+ import { BIP340Cryptosuite, BIP340DataIntegrityProof, SchnorrMultikey } from '@did-btcr2/cryptosuite';
4
+ import { CompressedSecp256k1PublicKey } from '@did-btcr2/keypair';
5
+ import { bytesToHex } from '@noble/hashes/utils';
6
+ import { canonicalization, DidBtcr2 } from '../did-btcr2.js';
7
+ import { Appendix } from '../utils/appendix.js';
8
+ import { DidDocument, ID_PLACEHOLDER_VALUE } from '../utils/did-document.js';
9
+ import { BeaconFactory } from './beacon/factory.js';
10
+ import { BeaconSignalDiscovery } from './beacon/signal-discovery.js';
11
+ import { BeaconUtils } from './beacon/utils.js';
12
+ import { Identifier } from './identifier.js';
13
+ /**
14
+ * Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
15
+ * Resolving a did:btcr2 identifier iteratively builds a DID document by applying BTCR2 Updates
16
+ * to an Initial DID Document that have been committed to the Bitcoin blockchain by Authorized
17
+ * Beacon Signals. The Initial DID Document is either deterministically created from the DID or
18
+ * provided by Sidecar Data.
19
+ * @class Resolve
20
+ * @type {Resolve}
21
+ */
22
+ export class Resolve {
23
+ /**
24
+ * 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}.
25
+ * @param {DidComponents} didComponents The decoded components of the did.
26
+ * @returns {DidDocument} The resolved DID Document object.
27
+ */
28
+ static deterministic(didComponents) {
29
+ // Encode the did from the didComponents
30
+ const did = Identifier.encode(didComponents);
31
+ // Deconstruct the bytes from the given components
32
+ const { genesisBytes } = didComponents;
33
+ // Construct a new CompressedSecp256k1PublicKey and deconstruct the publicKey and publicKeyMultibase
34
+ const { multibase: publicKeyMultibase } = new CompressedSecp256k1PublicKey(genesisBytes);
35
+ // Generate the service field for the DID Document
36
+ const service = BeaconUtils.generateBeaconServices({
37
+ id: did,
38
+ publicKey: genesisBytes,
39
+ network: getNetwork(didComponents.network),
40
+ beaconType: 'SingletonBeacon'
41
+ });
42
+ return new DidDocument({
43
+ id: did,
44
+ controller: [did],
45
+ verificationMethod: [{
46
+ id: `${did}#initialKey`,
47
+ type: 'Multikey',
48
+ controller: did,
49
+ publicKeyMultibase: publicKeyMultibase.encoded
50
+ }],
51
+ service
52
+ });
53
+ }
54
+ /**
55
+ * 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}.
56
+ * @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
57
+ * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
58
+ * @returns {Promise<DidDocument>} The resolved DID Document object
59
+ * @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
60
+ */
61
+ static async external(didComponents, genesisDocument) {
62
+ // Canonicalize and sha256 hash the currentDocument
63
+ const hashBytes = canonicalization.process(genesisDocument, { encoding: 'hex' });
64
+ // Compare the genesisBytes to the hashBytes
65
+ const genesisBytes = bytesToHex(didComponents.genesisBytes);
66
+ // If the genesisBytes do not match the hashBytes, throw an error
67
+ if (genesisBytes !== hashBytes) {
68
+ throw new ResolveError(`Initial document mismatch: genesisBytes ${genesisBytes} !== hashBytes ${hashBytes}`, INVALID_DID_DOCUMENT, { genesisBytes, hashBytes });
69
+ }
70
+ // Encode the did from the didComponents
71
+ const did = Identifier.encode(didComponents);
72
+ // Replace the placeholder did with the did throughout the currentDocument.
73
+ const currentDocument = JSON.parse(JSON.stringify(genesisDocument).replaceAll(ID_PLACEHOLDER_VALUE, did));
74
+ // Return a W3C conformant DID Document
75
+ return new DidDocument(currentDocument);
76
+ }
77
+ /**
78
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
79
+ * @param {Sidecar} sidecar The sidecar data to process.
80
+ * @returns {ProcessedSidecar} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
81
+ */
82
+ static sidecarData(sidecar = {}) {
83
+ // BTCR2 Signed Updates map
84
+ const updateMap = new Map();
85
+ if (sidecar.updates?.length)
86
+ for (const update of sidecar.updates) {
87
+ updateMap.set(canonicalization.process(update, { encoding: 'hex' }), update);
88
+ }
89
+ // CAS Announcements map
90
+ const casMap = new Map();
91
+ if (sidecar.casUpdates?.length)
92
+ for (const update of sidecar.casUpdates) {
93
+ casMap.set(canonicalization.process(update, { encoding: 'hex' }), update);
94
+ }
95
+ // SMT Proofs map
96
+ const smtMap = new Map();
97
+ if (sidecar.smtProofs?.length)
98
+ for (const proof of sidecar.smtProofs) {
99
+ smtMap.set(proof.id, proof);
100
+ }
101
+ return { updateMap, casMap, smtMap };
102
+ }
103
+ /**
104
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
105
+ * Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
106
+ * The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
107
+ * @param {DidComponents} didComponents The decoded components of the did.
108
+ * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
109
+ * @returns {Promise<DidDocument>} The resolved DID Document object.
110
+ * @throws {ResolveError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
111
+ */
112
+ static async currentDocument(didComponents, genesisDocument) {
113
+ // Deconstruct the hrp from the components
114
+ const { hrp, genesisBytes } = didComponents;
115
+ // If hrp `x`, perform external resolution
116
+ if (hrp === IdentifierHrp.x) {
117
+ if (!genesisDocument)
118
+ throw new ResolveError('External resolution requires genesisDocument', MISSING_UPDATE_DATA, { didComponents });
119
+ return await this.external(didComponents, genesisDocument);
120
+ }
121
+ // Check for hrp `k`
122
+ if (hrp === IdentifierHrp.k) {
123
+ // Validate genesis bytes as a compressed secp256k1 public key
124
+ if (!CompressedSecp256k1PublicKey.isValid(genesisBytes)) {
125
+ throw new ResolveError('Deterministic resolution requires valid secp256k1 public key', INVALID_DID, { genesisBytes });
126
+ }
127
+ // Perform deterministic resolution
128
+ return this.deterministic(didComponents);
129
+ }
130
+ // Else, throw an error for unsupported hrp
131
+ throw new ResolveError(`Unsupported DID hrp ${hrp}`, INVALID_DID, { hrp });
132
+ }
133
+ /**
134
+ * Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
135
+ * Signal Bytes (last output in OP_RETURN transaction).
136
+ * @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
137
+ * @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
138
+ * @param {BitcoinNetworkConnection} bitcoin The bitcoin network connection used to fetch beacon signals
139
+ * @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
140
+ */
141
+ static async beaconSignals(beaconServices, sidecarData, bitcoin) {
142
+ // Discover Beacon Signals via indexer server (esplora/electrs) or full node
143
+ const beaconServicesSignals = bitcoin.network.rest
144
+ ? await BeaconSignalDiscovery.indexer(beaconServices, bitcoin)
145
+ : await BeaconSignalDiscovery.fullnode(beaconServices, bitcoin);
146
+ // Process each beacon's signals in parallel
147
+ const promises = Array.from(beaconServicesSignals.entries()).map(async ([service, signals]) => {
148
+ // Skip beacons with no signals
149
+ if (!signals.length)
150
+ return [];
151
+ // Establish a typed beacon and process its signals
152
+ return BeaconFactory.establish(service).processSignals(signals, sidecarData);
153
+ });
154
+ return (await Promise.all(promises)).flat();
155
+ }
156
+ /**
157
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
158
+ * @param {DidDocument} currentDocument The current DID Document to apply the updates to.
159
+ * @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
160
+ * @param {string} [versionTime] The optional version time to limit updates to.
161
+ * @param {string} [versionId] The optional version id to limit updates to.
162
+ * @returns {Promise<DidResolutionResponse>} The updated DID Document, number of confirmations, and version id.
163
+ */
164
+ static async updates(currentDocument, unsortedUpdates, versionTime, versionId) {
165
+ // Start the version number being processed at 1
166
+ let currentVersionId = 1;
167
+ // Initialize an empty array to hold the update hashes
168
+ const updateHashHistory = [];
169
+ // 1. Sort updates by targetVersionId (ascending), using blockheight as tie-breaker
170
+ const updates = unsortedUpdates.sort(([upd0, blk0], [upd1, blk1]) => upd0.targetVersionId - upd1.targetVersionId || blk0.height - blk1.height);
171
+ // Create a default response object
172
+ const response = {
173
+ currentDocument,
174
+ versionId: `${currentVersionId}`,
175
+ confirmations: 0,
176
+ updated: ''
177
+ };
178
+ // Iterate over each (update block) pair
179
+ for (const [update, block] of updates) {
180
+ // Get the hash of the current document
181
+ const currentDocumentHash = canonicalization.process(response.currentDocument, { encoding: 'base58' });
182
+ // Set confirmations to the block confirmations
183
+ response.confirmations = block.confirmations;
184
+ // Safely convert versionTime to timestamp
185
+ const vTime = DateUtils.dateStringToTimestamp(versionTime || '');
186
+ // Safely convert block.blocktime to timestamp
187
+ const bTime = DateUtils.blocktimeToTimestamp(block.time);
188
+ // Set the updated field to the blocktime of the current update
189
+ response.updated = DateUtils.toISOStringNonFractional(bTime);
190
+ // if resolutionOptions.versionTime is defined and the blocktime is more recent, return currentDocument
191
+ if (vTime < bTime) {
192
+ return response;
193
+ }
194
+ // Check update.targetVersionId against currentVersionId
195
+ // If update.targetVersionId <= currentVersionId, confirm duplicate update
196
+ if (update.targetVersionId <= currentVersionId) {
197
+ updateHashHistory.push(currentDocumentHash);
198
+ this.confirmDuplicate(update, updateHashHistory);
199
+ }
200
+ // If update.targetVersionId == currentVersionId + 1, apply the update
201
+ else if (update.targetVersionId === currentVersionId + 1) {
202
+ // Prepend `z` to the sourceHash if it does not start with it
203
+ const sourceHash = update.sourceHash.startsWith('z') ? update.sourceHash : `z${update.sourceHash}`;
204
+ // Check if update.sourceHash !== currentDocumentHash
205
+ if (sourceHash !== currentDocumentHash) {
206
+ // Raise an INVALID_DID_UPDATE error if they do not match
207
+ throw new ResolveError(`Hash mismatch: update.sourceHash !== currentDocumentHash`, INVALID_DID_UPDATE, { sourceHash, currentDocumentHash });
208
+ }
209
+ // Apply the update to the currentDocument and set it in the response
210
+ response.currentDocument = await this.applyUpdate(response.currentDocument, update);
211
+ // Create unsigned_update by removing the proof property from update.
212
+ const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']);
213
+ // Push the canonicalized unsigned update hash to the updateHashHistory
214
+ updateHashHistory.push(canonicalization.process(unsignedUpdate, { encoding: 'base58' }));
215
+ }
216
+ // If update.targetVersionId > currentVersionId + 1, throw LATE_PUBLISHING error
217
+ else if (update.targetVersionId > currentVersionId + 1) {
218
+ throw new ResolveError(`Version Id Mismatch: targetVersionId cannot be > currentVersionId + 1`, 'LATE_PUBLISHING_ERROR', {
219
+ targetVersionId: update.targetVersionId,
220
+ currentVersionId: String(currentVersionId + 1)
221
+ });
222
+ }
223
+ // Increment currentVersionId
224
+ currentVersionId++;
225
+ // Set currentVersionId in response
226
+ response.versionId = `${currentVersionId}`;
227
+ // If resolutionOptions.versionId is defined and <= currentVersionId, return currentDocument
228
+ if (currentVersionId >= Number(versionId)) {
229
+ return response;
230
+ }
231
+ // Check if the current document is deactivated before further processing
232
+ if (currentDocument.deactivated) {
233
+ return response;
234
+ }
235
+ }
236
+ // Return response data
237
+ return response;
238
+ }
239
+ /**
240
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
241
+ * This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
242
+ * @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
243
+ * @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
244
+ */
245
+ static confirmDuplicate(update, updateHashHistory) {
246
+ // Create unsigned_update by removing the proof property from update.
247
+ const unsignedUpdate = JSONUtils.deleteKeys(update, ['proof']);
248
+ // Hash unsignedUpdate with JSON Document Hashing algorithm
249
+ const unsignedUpdateHash = canonicalization.process(unsignedUpdate);
250
+ // 5. Let historicalUpdateHash equal updateHashHistory[updateHashIndex].
251
+ const historicalUpdateHash = updateHashHistory[update.targetVersionId - 2];
252
+ // Check if the updateHash matches the historical hash
253
+ if (updateHashHistory[update.targetVersionId - 2] !== unsignedUpdateHash) {
254
+ throw new ResolveError(`Invalid duplicate: ${unsignedUpdateHash} does not match ${historicalUpdateHash}`, LATE_PUBLISHING_ERROR, { unsignedUpdateHash, updateHashHistory });
255
+ }
256
+ }
257
+ /**
258
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
259
+ * @param {DidDocument} currentDocument The current DID Document to apply the update to.
260
+ * @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
261
+ * @returns {Promise<DidDocument>} The updated DID Document after applying the update.
262
+ * @throws {ResolveError} If the update is invalid or cannot be applied.
263
+ */
264
+ static async applyUpdate(currentDocument, update) {
265
+ // Get the capability id from the to update proof.
266
+ const capabilityId = update.proof?.capability;
267
+ // Since this field is optional, check that it exists
268
+ if (!capabilityId) {
269
+ // If it does not exist, throw INVALID_DID_UPDATE error
270
+ throw new ResolveError('No root capability found in update', INVALID_DID_UPDATE, update);
271
+ }
272
+ // Get the root capability object by dereferencing the capabilityId
273
+ const rootCapability = Appendix.dereferenceZcapId(capabilityId);
274
+ // Deconstruct the invocationTarget and controller from the root capability
275
+ const { invocationTarget, controller: rootController } = rootCapability;
276
+ // Check that both invocationTarget and rootController equal currentDocument.id
277
+ if (![invocationTarget, rootController].every((id) => id === currentDocument.id)) {
278
+ // If they do not all match, throw INVALID_DID_UPDATE error
279
+ throw new ResolveError('Invalid root capability', INVALID_DID_UPDATE, { rootCapability, currentDocument });
280
+ }
281
+ // Get the verificationMethod field from the update proof as verificationMethodId.
282
+ const verificationMethodId = update.proof?.verificationMethod;
283
+ // Since this field is optional, check that it exists
284
+ if (!verificationMethodId) {
285
+ // If it does not exist, throw INVALID_DID_UPDATE error
286
+ throw new ResolveError('No verificationMethod found in update', INVALID_DID_UPDATE, update);
287
+ }
288
+ // Get the verificationMethod from the DID Document using the verificationMethodId.
289
+ const vm = DidBtcr2.getSigningMethod(currentDocument, verificationMethodId);
290
+ // Construct a new SchnorrMultikey.
291
+ const multikey = SchnorrMultikey.fromVerificationMethod(vm);
292
+ // Construct a new BIP340Cryptosuite with the SchnorrMultikey.
293
+ const cryptosuite = new BIP340Cryptosuite(multikey);
294
+ // Canonicalize the update
295
+ const canonicalUpdate = canonicalization.canonicalize(update);
296
+ // Construct a DataIntegrityProof with the cryptosuite
297
+ const diProof = new BIP340DataIntegrityProof(cryptosuite);
298
+ // Call the verifyProof method
299
+ const verificationResult = diProof.verifyProof(canonicalUpdate, 'capabilityInvocation');
300
+ // If the result is not verified, throw INVALID_DID_UPDATE error
301
+ if (!verificationResult.verified) {
302
+ throw new ResolveError('Invalid update: proof not verified', INVALID_DID_UPDATE, verificationResult);
303
+ }
304
+ // Apply the update.patch to the currentDocument to get the updatedDocument.
305
+ const updatedDocument = JSONPatch.apply(currentDocument, update.patch);
306
+ // Verify that updatedDocument is conformant to DID Core v1.1.
307
+ DidDocument.validate(updatedDocument);
308
+ // Canonicalize and hash the updatedDocument to get the currentDocumentHash.
309
+ const currentDocumentHash = canonicalization.process(currentDocument, { encoding: 'base58' });
310
+ // Prepare the update targetHash for comparison with currentDocumentHash.
311
+ const updateTargetHash = update.targetHash.startsWith('z') ? update.targetHash : `z${update.targetHash}`;
312
+ // Make sure the update.targetHash equals currentDocumentHash.
313
+ if (updateTargetHash !== currentDocumentHash) {
314
+ // If they do not match, throw INVALID_DID_UPDATE error.
315
+ throw new ResolveError(`Invalid update: updateTargetHash !== currentDocumentHash`, INVALID_DID_UPDATE, { updateTargetHash, currentDocumentHash });
316
+ }
317
+ // Return final updatedDocument.
318
+ return updatedDocument;
319
+ }
320
+ }
321
+ //# sourceMappingURL=resolve.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EACX,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,SAAS,EACT,aAAa,EACb,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE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kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,eAAe,EAAE,sBAAsB,CAAC,CAAC;QAExF,gEAAgE;QAChE,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC;YACjC,MAAM,IAAI,YAAY,CACpB,oCAAoC,EACpC,kBAAkB,EAAE,kBAAkB,CACvC,CAAC;QACJ,CAAC;QAED,4EAA4E;QAC5E,MAAM,eAAe,GAAG,SAAS,CAAC,KAAK,CAAC,eAAe,EAAE,MAAM,CAAC,KAAK,CAAgB,CAAC;QAEtF,8DAA8D;QAC9D,WAAW,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;QAEtC,4EAA4E;QAC5E,MAAM,mBAAmB,GAAG,gBAAgB,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAE9F,yEAAyE;QACzE,MAAM,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QAEzG,8DAA8D;QAC9D,IAAI,gBAAgB,KAAK,mBAAmB,EAAE,CAAC;YAC7C,wDAAwD;YACxD,MAAM,IAAI,YAAY,CACpB,0DAA0D,EAC1D,kBAAkB,EAAE,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAC9D,CAAC;QACJ,CAAC;QAED,iCAAiC;QACjC,OAAO,eAAe,CAAC;IACzB,CAAC;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/utils/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,113 @@
1
+ import { INVALID_DID_UPDATE, JSONPatch, UpdateError } from '@did-btcr2/common';
2
+ import { SchnorrMultikey } from '@did-btcr2/cryptosuite';
3
+ import { canonicalization } from '../did-btcr2.js';
4
+ import { DidDocument } from '../utils/did-document.js';
5
+ import { BeaconFactory } from './beacon/factory.js';
6
+ /**
7
+ * Implements {@link https://dcdpr.github.io/did-btcr2/operations/update.html | 7.3 Update}.
8
+ *
9
+ * An update to a did:btcr2 document is an invoked capability using the ZCAP-LD
10
+ * data format, signed by a verificationMethod that has the authority to make
11
+ * the update as specified in the previous DID document. Capability invocations
12
+ * for updates MUST be authorized using Data Integrity following the
13
+ * bip340-jcs-2025 cryptosuite with a proofPurpose of capabilityInvocation.
14
+ *
15
+ * @class Update
16
+ * @type {Update}
17
+ */
18
+ export class Update {
19
+ /**
20
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-unsigned-update | 7.3.b Construct BTCR2 Unsigned Update}.
21
+ * This process constructs a BTCR2 Unsigned Update conformant to the spec template.
22
+ *
23
+ * @param {Btcr2DidDocument} sourceDocument The source DID document to be updated.
24
+ * @param {PatchOperation[]} patches The array of JSON Patch operations to apply to the sourceDocument.
25
+ * @param {number} sourceVersionId The version ID of the source document.
26
+ * @returns {Promise<SignedBTCR2Update>} The constructed SignedBTCR2Update object.
27
+ * @throws {UpdateError} InvalidDid if sourceDocument.id does not match identifier.
28
+ */
29
+ static async construct(sourceDocument, patches, sourceVersionId) {
30
+ // Initialize an unsigned update conformant to btcr2 spec.
31
+ const unsignedUpdate = {
32
+ '@context': [
33
+ 'https://w3id.org/security/v2',
34
+ 'https://w3id.org/zcap/v1',
35
+ 'https://w3id.org/json-ld-patch/v1',
36
+ 'https://btcr2.dev/context/v1'
37
+ ],
38
+ patch: patches,
39
+ targetHash: '',
40
+ targetVersionId: sourceVersionId + 1,
41
+ sourceHash: canonicalization.process(sourceDocument, { encoding: 'base58' }),
42
+ };
43
+ // Apply all JSON patches to sourceDocument.
44
+ const targetDocument = JSONPatch.apply(sourceDocument, patches);
45
+ try {
46
+ // Ensure the targetDocument is conformant to DID Core v1.1.
47
+ DidDocument.isValid(targetDocument);
48
+ }
49
+ catch (error) {
50
+ // If validation fails, throw an UpdateError with INVALID_DID_UPDATE.
51
+ throw new UpdateError('Error validating targetDocument: ' + (error instanceof Error ? error.message : String(error)), INVALID_DID_UPDATE, targetDocument);
52
+ }
53
+ // Set the targetHash by canonicalizing the targetDocument and encoding it in base58.
54
+ unsignedUpdate.targetHash = canonicalization.process(targetDocument, { encoding: 'base58' });
55
+ // Return unsignedUpdate.
56
+ return unsignedUpdate;
57
+ }
58
+ /**
59
+ * Implements subsection {@link http://dcdpr.github.io/did-btcr2/operations/update.html#construct-btcr2-signed-update | 7.3.c Construct BTCR2 Signed Update }.
60
+ * This process constructs a BTCR2 Signed Update from a BTCR2 Unsigned Update.
61
+ *
62
+ * @param {string} did The did-btcr2 identifier to derive the root capability from
63
+ * @param {UnsignedBTCR2Update} unsignedUpdate The updatePayload object to be signed
64
+ * @param {DidVerificationMethod} verificationMethod The verificationMethod object to be used for signing
65
+ * @returns {SignedBTCR2Update} Did update payload secured with a proof => SignedBTCR2Update
66
+ * @throws {UpdateError} if the privateKeyBytes are invalid
67
+ */
68
+ static async sign(did, unsignedUpdate, verificationMethod, secretKey) {
69
+ // Parse the controller from the verificationMethod
70
+ const controller = verificationMethod.controller;
71
+ // Parse the fragment from the vmId
72
+ const id = verificationMethod.id.slice(verificationMethod.id.indexOf('#'));
73
+ // Construct a Schnorr Multikey
74
+ const multikey = SchnorrMultikey.fromSecretKey(id, controller, secretKey);
75
+ // Define the Data Integrity proof config
76
+ const config = {
77
+ '@context': [
78
+ 'https://w3id.org/security/v2',
79
+ 'https://w3id.org/zcap/v1',
80
+ 'https://w3id.org/json-ld-patch/v1',
81
+ 'https://btcr2.dev/context/v1'
82
+ ],
83
+ cryptosuite: 'bip340-jcs-2025',
84
+ type: 'DataIntegrityProof',
85
+ verificationMethod: verificationMethod.id,
86
+ proofPurpose: 'capabilityInvocation',
87
+ capability: `urn:zcap:root:${encodeURIComponent(did)}`,
88
+ capabilityAction: 'Write',
89
+ };
90
+ // Go from multikey => cryptosuite => diproof
91
+ const diproof = multikey.toCryptosuite().toDataIntegrityProof();
92
+ // Use the config to add a proof to the unsigned update
93
+ return diproof.addProof(unsignedUpdate, config);
94
+ }
95
+ /**
96
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/update.html#announce-did-update | 7.3.d Announce DID Update}.
97
+ * BTCR2 Signed Updates are announced to the Bitcoin blockchain depending on the Beacon Type.
98
+ * @param {BeaconService} beaconService The BeaconService object representing the funded beacon to announce the update to.
99
+ * @param {SignedBTCR2Update} update The signed update object to be announced.
100
+ * @param {KeyBytes} secretKey The private key used to sign the update for announcement.
101
+ * @returns {SignedBTCR2Update} The SignedBTCR2Update object containing data to validate the Beacon Signal
102
+ * @throws {UpdateError} if the beaconService type is invalid
103
+ */
104
+ static async announce(beaconService, update, secretKey, bitcoin) {
105
+ // Establish a beacon object
106
+ const beacon = BeaconFactory.establish(beaconService);
107
+ // Broadcast the update
108
+ const result = await beacon.broadcastSignal(update, secretKey, bitcoin);
109
+ // Return the sidecarData
110
+ return result;
111
+ }
112
+ }
113
+ //# sourceMappingURL=update.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/core/update.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EAGT,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,eAAe,EAGhB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAoB,WAAW,EAAyB,MAAM,0BAA0B,CAAC;AAChG,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,MAAM;IACjB;;;;;;;;;OASG;IACH,MAAM,CAAC,KAAK,CAAC,SAAS,CACpB,cAAgC,EAChC,OAAyB,EACzB,eAAuB;QAEvB,0DAA0D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