@bsv/sdk 1.4.1 → 1.4.3

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 (39) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/registry/RegistryClient.js +112 -89
  3. package/dist/cjs/src/registry/RegistryClient.js.map +1 -1
  4. package/dist/cjs/src/storage/StorageDownloader.js +82 -0
  5. package/dist/cjs/src/storage/StorageDownloader.js.map +1 -0
  6. package/dist/cjs/src/storage/__test/StorageDownloader.test.js +144 -0
  7. package/dist/cjs/src/storage/__test/StorageDownloader.test.js.map +1 -0
  8. package/dist/cjs/src/storage/index.js +3 -1
  9. package/dist/cjs/src/storage/index.js.map +1 -1
  10. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  11. package/dist/esm/src/registry/RegistryClient.js +110 -88
  12. package/dist/esm/src/registry/RegistryClient.js.map +1 -1
  13. package/dist/esm/src/storage/StorageDownloader.js +75 -0
  14. package/dist/esm/src/storage/StorageDownloader.js.map +1 -0
  15. package/dist/esm/src/storage/__test/StorageDownloader.test.js +139 -0
  16. package/dist/esm/src/storage/__test/StorageDownloader.test.js.map +1 -0
  17. package/dist/esm/src/storage/index.js +1 -0
  18. package/dist/esm/src/storage/index.js.map +1 -1
  19. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  20. package/dist/types/src/registry/RegistryClient.d.ts +24 -24
  21. package/dist/types/src/registry/RegistryClient.d.ts.map +1 -1
  22. package/dist/types/src/registry/types/index.d.ts +46 -19
  23. package/dist/types/src/registry/types/index.d.ts.map +1 -1
  24. package/dist/types/src/storage/StorageDownloader.d.ts +25 -0
  25. package/dist/types/src/storage/StorageDownloader.d.ts.map +1 -0
  26. package/dist/types/src/storage/__test/StorageDownloader.test.d.ts +2 -0
  27. package/dist/types/src/storage/__test/StorageDownloader.test.d.ts.map +1 -0
  28. package/dist/types/src/storage/index.d.ts +1 -0
  29. package/dist/types/src/storage/index.d.ts.map +1 -1
  30. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  31. package/dist/umd/bundle.js +1 -1
  32. package/docs/storage.md +51 -0
  33. package/package.json +1 -1
  34. package/src/registry/RegistryClient.ts +142 -114
  35. package/src/registry/__tests/RegistryClient.test.ts +136 -100
  36. package/src/registry/types/index.ts +50 -20
  37. package/src/storage/StorageDownloader.ts +91 -0
  38. package/src/storage/__test/StorageDownloader.test.ts +170 -0
  39. package/src/storage/index.ts +3 -0
@@ -6,18 +6,18 @@ import { PushDrop, LockingScript } from '../script/index.js';
6
6
  const REGISTRANT_TOKEN_AMOUNT = 1;
7
7
  /**
8
8
  * RegistryClient manages on-chain registry definitions for three types:
9
- * - BasketMap (basket-based items)
10
- * - ProtoMap (protocol-based items)
11
- * - CertMap (certificate-based items)
9
+ * - basket (basket-based items)
10
+ * - protocol (protocol-based items)
11
+ * - certificate (certificate-based items)
12
12
  *
13
13
  * It provides methods to:
14
14
  * - Register new definitions using pushdrop-based UTXOs.
15
- * - Resolve existing definitions using a overlay lookup service.
15
+ * - Resolve existing definitions using a lookup service.
16
16
  * - List registry entries associated with the operator's wallet.
17
17
  * - Revoke an existing registry entry by spending its UTXO.
18
18
  *
19
19
  * Registry operators use this client to establish and manage
20
- * canonical references for baskets, protocols, and certificates types.
20
+ * canonical references for baskets, protocols, and certificate types.
21
21
  */
