@did-btcr2/method 0.18.0 → 0.19.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 (262) hide show
  1. package/dist/browser.js +5240 -6079
  2. package/dist/browser.mjs +5240 -6079
  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/cas-beacon.js +55 -0
  36. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -0
  37. package/dist/cjs/core/beacon/factory.js +11 -10
  38. package/dist/cjs/core/beacon/factory.js.map +1 -1
  39. package/dist/cjs/core/beacon/interfaces.js +32 -0
  40. package/dist/cjs/core/beacon/interfaces.js.map +1 -0
  41. package/dist/cjs/core/beacon/singleton.js +59 -135
  42. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  43. package/dist/cjs/core/beacon/smt-beacon.js +56 -0
  44. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -0
  45. package/dist/cjs/core/beacon/utils.js +67 -105
  46. package/dist/cjs/core/beacon/utils.js.map +1 -1
  47. package/dist/cjs/core/identifier.js +18 -21
  48. package/dist/cjs/core/identifier.js.map +1 -1
  49. package/dist/cjs/core/interfaces.js +2 -0
  50. package/dist/cjs/core/interfaces.js.map +1 -0
  51. package/dist/cjs/core/resolve.js +511 -0
  52. package/dist/cjs/core/resolve.js.map +1 -0
  53. package/dist/cjs/{utils → core}/types.js.map +1 -1
  54. package/dist/cjs/core/{crud/update.js → update.js} +62 -52
  55. package/dist/cjs/core/update.js.map +1 -0
  56. package/dist/cjs/did-btcr2.js +109 -75
  57. package/dist/cjs/did-btcr2.js.map +1 -1
  58. package/dist/cjs/index.js +14 -15
  59. package/dist/cjs/index.js.map +1 -1
  60. package/dist/cjs/utils/appendix.js +10 -18
  61. package/dist/cjs/utils/appendix.js.map +1 -1
  62. package/dist/cjs/utils/did-document.js +51 -58
  63. package/dist/cjs/utils/did-document.js.map +1 -1
  64. package/dist/cjs/utils/general.js +1 -1
  65. package/dist/cjs/utils/general.js.map +1 -1
  66. package/dist/esm/core/beacon/aggregation/cohort/index.js +3 -3
  67. package/dist/esm/core/beacon/aggregation/cohort/index.js.map +1 -1
  68. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js +1 -9
  69. package/dist/esm/core/beacon/aggregation/cohort/messages/base.js.map +1 -1
  70. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js +2 -1
  71. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.js.map +1 -1
  72. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js +2 -1
  73. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.js.map +1 -1
  74. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js +2 -1
  75. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.js.map +1 -1
  76. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js +2 -1
  77. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/opt-in.js.map +1 -1
  78. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js +2 -1
  79. package/dist/esm/core/beacon/aggregation/cohort/messages/keygen/subscribe.js.map +1 -1
  80. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js +2 -1
  81. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.js.map +1 -1
  82. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js +2 -1
  83. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/authorization-request.js.map +1 -1
  84. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js +2 -1
  85. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.js.map +1 -1
  86. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js +2 -1
  87. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/request-signature.js.map +1 -1
  88. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js +2 -1
  89. package/dist/esm/core/beacon/aggregation/cohort/messages/sign/signature-authorization.js.map +1 -1
  90. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js +36 -18
  91. package/dist/esm/core/beacon/aggregation/communication/adapter/nostr.js.map +1 -1
  92. package/dist/esm/core/beacon/aggregation/coordinator.js +14 -14
  93. package/dist/esm/core/beacon/aggregation/coordinator.js.map +1 -1
  94. package/dist/esm/core/beacon/aggregation/participant.js +4 -3
  95. package/dist/esm/core/beacon/aggregation/participant.js.map +1 -1
  96. package/dist/esm/core/beacon/aggregation/session/index.js +1 -1
  97. package/dist/esm/core/beacon/aggregation/session/index.js.map +1 -1
  98. package/dist/esm/core/beacon/cas-beacon.js +55 -0
  99. package/dist/esm/core/beacon/cas-beacon.js.map +1 -0
  100. package/dist/esm/core/beacon/factory.js +11 -10
  101. package/dist/esm/core/beacon/factory.js.map +1 -1
  102. package/dist/esm/core/beacon/interfaces.js +32 -0
  103. package/dist/esm/core/beacon/interfaces.js.map +1 -0
  104. package/dist/esm/core/beacon/singleton.js +59 -135
  105. package/dist/esm/core/beacon/singleton.js.map +1 -1
  106. package/dist/esm/core/beacon/smt-beacon.js +56 -0
  107. package/dist/esm/core/beacon/smt-beacon.js.map +1 -0
  108. package/dist/esm/core/beacon/utils.js +67 -105
  109. package/dist/esm/core/beacon/utils.js.map +1 -1
  110. package/dist/esm/core/identifier.js +18 -21
  111. package/dist/esm/core/identifier.js.map +1 -1
  112. package/dist/esm/core/interfaces.js +2 -0
  113. package/dist/esm/core/interfaces.js.map +1 -0
  114. package/dist/esm/core/resolve.js +511 -0
  115. package/dist/esm/core/resolve.js.map +1 -0
  116. package/dist/esm/{utils → core}/types.js.map +1 -1
  117. package/dist/esm/core/{crud/update.js → update.js} +62 -52
  118. package/dist/esm/core/update.js.map +1 -0
  119. package/dist/esm/did-btcr2.js +109 -75
  120. package/dist/esm/did-btcr2.js.map +1 -1
  121. package/dist/esm/index.js +14 -15
  122. package/dist/esm/index.js.map +1 -1
  123. package/dist/esm/utils/appendix.js +10 -18
  124. package/dist/esm/utils/appendix.js.map +1 -1
  125. package/dist/esm/utils/did-document.js +51 -58
  126. package/dist/esm/utils/did-document.js.map +1 -1
  127. package/dist/esm/utils/general.js +1 -1
  128. package/dist/esm/utils/general.js.map +1 -1
  129. package/dist/types/core/beacon/aggregation/cohort/index.d.ts +1 -1
  130. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts +0 -7
  131. package/dist/types/core/beacon/aggregation/cohort/messages/base.d.ts.map +1 -1
  132. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.d.ts.map +1 -1
  133. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.d.ts.map +1 -1
  134. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.d.ts.map +1 -1
  135. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/opt-in.d.ts.map +1 -1
  136. package/dist/types/core/beacon/aggregation/cohort/messages/keygen/subscribe.d.ts.map +1 -1
  137. package/dist/types/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.d.ts.map +1 -1
  138. package/dist/types/core/beacon/aggregation/cohort/messages/sign/authorization-request.d.ts.map +1 -1
  139. package/dist/types/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.d.ts.map +1 -1
  140. package/dist/types/core/beacon/aggregation/cohort/messages/sign/request-signature.d.ts.map +1 -1
  141. package/dist/types/core/beacon/aggregation/cohort/messages/sign/signature-authorization.d.ts.map +1 -1
  142. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts +13 -5
  143. package/dist/types/core/beacon/aggregation/communication/adapter/nostr.d.ts.map +1 -1
  144. package/dist/types/core/beacon/aggregation/coordinator.d.ts +17 -29
  145. package/dist/types/core/beacon/aggregation/coordinator.d.ts.map +1 -1
  146. package/dist/types/core/beacon/aggregation/participant.d.ts.map +1 -1
  147. package/dist/types/core/beacon/cas-beacon.d.ts +47 -0
  148. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -0
  149. package/dist/types/core/beacon/factory.d.ts +5 -4
  150. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  151. package/dist/types/core/beacon/interfaces.d.ts +98 -0
  152. package/dist/types/core/beacon/interfaces.d.ts.map +1 -0
  153. package/dist/types/core/beacon/singleton.d.ts +22 -65
  154. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  155. package/dist/types/core/beacon/smt-beacon.d.ts +48 -0
  156. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -0
  157. package/dist/types/core/beacon/utils.d.ts +19 -97
  158. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  159. package/dist/types/core/identifier.d.ts.map +1 -1
  160. package/dist/types/core/interfaces.d.ts +94 -0
  161. package/dist/types/core/interfaces.d.ts.map +1 -0
  162. package/dist/types/core/resolve.d.ts +105 -0
  163. package/dist/types/core/resolve.d.ts.map +1 -0
  164. package/dist/types/core/types.d.ts +71 -0
  165. package/dist/types/core/types.d.ts.map +1 -0
  166. package/dist/types/core/{crud/update.d.ts → update.d.ts} +21 -20
  167. package/dist/types/core/update.d.ts.map +1 -0
  168. package/dist/types/did-btcr2.d.ts +45 -57
  169. package/dist/types/did-btcr2.d.ts.map +1 -1
  170. package/dist/types/index.d.ts +14 -15
  171. package/dist/types/index.d.ts.map +1 -1
  172. package/dist/types/utils/appendix.d.ts +5 -10
  173. package/dist/types/utils/appendix.d.ts.map +1 -1
  174. package/dist/types/utils/did-document-builder.d.ts +1 -1
  175. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  176. package/dist/types/utils/did-document.d.ts +31 -29
  177. package/dist/types/utils/did-document.d.ts.map +1 -1
  178. package/package.json +5 -5
  179. package/src/core/beacon/aggregation/cohort/index.ts +3 -3
  180. package/src/core/beacon/aggregation/cohort/messages/base.ts +1 -12
  181. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-advert.ts +2 -2
  182. package/src/core/beacon/aggregation/cohort/messages/keygen/cohort-ready.ts +2 -2
  183. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in-accept.ts +2 -2
  184. package/src/core/beacon/aggregation/cohort/messages/keygen/opt-in.ts +2 -2
  185. package/src/core/beacon/aggregation/cohort/messages/keygen/subscribe.ts +2 -2
  186. package/src/core/beacon/aggregation/cohort/messages/sign/aggregated-nonce.ts +2 -2
  187. package/src/core/beacon/aggregation/cohort/messages/sign/authorization-request.ts +2 -2
  188. package/src/core/beacon/aggregation/cohort/messages/sign/nonce-contribution.ts +2 -2
  189. package/src/core/beacon/aggregation/cohort/messages/sign/request-signature.ts +2 -2
  190. package/src/core/beacon/aggregation/cohort/messages/sign/signature-authorization.ts +2 -2
  191. package/src/core/beacon/aggregation/communication/adapter/nostr.ts +43 -21
  192. package/src/core/beacon/aggregation/coordinator.ts +41 -29
  193. package/src/core/beacon/aggregation/participant.ts +4 -3
  194. package/src/core/beacon/aggregation/session/index.ts +1 -1
  195. package/src/core/beacon/cas-beacon.ts +67 -0
  196. package/src/core/beacon/factory.ts +13 -15
  197. package/src/core/beacon/interfaces.ts +124 -0
  198. package/src/core/beacon/singleton.ts +75 -145
  199. package/src/core/beacon/smt-beacon.ts +70 -0
  200. package/src/core/beacon/utils.ts +80 -170
  201. package/src/core/identifier.ts +21 -24
  202. package/src/core/interfaces.ts +101 -0
  203. package/src/core/resolve.ts +707 -0
  204. package/src/core/types.ts +78 -0
  205. package/src/core/{crud/update.ts → update.ts} +75 -68
  206. package/src/did-btcr2.ts +152 -92
  207. package/src/index.ts +14 -24
  208. package/src/utils/appendix.ts +18 -22
  209. package/src/utils/did-document-builder.ts +1 -1
  210. package/src/utils/did-document.ts +67 -71
  211. package/src/utils/general.ts +1 -1
  212. package/dist/cjs/core/beacon/cid-aggregate.js +0 -116
  213. package/dist/cjs/core/beacon/cid-aggregate.js.map +0 -1
  214. package/dist/cjs/core/beacon/smt-aggregate.js +0 -126
  215. package/dist/cjs/core/beacon/smt-aggregate.js.map +0 -1
  216. package/dist/cjs/core/crud/deactivate.js +0 -14
  217. package/dist/cjs/core/crud/deactivate.js.map +0 -1
  218. package/dist/cjs/core/crud/read.js +0 -679
  219. package/dist/cjs/core/crud/read.js.map +0 -1
  220. package/dist/cjs/core/crud/update.js.map +0 -1
  221. package/dist/cjs/interfaces/beacon.js +0 -41
  222. package/dist/cjs/interfaces/beacon.js.map +0 -1
  223. package/dist/cjs/interfaces/crud.js +0 -2
  224. package/dist/cjs/interfaces/crud.js.map +0 -1
  225. package/dist/esm/core/beacon/cid-aggregate.js +0 -116
  226. package/dist/esm/core/beacon/cid-aggregate.js.map +0 -1
  227. package/dist/esm/core/beacon/smt-aggregate.js +0 -126
  228. package/dist/esm/core/beacon/smt-aggregate.js.map +0 -1
  229. package/dist/esm/core/crud/deactivate.js +0 -14
  230. package/dist/esm/core/crud/deactivate.js.map +0 -1
  231. package/dist/esm/core/crud/read.js +0 -679
  232. package/dist/esm/core/crud/read.js.map +0 -1
  233. package/dist/esm/core/crud/update.js.map +0 -1
  234. package/dist/esm/interfaces/beacon.js +0 -41
  235. package/dist/esm/interfaces/beacon.js.map +0 -1
  236. package/dist/esm/interfaces/crud.js +0 -2
  237. package/dist/esm/interfaces/crud.js.map +0 -1
  238. package/dist/types/core/beacon/cid-aggregate.d.ts +0 -102
  239. package/dist/types/core/beacon/cid-aggregate.d.ts.map +0 -1
  240. package/dist/types/core/beacon/smt-aggregate.d.ts +0 -111
  241. package/dist/types/core/beacon/smt-aggregate.d.ts.map +0 -1
  242. package/dist/types/core/crud/deactivate.d.ts +0 -13
  243. package/dist/types/core/crud/deactivate.d.ts.map +0 -1
  244. package/dist/types/core/crud/read.d.ts +0 -334
  245. package/dist/types/core/crud/read.d.ts.map +0 -1
  246. package/dist/types/core/crud/update.d.ts.map +0 -1
  247. package/dist/types/interfaces/beacon.d.ts +0 -116
  248. package/dist/types/interfaces/beacon.d.ts.map +0 -1
  249. package/dist/types/interfaces/crud.d.ts +0 -32
  250. package/dist/types/interfaces/crud.d.ts.map +0 -1
  251. package/dist/types/utils/types.d.ts +0 -38
  252. package/dist/types/utils/types.d.ts.map +0 -1
  253. package/src/canonicalize.d.ts +0 -6
  254. package/src/core/beacon/cid-aggregate.ts +0 -153
  255. package/src/core/beacon/smt-aggregate.ts +0 -135
  256. package/src/core/crud/deactivate.ts +0 -13
  257. package/src/core/crud/read.ts +0 -948
  258. package/src/interfaces/beacon.ts +0 -137
  259. package/src/interfaces/crud.ts +0 -33
  260. package/src/utils/types.ts +0 -41
  261. /package/dist/cjs/{utils → core}/types.js +0 -0
  262. /package/dist/esm/{utils → core}/types.js +0 -0
