@did-btcr2/method 0.19.0 → 0.22.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 (120) hide show
  1. package/README.md +223 -1
  2. package/dist/browser.js +3496 -4202
  3. package/dist/browser.mjs +3496 -4202
  4. package/dist/cjs/core/beacon/beacon.js +25 -0
  5. package/dist/cjs/core/beacon/beacon.js.map +1 -0
  6. package/dist/cjs/core/beacon/cas-beacon.js +20 -36
  7. package/dist/cjs/core/beacon/cas-beacon.js.map +1 -1
  8. package/dist/cjs/core/beacon/error.js +4 -4
  9. package/dist/cjs/core/beacon/error.js.map +1 -1
  10. package/dist/cjs/core/beacon/factory.js +5 -7
  11. package/dist/cjs/core/beacon/factory.js.map +1 -1
  12. package/dist/cjs/core/beacon/interfaces.js +1 -31
  13. package/dist/cjs/core/beacon/interfaces.js.map +1 -1
  14. package/dist/cjs/core/beacon/signal-discovery.js +183 -0
  15. package/dist/cjs/core/beacon/signal-discovery.js.map +1 -0
  16. package/dist/cjs/core/beacon/singleton.js +56 -86
  17. package/dist/cjs/core/beacon/singleton.js.map +1 -1
  18. package/dist/cjs/core/beacon/smt-beacon.js +22 -39
  19. package/dist/cjs/core/beacon/smt-beacon.js.map +1 -1
  20. package/dist/cjs/core/beacon/utils.js +4 -9
  21. package/dist/cjs/core/beacon/utils.js.map +1 -1
  22. package/dist/cjs/core/resolve.js +121 -307
  23. package/dist/cjs/core/resolve.js.map +1 -1
  24. package/dist/cjs/core/update.js +62 -154
  25. package/dist/cjs/core/update.js.map +1 -1
  26. package/dist/cjs/did-btcr2.js +100 -91
  27. package/dist/cjs/did-btcr2.js.map +1 -1
  28. package/dist/cjs/index.js +3 -1
  29. package/dist/cjs/index.js.map +1 -1
  30. package/dist/cjs/utils/appendix.js +6 -15
  31. package/dist/cjs/utils/appendix.js.map +1 -1
  32. package/dist/cjs/utils/did-document-builder.js +5 -6
  33. package/dist/cjs/utils/did-document-builder.js.map +1 -1
  34. package/dist/cjs/utils/did-document.js +42 -38
  35. package/dist/cjs/utils/did-document.js.map +1 -1
  36. package/dist/esm/core/beacon/beacon.js +25 -0
  37. package/dist/esm/core/beacon/beacon.js.map +1 -0
  38. package/dist/esm/core/beacon/cas-beacon.js +20 -36
  39. package/dist/esm/core/beacon/cas-beacon.js.map +1 -1
  40. package/dist/esm/core/beacon/error.js +4 -4
  41. package/dist/esm/core/beacon/error.js.map +1 -1
  42. package/dist/esm/core/beacon/factory.js +5 -7
  43. package/dist/esm/core/beacon/factory.js.map +1 -1
  44. package/dist/esm/core/beacon/interfaces.js +1 -31
  45. package/dist/esm/core/beacon/interfaces.js.map +1 -1
  46. package/dist/esm/core/beacon/signal-discovery.js +183 -0
  47. package/dist/esm/core/beacon/signal-discovery.js.map +1 -0
  48. package/dist/esm/core/beacon/singleton.js +56 -86
  49. package/dist/esm/core/beacon/singleton.js.map +1 -1
  50. package/dist/esm/core/beacon/smt-beacon.js +22 -39
  51. package/dist/esm/core/beacon/smt-beacon.js.map +1 -1
  52. package/dist/esm/core/beacon/utils.js +4 -9
  53. package/dist/esm/core/beacon/utils.js.map +1 -1
  54. package/dist/esm/core/resolve.js +121 -307
  55. package/dist/esm/core/resolve.js.map +1 -1
  56. package/dist/esm/core/update.js +62 -154
  57. package/dist/esm/core/update.js.map +1 -1
  58. package/dist/esm/did-btcr2.js +100 -91
  59. package/dist/esm/did-btcr2.js.map +1 -1
  60. package/dist/esm/index.js +3 -1
  61. package/dist/esm/index.js.map +1 -1
  62. package/dist/esm/utils/appendix.js +6 -15
  63. package/dist/esm/utils/appendix.js.map +1 -1
  64. package/dist/esm/utils/did-document-builder.js +5 -6
  65. package/dist/esm/utils/did-document-builder.js.map +1 -1
  66. package/dist/esm/utils/did-document.js +42 -38
  67. package/dist/esm/utils/did-document.js.map +1 -1
  68. package/dist/types/core/beacon/beacon.d.ts +44 -0
  69. package/dist/types/core/beacon/beacon.d.ts.map +1 -0
  70. package/dist/types/core/beacon/cas-beacon.d.ts +19 -30
  71. package/dist/types/core/beacon/cas-beacon.d.ts.map +1 -1
  72. package/dist/types/core/beacon/error.d.ts +2 -2
  73. package/dist/types/core/beacon/error.d.ts.map +1 -1
  74. package/dist/types/core/beacon/factory.d.ts +4 -6
  75. package/dist/types/core/beacon/factory.d.ts.map +1 -1
  76. package/dist/types/core/beacon/interfaces.d.ts +7 -46
  77. package/dist/types/core/beacon/interfaces.d.ts.map +1 -1
  78. package/dist/types/core/beacon/signal-discovery.d.ts +25 -0
  79. package/dist/types/core/beacon/signal-discovery.d.ts.map +1 -0
  80. package/dist/types/core/beacon/singleton.d.ts +17 -30
  81. package/dist/types/core/beacon/singleton.d.ts.map +1 -1
  82. package/dist/types/core/beacon/smt-beacon.d.ts +21 -33
  83. package/dist/types/core/beacon/smt-beacon.d.ts.map +1 -1
  84. package/dist/types/core/beacon/utils.d.ts.map +1 -1
  85. package/dist/types/core/interfaces.d.ts +1 -8
  86. package/dist/types/core/interfaces.d.ts.map +1 -1
  87. package/dist/types/core/resolve.d.ts +34 -47
  88. package/dist/types/core/resolve.d.ts.map +1 -1
  89. package/dist/types/core/types.d.ts +21 -8
  90. package/dist/types/core/types.d.ts.map +1 -1
  91. package/dist/types/core/update.d.ts +30 -73
  92. package/dist/types/core/update.d.ts.map +1 -1
  93. package/dist/types/did-btcr2.d.ts +44 -47
  94. package/dist/types/did-btcr2.d.ts.map +1 -1
  95. package/dist/types/index.d.ts +3 -1
  96. package/dist/types/index.d.ts.map +1 -1
  97. package/dist/types/utils/appendix.d.ts.map +1 -1
  98. package/dist/types/utils/did-document-builder.d.ts +5 -1
  99. package/dist/types/utils/did-document-builder.d.ts.map +1 -1
  100. package/dist/types/utils/did-document.d.ts +26 -21
  101. package/dist/types/utils/did-document.d.ts.map +1 -1
  102. package/package.json +8 -7
  103. package/src/core/beacon/beacon.ts +58 -0
  104. package/src/core/beacon/cas-beacon.ts +30 -44
  105. package/src/core/beacon/error.ts +5 -6
  106. package/src/core/beacon/factory.ts +7 -9
  107. package/src/core/beacon/interfaces.ts +7 -64
  108. package/src/core/beacon/signal-discovery.ts +237 -0
  109. package/src/core/beacon/singleton.ts +78 -100
  110. package/src/core/beacon/smt-beacon.ts +32 -49
  111. package/src/core/beacon/utils.ts +16 -13
  112. package/src/core/interfaces.ts +1 -9
  113. package/src/core/resolve.ts +163 -395
  114. package/src/core/types.ts +25 -8
  115. package/src/core/update.ts +91 -236
  116. package/src/did-btcr2.ts +154 -116
  117. package/src/index.ts +8 -1
  118. package/src/utils/appendix.ts +8 -22
  119. package/src/utils/did-document-builder.ts +5 -7
  120. package/src/utils/did-document.ts +80 -73