22
22
  export class RegistryClient {
23
23
  wallet;
@@ -32,17 +32,18 @@ export class RegistryClient {
32
32
  * Registry operators (i.e., identity key owners) can create these definitions
33
33
  * to establish canonical references for basket IDs, protocol specs, or certificate schemas.
34
34
  *
35
- * @param data - The structured information needed to register an item of kind 'basket', 'protocol', or 'certificate'.
35
+ * @param data - Structured information about a 'basket', 'protocol', or 'certificate'.
36
36
  * @returns A promise with the broadcast result or failure.
37
37
  */
38
38
  async registerDefinition(data) {
39
39
  const registryOperator = (await this.wallet.getPublicKey({ identityKey: true })).publicKey;
40
40
  const pushdrop = new PushDrop(this.wallet);
41
- // Build the array of fields, depending on the definition type
41
+ // Convert definition data into PushDrop fields
42
42
  const fields = this.buildPushDropFields(data, registryOperator);
43
- const protocol = this.getWalletProtocol(data.definitionType);
44
- // Lock the fields
45
- const lockingScript = await pushdrop.lock(fields, protocol, '1', 'self');
43
+ // Convert the user-friendly definitionType to the actual wallet protocol
44
+ const protocol = this.mapDefinitionTypeToWalletProtocol(data.definitionType);
45
+ // Lock the fields into a pushdrop-based UTXO
46
+ const lockingScript = await pushdrop.lock(fields, protocol, '1', 'anyone', true);
46
47
  // Create a transaction
47
48
  const { tx } = await this.wallet.createAction({
48
49
  description: `Register a new ${data.definitionType} item`,
@@ -50,16 +51,20 @@ export class RegistryClient {
50
51
  {
51
52
  satoshis: REGISTRANT_TOKEN_AMOUNT,
52
53
  lockingScript: lockingScript.toHex(),
53
- outputDescription: `New ${data.definitionType} registration token`
54
+ outputDescription: `New ${data.definitionType} registration token`,
55
+ basket: this.mapDefinitionTypeToBasketName(data.definitionType)
54
56
  }
55
- ]
57
+ ],
58
+ options: {
59
+ randomizeOutputs: false
60
+ }
56
61
  });
57
62
  if (tx === undefined) {
58
63
  throw new Error(`Failed to create ${data.definitionType} registration transaction!`);
59
64
  }
60
- // Broadcast
61
- const broadcaster = new TopicBroadcaster([this.getBroadcastTopic(data.definitionType)], {
62
- networkPreset: this.network ??= (await (this.wallet.getNetwork({}))).network
65
+ // Broadcast to the relevant topic
66
+ const broadcaster = new TopicBroadcaster([this.mapDefinitionTypeToTopic(data.definitionType)], {
67
+ networkPreset: this.network ??= (await this.wallet.getNetwork({})).network
63
68
  });
64
69
  return await broadcaster.broadcast(Transaction.fromAtomicBEEF(tx));
65
70
  }
@@ -70,7 +75,7 @@ export class RegistryClient {
70
75
  * - For "basket", the query is of type BasketMapQuery:
71
76
  * { basketID?: string; name?: string; registryOperators?: string[]; }
72
77
  * - For "protocol", the query is of type ProtoMapQuery:
73
- * { name?: string; registryOperators?: string[]; protocolID?: string; securityLevel?: number; }
78
+ * { name?: string; registryOperators?: string[]; protocolID?: WalletProtocol; }
74
79
  * - For "certificate", the query is of type CertMapQuery:
75
80
  * { type?: string; name?: string; registryOperators?: string[]; }
76
81
  *
@@ -80,24 +85,22 @@ export class RegistryClient {
80
85
  */
81
86
  async resolve(definitionType, query) {
82
87
  const resolver = new LookupResolver();
83
- // The service name depends on the kind
84
- const serviceName = this.getServiceName(definitionType);
85
- const result = await resolver.query({
86
- service: serviceName,
87
- query
88
- });
88
+ const serviceName = this.mapDefinitionTypeToServiceName(definitionType);
89
+ // Make the lookup query
90
+ const result = await resolver.query({ service: serviceName, query });
89
91
  if (result.type !== 'output-list') {
90
92
  return [];
91
93
  }
92
94
  const parsedRegistryRecords = [];
93
95
  for (const output of result.outputs) {
94
96
  try {
95
- const parsedTx = Transaction.fromAtomicBEEF(output.beef);
96
- const record = await this.parseLockingScript(definitionType, parsedTx.outputs[output.outputIndex].lockingScript);
97
+ const parsedTx = Transaction.fromBEEF(output.beef);
98
+ const lockingScript = parsedTx.outputs[output.outputIndex].lockingScript;
99
+ const record = await this.parseLockingScript(definitionType, lockingScript);
97
100
  parsedRegistryRecords.push(record);
98
101
  }
99
102
  catch {
100
- // skip
103
+ // Skip invalid or non-pushdrop outputs
101
104
  }
102
105
  }
103
106
  return parsedRegistryRecords;
@@ -111,29 +114,32 @@ export class RegistryClient {
111
114
  * @returns A promise that resolves to an array of RegistryRecord objects.
112
115
  */
113
116
  async listOwnRegistryEntries(definitionType) {
114
- const relevantBasketName = this.getBasketName(definitionType);
115
- const { outputs } = await this.wallet.listOutputs({
117
+ const relevantBasketName = this.mapDefinitionTypeToBasketName(definitionType);
118
+ const { outputs, BEEF } = await this.wallet.listOutputs({
116
119
  basket: relevantBasketName,
117
- include: 'locking scripts'
120
+ include: 'entire transactions'
118
121
  });
119
122
  const results = [];
120
123
  for (const output of outputs) {
121
- if (output.spendable) {
124
+ if (!output.spendable) {
122
125
  continue;
123
126
  }
124
127
  try {
125
- const record = await this.parseLockingScript(definitionType, LockingScript.fromHex(output.lockingScript));
126
128
  const [txid, outputIndex] = output.outpoint.split('.');
129
+ const tx = Transaction.fromBEEF(BEEF);
130
+ const lockingScript = tx.outputs[outputIndex].lockingScript;
131
+ const record = await this.parseLockingScript(definitionType, lockingScript);
127
132
  results.push({
128
133
  ...record,
129
134
  txid,
130
135
  outputIndex: Number(outputIndex),
131
136
  satoshis: output.satoshis,
132
- lockingScript: output.lockingScript
137
+ lockingScript: lockingScript.toHex(),
138
+ beef: BEEF
133
139
  });
134
140
  }
135
141
  catch {
136
- // ignore parse errors
142
+ // Ignore parse errors
137
143
  }
138
144
  }
139
145
  return results;
@@ -141,21 +147,14 @@ export class RegistryClient {
141
147
  /**
142
148
  * Revokes a registry record by spending its associated UTXO.
143
149
  *
144
- * This function creates a transaction that spends the UTXO corresponding to the provided registry record,
145
- * revoking the registry entry. It prepares an unlocker using the appropriate wallet protocol,
146
- * builds a signable transaction, signs it, and then broadcasts the finalized transaction.
147
- *
148
- * @param registryRecord - The registry record to revoke. It must include a valid txid, outputIndex, and lockingScript.
149
- * @returns A promise that resolves with either a BroadcastResponse upon success or a BroadcastFailure on error.
150
- * @throws If required fields are missing or if transaction creation/signing fails.
150
+ * @param registryRecord - Must have valid txid, outputIndex, and lockingScript.
151
+ * @returns Broadcast success/failure.
151
152
  */
152
153
  async revokeOwnRegistryEntry(registryRecord) {
153
154
  if (registryRecord.txid === undefined || typeof registryRecord.outputIndex === 'undefined' || registryRecord.lockingScript === undefined) {
154
- throw new Error('Invalid record. Missing txid, outputIndex, or lockingScript.');
155
+ throw new Error('Invalid registry record. Missing txid, outputIndex, or lockingScript.');
155
156
  }
156
- // Prepare the unlocker
157
- const pushdrop = new PushDrop(this.wallet);
158
- const unlocker = await pushdrop.unlock(this.getWalletProtocol(registryRecord.definitionType), '1', 'anyone');
157
+ // Create a descriptive label for the item we’re revoking
159
158
  const itemIdentifier = registryRecord.definitionType === 'basket'
160
159
  ? registryRecord.basketID
161
160
  : registryRecord.definitionType === 'protocol'
@@ -163,12 +162,10 @@ export class RegistryClient {
163
162
  : registryRecord.definitionType === 'certificate'
164
163
  ? (registryRecord.name !== undefined ? registryRecord.name : registryRecord.type)
165
164
  : 'unknown';
166
- const description = `Revoke ${registryRecord.definitionType} item: ${String(itemIdentifier)}`;
167
- // Create a new transaction that spends the UTXO
168
165
  const outpoint = `${registryRecord.txid}.${registryRecord.outputIndex}`;
169
166
  const { signableTransaction } = await this.wallet.createAction({
170
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
171
- description,
167
+ description: `Revoke ${registryRecord.definitionType} item: ${itemIdentifier}`,
168
+ inputBEEF: registryRecord.beef,
172
169
  inputs: [
173
170
  {
174
171
  outpoint,
@@ -180,30 +177,40 @@ export class RegistryClient {
180
177
  if (signableTransaction === undefined) {
181
178
  throw new Error('Failed to create signable transaction.');
182
179
  }
183
- // Build a transaction object, sign with the unlock script
184
- const tx = Transaction.fromBEEF(signableTransaction.tx);
185
- const finalUnlockScript = await unlocker.sign(tx, registryRecord.outputIndex);
186
- // Complete the signing
180
+ const partialTx = Transaction.fromBEEF(signableTransaction.tx);
181
+ // Prepare the unlocker
182
+ const pushdrop = new PushDrop(this.wallet);
183
+ const unlocker = await pushdrop.unlock(this.mapDefinitionTypeToWalletProtocol(registryRecord.definitionType), '1', 'anyone', 'all', false, registryRecord.satoshis, LockingScript.fromHex(registryRecord.lockingScript));
184
+ // Convert to Transaction, apply signature
185
+ const finalUnlockScript = await unlocker.sign(partialTx, registryRecord.outputIndex);
186
+ // Complete signing with the final unlock script
187
187
  const { tx: signedTx } = await this.wallet.signAction({
188
188
  reference: signableTransaction.reference,
189
189
  spends: {
190
190
  [registryRecord.outputIndex]: {
191
191
  unlockingScript: finalUnlockScript.toHex()
192
192
  }
193
+ },
194
+ options: {
195
+ acceptDelayedBroadcast: false
193
196
  }
194
197
  });
195
198
  if (signedTx === undefined) {
196
199
  throw new Error('Failed to finalize the transaction signature.');
197
200
  }
198
201
  // Broadcast
199
- const broadcaster = new TopicBroadcaster([this.getBroadcastTopic(registryRecord.definitionType)], {
200
- networkPreset: this.network ??= (await (this.wallet.getNetwork({}))).network
202
+ const broadcaster = new TopicBroadcaster([this.mapDefinitionTypeToTopic(registryRecord.definitionType)], {
203
+ networkPreset: this.network ??= (await this.wallet.getNetwork({})).network
201
204
  });
202
205
  return await broadcaster.broadcast(Transaction.fromAtomicBEEF(signedTx));
203
206
  }
204
207
  // --------------------------------------------------------------------------
205
- // INTERNAL HELPER METHODS
208
+ // INTERNAL UTILITY METHODS
206
209
  // --------------------------------------------------------------------------
210
+ /**
211
+ * Convert definition data into an array of pushdrop fields (strings).
212
+ * Each definition type has a slightly different shape.
213
+ */
207
214
  buildPushDropFields(data, registryOperator) {
208
215
  let fields;
209
216
  switch (data.definitionType) {
@@ -218,8 +225,7 @@ export class RegistryClient {
218
225
  break;
219
226
  case 'protocol':
220
227
  fields = [
221
- data.securityLevel.toString(),
222
- data.protocolID,
228
+ JSON.stringify(data.protocolID),
223
229
  data.name,
224
230
  data.iconURL,
225
231
  data.description,
@@ -237,14 +243,14 @@ export class RegistryClient {
237
243
  ];
238
244
  break;
239
245
  default:
240
- throw new Error('Invalid registry kind specified');
246
+ throw new Error('Unsupported definition type');
241
247
  }
242
- // Append the registry operator to all cases.
248
+ // Append the operator's public identity key last
243
249
  fields.push(registryOperator);
244
250
  return fields.map(field => Utils.toArray(field));
245
251
  }
246
252
  /**
247
- * Decodes a pushdrop locking script for a given registry kind,
253
+ * Decodes a pushdrop locking script for a given definition type,
248
254
  * returning a typed record with the appropriate fields.
249
255
  */
250
256
  async parseLockingScript(definitionType, lockingScript) {
@@ -253,15 +259,15 @@ export class RegistryClient {
253
259
  throw new Error('Not a valid registry pushdrop script.');
254
260
  }
255
261
  let registryOperator;
256
- let data;
262
+ let parsedData;
257
263
  switch (definitionType) {
258
264
  case 'basket': {
259
- if (decoded.fields.length !== 6) {
265
+ if (decoded.fields.length !== 7) {
260
266
  throw new Error('Unexpected field count for basket type.');
261
267
  }
262
268
  const [basketID, name, iconURL, description, docURL, operator] = decoded.fields;
263
269
  registryOperator = Utils.toUTF8(operator);
264
- data = {
270
+ parsedData = {
265
271
  definitionType: 'basket',
266
272
  basketID: Utils.toUTF8(basketID),
267
273
  name: Utils.toUTF8(name),
@@ -273,14 +279,13 @@ export class RegistryClient {
273
279
  }
274
280
  case 'protocol': {
275
281
  if (decoded.fields.length !== 7) {
276
- throw new Error('Unexpected field count for proto type.');
282
+ throw new Error('Unexpected field count for protocol type.');
277
283
  }
278
- const [securityLevel, protocolID, name, iconURL, description, docURL, operator] = decoded.fields;
284
+ const [protocolID, name, iconURL, description, docURL, operator] = decoded.fields;
279
285
  registryOperator = Utils.toUTF8(operator);
280
- data = {
286
+ parsedData = {
281
287
  definitionType: 'protocol',
282
- securityLevel: parseInt(Utils.toUTF8(securityLevel), 10),
283
- protocolID: Utils.toUTF8(protocolID),
288
+ protocolID: deserializeWalletProtocol(Utils.toUTF8(protocolID)),
284
289
  name: Utils.toUTF8(name),
285
290
  iconURL: Utils.toUTF8(iconURL),
286
291
  description: Utils.toUTF8(description),
@@ -289,19 +294,19 @@ export class RegistryClient {
289
294
  break;
290
295
  }
291
296
  case 'certificate': {
292
- if (decoded.fields.length !== 7) {
297
+ if (decoded.fields.length !== 8) {
293
298
  throw new Error('Unexpected field count for certificate type.');
294
299
  }
295
300
  const [certType, name, iconURL, description, docURL, fieldsJSON, operator] = decoded.fields;
296
301
  registryOperator = Utils.toUTF8(operator);
297
- let parsedFields;
302
+ let parsedFields = {};
298
303
  try {
299
304
  parsedFields = JSON.parse(Utils.toUTF8(fieldsJSON));
300
305
  }
301
306
  catch {
302
- parsedFields = {};
307
+ // If there's a JSON parse error, assume empty
303
308
  }
304
- data = {
309
+ parsedData = {
305
310
  definitionType: 'certificate',
306
311
  type: Utils.toUTF8(certType),
307
312
  name: Utils.toUTF8(name),
@@ -313,21 +318,20 @@ export class RegistryClient {
313
318
  break;
314
319
  }
315
320
  default:
316
- throw new Error('Invalid registry kind for parsing.');
321
+ throw new Error(`Unsupported definition type: ${definitionType}`);
317
322
  }
323
+ // Enforce that the pushdrop belongs to the CURRENT identity key
318
324
  const currentIdentityKey = (await this.wallet.getPublicKey({ identityKey: true })).publicKey;
319
325
  if (registryOperator !== currentIdentityKey) {
320
326
  throw new Error('This registry token does not belong to the current wallet.');
321
327
  }
322
- return {
323
- ...data,
324
- registryOperator
325
- };
328
+ // Return the typed data plus the operator key
329
+ return { ...parsedData, registryOperator };
326
330
  }
327
331
  /**
328
- * Returns the (protocolID, keyID) used for pushdrop based on the registry kind.
332
+ * Convert our definitionType to the wallet protocol format ([protocolID, keyID]).
329
333
  */
330
- getWalletProtocol(definitionType) {
334
+ mapDefinitionTypeToWalletProtocol(definitionType) {
331
335
  switch (definitionType) {
332
336
  case 'basket':
333
337
  return [1, 'basketmap'];
@@ -336,13 +340,13 @@ export class RegistryClient {
336
340
  case 'certificate':
337
341
  return [1, 'certmap'];
338
342
  default:
339
- throw new Error(`Unknown registry type: ${definitionType}`);
343
+ throw new Error(`Unknown definition type: ${definitionType}`);
340
344
  }
341
345
  }
342
346
  /**
343
- * Returns the name of the basket used by the wallet
347
+ * Convert 'basket'|'protocol'|'certificate' to the basket name used by the wallet.
344
348
  */
345
- getBasketName(definitionType) {
349
+ mapDefinitionTypeToBasketName(definitionType) {
346
350
  switch (definitionType) {
347
351
  case 'basket':
348
352
  return 'basketmap';
@@ -351,13 +355,13 @@ export class RegistryClient {
351
355
  case 'certificate':
352
356
  return 'certmap';
353
357
  default:
354
- throw new Error(`Unknown basket type: ${definitionType}`);
358
+ throw new Error(`Unknown definition type: ${definitionType}`);
355
359
  }
356
360
  }
357
361
  /**
358
- * Returns the broadcast topic to be used with SHIPBroadcaster.
362
+ * Convert 'basket'|'protocol'|'certificate' to the broadcast topic name.
359
363
  */
360
- getBroadcastTopic(definitionType) {
364
+ mapDefinitionTypeToTopic(definitionType) {
361
365
  switch (definitionType) {
362
366
  case 'basket':
363
367
  return 'tm_basketmap';
@@ -366,13 +370,13 @@ export class RegistryClient {
366
370
  case 'certificate':
367
371
  return 'tm_certmap';
368
372
  default:
369
- throw new Error(`Unknown topic type: ${definitionType}`);
373
+ throw new Error(`Unknown definition type: ${definitionType}`);
370
374
  }
371
375
  }
372
376
  /**
373
- * Returns the lookup service name to use.
377
+ * Convert 'basket'|'protocol'|'certificate' to the lookup service name.
374
378
  */
375
- getServiceName(definitionType) {
379
+ mapDefinitionTypeToServiceName(definitionType) {
376
380
  switch (definitionType) {
377
381
  case 'basket':
378
382
  return 'ls_basketmap';
@@ -381,8 +385,26 @@ export class RegistryClient {
381
385
  case 'certificate':
382
386
  return 'ls_certmap';
383
387
  default:
384
- throw new Error(`Unknown service type: ${definitionType}`);
388
+ throw new Error(`Unknown definition type: ${definitionType}`);
385
389
  }
386
390
  }
387
391
  }
392
+ export function deserializeWalletProtocol(str) {
393
+ // Parse the JSON string back into a JavaScript value.
394
+ const parsed = JSON.parse(str);
395
+ // Validate that the parsed value is an array with exactly two elements.
396
+ if (!Array.isArray(parsed) || parsed.length !== 2) {
397
+ throw new Error('Invalid wallet protocol format.');
398
+ }
399
+ const [security, protocolString] = parsed;
400
+ // Validate that the security level is one of the allowed numbers.
401
+ if (![0, 1, 2].includes(security)) {
402
+ throw new Error('Invalid security level.');
403
+ }
404
+ // Validate that the protocol string is a string and its length is within the allowed bounds.
405
+ if (typeof protocolString !== 'string') {
406
+ throw new Error('Invalid protocolID');
407
+ }
408
+ return [security, protocolString];
409
+ }
388
410
  //# sourceMappingURL=RegistryClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RegistryClient.js","sourceRoot":"","sources":["../../../../src/registry/RegistryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,YAAY,EAGb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,KAAK,EACN,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EACL,WAAW,EAGZ,MAAM,yBAAyB,CAAA;AAChC,OAAO,EACL,cAAc,EACd,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,MAAM,CAAA;IAEzC,kEAAkE;IAClE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACjC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;KAC3C;IAED,6FAA6F;IAC7F,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE;QACtC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;KACtC;IAED,OAAO,CAAC,QAAyB,EAAE,cAAc,CAAC,CAAA;AACpD,CAAC"}
@@ -0,0 +1,75 @@
1
+ import { LookupResolver } from '../overlay-tools/index.js';
2
+ import { StorageUtils } from './index.js';
3
+ import PushDrop from '../script/templates/PushDrop.js';
4
+ import Transaction from '../transaction/Transaction.js';
5
+ import { Hash, Utils } from '../primitives/index.js';
6
+ /**
7
+ * Locates HTTP URLs where content can be downloaded. It uses the passed or the default one.
8
+ *
9
+ * @param {Object} obj All parameters are passed in an object.
10
+ * @param {String} obj.uhrpUrl The UHRP url to resolve.
11
+ * @param {string} obj.confederacyHost HTTPS URL for for the with default setting.
12
+ *
13
+ * @return {Array<String>} An array of HTTP URLs where content can be downloaded.
14
+ * @throws {Error} If UHRP url parameter invalid or is not an array
15
+ * or there is an error retrieving url(s) stored in the UHRP token.
16
+ */
17
+ export class StorageDownloader {
18
+ networkPreset = 'mainnet';
19
+ constructor(config) {
20
+ this.networkPreset = config?.networkPreset;
21
+ }
22
+ async resolve(uhrpUrl) {
23
+ // Use UHRP lookup service
24
+ const lookupResolver = new LookupResolver({ networkPreset: this.networkPreset });
25
+ const response = await lookupResolver.query({ service: 'ls_uhrp', query: { uhrpUrl } });
26
+ if (response.type !== 'output-list') {
27
+ throw new Error('Lookup answer must be an output list');
28
+ }
29
+ const decodedResults = [];
30
+ for (let i = 0; i < response.outputs.length; i++) {
31
+ const tx = Transaction.fromBEEF(response.outputs[i].beef);
32
+ const { fields } = PushDrop.decode(tx.outputs[response.outputs[i].outputIndex].lockingScript);
33
+ decodedResults.push(Utils.toUTF8(fields[2]));
34
+ }
35
+ return decodedResults;
36
+ }
37
+ async download(uhrpUrl) {
38
+ if (!StorageUtils.isValidURL(uhrpUrl)) {
39
+ throw new Error('Invalid parameter UHRP url');
40
+ }
41
+ const hash = StorageUtils.getHashFromURL(uhrpUrl);
42
+ const downloadURLs = await this.resolve(uhrpUrl);
43
+ if (!Array.isArray(downloadURLs) || downloadURLs.length === 0) {
44
+ throw new Error('No one currently hosts this file!');
45
+ }
46
+ for (let i = 0; i < downloadURLs.length; i++) {
47
+ try {
48
+ // The url is fetched
49
+ const result = await fetch(downloadURLs[i], { method: 'GET' });
50
+ // If the request fails, continue to the next url
51
+ if (!result.ok || result.status >= 400) {
52
+ continue;
53
+ }
54
+ const body = await result.arrayBuffer();
55
+ // The body is loaded into a number array
56
+ const content = [...new Uint8Array(body)];
57
+ const contentHash = Hash.sha256(content);
58
+ for (let i = 0; i < contentHash.length; ++i) {
59
+ if (contentHash[i] !== hash[i]) {
60
+ throw new Error('Value of content does not match hash of the url given');
61
+ }
62
+ }
63
+ return {
64
+ data: content,
65
+ mimeType: result.headers.get('Content-Type')
66
+ };
67
+ }
68
+ catch (error) {
69
+ continue;
70
+ }
71
+ }
72
+ throw new Error(`Unable to download content from ${uhrpUrl}`);
73
+ }
74
+ }
75
+ //# sourceMappingURL=StorageDownloader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StorageDownloader.js","sourceRoot":"","sources":["../../../../src/storage/StorageDownloader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzC,OAAO,QAAQ,MAAM,iCAAiC,CAAA;AACtD,OAAO,WAAW,MAAM,+BAA+B,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAWpD;;;;;;;;;;GAUG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