@@ -1,36 +1,10 @@
1
+ import { getNetwork } from '@did-btcr2/bitcoin';
1
2
  import { DidMethodError, KeyBytes, Maybe, MethodError } from '@did-btcr2/common';
2
- import { DidService } from '@web5/dids';
3
3
  import { networks, payments } from 'bitcoinjs-lib';
4
- import { BeaconService, BeaconServiceAddress } from '../../interfaces/beacon.js';
5
4
  import { Appendix } from '../../utils/appendix.js';
6
5
  import { DidDocument } from '../../utils/did-document.js';
7
- import { BeaconFactory } from './factory.js';
8
- export interface GenerateBeaconParams {
9
- identifier: string;
10
- publicKey: KeyBytes;
11
- network: networks.Network;
12
- type: string;
13
- }
14
- /**
15
- * Required parameters for generating Beacon Services.
16
- * @interface GenerateBitcoinAddrsParams
17
- * @type {GenerateBitcoinAddrsParams}
18
- */
19
- export interface GenerateBitcoinAddrsParams {
20
- publicKey: KeyBytes;
21
- network: networks.Network;
22
- }
23
-
24
- /**
25
- * Required parameters for generating Beacon Services.
26
- * @interface GenerateBeaconServicesParams
27
- * @type {GenerateBeaconServicesParams}
28
- */
29
- export interface GenerateBeaconServicesParams {
30
- publicKey: KeyBytes;
31
- network: networks.Network
32
- beaconType: string;
33
- }
6
+ import { Identifier } from '../identifier.js';
7
+ import { BeaconService } from './interfaces.js';
34
8
 