@@ -1,14 +1,13 @@
1
- import { BitcoinNetworkConnection, RawTransactionRest, RawTransactionV2 } from '@did-btcr2/bitcoin';
2
- import { HexString, UnixTimestamp } from '@did-btcr2/common';
3
- import { DidServiceEndpoint, DidService as IDidService } from '@web5/dids';
4
- import { SidecarData } from '../types.js';
5
- import { BTCR2SignedUpdate } from '@did-btcr2/cryptosuite';
1
+ import { RawTransactionRest, RawTransactionV2 } from '@did-btcr2/bitcoin';
2
+ import { UnixTimestamp } from '@did-btcr2/common';
3
+ import { DidServiceEndpoint, DidService } from '@web5/dids';
6
4
  /**
7
- * Represents a Beacon Service, which extends the DID Service with a service endpoint.
5
+ * Represents a Beacon Service, which extends a W3C DID Service by setting serviceEndpoint
6
+ * as a single DidServiceEndpoint.
8
7
  * @interface BeaconService
9
- * @extends IDidService
8
+ * @extends DidService
10
9
  */
11
- export interface BeaconService extends IDidService {
10
+ export interface BeaconService extends DidService {
12
11
  serviceEndpoint: DidServiceEndpoint;
13
12
  }
14
13
  /**
@@ -58,41 +57,3 @@ export interface BeaconSignal {
58
57
  */
59
58
  blockMetadata: BlockMetadata;
60
59
  }
