@bsv/overlay 2.3.1 → 2.6.1

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 (201) hide show
  1. package/README.md +166 -0
  2. package/dist/cjs/mod.d.ts +3 -0
  3. package/dist/cjs/mod.d.ts.map +1 -1
  4. package/dist/cjs/mod.js +8 -1
  5. package/dist/cjs/mod.js.map +1 -1
  6. package/dist/cjs/package.json +10 -4
  7. package/dist/cjs/src/BASM.d.ts +6 -0
  8. package/dist/cjs/src/BASM.d.ts.map +1 -1
  9. package/dist/cjs/src/BASM.js +21 -8
  10. package/dist/cjs/src/BASM.js.map +1 -1
  11. package/dist/cjs/src/BASMRemote.d.ts +8 -1
  12. package/dist/cjs/src/BASMRemote.d.ts.map +1 -1
  13. package/dist/cjs/src/BASMRemote.js +179 -13
  14. package/dist/cjs/src/BASMRemote.js.map +1 -1
  15. package/dist/cjs/src/BASMValidation.d.ts +27 -0
  16. package/dist/cjs/src/BASMValidation.d.ts.map +1 -0
  17. package/dist/cjs/src/BASMValidation.js +108 -0
  18. package/dist/cjs/src/BASMValidation.js.map +1 -0
  19. package/dist/cjs/src/DiscoveryAdvertisementValidation.d.ts +11 -0
  20. package/dist/cjs/src/DiscoveryAdvertisementValidation.d.ts.map +1 -0
  21. package/dist/cjs/src/DiscoveryAdvertisementValidation.js +60 -0
  22. package/dist/cjs/src/DiscoveryAdvertisementValidation.js.map +1 -0
  23. package/dist/cjs/src/Engine.d.ts +37 -13
  24. package/dist/cjs/src/Engine.d.ts.map +1 -1
  25. package/dist/cjs/src/Engine.js +1713 -336
  26. package/dist/cjs/src/Engine.js.map +1 -1
  27. package/dist/cjs/src/EngineAdmission.d.ts +70 -0
  28. package/dist/cjs/src/EngineAdmission.d.ts.map +1 -0
  29. package/dist/cjs/src/EngineAdmission.js +297 -0
  30. package/dist/cjs/src/EngineAdmission.js.map +1 -0
  31. package/dist/cjs/src/GASP/OverlayGASPRemote.d.ts +4 -3
  32. package/dist/cjs/src/GASP/OverlayGASPRemote.d.ts.map +1 -1
  33. package/dist/cjs/src/GASP/OverlayGASPRemote.js +27 -43
  34. package/dist/cjs/src/GASP/OverlayGASPRemote.js.map +1 -1
  35. package/dist/cjs/src/GASP/OverlayGASPStorage.d.ts +22 -16
  36. package/dist/cjs/src/GASP/OverlayGASPStorage.d.ts.map +1 -1
  37. package/dist/cjs/src/GASP/OverlayGASPStorage.js +206 -57
  38. package/dist/cjs/src/GASP/OverlayGASPStorage.js.map +1 -1
  39. package/dist/cjs/src/RemoteSecurity.d.ts +50 -0
  40. package/dist/cjs/src/RemoteSecurity.d.ts.map +1 -0
  41. package/dist/cjs/src/RemoteSecurity.js +301 -0
  42. package/dist/cjs/src/RemoteSecurity.js.map +1 -0
  43. package/dist/cjs/src/storage/AdmissionStorage.d.ts +185 -0
  44. package/dist/cjs/src/storage/AdmissionStorage.d.ts.map +1 -0
  45. package/dist/cjs/src/storage/AdmissionStorage.js +93 -0
  46. package/dist/cjs/src/storage/AdmissionStorage.js.map +1 -0
  47. package/dist/cjs/src/storage/RecoveryContract.d.ts +50 -0
  48. package/dist/cjs/src/storage/RecoveryContract.d.ts.map +1 -0
  49. package/dist/cjs/src/storage/RecoveryContract.js +35 -0
  50. package/dist/cjs/src/storage/RecoveryContract.js.map +1 -0
  51. package/dist/cjs/src/storage/Storage.d.ts +32 -19
  52. package/dist/cjs/src/storage/Storage.d.ts.map +1 -1
  53. package/dist/cjs/src/storage/Storage.js +5 -0
  54. package/dist/cjs/src/storage/Storage.js.map +1 -1
  55. package/dist/cjs/src/storage/knex/KnexStorage.d.ts +8 -8
  56. package/dist/cjs/src/storage/knex/KnexStorage.d.ts.map +1 -1
  57. package/dist/cjs/src/storage/knex/KnexStorage.js +98 -61
  58. package/dist/cjs/src/storage/knex/KnexStorage.js.map +1 -1
  59. package/dist/cjs/src/storage/knex/all-migrations.d.ts.map +1 -1
  60. package/dist/cjs/src/storage/knex/all-migrations.js +5 -1
  61. package/dist/cjs/src/storage/knex/all-migrations.js.map +1 -1
  62. package/dist/cjs/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.d.ts +4 -0
  63. package/dist/cjs/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.d.ts.map +1 -0
  64. package/dist/cjs/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.js +36 -0
  65. package/dist/cjs/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.js.map +1 -0
  66. package/dist/cjs/src/storage/knex/migrations/2026-09-20-001-spent-by.d.ts +5 -0
  67. package/dist/cjs/src/storage/knex/migrations/2026-09-20-001-spent-by.d.ts.map +1 -0
  68. package/dist/cjs/src/storage/knex/migrations/2026-09-20-001-spent-by.js +16 -0
  69. package/dist/cjs/src/storage/knex/migrations/2026-09-20-001-spent-by.js.map +1 -0
  70. package/dist/cjs/src/storage/mongo/MongoAdmissionPlan.d.ts +18 -0
  71. package/dist/cjs/src/storage/mongo/MongoAdmissionPlan.d.ts.map +1 -0
  72. package/dist/cjs/src/storage/mongo/MongoAdmissionPlan.js +229 -0
  73. package/dist/cjs/src/storage/mongo/MongoAdmissionPlan.js.map +1 -0
  74. package/dist/cjs/src/storage/mongo/MongoAdmissionStorage.d.ts +112 -0
  75. package/dist/cjs/src/storage/mongo/MongoAdmissionStorage.d.ts.map +1 -0
  76. package/dist/cjs/src/storage/mongo/MongoAdmissionStorage.js +675 -0
  77. package/dist/cjs/src/storage/mongo/MongoAdmissionStorage.js.map +1 -0
  78. package/dist/cjs/src/storage/mongo/MongoOverlayStorage.d.ts +71 -0
  79. package/dist/cjs/src/storage/mongo/MongoOverlayStorage.d.ts.map +1 -0
  80. package/dist/cjs/src/storage/mongo/MongoOverlayStorage.js +453 -0
  81. package/dist/cjs/src/storage/mongo/MongoOverlayStorage.js.map +1 -0
  82. package/dist/cjs/src/storage/mongo/MongoPayloadStore.d.ts +134 -0
  83. package/dist/cjs/src/storage/mongo/MongoPayloadStore.d.ts.map +1 -0
  84. package/dist/cjs/src/storage/mongo/MongoPayloadStore.js +756 -0
  85. package/dist/cjs/src/storage/mongo/MongoPayloadStore.js.map +1 -0
  86. package/dist/cjs/src/storage/mongo/MongoReadGuards.d.ts +44 -0
  87. package/dist/cjs/src/storage/mongo/MongoReadGuards.d.ts.map +1 -0
  88. package/dist/cjs/src/storage/mongo/MongoReadGuards.js +135 -0
  89. package/dist/cjs/src/storage/mongo/MongoReadGuards.js.map +1 -0
  90. package/dist/cjs/src/storage/mongo/MongoSchema.d.ts +67 -0
  91. package/dist/cjs/src/storage/mongo/MongoSchema.d.ts.map +1 -0
  92. package/dist/cjs/src/storage/mongo/MongoSchema.js +743 -0
  93. package/dist/cjs/src/storage/mongo/MongoSchema.js.map +1 -0
  94. package/dist/cjs/src/storage/mongo/MongoTransactionRunner.d.ts +69 -0
  95. package/dist/cjs/src/storage/mongo/MongoTransactionRunner.d.ts.map +1 -0
  96. package/dist/cjs/src/storage/mongo/MongoTransactionRunner.js +368 -0
  97. package/dist/cjs/src/storage/mongo/MongoTransactionRunner.js.map +1 -0
  98. package/dist/cjs/src/storage/mongo.d.ts +9 -0
  99. package/dist/cjs/src/storage/mongo.d.ts.map +1 -0
  100. package/dist/cjs/src/storage/mongo.js +25 -0
  101. package/dist/cjs/src/storage/mongo.js.map +1 -0
  102. package/dist/esm/mod.js +3 -0
  103. package/dist/esm/mod.js.map +1 -1
  104. package/dist/esm/src/BASM.js +21 -8
  105. package/dist/esm/src/BASM.js.map +1 -1
  106. package/dist/esm/src/BASMRemote.js +176 -12
  107. package/dist/esm/src/BASMRemote.js.map +1 -1
  108. package/dist/esm/src/BASMValidation.js +95 -0
  109. package/dist/esm/src/BASMValidation.js.map +1 -0
  110. package/dist/esm/src/DiscoveryAdvertisementValidation.js +57 -0
  111. package/dist/esm/src/DiscoveryAdvertisementValidation.js.map +1 -0
  112. package/dist/esm/src/Engine.js +1698 -326
  113. package/dist/esm/src/Engine.js.map +1 -1
  114. package/dist/esm/src/EngineAdmission.js +280 -0
  115. package/dist/esm/src/EngineAdmission.js.map +1 -0
  116. package/dist/esm/src/GASP/OverlayGASPRemote.js +27 -43
  117. package/dist/esm/src/GASP/OverlayGASPRemote.js.map +1 -1
  118. package/dist/esm/src/GASP/OverlayGASPStorage.js +200 -56
  119. package/dist/esm/src/GASP/OverlayGASPStorage.js.map +1 -1
  120. package/dist/esm/src/RemoteSecurity.js +279 -0
  121. package/dist/esm/src/RemoteSecurity.js.map +1 -0
  122. package/dist/esm/src/storage/AdmissionStorage.js +85 -0
  123. package/dist/esm/src/storage/AdmissionStorage.js.map +1 -0
  124. package/dist/esm/src/storage/RecoveryContract.js +31 -0
  125. package/dist/esm/src/storage/RecoveryContract.js.map +1 -0
  126. package/dist/esm/src/storage/Storage.js +4 -1
  127. package/dist/esm/src/storage/Storage.js.map +1 -1
  128. package/dist/esm/src/storage/knex/KnexStorage.js +98 -61
  129. package/dist/esm/src/storage/knex/KnexStorage.js.map +1 -1
  130. package/dist/esm/src/storage/knex/all-migrations.js +5 -1
  131. package/dist/esm/src/storage/knex/all-migrations.js.map +1 -1
  132. package/dist/esm/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.js +32 -0
  133. package/dist/esm/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.js.map +1 -0
  134. package/dist/esm/src/storage/knex/migrations/2026-09-20-001-spent-by.js +12 -0
  135. package/dist/esm/src/storage/knex/migrations/2026-09-20-001-spent-by.js.map +1 -0
  136. package/dist/esm/src/storage/mongo/MongoAdmissionPlan.js +217 -0
  137. package/dist/esm/src/storage/mongo/MongoAdmissionPlan.js.map +1 -0
  138. package/dist/esm/src/storage/mongo/MongoAdmissionStorage.js +673 -0
  139. package/dist/esm/src/storage/mongo/MongoAdmissionStorage.js.map +1 -0
  140. package/dist/esm/src/storage/mongo/MongoOverlayStorage.js +451 -0
  141. package/dist/esm/src/storage/mongo/MongoOverlayStorage.js.map +1 -0
  142. package/dist/esm/src/storage/mongo/MongoPayloadStore.js +747 -0
  143. package/dist/esm/src/storage/mongo/MongoPayloadStore.js.map +1 -0
  144. package/dist/esm/src/storage/mongo/MongoReadGuards.js +129 -0
  145. package/dist/esm/src/storage/mongo/MongoReadGuards.js.map +1 -0
  146. package/dist/esm/src/storage/mongo/MongoSchema.js +730 -0
  147. package/dist/esm/src/storage/mongo/MongoSchema.js.map +1 -0
  148. package/dist/esm/src/storage/mongo/MongoTransactionRunner.js +371 -0
  149. package/dist/esm/src/storage/mongo/MongoTransactionRunner.js.map +1 -0
  150. package/dist/esm/src/storage/mongo.js +9 -0
  151. package/dist/esm/src/storage/mongo.js.map +1 -0
  152. package/dist/types/mod.d.ts +3 -0
  153. package/dist/types/mod.d.ts.map +1 -1
  154. package/dist/types/src/BASM.d.ts +6 -0
  155. package/dist/types/src/BASM.d.ts.map +1 -1
  156. package/dist/types/src/BASMRemote.d.ts +8 -1
  157. package/dist/types/src/BASMRemote.d.ts.map +1 -1
  158. package/dist/types/src/BASMValidation.d.ts +27 -0
  159. package/dist/types/src/BASMValidation.d.ts.map +1 -0
  160. package/dist/types/src/DiscoveryAdvertisementValidation.d.ts +11 -0
  161. package/dist/types/src/DiscoveryAdvertisementValidation.d.ts.map +1 -0
  162. package/dist/types/src/Engine.d.ts +37 -13
  163. package/dist/types/src/Engine.d.ts.map +1 -1
  164. package/dist/types/src/EngineAdmission.d.ts +70 -0
  165. package/dist/types/src/EngineAdmission.d.ts.map +1 -0
  166. package/dist/types/src/GASP/OverlayGASPRemote.d.ts +4 -3
  167. package/dist/types/src/GASP/OverlayGASPRemote.d.ts.map +1 -1
  168. package/dist/types/src/GASP/OverlayGASPStorage.d.ts +22 -16
  169. package/dist/types/src/GASP/OverlayGASPStorage.d.ts.map +1 -1
  170. package/dist/types/src/RemoteSecurity.d.ts +50 -0
  171. package/dist/types/src/RemoteSecurity.d.ts.map +1 -0
  172. package/dist/types/src/storage/AdmissionStorage.d.ts +185 -0
  173. package/dist/types/src/storage/AdmissionStorage.d.ts.map +1 -0
  174. package/dist/types/src/storage/RecoveryContract.d.ts +50 -0
  175. package/dist/types/src/storage/RecoveryContract.d.ts.map +1 -0
  176. package/dist/types/src/storage/Storage.d.ts +32 -19
  177. package/dist/types/src/storage/Storage.d.ts.map +1 -1
  178. package/dist/types/src/storage/knex/KnexStorage.d.ts +8 -8
  179. package/dist/types/src/storage/knex/KnexStorage.d.ts.map +1 -1
  180. package/dist/types/src/storage/knex/all-migrations.d.ts.map +1 -1
  181. package/dist/types/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.d.ts +4 -0
  182. package/dist/types/src/storage/knex/migrations/2026-09-17-001-topical-uniqueness.d.ts.map +1 -0
  183. package/dist/types/src/storage/knex/migrations/2026-09-20-001-spent-by.d.ts +5 -0
  184. package/dist/types/src/storage/knex/migrations/2026-09-20-001-spent-by.d.ts.map +1 -0
  185. package/dist/types/src/storage/mongo/MongoAdmissionPlan.d.ts +18 -0
  186. package/dist/types/src/storage/mongo/MongoAdmissionPlan.d.ts.map +1 -0
  187. package/dist/types/src/storage/mongo/MongoAdmissionStorage.d.ts +112 -0
  188. package/dist/types/src/storage/mongo/MongoAdmissionStorage.d.ts.map +1 -0
  189. package/dist/types/src/storage/mongo/MongoOverlayStorage.d.ts +71 -0
  190. package/dist/types/src/storage/mongo/MongoOverlayStorage.d.ts.map +1 -0
  191. package/dist/types/src/storage/mongo/MongoPayloadStore.d.ts +134 -0
  192. package/dist/types/src/storage/mongo/MongoPayloadStore.d.ts.map +1 -0
  193. package/dist/types/src/storage/mongo/MongoReadGuards.d.ts +44 -0
  194. package/dist/types/src/storage/mongo/MongoReadGuards.d.ts.map +1 -0
  195. package/dist/types/src/storage/mongo/MongoSchema.d.ts +67 -0
  196. package/dist/types/src/storage/mongo/MongoSchema.d.ts.map +1 -0
  197. package/dist/types/src/storage/mongo/MongoTransactionRunner.d.ts +69 -0
  198. package/dist/types/src/storage/mongo/MongoTransactionRunner.d.ts.map +1 -0
  199. package/dist/types/src/storage/mongo.d.ts +9 -0
  200. package/dist/types/src/storage/mongo.d.ts.map +1 -0
  201. package/package.json +11 -5