35
9
  /**
36
10
  * Static class of utility functions for the Beacon Service
@@ -44,11 +18,11 @@ export class BeaconUtils {
44
18
  * @returns {string} The Bitcoin address extracted from the URI
45
19
  * @throws {DidMethodError} if the URI is not a valid Bitcoin URI
46
20
  */
47
- public static parseBitcoinAddress(uri: string): string {
21
+ static parseBitcoinAddress(uri: string): string {
48
22
  if (!uri.startsWith('bitcoin:')) {
49
- throw new DidMethodError('Invalid Bitcoin URI format', { type: 'BEACON_ERROR' });
23
+ throw new MethodError('Invalid Bitcoin URI format', 'BEACON_SERVICE_ERROR', { uri });
50
24
  }
51
- return uri.replace('bitcoin:', '').split('?')[0]; // Extracts address from "bitcoin:<address>?params"
25
+ return uri.replace('bitcoin:', '').split('?')[0];
52
26
  }
53
27
 
54
28
  /**
@@ -56,12 +30,12 @@ export class BeaconUtils {
56
30
  * @param {BeaconService} obj The object to validate
57
31
  * @returns {boolean} A boolean indicating whether the object is a Beacon Service
58
32
  */
59
- public static isBeaconService(obj: Maybe<BeaconService>): boolean {
33
+ static isBeaconService(obj: Maybe<BeaconService>): boolean {
60
34
  // Return false if the given obj is not a valid DidService.
61
35
  if(!Appendix.isDidService(obj)) return false;
62
36
 
63
37
  // Return false if the type is not a valid beacon service type.
64
- if(!['SingletonBeacon', 'CIDAggregateBeacon', 'SMTAggregateBeacon'].includes(obj.type)) return false;
38
+ if(!['SingletonBeacon', 'CASBeacon', 'SMTBeacon'].includes(obj.type)) return false;
65
39
 
66
40
  // Return false if the serviceEndpoint is not a valid BIP21 bitcoin address.
67
41
  if ([obj.serviceEndpoint].flat().some(ep => typeof ep === 'string' && !ep.startsWith('bitcoin:'))) return false;
@@ -79,38 +53,26 @@ export class BeaconUtils {
79
53
  * @returns {DidService[]} An array of DidService objects
80
54
  * @throws {TypeError} if the didDocument is not provided
81
55
  */
82
- public static getBeaconServices(didDocument: DidDocument): BeaconService[] {
83
- // Filter out any invalid did service objects.
84
- const didServices: DidService[] = didDocument.service?.filter(Appendix.isDidService) ?? [];
56
+ static getBeaconServices(didDocument: DidDocument): BeaconService[] {
85
57
  // Filter for valid beacon service objects.
86
- return (didServices.filter(this.isBeaconService) ?? []) as BeaconService[];
58
+ return (didDocument.service.filter(this.isBeaconService) ?? []) as BeaconService[];
87
59
  }
88
60
 
89
61
  /**
90
- * Generate all 3 Beacon Service Endpoints for a given public key.
91
- * @param {GenerateBitcoinAddrsParams} params Required parameters for generating Beacon Services.
92
- * @param {KeyBytes} params.publicKey Public key bytes used to generate the beacon object serviceEndpoint.
93
- * @param {Network} params.network Bitcoin network interface from bitcoinlib-js.
62
+ * Create the 3 default Beacon Service Endpoints for a given `k` (public-key-based) identifier.
63
+ * @param {string} did The DID for which to create the beacon services.
94
64
  * @returns {Array<Array<string>>} 2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
95
65
  * @throws {DidMethodError} if the bitcoin address is invalid.
96
66
  */
97
- public static generateBeaconAddresses({ identifier, publicKey, network }: {
98
- identifier: string;
99
- publicKey: KeyBytes;
100
- network: networks.Network;
101
- }): Array<Array<string>> {
67
+ static createBeaconServices(did: string, beaconType: string): Array<BeaconService> {
102
68
  try {
103
- const p2pkh = payments.p2pkh({ pubkey: publicKey, network }).address;
104
- const p2wpkh = payments.p2wpkh({ pubkey: publicKey, network }).address;
105
- const p2tr = payments.p2tr({ network, internalPubkey: publicKey.slice(1, 33) }).address;
106
- if (!p2pkh || !p2wpkh || !p2tr) {
107
- throw new DidMethodError('Failed to generate bitcoin addresses');
108
- }
109
- return [
110
- [`${identifier}#initialP2PKH`, p2pkh],
111
- [`${identifier}#initialP2WPKH`, p2wpkh],
112
- [`${identifier}#initialP2TR`, p2tr]
113
- ];
69
+ // Get the Network class
70
+ const addrTypes = ['p2pkh', 'p2wpkh', 'p2tr'] as Array<'p2pkh' | 'p2wpkh' | 'p2tr'>;
71
+
72
+ // Map over the address types and create the beacon services
73
+ return addrTypes.map(
74
+ (addrType) => this.createBeaconService(did, addrType, beaconType)
75
+ );
114
76
  } catch (error) {
115
77
  console.error(error);
116
78
  process.exit(1);
@@ -119,150 +81,98 @@ export class BeaconUtils {
119
81
 
120
82
  /**
121
83
  * Generate a set of Beacon Services for a given public key.
122
- * @param {GenerateBeaconServicesParams} params Required parameters for generating Beacon Services.
123
- * @param {KeyBytes} params.publicKey Public key bytes used to generate the beacon object serviceEndpoint.
124
- * @param {Network} params.network Bitcoin network interface from bitcoinlib-js.
125
- * @param {string} params.beaconType The type of beacon service to create.
126
- * @param {string} params.addressType The type of address to create (p2pkh, p2wpkh, p2tr).
84
+ * @param {string} did The did for the beacon service.
85
+ * @param {string} addressType The type of bitcoin address to generate (p2pkh, p2wpkh, p2tr).
86
+ * @param {string} beaconType The type of beacon service to create.
127
87
  * @returns {BeaconService} A BeaconService object.
128
88
  * @throws {DidMethodError} if the bitcoin address is invalid.
129
89
  */
130
- public static generateBeaconService({ id, publicKey: pubkey, network, addressType, type }: {
131
- id: string;
132
- publicKey: KeyBytes;
133
- network: networks.Network;
134
- addressType: 'p2pkh' | 'p2wpkh' | 'p2tr';
135
- type: string;
136
- }): BeaconService {
90
+ static createBeaconService(did: string, addressType: 'p2pkh' | 'p2wpkh' | 'p2tr', beaconType: string): BeaconService {
137
91
  try {
138
- if(!id.includes('#')) {
139
- id = `${id}#initial${addressType.toUpperCase()}`;
140
- }
92
+ // Decode the DID to get the network and genesis bytes
93
+ const components = Identifier.decode(did);
94
+ // Get the Network class
95
+ const network = getNetwork(components.network);
96
+ // Get the genesis bytes
97
+ const pubkey = components.genesisBytes;
98
+ // Build the id
99
+ const id = `${did}#initial${addressType.toUpperCase()}`;
100
+ // Generate the bitcoin address
141
101
  const serviceEndpoint = `bitcoin:${payments[addressType]({ pubkey, network }).address}`;
142
- return { id, type, serviceEndpoint, };
102
+ // Return the beacon serviceD
103
+ return { id, type: beaconType, serviceEndpoint, };
143
104
  } catch (error) {
144
105
  console.error(error);
145
106
  process.exit(1);
146
107
  }
147
108
  }
148
109
 
110
+
149
111
  /**
150
- * Generate a custom Beacon Service.
151
- * @param {GenerateBeaconServicesParams} params Required parameters for generating Beacon Services.
152
- * @returns
112
+ * Generate three default Beacon Service Endpoints for a given `k` (public-key-based) identifier.
113
+ * @param {string} did The DID for which to create the beacon services.
114
+ * @returns {Array<Array<string>>} 2D Array of bitcoin addresses (p2pkh, p2wpkh, p2tr).
115
+ * @throws {DidMethodError} if the bitcoin address is invalid.
153
116
  */
154
- public static generateBeaconServiceCustom({ id, publicKey: pubkey, network, addressType, type }: {
117
+ static generateBeaconServices({ id, publicKey, network, beaconType }: {
155
118
  id: string;
156
119
  publicKey: KeyBytes;
157
120
  network: networks.Network;
158
- addressType: 'p2pkh' | 'p2wpkh' | 'p2tr';
159
- type: string;
160
- }): BeaconService {
121
+ beaconType: string;
122
+ }): Array<BeaconService> {
161
123
  try {
162
- if(!id.includes('#')) {
163
- throw new MethodError(
164
- 'Invalid id format. It should include a fragment identifier (e.g., #initialP2PKH).',
165
- 'BEACON_ERROR',
166
- { id }
167
- );
124
+ // Generate the bitcoin addresses for the given public key and network
125
+ const p2pkh = payments.p2pkh({ pubkey: publicKey, network }).address;
126
+ const p2wpkh = payments.p2wpkh({ pubkey: publicKey, network }).address;
127
+ const p2tr = payments.p2tr({ network, internalPubkey: publicKey.slice(1, 33) }).address;
128
+ // Check that all addresses were generated successfully
129
+ if (!p2pkh || !p2wpkh || !p2tr) {
130
+ throw new DidMethodError('Failed to generate bitcoin addresses');
168
131
  }
169
- const serviceEndpoint = `bitcoin:${payments[addressType]({ pubkey, network }).address}`;
170
- return { id, type, serviceEndpoint, };
132
+ // Return the beacon services with the generated addresses as service endpoints
133
+ return [
134
+ {
135
+ id : `${id}#initialP2PKH`,
136
+ type : beaconType,
137
+ serviceEndpoint : `bitcoin:${p2pkh}`
138
+ },
139
+ {
140
+ id : `${id}#initialP2WPKH`,
141
+ type : beaconType,
142
+ serviceEndpoint : `bitcoin:${p2wpkh}`
143
+ },
144
+ {
145
+ id : `${id}#initialP2TR`,
146
+ type : beaconType,
147
+ serviceEndpoint : `bitcoin:${p2tr}`
148
+ },
149
+ ];
171
150
  } catch (error) {
172
151
  console.error(error);
173
152
  process.exit(1);
174
153
  }
175
154
  }
176
155
 
177
- /**
178
- * Generate beacon services.
179
- * @param {GenerateBeaconServicesParams} params Required parameters for generating Beacon Services.
180
- * @param {string} params.network The name of the Bitcoin network to use.
181
- * @param {Uint8Array} params.publicKey Byte array representation of a public key used to generate a new btcr2 key-id-type.
182
- * @param {string} params.beaconType Optional beacon type to use (default: SingletonBeacon).
183
- * @returns {DidService[]} Array of DidService objects.
184
- */
185
- public static generateBeaconServices({ identifier, network, type, publicKey }: {
186
- identifier: string;
187
- publicKey: KeyBytes;
188
- network: networks.Network;
189
- type: string;
190
- }): Array<BeaconService> {
191
- // Generate the bitcoin addresses
192
- const bitcoinAddrs = this.generateBeaconAddresses({ identifier, publicKey, network, });
193
-
194
- // Map the bitcoin addresses to the beacon service
195
- return bitcoinAddrs.map(([id, address]) => {
196
- // Convert the address to a BIP-21 URI
197
- const serviceEndpoint = `bitcoin:${address}`;
198
- // Create the beacon object
199
- const beacon = BeaconFactory.establish({ id, type, serviceEndpoint });
200
- // Return the beacon service
201
- return beacon.service;
202
- });
203
- }
204
-
205
- /**
206
- * Generate a single beacon service.
207
- * @param {GenerateBeaconParams} params Required parameters for generating a single Beacon Service.
208
- * @param {string} params.identifier The identifier for the beacon service.
209
- * @param {string} params.network The name of the Bitcoin network to use.
210
- * @param {Uint8Array} params.publicKey Byte array representation of a public key used to generate a new btcr2 key-id-type.
211
- * @param {string} params.type The type of beacon service to create.
212
- * @returns {BeaconService} A BeaconService object.
213
- * @throws {DidMethodError} if the bitcoin address is invalid.
214
- */
215
- public static generateBeacon({ identifier, network, type, publicKey }: {
216
- identifier: string;
217
- publicKey: KeyBytes;
218
- network: networks.Network;
219
- type: string;
220
- }): BeaconService {
221
- // Generate the bitcoin addresses
222
- const bitcoinAddrs = this.generateBeaconAddresses({ identifier, publicKey, network, });
223
-
224
- // Map the bitcoin addresses to the beacon service
225
- const beacon = bitcoinAddrs.map(([id, address]) => {
226
- // Convert the address to a BIP-21 URI
227
- const serviceEndpoint = `bitcoin:${address}`;
228
- // Create the beacon object
229
- const beacon = BeaconFactory.establish({ id, type, serviceEndpoint });
230
- // Return the beacon service
231
- return beacon.service;
232
- });
233
-
234
- return beacon[0];
235
- }
236
-
237
- /**
238
- * Manufacture a pre-filled Beacon using the BeaconFactory.
239
- * @param {BeaconServicesParams} params Required parameters for generating a single Beacon Service.
240
- * @param {string} params.serviceId The type of service being created (#initialP2PKH, #initialP2WPKH, #initialP2TR).
241
- * @param {string} params.beaconType The type of beacon service being created (SingletonBeacon, SMTAggregatorBeacon).
242
- * @param {string} params.bitcoinAddress The bitcoin address to use for the service endpoint.
243
- * @returns {BeaconService} One BeaconService object.
244
- */
245
- public static manufactureBeacon(params: BeaconService): BeaconService {
246
- return BeaconFactory.establish(params).service;
247
- }
248
-
249
156
  /**
250
157
  * Convert beacon service endpoints from BIP-21 URIs to addresses.
251
- * @param {Array<BeaconService>} beacons The list of beacon services.
252
- * @returns {Array<BeaconServiceAddress>} An array of beacon services with address: bitcoinAddress.
158
+ * @param {BeaconService} beacon The beacon service to parse.
159
+ * @returns {BeaconServiceAddress} The beacon service with the address field extracted from the serviceEndpoint.
253
160
  */
254
- public static toBeaconServiceAddress(beacons: Array<BeaconService>): Array<BeaconServiceAddress> {
255
- return beacons.map((beacon) => ({ ...beacon, address: beacon.serviceEndpoint.replace('bitcoin:', '')}));
161
+ static parseBeaconServiceEndpoint(beacon: BeaconService): BeaconService {
162
+ return { ...beacon, serviceEndpoint: beacon.serviceEndpoint.replace('bitcoin:', '')};
256
163
  }
257
164
 
258
165
  /**
259
166
  * Create a map of address => beaconService with address field.
260
167
  * @param {Array<BeaconService>} beacons The list of beacon services.
261
- * @returns {Map<string, BeaconServiceAddress>} A map of address => beaconService.
168
+ * @returns {Map<string, BeaconService>} A map of address => beaconService.
262
169
  */
263
- public static getBeaconServiceAddressMap(beacons: Array<BeaconService>): Map<string, BeaconServiceAddress> {
264
- const beaconAddrs = this.toBeaconServiceAddress(beacons);
265
- return new Map<string, BeaconServiceAddress>(beaconAddrs.map((beacon) => ([beacon.address, beacon])));
170
+ static getBeaconServicesMap(beacons: Array<BeaconService>): Map<string, BeaconService> {
171
+ return new Map<string, BeaconService>(
172
+ beacons
173
+ .map(this.parseBeaconServiceEndpoint)
174
+ .map((beacon) => ([beacon.serviceEndpoint as string, beacon]))
175
+ );
266
176
  }
267
177
 
268
178
  /**
@@ -270,7 +180,7 @@ export class BeaconUtils {
270
180
  * @param {DidDocument} didDocument The DID Document to extract the services from.
271
181
  * @returns {string[]} An array of beacon service ids.
272
182
  */
273
- public static getBeaconServiceIds(didDocument: DidDocument): string[] {
183
+ static getBeaconServiceIds(didDocument: DidDocument): string[] {
274
184
  return this.getBeaconServices(didDocument).map((beacon) => beacon.id);
275
185
  }
276
186
  }
@@ -1,4 +1,4 @@
1
- import { BitcoinNetworkNames, Bytes, IdentifierTypes, INVALID_DID, METHOD_NOT_SUPPORTED, MethodError } from '@did-btcr2/common';
1
+ import { BitcoinNetworkNames, Bytes, IdentifierError, IdentifierTypes, INVALID_DID, METHOD_NOT_SUPPORTED } from '@did-btcr2/common';
2
2
  import { CompressedSecp256k1PublicKey, SchnorrKeyPair } from '@did-btcr2/keypair';
3
3
  import { bech32m } from '@scure/base';
4
4
 
@@ -48,7 +48,7 @@ export class Identifier {
48
48
  * @param {KeyBytes | DocumentBytes} params.genesisBytes Public key or an intermediate document bytes.
49
49
  * @returns {string} The new did:btcr2 identifier.
50
50
  */
51
- public static encode({ idType, version, network, genesisBytes }: {
51
+ static encode({ idType, version, network, genesisBytes }: {
52
52
  idType: string;
53
53
  version: number;
54
54
  network: string;
@@ -56,22 +56,22 @@ export class Identifier {
56
56
  }): string {
57
57
  // 1. If idType is not a valid value per above, raise invalidDid error.
58
58
  if (!(idType in IdentifierTypes)) {
59
- throw new MethodError('Expected "idType" to be "KEY" or "EXTERNAL"', INVALID_DID, {idType});
59
+ throw new IdentifierError('Expected "idType" to be "KEY" or "EXTERNAL"', INVALID_DID, {idType});
60
60
  }
61
61
 
62
62
  // 2. If version is greater than 1, raise invalidDid error.
63
63
  if (isNaN(version) || version > 1) {
64
- throw new MethodError('Expected "version" to be 1', INVALID_DID, {version});
64
+ throw new IdentifierError('Expected "version" to be 1', INVALID_DID, {version});
65
65
  }
66
66
 
67
67
  // 3. If network is not a valid value (bitcoin|signet|regtest|testnet3|testnet4|number), raise invalidDid error.
68
68
  if (typeof network === 'string' && !(network in BitcoinNetworkNames)) {
69
- throw new MethodError('Invalid "network" name', INVALID_DID, {network});
69
+ throw new IdentifierError('Invalid "network" name', INVALID_DID, {network});
70
70
  }
71
71
 
72
72
  // 4. If network is a number and is outside the range of 1-8, raise invalidDid error.
73
73
  if(typeof network === 'number' && (network < 0 || network > 8)) {
74
- throw new MethodError('Invalid "network" number', INVALID_DID, {network});
74
+ throw new IdentifierError('Invalid "network" number', INVALID_DID, {network});
75
75
  }
76
76
 
77
77
  // 5. If idType is “key” and genesisBytes is not a valid compressed secp256k1 public key, raise invalidDid error.
@@ -79,7 +79,7 @@ export class Identifier {
79
79
  try {
80
80
  new CompressedSecp256k1PublicKey(genesisBytes);
81
81
  } catch {
82
- throw new MethodError(
82
+ throw new IdentifierError(
83
83
  'Expected "genesisBytes" to be a valid compressed secp256k1 public key',
84
84
  INVALID_DID, { genesisBytes }
85
85
  );
@@ -127,15 +127,12 @@ export class Identifier {
127
127
  // 14. Create a dataBytes byte array from nibbles, where index is from 0 to nibbles.length / 2 - 1 and
128
128
  // encodingBytes[index] = (nibbles[2 * index] << 4) | nibbles[2 * index + 1].
129
129
  if (fCount !== 0){
130
- for(let index in Array.from({ length: (nibbles.length / 2) - 1 })) {
131
- throw new MethodError('Not implemented', 'NOT_IMPLEMENTED', { index });
130
+ for(const index in Array.from({ length: (nibbles.length / 2) - 1 })) {
131
+ throw new IdentifierError('Not implemented', 'NOT_IMPLEMENTED', { index });
132
132
  }
133
133
  }
134
134
  const dataBytes = new Uint8Array([(nibbles[2 * 0] << 4) | nibbles[2 * 0 + 1], ...genesisBytes]);
135
135
 
136
- // 15. Set identifier to “did:btcr2:”.
137
- // 16. Pass hrp and dataBytes to the Bech32m Encoding algorithm, retrieving encodedString.
138
- // 17. Append encodedString to identifier.
139
136
  // 18. Return identifier.
140
137
  return `did:btcr2:${bech32m.encodeFromBytes(hrp, dataBytes)}`;
141
138
  }
@@ -148,13 +145,13 @@ export class Identifier {
148
145
  * @throws {DidErrorCode.InvalidDid} if identifier is invalid
149
146
  * @throws {DidErrorCode.MethodNotSupported} if the method is not supported
150
147
  */
151
- public static decode(identifier: string): DidComponents {
148
+ static decode(identifier: string): DidComponents {
152
149
  // 1. Split identifier into an array of components at the colon : character.
153
150
  const components = identifier.split(':');
154
151
 
155
152
  // 2. If the length of the components array is not 3, raise invalidDid error.
156
153
  if (components.length !== 3){
157
- throw new MethodError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
154
+ throw new IdentifierError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
158
155
  }
159
156
 
160
157
  // Deconstruct the components of the identifier: scheme, method, encoded
@@ -162,26 +159,26 @@ export class Identifier {
162
159
 
163
160
  // 3. If components[0] is not “did”, raise invalidDid error.
164
161
  if (scheme !== 'did') {
165
- throw new MethodError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
162
+ throw new IdentifierError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
166
163
  }
167
164
  // 4. If components[1] is not “btcr2”, raise methodNotSupported error.
168
165
  if (method !== 'btcr2') {
169
- throw new MethodError(`Invalid did method: ${method}`, METHOD_NOT_SUPPORTED, { identifier });
166
+ throw new IdentifierError(`Invalid did method: ${method}`, METHOD_NOT_SUPPORTED, { identifier });
170
167
  }
171
168
 
172
169
  // 5. Set encodedString to components[2].
173
170
  if (!encoded) {
174
- throw new MethodError(`Invalid method-specific id: ${identifier}`, INVALID_DID, { identifier });
171
+ throw new IdentifierError(`Invalid method-specific id: ${identifier}`, INVALID_DID, { identifier });
175
172
  }
176
173
  // 6. Pass encodedString to the Bech32m Decoding algorithm, retrieving hrp and dataBytes.
177
174
  const {prefix: hrp, bytes: dataBytes} = bech32m.decodeToBytes(encoded);
178
175
 
179
176
  // 7. If the Bech32m decoding algorithm fails, raise invalidDid error.
180
177
  if (!['x', 'k'].includes(hrp)) {
181
- throw new MethodError(`Invalid hrp: ${hrp}`, INVALID_DID, { identifier });
178
+ throw new IdentifierError(`Invalid hrp: ${hrp}`, INVALID_DID, { identifier });
182
179
  }
183
180
  if (!dataBytes) {
184
- throw new MethodError(`Failed to decode id: ${encoded}`, INVALID_DID, { identifier });
181
+ throw new IdentifierError(`Failed to decode id: ${encoded}`, INVALID_DID, { identifier });
185
182
  }
186
183
 
187
184
  // 8. Map hrp to idType from the following:
@@ -216,7 +213,7 @@ export class Identifier {
216
213
  nibblesConsumed += 1;
217
214
  // 14. If version is greater than 1, raise invalidDid error.
218
215
  if (version > 1) {
219
- throw new MethodError(`Invalid version: ${version}`, INVALID_DID, { identifier });
216
+ throw new IdentifierError(`Invalid version: ${version}`, INVALID_DID, { identifier });
220
217
  }
221
218
  }
222
219
 
@@ -244,7 +241,7 @@ export class Identifier {
244
241
  if (networkValue >= 0x8 && networkValue <= 0xF) {
245
242
  network = networkValue - 11;
246
243
  } else {
247
- throw new MethodError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
244
+ throw new IdentifierError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
248
245
  }
249
246
  }
250
247
 
@@ -254,7 +251,7 @@ export class Identifier {
254
251
  const fillerNibble = currentByte & 0x0F;
255
252
  // 17.2 If fillerNibble is not 0, raise invalidDid error.
256
253
  if (fillerNibble !== 0) {
257
- throw new MethodError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
254
+ throw new IdentifierError(`Invalid did: ${identifier}`, INVALID_DID, { identifier });
258
255
  }
259
256
  }
260
257
 
@@ -266,7 +263,7 @@ export class Identifier {
266
263
  try {
267
264
  new CompressedSecp256k1PublicKey(genesisBytes);
268
265
  } catch {
269
- throw new MethodError(`Invalid genesisBytes: ${genesisBytes}`, INVALID_DID, { identifier });
266
+ throw new IdentifierError(`Invalid genesisBytes: ${genesisBytes}`, INVALID_DID, { identifier });
270
267
  }
271
268
  }
272
269
 
@@ -278,7 +275,7 @@ export class Identifier {
278
275
  * Generates a new did:btcr2 identifier based on a newly generated key pair.
279
276
  * @returns {string} The new did:btcr2 identifier.
280
277
  */
281
- public static generate(): { keys: SchnorrKeyPair; identifier: { controller: string; id: string } } {
278
+ static generate(): { keys: SchnorrKeyPair; identifier: { controller: string; id: string } } {
282
279
  const keys = SchnorrKeyPair.generate();
283
280
  const did = this.encode({
284
281
  idType : IdentifierTypes.KEY,
@@ -0,0 +1,101 @@
1
+ import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
+ import { DidResolutionOptions } from '@web5/dids';
3
+ import { Sidecar } from './types.js';
4
+
5
+ export interface RootCapability {
6
+ '@context': string;
7
+ id: string;
8
+ controller: string;
9
+ invocationTarget: string;
10
+ }
11
+
12
+ /**
13
+ * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#resolution-options-example-panel-show | Resolution Options}
14
+ * for data structure details.
15
+ */
16
+ export interface ResolutionOptionsCore extends DidResolutionOptions {
17
+ /**
18
+ * Optional ASCII string representation of the specific version of a DID document
19
+ * to be resolved.
20
+ */
21
+ versionId?: string
22
+
23
+ /**
24
+ * Optional XML Datetime normalized to UTC without sub-second decimal precision.
25
+ * The DID document to be resolved is the most recent version of the DID document
26
+ * that was valid for the DID before the specified versionTime.
27
+ */
28
+ versionTime?: string;
29
+
30
+ /**
31
+ * Data transmitted via {@link https://dcdpr.github.io/did-btcr2/data-structures.html#sidecar-data-example-panel-show | Sidecar (data structure)}.
32
+ * Includes Singleton beacon updates, CAS announcements, and SMT proofs.
33
+ */
34
+ sidecar?: Sidecar;
35
+ }
36
+
37
+ /**
38
+ * Full set of resolution options for the did:btcr2 method. See {@link ResolutionOptionsCore}
39
+ * for the resolution options defined by the specification.
40
+ * @extends ResolutionOptionsCore
41
+ */
42
+ export interface ResolutionOptions extends ResolutionOptionsCore {
43
+ /**
44
+ * Drivers for interacting with external systems, such as the Bitcoin network.
45
+ */
46
+ drivers: {
47
+ bitcoin?: BitcoinNetworkConnection;
48
+ };
49
+
50
+ /**
51
+ * Flag to signal a full blockchain search for beacon signals from genesis
52
+ * block to chain tip during resolution, instead of using an indexer.
53
+ * @type {boolean}
54
+ * @default false
55
+ */
56
+ fullBlockchainTraversal?: boolean;
57
+ }
58
+
59
+ /**
60
+ * {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-proof | SMT Proof}
61
+ * a set of SHA-256 hashes for nodes in a Sparse Merkle Tree that together form
62
+ * a path from a leaf in the tree to the Merkle root, proving that the leaf is in the tree.
63
+ * See {@link https://dcdpr.github.io/did-btcr2/data-structures.html#smt-proof | SMT Proof (data structure)}.
64
+ *
65
+ * @example
66
+ * ```json
67
+ * {
68
+ * "id": "<< Hexadecimal of Root Hash >>",
69
+ * "nonce": "<< Hexadecimal of Nonce 1101 >>",
70
+ * "updateId": "<< Hexadecimal of hash(Data Block 1101) >>",
71
+ * "collapsed": "<< Hexadecimal of 0001 >>",
72
+ * "hashes": [
73
+ * "<< Hexadecimal of Hash 1110 >>",
74
+ * "<< Hexadecimal of Hash 1001 >>",
75
+ * "<< Hexadecimal of Hash 0 >>"
76
+ * ]
77
+ * }
78
+ * ```
79
+ */
80
+ export interface SMTProof {
81
+ /**
82
+ * The SHA-256 hash of the root node of the Sparse Merkle Tree.
83
+ */
84
+ id: string;
85
+ /**
86
+ * Optional 256-bit nonce generated for each update. MUST be encoded as a string using the "base64url" [RFC4648] encoding.
87
+ */
88
+ nonce?: string;
89
+ /**
90
+ * Optional BTCR2 Signed Update (data structure) hashed with the JSON Document Hashing algorithm.
91
+ */
92
+ updateId?: string;
93
+ /**
94
+ * Bitmap of zero nodes within the path (see: collapsed leaves).
95
+ */
96
+ collapsed: string;
97
+ /**
98
+ * Array of SHA-256 hashes representing the sibling SMT nodes from the leaf, containing the SHA-256 hash of the BTCR2 Signed Update or the “zero identity”, to the root.
99
+ */
100
+ hashes: string[];
101
+ }