61
- /**
62
- * Abstract class representing an AggregateBeacon.
63
- * @abstract
64
- * @class AggregateBeacon
65
- * @type {AggregateBeacon}
66
- */
67
- export declare abstract class AggregateBeacon {
68
- /**
69
- * The Beacon service object parsed from the DID Document.
70
- */
71
- service: BeaconService;
72
- /**
73
- * The array of Beacon Signals associated with this Beacon service.
74
- */
75
- signals: Array<BeaconSignal>;
76
- /**
77
- * The sidecar data associated with this Beacon service.
78
- * TODO: Make this more specific to Beacon type.
79
- */
80
- sidecar: SidecarData;
81
- /**
82
- * The Bitcoin network connection associated with this Beacon service.
83
- */
84
- bitcoin: BitcoinNetworkConnection;
85
- constructor(service: BeaconService, signals: Array<BeaconSignal>, sidecar: SidecarData, bitcoin?: BitcoinNetworkConnection);
86
- /**
87
- * Generates an unsigned update in a Beacon Signal (implemented by subclasses).
88
- */
89
- abstract generateSignal(updateHash: HexString): BeaconSignal;
90
- /**
91
- * Processes a Beacon Signal (implemented by subclasses).
92
- */
93
- abstract processSignals(): Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>;
94
- /**
95
- * Broadcasts a signed update in a Beacon Signal (implemented by subclasses).
96
- */
97
- abstract broadcastSignal(updateHash: HexString): Promise<HexString>;
98
- }
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACpG,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,UAAU,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,aAAc,SAAQ,WAAW;IAC9C,eAAe,EAAE,kBAAkB,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACtD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG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EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;GAKG;AACH,MAAM,WAAW,aAAc,SAAQ,UAAU;IAC7C,eAAe,EAAE,kBAAkB,CAAC;CACvC;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACtD;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC3B;;MAEE;IACH,MAAM,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,IAAI,EAAE,aAAa,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,EAAE,EAAE,kBAAkB,GAAG,gBAAgB,CAAC;IAE1C;;OAEG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,aAAa,EAAE,aAAa,CAAC;CAC9B"}
@@ -0,0 +1,25 @@
1
+ import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
+ import { BeaconService, BeaconSignal } from './interfaces.js';
3
+ /**
4
+ * Static utility class for discovering Beacon Signals on the Bitcoin blockchain.
5
+ * Extracted from {@link Resolve} for single-responsibility and independent testability.
6
+ *
7
+ * @class BeaconSignalDiscovery
8
+ */
9
+ export declare class BeaconSignalDiscovery {
10
+ /**
11
+ * Retrieves the beacon signals for the given array of BeaconService objects
12
+ * using an esplora/electrs REST API connection via a bitcoin I/O driver.
13
+ * @param {Array<BeaconService>} beaconServices Array of BeaconService objects to retrieve signals for
14
+ * @param {BitcoinNetworkConnection} bitcoin Bitcoin network connection to use for REST calls
15
+ * @returns {Promise<Map<BeaconService, Array<BeaconSignal>>>} Map of beacon service to its discovered signals
16
+ */
17
+ static indexer(beaconServices: Array<BeaconService>, bitcoin: BitcoinNetworkConnection): Promise<Map<BeaconService, Array<BeaconSignal>>>;
18
+ /**
19
+ * Traverse the full blockchain from genesis to chain top looking for beacon signals.
20
+ * @param {Array<BeaconService>} beaconServices Array of BeaconService objects to search for signals.
21
+ * @param {BitcoinNetworkConnection} bitcoin Bitcoin network connection to use for RPC calls.
22
+ * @returns {Promise<Map<BeaconService, Array<BeaconSignal>>>} Map of beacon service to its discovered signals.
23
+ */
24
+ static fullnode(beaconServices: Array<BeaconService>, bitcoin: BitcoinNetworkConnection): Promise<Map<BeaconService, Array<BeaconSignal>>>;
25
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal-discovery.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/signal-discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EAKzB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG9D;;;;;GAKG;AACH,qBAAa,qBAAqB;IAEhC;;;;;;OAMG;WACU,OAAO,CAClB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,EACpC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;IA0EnD;;;;;OAKG;WACU,QAAQ,CACnB,cAAc,EAAE,KAAK,CAAC,aAAa,CAAC,EACpC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;CA4HpD"}
@@ -1,48 +1,35 @@
1
1
  import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
- import { HexString } from '@did-btcr2/common';
3
- import { BTCR2SignedUpdate } from '@did-btcr2/cryptosuite';
2
+ import { KeyBytes } from '@did-btcr2/common';
3
+ import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
4
  import { SidecarData } from '../types.js';
5
- import { AggregateBeacon, BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
5
+ import { Beacon } from './beacon.js';
6
+ import { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
6
7
  /**
7
8
  * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#singleton-beacon | Singleton Beacon}.
8
- *
9
9
  * @class SingletonBeacon
10
10
  * @type {SingletonBeacon}
11
- * @extends {AggregateBeacon}
11
+ * @extends {Beacon}
12
12
  */
13
- export declare class SingletonBeacon extends AggregateBeacon {
13
+ export declare class SingletonBeacon extends Beacon {
14
14
  /**
15
15
  * Creates an instance of SingletonBeacon.
16
- * @param {BeaconService} service The Beacon service.
17
- * @param {?BeaconSidecarData} sidecar The SingletonBeacon sidecar data.
18
- */
19
- constructor(service: BeaconService, signals: Array<BeaconSignal>, sidecar: SidecarData, bitcoin?: BitcoinNetworkConnection);
20
- /**
21
- * Static, convenience method for establishing a CASBeacon object.
22
- * @param {string} service The Beacon service.
23
- * @param {SidecarData} sidecar The sidecar data.
24
- * @returns {SingletonBeacon} The Singleton Beacon.
25
- */
26
- static establish(service: BeaconService, signals: Array<BeaconSignal>, sidecar: SidecarData): SingletonBeacon;
27
- /**
28
- * Generates a Beacon Signal for a Singleton Beacon Service.
29
- * @param {HexString} updateHash The update hash to be included in the Beacon Signal.
30
- * @returns {BeaconSignal} The generated signal.
31
- * @throws {MethodError} if the signal is invalid.
16
+ * @param {BeaconService} service The BeaconService object representing the funded beacon to announce the update to.
17
+ *
32
18
  */
33
- generateSignal(updateHash: HexString): BeaconSignal;
19
+ constructor(service: BeaconService);
34
20
  /**
35
21
  * Processes an array of Beacon Signals associated with a Singleton Beacon Service.
36
- * @returns {Promise<BTCR2SignedUpdate | undefined>} The DID Update payload announced by the Beacon Signal.
22
+ * @returns {Promise<SignedBTCR2Update | undefined>} The DID Update payload announced by the Beacon Signal.
37
23
  * @throws {SingletonBeaconError} if the signalTx is invalid or the signalSidecarData is invalid.
38
24
  */
39
- processSignals(): Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>;
25
+ processSignals(signals: Array<BeaconSignal>, sidecar: SidecarData): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
40
26
  /**
41
- * Broadcasts a SingletonBeacon signal.
42
- * TODO: Design and implement a way to construct, sign and send via RPC
43
- *
44
- * @returns {SignedRawTx} Successful output of a bitcoin transaction.
27
+ * Broadcasts a SingletonBeacon signal to the Bitcoin network.
28
+ * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
29
+ * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
30
+ * @param {BitcoinNetworkConnection} bitcoin The Bitcoin network connection.
31
+ * @returns {Promise<SignedBTCR2Update>} The signed update that was broadcast.
45
32
  * @throws {SingletonBeaconError} if the bitcoin address is invalid or unfunded.
46
33
  */
47
- broadcastSignal(updateHash: HexString): Promise<HexString>;
34
+ broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinNetworkConnection): Promise<SignedBTCR2Update>;
48
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAgF,MAAM,mBAAmB,CAAC;AAC5H,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAO3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE9F;;;;;;GAMG;AACH,qBAAa,eAAgB,SAAQ,eAAe;IAElD;;;;OAIG;gBAED,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE,wBAAwB;IAKpC;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,WAAW,GAAG,eAAe;IAI7G;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,SAAS,GAAG,YAAY;IAInD;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;IA2C1E;;;;;;OAMG;IACG,eAAe,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;CAwEjE"}
1
+ {"version":3,"file":"singleton.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/singleton.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAA0C,QAAQ,EAAuB,MAAM,mBAAmB,CAAC;AAC1G,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAK3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE7E;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,MAAM;IAEzC;;;;OAIG;gBACS,OAAO,EAAE,aAAa;IAIlC;;;;OAIG;IACG,cAAc,CAClB,OAAO,EAAE,KAAK,CAAC,YAAY,CAAC,EAC5B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC,CAAC;IA0CrD;;;;;;;OAOG;IACG,eAAe,CACnB,YAAY,EAAE,iBAAiB,EAC/B,SAAS,EAAE,QAAQ,EACnB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC;CAqE9B"}
@@ -1,48 +1,36 @@
1
1
  import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
- import { HexString } from '@did-btcr2/common';
3
- import { BTCR2SignedUpdate } from '@did-btcr2/cryptosuite';
2
+ import { KeyBytes } from '@did-btcr2/common';
3
+ import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
4
4
  import { SidecarData } from '../types.js';
5
- import { AggregateBeacon, BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
5
+ import { Beacon } from './beacon.js';
6
+ import { BeaconService, BeaconSignal, BlockMetadata } from './interfaces.js';
6
7
  /**
7
- * TODO: Finish implementation
8
8
  * Implements {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-beacon | SMTBeacon}.
9
9
  * @class SMTBeacon
10
10
  * @type {SMTBeacon}
11
- * @extends {AggregateBeacon}
11
+ * @extends {Beacon}
12
12
  */
13
- export declare class SMTBeacon extends AggregateBeacon {
13
+ export declare class SMTBeacon extends Beacon {
14
14
  /**
15
- * Creates an instance of SingletonBeacon.
15
+ * Creates an instance of SMTBeacon.
16
16
  * @param {BeaconService} service The Beacon service.
17
- * @param {Array<BeaconSignal>} signals The SingletonBeacon sidecar data.
18
- * @param {SidecarData} sidecar The sidecar data.
19
17
  */
20
- constructor(service: BeaconService, signals: Array<BeaconSignal>, sidecar: SidecarData, bitcoin?: BitcoinNetworkConnection);
18
+ constructor(service: BeaconService);
21
19
  /**
22
- * Static, convenience method for establishing a SMTBeacon object.
23
- * @param {string} service The Beacon service.
24
- * @param {SidecarData} sidecar The sidecar data.
25
- * @returns {SingletonBeacon} The Singleton Beacon.
20
+ * Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-smt-beacon | 7.2.e.1 Process SMT Beacon}.
21
+ * @param {Array<BeaconSignal>} signals The array of Beacon Signals to process.
22
+ * @param {SidecarData} sidecar The sidecar data associated with the SMT Beacon.
23
+ * @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The processed signals.
24
+ * @throws {SMTBeaconError} if processing fails.
26
25
  */
27
- static establish(service: BeaconService, signals: Array<BeaconSignal>, sidecar: SidecarData): SMTBeacon;
26
+ processSignals(signals: Array<BeaconSignal>, sidecar: SidecarData): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
28
27
  /**
29
- * TODO: Figure out if this is necessary or not.
30
- * @param {HexString} updateHash The hash of the BTCR2 update to generate the signal for.
31
- * @returns {BeaconSignal} The generated signal.
32
- * @throws {MethodError} if the signal is invalid.
28
+ * Broadcast CAS Beacon signal to the Bitcoin network.
29
+ * @param {SignedBTCR2Update} signedUpdate The signed BTCR2 update to broadcast.
30
+ * @param {KeyBytes} secretKey The secret key for signing the Bitcoin transaction.
31
+ * @param {BitcoinNetworkConnection} bitcoin The Bitcoin network connection.
32
+ * @return {Promise<SignedBTCR2Update>} The signed update that was broadcasted.
33
+ * @throws {SMTBeaconError} if broadcasting fails.
33
34
  */
34
- generateSignal(updateHash: HexString): BeaconSignal;
35
- /**
36
- * Process SMTBeacon signals.
37
- * @returns {Promise<Array<BTCR2SignedUpdate>>} The processed signed update or undefined.
38
- * @throws {MethodError} if the signal processing fails.
39
- */
40
- processSignals(): Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>;
41
- /**
42
- * Broadcast a SMTBeacon signal.
43
- * @param {HexString} updateHash The hash of the BTCR2 update to broadcast.
44
- * @returns {Promise<SignalsMetadata>} The result of the broadcast.
45
- * @throws {MethodError} if the broadcast fails.
46
- */
47
- broadcastSignal(updateHash: HexString): Promise<HexString>;
35
+ broadcastSignal(signedUpdate: SignedBTCR2Update, secretKey: KeyBytes, bitcoin: BitcoinNetworkConnection): Promise<SignedBTCR2Update>;
48
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"smt-beacon.d.ts","sourceRoot":"","sources":["../../../../src/core/beacon/smt-beacon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAe,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE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CAAC;IAiBlF;;;;;;;OAOG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,GAAG,QAAQ,GAAG,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa;IAsBpH;;;;;OAKG;IACH,MAAM,CAAC,sBAAsB,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,EAAE;QACpE,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,QAAQ,CAAC;QACpB,OAAO,EAAE,QAAQ,CAAC,OAAO,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;KACpB,GAAG,KAAK,CAAC,aAAa,CAAC;IAoCxB;;;;OAIG;IACH,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,aAAa,GAAG,aAAa;IAIvE;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;IAQtF;;;;OAIG;IACH,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,EAAE;CAG/D"}
@@ -38,16 +38,9 @@ export interface ResolutionOptions extends ResolutionOptionsCore {
38
38
  /**
39
39
  * Drivers for interacting with external systems, such as the Bitcoin network.
40
40
  */
41
- drivers: {
41
+ drivers?: {
42
42
  bitcoin?: BitcoinNetworkConnection;
43
43
  };
44
- /**
45
- * Flag to signal a full blockchain search for beacon signals from genesis
46
- * block to chain tip during resolution, instead of using an indexer.
47
- * @type {boolean}
48
- * @default false
49
- */
50
- fullBlockchainTraversal?: boolean;
51
44
  }
52
45
  /**
53
46
  * {@link https://dcdpr.github.io/did-btcr2/terminology.html#smt-proof | SMT Proof}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/core/interfaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,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c;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC9D;;OAEG;IACH,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,wBAAwB,CAAC;KACpC,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB"}
@@ -1,17 +1,20 @@
1
1
  import { BitcoinNetworkConnection } from '@did-btcr2/bitcoin';
2
- import { BTCR2SignedUpdate } from '@did-btcr2/cryptosuite';
2
+ import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
3
  import { DidDocument } from '../utils/did-document.js';
4
- import { BeaconService, BeaconSignal, BlockMetadata } from './beacon/interfaces.js';
4
+ import { BeaconService, BlockMetadata } from './beacon/interfaces.js';
5
5
  import { DidComponents } from './identifier.js';
6
6
  import { Sidecar, SidecarData } from './types.js';
7
7
  /**
8
8
  * The response object for DID Resolution.
9
9
  */
10
10
  export interface DidResolutionResponse {
11
- currentDocument: DidDocument;
12
- confirmations: number;
13
- versionId: string;
14
- updated: string;
11
+ didDocument: DidDocument;
12
+ metadata: {
13
+ confirmations?: number;
14
+ versionId: string;
15
+ updated?: string;
16
+ deactivated?: boolean;
17
+ };
15
18
  }
16
19
  /**
17
20
  * Implements {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html | 7.2 Resolve}.
@@ -23,22 +26,6 @@ export interface DidResolutionResponse {
23
26
  * @type {Resolve}
24
27
  */
25
28
  export declare class Resolve {
26
- /**
27
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
28
- * @param {Sidecar} sidecar The sidecar data to process.
29
- * @returns {SidecarData} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
30
- */
31
- static processSidecarData(sidecar?: Sidecar): SidecarData;
32
- /**
33
- * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
34
- * Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
35
- * The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
36
- * @param {DidComponents} didComponents The decoded components of the did.
37
- * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
38
- * @returns {Promise<DidDocument>} The resolved DID Document object.
39
- * @throws {DidError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
40
- */
41
- static establishCurrentDocument(didComponents: DidComponents, genesisDocument?: object): Promise<DidDocument>;
42
29
  /**
43
30
  * 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}.
44
31
  * @param {DidComponents} didComponents The decoded components of the did.
@@ -50,56 +37,56 @@ export declare class Resolve {
50
37
  * @param {DidComponents} didComponents BTCR2 DID components used to resolve the DID Document
51
38
  * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
52
39
  * @returns {Promise<DidDocument>} The resolved DID Document object
53
- * @throws {MethodError} InvalidDidDocument if not conformant to DID Core v1.1
40
+ * @throws {ResolveError} InvalidDidDocument if not conformant to DID Core v1.1
54
41
  */
55
42
  static external(didComponents: DidComponents, genesisDocument: object): Promise<DidDocument>;
43
+ /**
44
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-sidecar-data | Process Sidecar Data}
45
+ * @param {Sidecar} sidecar The sidecar data to process.
46
+ * @returns {ProcessedSidecar} The processed sidecar data containing maps of updates, CAS announcements, and SMT proofs.
47
+ */
48
+ static sidecarData(sidecar?: Sidecar): SidecarData;
49
+ /**
50
+ * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#establish-current-document | 7.2.d Establish current_document}.
51
+ * Resolution begins by creating an Initial Did Document called current_document (Current DID Document).
52
+ * The current_document is iteratively patched with BTCR2 Signed Updates announced by Authorized Beacon Signals.
53
+ * @param {DidComponents} didComponents The decoded components of the did.
54
+ * @param {GenesisDocument} genesisDocument The genesis document for resolving the DID Document.
55
+ * @returns {Promise<DidDocument>} The resolved DID Document object.
56
+ * @throws {ResolveError} if the DID hrp is invalid, no sidecarData passed and hrp = "x".
57
+ */
58
+ static currentDocument(didComponents: DidComponents, genesisDocument?: object): Promise<DidDocument>;
56
59
  /**
57
60
  * Finds uses the beacon services in the currentDocument to scan for onchain Beacon Signals (transactions) containing
58
61
  * Signal Bytes (last output in OP_RETURN transaction).
59
62
  * @param {Array<BeaconService>} beaconServices The array of BeaconService objects to search for signals.
60
63
  * @param {SidecarData} sidecarData The sidecar data containing maps of updates, CAS announcements, and SMT proofs.
61
64
  * @param {BitcoinNetworkConnection} bitcoin The bitcoin network connection used to fetch beacon signals
62
- * @param {boolean} [fullBlockchainTraversal=false] Whether to perform a full blockchain traversal or use an indexer
63
- * @returns {Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
65
+ * @returns {Promise<Array<[SignedBTCR2Update, BlockMetadata]>>} The array of BTCR2 Signed Updates announced by the Beacon Signals.
64
66
  */
65
- static processBeaconSignals(beaconServices: Array<BeaconService>, sidecarData: SidecarData, bitcoin: BitcoinNetworkConnection, fullBlockchainTraversal?: boolean): Promise<Array<[BTCR2SignedUpdate, BlockMetadata]>>;
67
+ static beaconSignals(beaconServices: Array<BeaconService>, sidecarData: SidecarData, bitcoin: BitcoinNetworkConnection): Promise<Array<[SignedBTCR2Update, BlockMetadata]>>;
66
68
  /**
67
69
  * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#process-updates | 7.2.f Process updates Array}.
68
70
  * @param {DidDocument} currentDocument The current DID Document to apply the updates to.
69
- * @param {Array<[BTCR2SignedUpdate, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
71
+ * @param {Array<[SignedBTCR2Update, BlockMetadata]>} unsortedUpdates The unsorted array of BTCR2 Signed Updates and their associated Block Metadata.
70
72
  * @param {string} [versionTime] The optional version time to limit updates to.
71
73
  * @param {string} [versionId] The optional version id to limit updates to.
72
74
  * @returns {Promise<DidResolutionResponse>} The updated DID Document, number of confirmations, and version id.
73
75
  */
74
- static processUpdatesArray(currentDocument: DidDocument, unsortedUpdates: Array<[BTCR2SignedUpdate, BlockMetadata]>, versionTime?: string, versionId?: string): Promise<DidResolutionResponse>;
75
- /**
76
- * Retrieves the beacon signals for the given array of BeaconService objects
77
- * using a esplora/electrs REST API connection via a bitcoin I/O driver.
78
- * @param {Array<BeaconService>} beaconServices Array of BeaconService objects to retrieve signals for
79
- * @param {BitcoinNetworkConnection} bitcoin Bitcoin network connection to use for REST calls
80
- * @returns {Promise<Array<BeaconSignal>>} Promise resolving to an array of BeaconSignal objects
81
- */
82
- static queryBlockchainIndexer(beaconServices: Array<BeaconService>, bitcoin: BitcoinNetworkConnection): Promise<Map<BeaconService, Array<BeaconSignal>>>;
83
- /**
84
- * Traverse the full blockchain from genesis to chain top looking for beacon signals.
85
- * @param {Array<BeaconService>} beaconServices Array of BeaconService objects to search for signals.
86
- * @param {BitcoinNetworkConnection} bitcoin Bitcoin network connection to use for RPC calls.
87
- * @returns {Promise<Array<BeaconSignal>>} Promise resolving to an array of BeaconSignal objects.
88
- */
89
- static traverseFullBlockchain(beaconServices: Array<BeaconService>, bitcoin: BitcoinNetworkConnection): Promise<Map<BeaconService, Array<BeaconSignal>>>;
76
+ static updates(currentDocument: DidDocument, unsortedUpdates: Array<[SignedBTCR2Update, BlockMetadata]>, versionTime?: string, versionId?: string): Promise<DidResolutionResponse>;
90
77
  /**
91
78
  * Implements subsection {@link https://dcdpr.github.io/did-btcr2/#confirm-duplicate-update | 7.2.f.1 Confirm Duplicate Update}.
92
79
  * This step confirms that an update with a lower-than-expected targetVersionId is a true duplicate.
93
- * @param {BTCR2SignedUpdate} update The BTCR2 Signed Update to confirm as a duplicate.
80
+ * @param {SignedBTCR2Update} update The BTCR2 Signed Update to confirm as a duplicate.
94
81
  * @returns {void} Does not return a value, but throws an error if the update is not a valid duplicate.
95
82
  */
96
- static confirmDuplicateUpdate(update: BTCR2SignedUpdate, updateHashHistory: string[]): void;
83
+ static confirmDuplicate(update: SignedBTCR2Update, updateHashHistory: string[]): void;
97
84
  /**
98
85
  * Implements subsection {@link https://dcdpr.github.io/did-btcr2/operations/resolve.html#apply-update | 7.2.f.3 Apply Update}.
99
86
  * @param {DidDocument} currentDocument The current DID Document to apply the update to.
100
- * @param {BTCR2SignedUpdate} update The BTCR2 Signed Update to apply.
87
+ * @param {SignedBTCR2Update} update The BTCR2 Signed Update to apply.
101
88
  * @returns {Promise<DidDocument>} The updated DID Document after applying the update.
102
89
  * @throws {ResolveError} If the update is invalid or cannot be applied.
103
90
  */
104
- static applyDidUpdate(currentDocument: DidDocument, update: BTCR2SignedUpdate): Promise<DidDocument>;
91
+ static applyUpdate(currentDocument: DidDocument, update: SignedBTCR2Update): Promise<DidDocument>;
105
92
  }
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/core/resolve.ts"],"names":[],"mappings":"AA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B,GACxB,OAAO,CAAC,WAAW,CAAC;CAiFxB"}
@@ -1,5 +1,5 @@
1
1
  import { HexString } from '@did-btcr2/common';
2
- import { BTCR2SignedUpdate } from '@did-btcr2/cryptosuite';
2
+ import { SignedBTCR2Update } from '@did-btcr2/cryptosuite';
3
3
  import { SMTProof } from './interfaces.js';
4
4
  /**
5
5
  * {@link https://dcdpr.github.io/did-btcr2/data-structures.html#cas-announcement | CAS Announcement }
@@ -37,7 +37,7 @@ export type Sidecar = {
37
37
  * Optional array of BTCR2 Signed Updates. Required if the DID being resolved
38
38
  * has ever had a published BTCR2 Update.
39
39
  */
40
- updates?: Array<BTCR2SignedUpdate>;
40
+ updates?: Array<SignedBTCR2Update>;
41
41
  /**
42
42
  * Optional array of CAS Announcements. Required if the DID being reslved has
43
43
  * used a CAS Beacon to publish a BTCR2 Update.
@@ -49,23 +49,36 @@ export type Sidecar = {
49
49
  */
50
50
  smtProofs?: Array<SMTProof>;
51
51
  };
52
+ /**
53
+ * The Sidecar data structure used for Singleton Beacons.
54
+ */
55
+ export type SingletonBeaconSidecarData = Map<HexString, SignedBTCR2Update>;
56
+ /**
57
+ * The Sidecar data structure used for CAS Beacons.
58
+ */
59
+ export type CASBeaconSidecarData = Map<HexString, CASAnnouncement>;
60
+ /**
61
+ * The Sidecar data structure used for SMT Beacons.
62
+ */
63
+ export type SMTBeaconSidecarData = Map<string, SMTProof>;
52
64
  /**
53
65
  * The Sidecar data structure post-processing used for resolution.
54
66
  */
55
67
  export type SidecarData = {
56
68
  /**
57
69
  * Map of BTCR2 Signed Updates by their hash bytes.
58
- * @type {Map<HexString, BTCR2SignedUpdate>}
59
70
  */
60
- updateMap: Map<HexString, BTCR2SignedUpdate>;
71
+ updateMap: SingletonBeaconSidecarData;
61
72
  /**
62
73
  * Map of CAS Announcements by their hash bytes.
63
- * @type {Map<HexString, CASAnnouncement>}
64
74
  */
65
- casMap: Map<HexString, CASAnnouncement>;
75
+ casMap: CASBeaconSidecarData;
66
76
  /**
67
77
  * Map of SMT Proofs by their ID.
68
- * @type {Map<string, SMTProof>}
69
78
  */
70
- smtMap: Map<string, SMTProof>;
79
+ smtMap: SMTBeaconSidecarData;
71
80
  };
81
+ /**
82
+ * Union type for all Beacon Sidecar data structures.
83
+ */
84
+ export type BeaconSidecarData = SingletonBeaconSidecarData | CASBeaconSidecarData | SMTBeaconSidecarData;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,OAAO,GAAG;IACpB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;OAGG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAElC;;;OAGG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;IAEpC;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;;OAGG;IACH,SAAS,EAAE,GAAG,CAAC,SAAS,EAAE,iBAAiB,CAAC,CAAC;IAC7C;;;OAGG;IACH,MAAM,EAAE,GAAG,CAAC,SAAS,EAAE,eAAe,CAAC,CAAC;IACxC;;;OAGG;IACH,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAC/B,CA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