@@ -9,7 +9,12 @@ import { SyncConfiguration } from './SyncConfiguration.js';
9
9
  import { type AdmittedListResponse, type BASMPeerSyncReport, type CompoundMerklePathResponse, type RawTransactionResponse, type ReorgReport, type TopicAnchorHeaderResolver, type TopicAnchorRangeResponse, type TopicAnchorTip } from './BASM.js';
10
10
  type UTXOHistoryHydrationContext = {
11
11
  outputCache: Map<string, Promise<Output | null>>;
12
+ budgetedOutputs: Set<string>;
13
+ hydratedNodes: number;
14
+ relationCount: number;
15
+ totalBeefBytes: number;
12
16
  };
17
+ type SubmissionMode = 'historical-tx' | 'current-tx' | 'historical-tx-no-spv';
13
18
  /**
14
19
  * An engine for running BSV Overlay Services (topic managers and lookup services).
15
20
  */
@@ -38,6 +43,8 @@ export declare class Engine {
38
43
  basmSyncEnabled: boolean;
39
44
  unprovenEvictionBlocks: number;
40
45
  maxLookupResults: number;
46
+ private submissionTail;
47
+ private basmFetchImpl?;
41
48
  /**
42
49
  * Creates a new Overlay Services Engine
43
50
  * @param {[key: string]: TopicManager} managers - manages topic admittance
@@ -108,6 +115,7 @@ export declare class Engine {
108
115
  rebuildFromHeight: number;
109
116
  newTipHeight: number;
110
117
  }): Promise<ReorgReport>;
118
+ private reconcileReorg;
111
119
  /**
112
120
  * Revalidation sweep: the reorg fallback for chain trackers without a reorg
113
121
  * event stream, and the catch-up step on every reorg-SSE (re)connect (the
@@ -134,6 +142,10 @@ export declare class Engine {
134
142
  private applyTopicStorageMutation;
135
143
  private applyStorageMutations;
136
144
  private propagateSubmission;
145
+ private assertSupportedTopics;
146
+ private shouldSkipPropagation;
147
+ private notifySteakReady;
148
+ private acknowledgeOverlayAdmission;
137
149
  /**
138
150
  * Submits a transaction for processing by Overlay Services.
139
151
  * @param {TaggedBEEF} taggedBEEF - The transaction to process
@@ -141,11 +153,13 @@ export declare class Engine {
141
153
  * @param {string} mode — Indicates the submission behavior, whether historical or current. Historical transactions are not broadcast or propagated.
142
154
  * @param {number[]} offChainValues — Values necessary to evaluate topical admittance that are not stored on-chain.
143
155
  *
144
- * The optional callback function should be used to get STEAK when ready, and avoid waiting for broadcast and transaction propagation to complete.
156
+ * The optional callback is invoked after any required transaction broadcast and
157
+ * local storage mutations have completed, but before peer-to-peer propagation.
145
158
  *
146
159
  * @returns {Promise<STEAK>} The submitted transaction execution acknowledgement
147
160
  */
148
- submit(taggedBEEF: TaggedBEEF, onSteakReady?: (steak: STEAK) => void, mode?: 'historical-tx' | 'current-tx' | 'historical-tx-no-spv', offChainValues?: number[]): Promise<STEAK>;
161
+ submit(taggedBEEF: TaggedBEEF, onSteakReady?: (steak: STEAK) => void, mode?: SubmissionMode, offChainValues?: number[]): Promise<STEAK>;
162
+ private submitUnlocked;
149
163
  /**
150
164
  * Submit a lookup question to the Overlay Services Engine, and receive back a Lookup Answer
151
165
  * @param LookupQuestion — The question to ask the Overlay Services Engine
@@ -154,6 +168,8 @@ export declare class Engine {
154
168
  lookup(lookupQuestion: LookupQuestion): Promise<LookupAnswer>;
155
169
  private createUTXOHistoryHydrationContext;
156
170
  private toOutputCacheKey;
171
+ private assertLookupFormula;
172
+ private validateLookupOutput;
157
173
  private preloadOutputsWithBEEF;
158
174
  private loadOutputWithBEEF;
159
175
  private hydrateUTXOHistoryNode;
@@ -176,6 +192,7 @@ export declare class Engine {
176
192
  * @throws Will throw an error if there are issues during the advertisement synchronization process.
177
193
  * @returns {Promise<void>} A promise that resolves when the synchronization process is complete.
178
194
  */
195
+ private validateCurrentAdvertisements;
179
196
  syncAdvertisements(): Promise<void>;
180
197
  /**
181
198
  * This method goes through each topic that we support syncing and attempts to sync with each endpoint
@@ -187,13 +204,23 @@ export declare class Engine {
187
204
  startGASPSync(): Promise<void>;
188
205
  private syncGASPWithPeer;
189
206
  private resolveSyncEndpointsForTopic;
207
+ private assertSupportedBASMTopic;
208
+ private assertTopicAnchorTip;
209
+ private assertTopicBlockAnchor;
190
210
  provideTopicAnchorTip(topic: string): Promise<TopicAnchorTip>;
191
211
  provideTopicAnchorRange(topic: string, fromHeight: number, toHeight: number): Promise<TopicAnchorRangeResponse>;
192
212
  provideAdmittedList(topic: string, blockHeight: number, blockHash?: string): Promise<AdmittedListResponse>;
193
213
  provideCompoundMerklePath(topic: string, blockHeight: number, txids: string[]): Promise<CompoundMerklePathResponse>;
194
- provideRawTransactions(txids: string[]): Promise<RawTransactionResponse>;
214
+ provideRawTransactions(txids: string[], topic?: string): Promise<RawTransactionResponse>;
195
215
  startBASMSync(): Promise<BASMPeerSyncReport[]>;
196
216
  private reconcileBASMWithPeer;
217
+ private requireMatchingRemoteBASMTip;
218
+ private finishBASMWhenRemoteIsNotAhead;
219
+ private requireBASMRangePrefix;
220
+ private advanceBASMWithRemoteAnchors;
221
+ private markBASMPeerSyncError;
222
+ private requireCanonicalBASMAnchor;
223
+ private validateBASMProofPositions;
197
224
  private reconcileRemoteAnchor;
198
225
  private fetchBASMMissingTransactions;
199
226
  evictUnprovenTransactions(options?: {
@@ -223,6 +250,7 @@ export declare class Engine {
223
250
  error: string;
224
251
  }>;
225
252
  }>;
253
+ private validateUnprovenCandidates;
226
254
  maintainUnprovenTransactions(options: {
227
255
  topic?: string;
228
256
  thresholdBlocks?: number;
@@ -279,7 +307,7 @@ export declare class Engine {
279
307
  * @returns A promise that resolves to a GASPNode containing the raw transaction and other optional data.
280
308
  * @throws An error if no output is found for the given transaction ID and output index.
281
309
  */
282
- provideForeignGASPNode(graphID: string, txid: string, outputIndex: number): Promise<GASPNode>;
310
+ provideForeignGASPNode(graphID: string, txid: string, outputIndex: number, topic?: string): Promise<GASPNode>;
283
311
  /**
284
312
  * Traverse and return the history of a UTXO.
285
313
  *
@@ -294,7 +322,7 @@ export declare class Engine {
294
322
  * @param {number} [currentDepth=0] - The current depth of the traversal relative to the top-level UTXO.
295
323
  *
296
324
  * @returns {Promise<Output | undefined>} - A promise that resolves to the output history if found, or undefined if not.
297
- */
325
+ */
298
326
  getUTXOHistory(output: Output, historySelector?: ((beef: number[], outputIndex: number, currentDepth: number) => Promise<boolean>) | number, currentDepth?: number, context?: UTXOHistoryHydrationContext): Promise<Output | undefined>;
299
327
  /**
300
328
  * Delete a UTXO and all stale consumed inputs.
@@ -302,6 +330,8 @@ export declare class Engine {
302
330
  * @returns {Promise<void>} - A promise that resolves when the deletion process is complete.
303
331
  */
304
332
  private deleteUTXODeep;
333
+ private assertStoredOutputRelations;
334
+ private assertStoredOutputMatches;
305
335
  /**
306
336
  * Given a new transaction proof (txid, proof),
307
337
  * update tx.merklePath if appropriate,
@@ -312,14 +342,8 @@ export declare class Engine {
312
342
  * @param proof for txid
313
343
  */
314
344
  private updateInputProofs;
315
- /**
316
- * Recursively updates beefs (merkle proofs) of this output and its consumedBy lineage.
317
- *
318
- * @param output - An output derived from txid which may benefit from new proof.
319
- * @param txid - The txid for which proof is a valid merkle path.
320
- * @param proof - The merklePath proving txid is a mined transaction hash
321
- */
322
- private updateMerkleProof;
345
+ private prepareMerkleProofUpdate;
346
+ private collectMerkleProofOutputs;
323
347
  /**
324
348
  * Recursively prune UTXOs when an incoming Merkle Proof is received.
325
349
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Engine.d.ts","sourceRoot":"","sources":["../../../src/Engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,EAEL,YAAY,EACZ,UAAU,EACV,WAAW,EAEX,UAAU,EAAE,KAAK,EACjB,cAAc,EACd,YAAY,EAMZ,2BAA2B,EAG5B,MAAM,UAAU,CAAA;AACjB,OAAO,EAAqB,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAC/D,OAAO,EAAQ,kBAAkB,EAAE,mBAAmB,EAAE,QAAQ,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AG,OAAO,CAAC,MAAM,CAAC,CASnE;IAED;;;;OAIG;IACG,wCAAwC,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,CAU7E;IAED;;;;;;;;;OASG;IACH,OAAO,CAAC,UAAU;CAwCnB"}
@@ -0,0 +1,70 @@
1
+ import type { Transaction } from '@bsv/sdk';
2
+ import { type AdmissionCommit, type AdmissionCommitResult, type AdmissionPayloadRef, type AdmissionStorage, type HistoryFence, type StorageScope } from './storage/AdmissionStorage.js';
3
+ import type { Output } from './Output.js';
4
+ import type { LookupService } from './LookupService.js';
5
+ export declare const OVERLAY_ENGINE_POLICY_ID = "overlay-engine-submit-v1";
6
+ export type OverlayAdmissionMode = 'live' | 'historical';
7
+ type TopicValidationLike = {
8
+ topic: string;
9
+ isDupe: boolean;
10
+ previousCoins: number[];
11
+ previousOutputs: Array<Output | null>;
12
+ admissibleOutputs: {
13
+ outputsToAdmit: number[];
14
+ coinsToRetain: number[];
15
+ coinsRemoved?: number[];
16
+ };
17
+ };
18
+ export interface OverlayAdmissionHost {
19
+ admission: AdmissionStorage;
20
+ admissionScope: StorageScope;
21
+ publishAdmissionPayload?: (input: {
22
+ kind: AdmissionPayloadRef['kind'];
23
+ bytes: Uint8Array;
24
+ txid?: string;
25
+ }) => Promise<AdmissionPayloadRef>;
26
+ enlistedIndexTargets?: () => readonly string[];
27
+ getHistoryFence?: (topic: string) => Promise<HistoryFence>;
28
+ }
29
+ export declare function getOverlayAdmissionHost(storage: unknown): OverlayAdmissionHost | undefined;
30
+ export declare function overlayAdmissionContextDigest(offChainValues?: number[]): string;
31
+ export declare function overlayAdmissionOperationId(_mode: OverlayAdmissionMode, txid: string, topics: string[]): string;
32
+ export declare function overlayAdmissionMode(mode: 'historical-tx' | 'current-tx' | 'historical-tx-no-spv'): OverlayAdmissionMode;
33
+ /**
34
+ * Selects the topics that require a new admission decision: topics that did
35
+ * not fail validation, are not already-applied dupes, and actually admit or
36
+ * retain something (or consume a previously-admitted coin). Already-applied
37
+ * (dupe) topics are excluded so that a retry — including a historical GASP
38
+ * replay after a live admit, or a multi-topic resubmit where only some
39
+ * topics were previously applied — never re-submits an admission decision
40
+ * for a topic that MongoAdmissionStorage.assertAppliedAvailable would reject
41
+ * as belonging to a different operation.
42
+ */
43
+ export declare function selectNewAdmissionTopics<T extends TopicValidationLike>(validations: readonly T[], failedTopics: Set<string>): T[];
44
+ export declare function buildOverlayAdmissionPlan(input: {
45
+ host: OverlayAdmissionHost;
46
+ tx: Transaction;
47
+ txid: string;
48
+ beef: number[];
49
+ topics: string[];
50
+ mode: OverlayAdmissionMode;
51
+ offChainValues?: number[];
52
+ validations: TopicValidationLike[];
53
+ failedTopics: Set<string>;
54
+ lookupServices: {
55
+ [key: string]: LookupService;
56
+ };
57
+ includePropagation: boolean;
58
+ applied?: {
59
+ firstSeenHeight?: number;
60
+ blockHeight?: number;
61
+ blockHash?: string;
62
+ blockIndex?: number;
63
+ merkleRoot?: string;
64
+ };
65
+ }): Promise<AdmissionCommit>;
66
+ export declare function waitForAdmissionReceipt(admission: AdmissionStorage, plan: AdmissionCommit, rebuild: () => Promise<AdmissionCommit>): Promise<AdmissionCommitResult & {
67
+ state: 'committed';
68
+ }>;
69
+ export {};
70
+ //# sourceMappingURL=EngineAdmission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EngineAdmission.d.ts","sourceRoot":"","sources":["../../../src/EngineAdmission.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAS,WAAW,EAAE,MAAM,UAAU,CAAA;AAElD,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAE1B,KAAK,mBAAmB,EAExB,KAAK,gBAAgB,EAErB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,+BAA+B,CAAA;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEv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asp';
2
2
  export declare class OverlayGASPRemote implements GASPRemote {
3
- endpointURL: string;
4
- topic: string;
5
- constructor(endpointURL: string, topic: string);
3
+ readonly endpointURL: string;
4
+ readonly topic: string;
5
+ private readonly fetchImpl;
6
+ constructor(endpointURL: string, topic: string, fetchImpl?: typeof fetch);
6
7
  /**
7
8
  * Given an outgoing initial request, sends the request to the foreign instance and obtains their initial response.
8
9
  * @param request
@@ -1 +1 @@
1
- {"version":3,"file":"OverlayGASPRemote.d.ts","sourceRoot":"","sources":["../../../../src/GASP/OverlayGASPRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE7H,qBAAa,iBAAkB,YAAW,UAAU;IAC9B,WAAW,EAAE,MAAM;IAAS,KAAK,EAAE,MAAM;IAA7D,YAAoB,WAAW,EAAE,MAAM,EAAS,KAAK,EAAE,MAAM,EAAK;IAElE;;;;OAIG;IACG,kBAAkB,CAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAiCnF;IAED;;;;;;;OAOG;IACG,WAAW,CAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAwC3G;IAKK,eAAe,CAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEhF;IAIK,UAAU,CAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAExE;CACF"}
1
+ {"version":3,"file":"OverlayGASPRemote.d.ts","sourceRoot":"","sources":["../../../../src/GASP/OverlayGASPRemote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAe7H,qBAAa,iBAAkB,YAAW,UAAU;IAClD,SAAgB,WAAW,EAAE,MAAM,CAAA;IACnC,SAAgB,KAAK,EAAE,MAAM,CAAA;IAC7B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAc;IAExC,YAAa,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,OAAO,KAAK,EAMxE;IAED;;;;OAIG;IACG,kBAAkB,CAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAmBnF;IAED;;;;;;;OAOG;IACG,WAAW,CAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAyB3G;IAKK,eAAe,CAAE,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAEhF;IAIK,UAAU,CAAE,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAExE;CACF"}
@@ -22,14 +22,20 @@ export declare class OverlayGASPStorage implements GASPStorage {
22
22
  topic: string;
23
23
  engine: Engine;
24
24
  maxNodesInGraph?: number | undefined;
25
+ maxBytesInGraph: number;
25
26
  readonly temporaryGraphNodeRefs: Record<string, GraphNode>;
27
+ private readonly graphNodeCounts;
28
+ private readonly graphByteCounts;
26
29
  private static activeAnchorValidations;
27
30
  private static readonly anchorValidationQueue;
28
31
  private static activeFinalizations;
29
32
  private static readonly finalizationQueue;
30
33
  private static readonly MAX_CONCURRENT_ANCHOR_VALIDATIONS;
31
34
  private static readonly MAX_CONCURRENT_FINALIZATIONS;
32
- constructor(topic: string, engine: Engine, maxNodesInGraph?: number | undefined);
35
+ constructor(topic: string, engine: Engine, maxNodesInGraph?: number | undefined, maxBytesInGraph?: number);
36
+ private graphNodeKey;
37
+ private graphNode;
38
+ private nodeByteLength;
33
39
  private static acquireAnchorValidationSlot;
34
40
  private static releaseAnchorValidationSlot;
35
41
  private static acquireFinalizationSlot;
@@ -50,10 +56,10 @@ export declare class OverlayGASPStorage implements GASPStorage {
50
56
  */
51
57
  hydrateGASPNode(graphID: string, txid: string, outputIndex: number, _metadata: boolean): Promise<GASPNode>;
52
58
  /**
53
- * For a given node, returns the inputs needed to complete the graph, including whether updated metadata is requested for those inputs.
54
- * @param tx The node for which needed inputs should be found.
55
- * @returns A promise for a mapping of requested input transactions and whether metadata should be provided for each.
56
- */
59
+ * For a given node, returns the inputs needed to complete the graph, including whether updated metadata is requested for those inputs.
60
+ * @param tx The node for which needed inputs should be found.
61
+ * @returns A promise for a mapping of requested input transactions and whether metadata should be provided for each.
62
+ */
57
63
  findNeededInputs(tx: GASPNode): Promise<GASPNodeResponse | undefined>;
58
64
  /**
59
65
  * Ensures that no inputs are requested from foreign nodes before sending any GASP response
@@ -61,21 +67,21 @@ export declare class OverlayGASPStorage implements GASPStorage {
61
67
  */
62
68
  private stripAlreadyKnownInputs;
63
69
  /**
64
- * Appends a new node to a temporary graph.
65
- * @param tx The node to append to this graph.
66
- * @param spentBy Unless this is the same node identified by the graph ID, denotes the TXID and input index for the node which spent this one, in 36-byte format.
67
- * @throws If the node cannot be appended to the graph, either because the graph ID is for a graph the recipient does not want or because the graph has grown to be too large before being finalized.
68
- */
70
+ * Appends a new node to a temporary graph.
71
+ * @param tx The node to append to this graph.
72
+ * @param spentBy Unless this is the same node identified by the graph ID, denotes the TXID and input index for the node which spent this one, in 36-byte format.
73
+ * @throws If the node cannot be appended to the graph, either because the graph ID is for a graph the recipient does not want or because the graph has grown to be too large before being finalized.
74
+ */
69
75
  appendToGraph(tx: GASPNode, spentBy?: string | undefined): Promise<void>;
70
76
  private previousCoinIndexes;
71
77
  private admitHistoricalBEEF;
72
78
  /**
73
- * Checks whether the given graph, in its current state, makes reference only to transactions that are proven in the blockchain, or already known by the recipient to be valid.
74
- * Additionally, in a breadth-first manner (ensuring that all inputs for any given node are processed before nodes that spend them), it ensures that the root node remains valid according to the rules of the overlay's topic manager,
75
- * while considering any coins which the Manager had previously indicated were either valid or invalid.
76
- * @param graphID The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
77
- * @throws If the graph is not well-anchored, according to the rules of Bitcoin or the rules of the Overlay Topic Manager.
78
- */
79
+ * Checks whether the given graph, in its current state, makes reference only to transactions that are proven in the blockchain, or already known by the recipient to be valid.
80
+ * Additionally, in a breadth-first manner (ensuring that all inputs for any given node are processed before nodes that spend them), it ensures that the root node remains valid according to the rules of the overlay's topic manager,
81
+ * while considering any coins which the Manager had previously indicated were either valid or invalid.
82
+ * @param graphID The TXID and output index (in 36-byte format) for the UTXO at the tip of this graph.
83
+ * @throws If the graph is not well-anchored, according to the rules of Bitcoin or the rules of the Overlay Topic Manager.
84
+ */
79
85
  validateGraphAnchor(graphID: string): Promise<void>;
80
86
  /**
81
87
  * Deletes all data associated with a temporary graph that has failed to sync, if the graph exists.
@@ -1 +1 @@
1
- {"version":3,"file":"OverlayGASPStorage.d.ts","sourceRoot":"","sources":["../../../../src/GASP/OverlayGASPStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE/E,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,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G,gBAAgB,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAAC,gBAAgB,GAAG,SAAS,CAAC,CAmE1E;IAED;;;OAGG;YACW,uBAAuB;IAoBrC;;;;;OAKG;IACG,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CA2E7E;IAED,OAAO,CAAC,mBAAmB;YAYb,mBAAmB;IAuCjC;;;;;;OAMG;IACG,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAuCxD;IAED;;;OAGG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUjD;IAED;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAqBlD;IAED;;;;OAIG;IACH,OAAO,CAAC,2BAA2B;IAiCnC;;;;OAIG;IACH,OAAO,CAAC,cAAc;CA2BvB"}
@@ -0,0 +1,50 @@
1
+ import { Transaction, type AdmittanceInstructions } from '@bsv/sdk';
2
+ export declare const MAX_GASP_PAGE_SIZE = 10000;
3
+ export declare const MAX_BASM_TXIDS = 256;
4
+ export declare const MAX_REMOTE_JSON_BYTES: number;
5
+ export declare const MAX_GASP_NODE_JSON_BYTES: number;
6
+ export declare const MAX_RAW_TRANSACTION_BYTES: number;
7
+ export declare const REMOTE_BODY_TIMEOUT_MS = 30000;
8
+ export declare function validateAdmittanceInstructions(value: unknown, tx: Transaction, previousCoins: number[]): AdmittanceInstructions;
9
+ export declare function assertTopic(topic: unknown, label?: string): asserts topic is string;
10
+ export declare function assertRegistryName(value: unknown, label: string): asserts value is string;
11
+ export declare function assertHash(value: unknown, label: string): asserts value is string;
12
+ export declare function assertOutputIndex(value: unknown, label: string): asserts value is number;
13
+ export declare function assertNonnegativeInteger(value: unknown, label: string): asserts value is number;
14
+ export declare function assertOutpoint(value: unknown, label: string): asserts value is string;
15
+ export declare function assertHexBytes(value: unknown, label: string, maxBytes: number, allowEmpty?: boolean): asserts value is string;
16
+ export declare function assertTxidList(value: unknown, label: string, options?: {
17
+ allowEmpty?: boolean;
18
+ max?: number;
19
+ }): asserts value is string[];
20
+ export declare function normalizePeerEndpoint(endpoint: string): string;
21
+ export declare function securePeerFetch(endpoint: string, supplied?: typeof fetch): {
22
+ endpoint: string;
23
+ fetchImpl: typeof fetch;
24
+ };
25
+ export declare function readPeerJSON(response: Response, maxBytes?: number): Promise<unknown>;
26
+ export declare function assertGASPInitialResponse(value: unknown, maxOutputs: number): asserts value is {
27
+ UTXOList: Array<{
28
+ txid: string;
29
+ outputIndex: number;
30
+ score: number;
31
+ }>;
32
+ since: number;
33
+ };
34
+ export declare function assertGASPNode(value: unknown, expected: {
35
+ graphID: string;
36
+ txid: string;
37
+ outputIndex: number;
38
+ }): asserts value is {
39
+ graphID: string;
40
+ rawTx: string;
41
+ outputIndex: number;
42
+ proof?: string;
43
+ txMetadata?: string;
44
+ outputMetadata?: string;
45
+ inputs?: Record<string, {
46
+ hash: string;
47
+ }>;
48
+ };
49
+ export declare function assertRawTransactionMatches(txid: string, rawTx: string): void;
50
+ //# sourceMappingURL=RemoteSecurity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RemoteSecurity.d.ts","sourceRoot":"","sources":["../../../src/RemoteSecurity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA0B,KAAK,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAE3F,eAAO,MAAM,kBAAkB,QAAS,CAAA;AACxC,eAAO,MAAM,cAAc,MAAM,CAAA;AACjC,eAAO,MAAM,qBAAqB,QAAmB,CAAA;AACrD,eAAO,MAAM,wBAAwB,QAAmB,CAAA;AACxD,eAAO,MAAM,yBAAyB,QAAmB,CAAA;AACzD,eAAO,MAAM,sBAAsB,QAAS,CAAA;AAe5C,wBAAgB,8BAA8B,CAC5C,KAAK,EA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QAAQ,CAAC,EAAE,OAAO,KAAK,GACtB;IACD,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,OAAO,KAAK,CAAA;CACxB,CAMA;AA+DD,wBAAsB,YAAY,CAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,SAAwB,GAC/B,OAAO,CAAC,OAAO,CAAC,CA2BlB;AAED,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,OAAO,EACd,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,KAAK,IAAI;IAClB,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACrE,KAAK,EAAE,MAAM,CAAA;CACd,CAgBA;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,GAC/D,OAAO,CAAC,KAAK,IAAI;IAClB,OAAO,EAAE,MAAM,CAAA;IACf,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAC1C,CAuCA;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAY7E"}
@@ -0,0 +1,185 @@
1
+ import type { HistoryRevisionHandoff } from './RecoveryContract.js';
2
+ /** Canonical unsigned decimal, 0..2^64-1. Never round through a JS number. */
3
+ export type StorageUint64 = string & {
4
+ readonly __brand: unique symbol;
5
+ };
6
+ export interface StorageScope {
7
+ network: string;
8
+ genesisHash: string;
9
+ nodeId: string;
10
+ }
11
+ /** These revisions are independent: a late admission need not be a reorg. */
12
+ export interface HistoryFence {
13
+ chainEpoch: StorageUint64;
14
+ topicHistoryGeneration: StorageUint64;
15
+ }
16
+ export interface AdmissionIdentity {
17
+ scope: StorageScope;
18
+ /** Derived from verified immutable transaction bytes before storage is called. */
19
+ txid: string;
20
+ mode: 'live' | 'historical';
21
+ /** Digest of off-chain values and any other immutable admission-policy inputs. */
22
+ contextDigest: string;
23
+ topics: Array<{
24
+ topic: string;
25
+ policyId: string;
26
+ }>;
27
+ }
28
+ export interface AdmissionOperationKey {
29
+ scope: StorageScope;
30
+ operationId: string;
31
+ semanticDigest: string;
32
+ }
33
+ /** Small reference to content published outside the database transaction. */
34
+ export interface AdmissionPayloadRef {
35
+ digest: string;
36
+ byteLength: StorageUint64;
37
+ kind: 'raw-transaction' | 'merkle-path' | 'beef-manifest' | 'locking-script' | 'outbox-data';
38
+ }
39
+ export interface AdmissionOutpoint {
40
+ txid: string;
41
+ /** Canonical decimal uint32, the transaction wire outpoint index domain. */
42
+ outputIndex: StorageUint64;
43
+ }
44
+ /** Adapter-issued revision token; absence is also a read predicate. */
45
+ export interface AdmissionReadPredicate {
46
+ key: string;
47
+ expectedVersion: string | null;
48
+ }
49
+ export interface AdmissionOutput extends AdmissionOutpoint {
50
+ satoshis: StorageUint64;
51
+ score: StorageUint64;
52
+ /** A byte range supports even an individually oversized output script. */
53
+ script: {
54
+ payload: AdmissionPayloadRef;
55
+ offset: StorageUint64;
56
+ byteLength: StorageUint64;
57
+ };
58
+ }
59
+ export interface AdmissionTopicDecision {
60
+ topic: string;
61
+ expectedHistory: HistoryFence;
62
+ /** Includes all point/range/projection reads that influenced topic admission. */
63
+ reads: AdmissionReadPredicate[];
64
+ spends: Array<{
65
+ outpoint: AdmissionOutpoint;
66
+ expectedVersion: string;
67
+ spender: string;
68
+ }>;
69
+ /** Remove current serving outputs only; retain applied history and evidence. */
70
+ evictions: AdmissionOutpoint[];
71
+ outputs: AdmissionOutput[];
72
+ edges: Array<{
73
+ source: AdmissionOutpoint;
74
+ consumer: AdmissionOutpoint;
75
+ }>;
76
+ /** Retain this history after output spend, serving moderation or index eviction. */
77
+ applied: {
78
+ txid: string;
79
+ firstSeenHeight?: StorageUint64;
80
+ proof?: AdmissionPayloadRef;
81
+ block?: {
82
+ height: StorageUint64;
83
+ hash: string;
84
+ index: StorageUint64;
85
+ merkleRoot: string;
86
+ };
87
+ };
88
+ /** Invalidate downstream anchors/comparisons; own repair checkpoint moves atomically. */
89
+ historyUpdate?: {
90
+ nextTopicHistoryGeneration: StorageUint64;
91
+ affectedFromHeight: StorageUint64;
92
+ /** Present when a recovery worker itself caused this history revision. */
93
+ handoff?: HistoryRevisionHandoff;
94
+ };
95
+ }
96
+ /** Every event has a stable scope-local ID and ready payload references. */
97
+ export interface AdmissionOutboxIntent {
98
+ eventId: string;
99
+ kind: 'lookup' | 'propagation';
100
+ target: string;
101
+ payloads: AdmissionPayloadRef[];
102
+ }
103
+ export interface AdmissionCommit {
104
+ key: AdmissionOperationKey;
105
+ identity: AdmissionIdentity;
106
+ /** Shared raw/proof components or a manifest; never per-output inline BEEF. */
107
+ payloads: AdmissionPayloadRef[];
108
+ decisions: AdmissionTopicDecision[];
109
+ outbox: AdmissionOutboxIntent[];
110
+ /** Exact UTF-8 STEAK JSON saved with the commit, then replayed without regeneration. */
111
+ steak: string;
112
+ }
113
+ export interface AdmissionReceipt {
114
+ operationId: string;
115
+ semanticDigest: string;
116
+ /** Only the selected adapter can establish this guarantee. */
117
+ durability: 'atomic-local';
118
+ steak: string;
119
+ /** Only enlisted indexes may be visible at commit. External indexes remain pending. */
120
+ indexes: Array<{
121
+ target: string;
122
+ state: 'visible' | 'pending';
123
+ }>;
124
+ propagation: 'not-requested' | 'pending';
125
+ }
126
+ /** Pending is not an ACK. Unknown commit must retain its opaque attempt identity. */
127
+ export type AdmissionCommitResult = {
128
+ state: 'committed';
129
+ receipt: AdmissionReceipt;
130
+ } | {
131
+ state: 'pending';
132
+ attemptId: string;
133
+ } | {
134
+ state: 'rejected';
135
+ code: 'digest-mismatch' | 'read-conflict' | 'spend-conflict' | 'payload-not-ready' | 'unsupported-projection' | 'invalid-plan';
136
+ };
137
+ export type AdmissionReconcileResult = AdmissionCommitResult | {
138
+ state: 'aborted';
139
+ };
140
+ /**
141
+ * Optional v1 contract, separate from legacy CRUD Storage. No current adapter or
142
+ * Engine call path implements it. A provider must atomically revalidate reads,
143
+ * fences, conditional spends and ready-payload pins, and save every effect plus
144
+ * the receipt. Matching retries return the saved receipt before checking stale
145
+ * reads; conflicting semantic digests reject. Do not run verification, uploads,
146
+ * network requests or arbitrary plug-ins inside commitAdmission.
147
+ *
148
+ * TransientTransactionError permits a fresh whole-body attempt after abort and
149
+ * reread/redecision. UnknownTransactionCommitResult requires reconcileAdmission
150
+ * on the SAME attempt until committed or definitively aborted; absence of an
151
+ * operation record alone does not establish abort. Repeated commitAdmission
152
+ * must first recover any persisted unresolved attempt for this operation, even
153
+ * after a lost response or process restart, before it can start a fresh body.
154
+ * Transport failures remain
155
+ * errors, never rejection/abort or a successful local ACK.
156
+ */
157
+ export interface AdmissionStorage {
158
+ readonly protocol: 'overlay-admission-v1';
159
+ commitAdmission: (plan: AdmissionCommit) => Promise<AdmissionCommitResult>;
160
+ reconcileAdmission: (key: AdmissionOperationKey, attemptId?: string) => Promise<AdmissionReconcileResult>;
161
+ }
162
+ /** External projection delivery may be retried only with both capabilities. */
163
+ export interface ReplaySafeProjection {
164
+ readonly protocol: 'overlay-projection-v1';
165
+ applyEvent: (scope: StorageScope, intent: AdmissionOutboxIntent) => Promise<{
166
+ checkpoint: string;
167
+ }>;
168
+ reconcile: (scope: StorageScope, checkpoint: string | null) => Promise<{
169
+ checkpoint: string;
170
+ }>;
171
+ }
172
+ /** Shape detection is a declaration, not proof that an adapter is durable. */
173
+ export declare function getAdmissionStorage(storage: unknown): AdmissionStorage | undefined;
174
+ export declare function isReplaySafeProjection(projection: unknown): projection is ReplaySafeProjection;
175
+ export declare function parseStorageUint64(value: string): bigint;
176
+ export declare function asStorageUint64(value: string): StorageUint64;
177
+ /** Validate the wire outpoint domain before conversion to an exact STEAK number. */
178
+ export declare function parseStorageOutputIndex(value: string): number;
179
+ /**
180
+ * SHA-256 of UTF-8 length-framed fields, see specs/overlay/persistence-v1.md.
181
+ * Mutable reads/decisions and proof variants are deliberately outside semantic
182
+ * identity. Their validation and atomic read predicates remain mandatory.
183
+ */
184
+ export declare function admissionSemanticDigest(identity: AdmissionIdentity): string;
185
+ //# sourceMappingURL=AdmissionStorage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdmissionStorage.d.ts","sourceRoot":"","sources":["../../../../src/storage/AdmissionStorage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAEnE,8EAA8E;AAC9E,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,MAAM,CAAA;CAAE,CAAA;AAExE,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,aAAa,CAAA;IACzB,sBAAsB,EAAE,aAAa,CAAA;CACtC;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,YAAY,CAAA;IACnB,kFAAkF;IAClF,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,GAAG,YAAY,CAAA;IAC3B,kFAAkF;IAClF,aAAa,EAAE,MAAM,CAAA;IACrB,MAAM,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,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