@bsv/sdk 1.4.17 → 1.4.19

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 (59) hide show
  1. package/dist/cjs/package.json +1 -1
  2. package/dist/cjs/src/kvstore/LocalKVStore.js +152 -141
  3. package/dist/cjs/src/kvstore/LocalKVStore.js.map +1 -1
  4. package/dist/cjs/src/storage/StorageUploader.js +122 -14
  5. package/dist/cjs/src/storage/StorageUploader.js.map +1 -1
  6. package/dist/cjs/src/storage/__test/StorageUploader.test.js +85 -14
  7. package/dist/cjs/src/storage/__test/StorageUploader.test.js.map +1 -1
  8. package/dist/cjs/src/wallet/WERR_REVIEW_ACTIONS.js +29 -0
  9. package/dist/cjs/src/wallet/WERR_REVIEW_ACTIONS.js.map +1 -0
  10. package/dist/cjs/src/wallet/WalletError.js +4 -3
  11. package/dist/cjs/src/wallet/WalletError.js.map +1 -1
  12. package/dist/cjs/src/wallet/index.js +4 -1
  13. package/dist/cjs/src/wallet/index.js.map +1 -1
  14. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js +13 -6
  15. package/dist/cjs/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  16. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  17. package/dist/esm/src/kvstore/LocalKVStore.js +151 -141
  18. package/dist/esm/src/kvstore/LocalKVStore.js.map +1 -1
  19. package/dist/esm/src/storage/StorageUploader.js +119 -14
  20. package/dist/esm/src/storage/StorageUploader.js.map +1 -1
  21. package/dist/esm/src/storage/__test/StorageUploader.test.js +85 -14
  22. package/dist/esm/src/storage/__test/StorageUploader.test.js.map +1 -1
  23. package/dist/esm/src/wallet/WERR_REVIEW_ACTIONS.js +31 -0
  24. package/dist/esm/src/wallet/WERR_REVIEW_ACTIONS.js.map +1 -0
  25. package/dist/esm/src/wallet/WalletError.js +3 -2
  26. package/dist/esm/src/wallet/WalletError.js.map +1 -1
  27. package/dist/esm/src/wallet/index.js +2 -0
  28. package/dist/esm/src/wallet/index.js.map +1 -1
  29. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js +13 -6
  30. package/dist/esm/src/wallet/substrates/HTTPWalletJSON.js.map +1 -1
  31. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  32. package/dist/types/src/kvstore/LocalKVStore.d.ts +10 -4
  33. package/dist/types/src/kvstore/LocalKVStore.d.ts.map +1 -1
  34. package/dist/types/src/storage/StorageUploader.d.ts +77 -14
  35. package/dist/types/src/storage/StorageUploader.d.ts.map +1 -1
  36. package/dist/types/src/wallet/WERR_REVIEW_ACTIONS.d.ts +23 -0
  37. package/dist/types/src/wallet/WERR_REVIEW_ACTIONS.d.ts.map +1 -0
  38. package/dist/types/src/wallet/Wallet.interfaces.d.ts +22 -0
  39. package/dist/types/src/wallet/Wallet.interfaces.d.ts.map +1 -1
  40. package/dist/types/src/wallet/WalletError.d.ts +4 -3
  41. package/dist/types/src/wallet/WalletError.d.ts.map +1 -1
  42. package/dist/types/src/wallet/index.d.ts +1 -0
  43. package/dist/types/src/wallet/index.d.ts.map +1 -1
  44. package/dist/types/src/wallet/substrates/HTTPWalletJSON.d.ts.map +1 -1
  45. package/dist/types/tsconfig.types.tsbuildinfo +1 -1
  46. package/dist/umd/bundle.js +1 -1
  47. package/docs/kvstore.md +9 -8
  48. package/docs/storage.md +117 -7
  49. package/docs/wallet.md +146 -38
  50. package/package.json +1 -1
  51. package/src/kvstore/LocalKVStore.ts +156 -151
  52. package/src/kvstore/__tests/LocalKVStore.test.ts +104 -193
  53. package/src/storage/StorageUploader.ts +156 -14
  54. package/src/storage/__test/StorageUploader.test.ts +134 -15
  55. package/src/wallet/WERR_REVIEW_ACTIONS.ts +30 -0
  56. package/src/wallet/Wallet.interfaces.ts +24 -0
  57. package/src/wallet/WalletError.ts +4 -2
  58. package/src/wallet/index.ts +2 -0
  59. package/src/wallet/substrates/HTTPWalletJSON.ts +12 -6
@@ -1,8 +1,8 @@
1
- import LockingScript from '../script/LockingScript.js';
2
1
  import PushDrop from '../script/templates/PushDrop.js';
3
2
  import * as Utils from '../primitives/utils.js';
4
3
  import WalletClient from '../wallet/WalletClient.js';
5
4
  import Transaction from '../transaction/Transaction.js';
5
+ import { Beef } from '../transaction/Beef.js';
6
6
  /**
7
7
  * Implements a key-value storage system backed by transaction outputs managed by a wallet.
8
8
  * Each key-value pair is represented by a PushDrop token output in a specific context (basket).
@@ -37,12 +37,12 @@ export default class LocalKVStore {
37
37
  * Creates an instance of the localKVStore.
38
38
  *
39
39
  * @param {WalletInterface} [wallet=new WalletClient()] - The wallet interface to use. Defaults to a new WalletClient instance.
40
- * @param {string} [context='kvstore-default'] - The context (basket) for namespacing keys. Defaults to 'kvstore-default'.
40
+ * @param {string} [context='kvstoredefault'] - The context (basket) for namespacing keys. Defaults to 'kvstore default'.
41
41
  * @param {boolean} [encrypt=true] - Whether to encrypt values. Defaults to true.
42
42
  * @param {string} [originator] — An originator to use with PushDrop and the wallet, if provided.
43
43
  * @throws {Error} If the context is missing or empty.
44
44
  */
45
- constructor(wallet = new WalletClient(), context = 'kvstore-default', encrypt = true, originator) {
45
+ constructor(wallet = new WalletClient(), context = 'kvstore default', encrypt = true, originator) {
46
46
  if (typeof context !== 'string' || context.length < 1) {
47
47
  throw new Error('A context in which to operate is required.');
48
48
  }
@@ -51,6 +51,19 @@ export default class LocalKVStore {
51
51
  this.encrypt = encrypt;
52
52
  this.originator = originator;
53
53
  }
54
+ getProtocol(key) {
55
+ return { protocolID: [2, this.context], keyID: key };
56
+ }
57
+ async getOutputs(key, limit) {
58
+ const results = await this.wallet.listOutputs({
59
+ basket: this.context,
60
+ tags: [key],
61
+ tagQueryMode: 'all',
62
+ include: 'entire transactions',
63
+ limit
64
+ });
65
+ return results;
66
+ }
54
67
  /**
55
68
  * Retrieves the value associated with a given key.
56
69
  *
@@ -58,46 +71,81 @@ export default class LocalKVStore {
58
71
  * @param {string | undefined} [defaultValue=undefined] - The value to return if the key is not found.
59
72
  * @returns {Promise<string | undefined>} A promise that resolves to the value as a string,
60
73
  * the defaultValue if the key is not found, or undefined if no defaultValue is provided.
61
- * @throws {Error} If multiple outputs are found for the key (ambiguous state).
74
+ * @throws {Error} If too many outputs are found for the key (ambiguous state).
62
75
  * @throws {Error} If the found output's locking script cannot be decoded or represents an invalid token format.
63
76
  */
64
77
  async get(key, defaultValue = undefined) {
65
- const results = await this.wallet.listOutputs({
66
- basket: this.context,
67
- tags: [key],
68
- include: 'locking scripts'
69
- });
70
- if (results.outputs.length === 0) {
71
- return defaultValue;
78
+ const r = await this.lookupValue(key, defaultValue, 5);
79
+ return r.value;
80
+ }
81
+ getLockingScript(output, beef) {
82
+ const [txid, vout] = output.outpoint.split('.');
83
+ const tx = beef.findTxid(txid)?.tx;
84
+ if (tx == null) {
85
+ throw new Error(`beef must contain txid ${txid}`);
72
86
  }
73
- else if (results.outputs.length > 1) {
74
- throw new Error('Multiple tokens found for this key. You need to call set to collapse this ambiguous state before you can get this value again.');
87
+ const lockingScript = tx.outputs[Number(vout)].lockingScript;
88
+ return lockingScript;
89
+ }
90
+ async lookupValue(key, defaultValue, limit) {
91
+ const lor = await this.getOutputs(key, limit);
92
+ const r = { value: defaultValue, outpoint: undefined, lor };
93
+ const { outputs } = lor;
94
+ if (outputs.length === 0) {
95
+ return r;
75
96
  }
76
- let fields;
97
+ const output = outputs.slice(-1)[0];
98
+ r.outpoint = output.outpoint;
99
+ let field;
77
100
  try {
78
- if (typeof results.outputs[0].lockingScript !== 'string') {
79
- throw new Error('No locking script');
101
+ if (lor.BEEF === undefined) {
102
+ throw new Error('entire transactions listOutputs option must return valid BEEF');
80
103
  }
81
- const decoded = PushDrop.decode(LockingScript.fromHex(results.outputs[0].lockingScript));
82
- if (decoded.fields.length !== 1) {
104
+ const lockingScript = this.getLockingScript(output, Beef.fromBinary(lor.BEEF));
105
+ const decoded = PushDrop.decode(lockingScript);
106
+ if (decoded.fields.length < 1 || decoded.fields.length > 2) {
83
107
  throw new Error('Invalid token.');
84
108
  }
85
- fields = decoded.fields;
109
+ field = decoded.fields[0];
86
110
  }
87
111
  catch (_) {
88
- throw new Error(`Invalid value found. You need to call set to collapse the corrupted state (or relinquish the corrupted ${results.outputs[0].outpoint} output from the ${this.context} basket) before you can get this value again.`);
112
+ throw new Error(`Invalid value found. You need to call set to collapse the corrupted state (or relinquish the corrupted ${outputs[0].outpoint} output from the ${this.context} basket) before you can get this value again.`);
89
113
  }
90
114
  if (!this.encrypt) {
91
- return Utils.toUTF8(fields[0]);
115
+ r.value = Utils.toUTF8(field);
92
116
  }
93
117
  else {
94
118
  const { plaintext } = await this.wallet.decrypt({
95
- protocolID: [2, this.context],
96
- keyID: key,
97
- ciphertext: fields[0]
119
+ ...this.getProtocol(key),
120
+ ciphertext: field
121
+ });
122
+ r.value = Utils.toUTF8(plaintext);
123
+ }
124
+ return r;
125
+ }
126
+ getInputs(outputs) {
127
+ const inputs = [];
128
+ for (let i = 0; i < outputs.length; i++) {
129
+ inputs.push({
130
+ outpoint: outputs[i].outpoint,
131
+ unlockingScriptLength: 74,
132
+ inputDescription: 'Previous key-value token'
98
133
  });
99
- return Utils.toUTF8(plaintext);
100
134
  }
135
+ return inputs;
136
+ }
137
+ async getSpends(key, outputs, pushdrop, atomicBEEF) {
138
+ const p = this.getProtocol(key);
139
+ const tx = Transaction.fromAtomicBEEF(atomicBEEF);
140
+ const spends = {};
141
+ for (let i = 0; i < outputs.length; i++) {
142
+ const unlocker = pushdrop.unlock(p.protocolID, p.keyID, 'self');
143
+ const unlockingScript = await unlocker.sign(tx, i);
144
+ spends[i] = {
145
+ unlockingScript: unlockingScript.toHex()
146
+ };
147
+ }
148
+ return spends;
101
149
  }
102
150
  /**
103
151
  * Sets or updates the value associated with a given key.
@@ -113,87 +161,64 @@ export default class LocalKVStore {
113
161
  * @returns {Promise<OutpointString>} A promise that resolves to the outpoint string (txid.vout) of the new or updated token output.
114
162
  */
115
163
  async set(key, value) {
164
+ const current = await this.lookupValue(key, undefined, 10);
165
+ if (current.value === value) {
166
+ if (current.outpoint === undefined) {
167
+ throw new Error('outpoint must be valid when value is valid and unchanged');
168
+ }
169
+ // Don't create a new transaction if the value doesn't need to change...
170
+ return current.outpoint;
171
+ }
172
+ const protocol = this.getProtocol(key);
116
173
  let valueAsArray = Utils.toArray(value, 'utf8');
117
174
  if (this.encrypt) {
118
175
  const { ciphertext } = await this.wallet.encrypt({
119
- plaintext: valueAsArray,
120
- protocolID: [2, this.context],
121
- keyID: key
176
+ ...protocol,
177
+ plaintext: valueAsArray
122
178
  });
123
179
  valueAsArray = ciphertext;
124
180
  }
125
181
  const pushdrop = new PushDrop(this.wallet, this.originator);
126
- const lockingScript = await pushdrop.lock([valueAsArray], [2, this.context], key, 'self');
127
- const results = await this.wallet.listOutputs({
128
- basket: this.context,
129
- tags: [key],
130
- include: 'entire transactions'
131
- });
132
- if (results.totalOutputs !== 0) {
133
- try {
134
- const inputs = [];
135
- for (let i = 0; i < results.outputs.length; i++) {
136
- inputs.push({
137
- outpoint: results.outputs[i].outpoint,
138
- unlockingScriptLength: 74,
139
- inputDescription: 'Previous key-value token'
140
- });
141
- }
142
- const { signableTransaction } = await this.wallet.createAction({
143
- description: `Update ${key} in ${this.context}`,
144
- inputBEEF: results.BEEF,
145
- inputs,
146
- outputs: [{
147
- lockingScript: lockingScript.toHex(),
148
- satoshis: 1,
149
- outputDescription: 'Key-value token'
150
- }],
151
- options: {
152
- acceptDelayedBroadcast: false,
153
- randomizeOutputs: false
154
- }
155
- });
156
- if (typeof signableTransaction !== 'object') {
157
- throw new Error('Wallet did not return a signable transaction when expected.');
158
- }
159
- const tx = Transaction.fromAtomicBEEF(signableTransaction.tx);
160
- const spends = {};
161
- for (let i = 0; i < results.outputs.length; i++) {
162
- const unlocker = pushdrop.unlock([2, this.context], key, 'self');
163
- const unlockingScript = await unlocker.sign(tx, i);
164
- spends[i] = {
165
- unlockingScript: unlockingScript.toHex()
166
- };
182
+ const lockingScript = await pushdrop.lock([valueAsArray], protocol.protocolID, protocol.keyID, 'self');
183
+ const { outputs, BEEF: inputBEEF } = current.lor;
184
+ let outpoint;
185
+ try {
186
+ const inputs = this.getInputs(outputs);
187
+ const { txid, signableTransaction } = await this.wallet.createAction({
188
+ description: `Update ${key} in ${this.context}`,
189
+ inputBEEF,
190
+ inputs,
191
+ outputs: [{
192
+ basket: this.context,
193
+ tags: [key],
194
+ lockingScript: lockingScript.toHex(),
195
+ satoshis: 1,
196
+ outputDescription: 'Key-value token'
197
+ }],
198
+ options: {
199
+ acceptDelayedBroadcast: false,
200
+ randomizeOutputs: false
167
201
  }
202
+ });
203
+ if (outputs.length > 0 && typeof signableTransaction !== 'object') {
204
+ throw new Error('Wallet did not return a signable transaction when expected.');
205
+ }
206
+ if (signableTransaction == null) {
207
+ outpoint = `${txid}.0`;
208
+ }
209
+ else {
210
+ const spends = await this.getSpends(key, outputs, pushdrop, signableTransaction.tx);
168
211
  const { txid } = await this.wallet.signAction({
169
212
  reference: signableTransaction.reference,
170
213
  spends
171
214
  });
172
- return `${txid}.0`;
173
- }
174
- catch (_) {
175
- // Signing failed, relinquish original outputs
176
- for (let i = 0; i < results.outputs.length; i++) {
177
- await this.wallet.relinquishOutput({
178
- output: results.outputs[i].outpoint,
179
- basket: this.context
180
- });
181
- }
215
+ outpoint = `${txid}.0`;
182
216
  }
183
217
  }
184
- const { txid } = await this.wallet.createAction({
185
- description: `Set ${key} in ${this.context}`,
186
- outputs: [{
187
- lockingScript: lockingScript.toHex(),
188
- satoshis: 1,
189
- outputDescription: 'Key-value token'
190
- }],
191
- options: {
192
- acceptDelayedBroadcast: false,
193
- randomizeOutputs: false
194
- }
195
- });
196
- return `${txid}.0`;
218
+ catch (_) {
219
+ throw new Error(`There are ${outputs.length} outputs with tag ${key} that cannot be unlocked.`);
220
+ }
221
+ return outpoint;
197
222
  }
198
223
  /**
199
224
  * Removes the key-value pair associated with the given key.
@@ -203,61 +228,46 @@ export default class LocalKVStore {
203
228
  * If signing the removal transaction fails, it relinquishes the original outputs instead of spending.
204
229
  *
205
230
  * @param {string} key - The key to remove.
206
- * @returns {Promise<string | void>} A promise that resolves to the txid of the removal transaction if successful.
231
+ * @returns {Promise<string[]>} A promise that resolves to the txids of the removal transactions if successful.
207
232
  */
208
233
  async remove(key) {
209
- const results = await this.wallet.listOutputs({
210
- basket: this.context,
211
- tags: [key],
212
- include: 'entire transactions'
213
- });
214
- if (results.totalOutputs === 0) {
215
- return; // Key not found, do nothing
216
- }
217
- const pushdrop = new PushDrop(this.wallet, this.originator);
218
- try {
219
- const inputs = [];
220
- for (let i = 0; i < results.outputs.length; i++) {
221
- inputs.push({
222
- outpoint: results.outputs[i].outpoint,
223
- unlockingScriptLength: 74,
224
- inputDescription: 'Previous key-value token'
225
- });
226
- }
227
- const { signableTransaction } = await this.wallet.createAction({
228
- description: `Remove ${key} in ${this.context}`,
229
- inputBEEF: results.BEEF,
230
- inputs,
231
- options: {
232
- acceptDelayedBroadcast: false
234
+ const txids = [];
235
+ for (;;) {
236
+ const { outputs, BEEF: inputBEEF, totalOutputs } = await this.getOutputs(key);
237
+ if (outputs.length > 0) {
238
+ const pushdrop = new PushDrop(this.wallet, this.originator);
239
+ try {
240
+ const inputs = this.getInputs(outputs);
241
+ const { signableTransaction } = await this.wallet.createAction({
242
+ description: `Remove ${key} in ${this.context}`,
243
+ inputBEEF,
244
+ inputs,
245
+ options: {
246
+ acceptDelayedBroadcast: false
247
+ }
248
+ });
249
+ if (typeof signableTransaction !== 'object') {
250
+ throw new Error('Wallet did not return a signable transaction when expected.');
251
+ }
252
+ const spends = await this.getSpends(key, outputs, pushdrop, signableTransaction.tx);
253
+ const { txid } = await this.wallet.signAction({
254
+ reference: signableTransaction.reference,
255
+ spends
256
+ });
257
+ if (txid === undefined) {
258
+ throw new Error('signAction must return a valid txid');
259
+ }
260
+ txids.push(txid);
261
+ }
262
+ catch (_) {
263
+ throw new Error(`There are ${totalOutputs} outputs with tag ${key} that cannot be unlocked.`);
233
264
  }
234
- });
235
- if (typeof signableTransaction !== 'object') {
236
- throw new Error('Wallet did not return a signable transaction when expected.');
237
- }
238
- const tx = Transaction.fromAtomicBEEF(signableTransaction.tx);
239
- const spends = {};
240
- for (let i = 0; i < results.outputs.length; i++) {
241
- const unlocker = pushdrop.unlock([2, this.context], key, 'self');
242
- const unlockingScript = await unlocker.sign(tx, i);
243
- spends[i] = {
244
- unlockingScript: unlockingScript.toHex()
245
- };
246
265
  }
247
- const { txid } = await this.wallet.signAction({
248
- reference: signableTransaction.reference,
249
- spends
250
- });
251
- return txid;
252
- }
253
- catch (_) {
254
- for (let i = 0; i < results.outputs.length; i++) {
255
- await this.wallet.relinquishOutput({
256
- output: results.outputs[i].outpoint,
257
- basket: this.context
258
- });
266
+ if (outputs.length === totalOutputs) {
267
+ break;
259
268
  }
260
269
  }
270
+ return txids;
261
271
  }
262
272
  }
263
273
  //# sourceMappingURL=LocalKVStore.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocalKVStore.js","sourceRoot":"","sources":["../../../../src/kvstore/LocalKVStore.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,4BAA4B,CAAA;AACtD,OAAO,QAAQ,MAAM,iCAAiC,CAAA;AACtD,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAA;AAE/C,OAAO,YAAY,MAAM,2BAA2B,CAAA;AACpD,OAAO,WAAW,MAAM,+BAA+B,CAAA;AAEvD;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B;;;;OAIG;IACc,MAAM,CAAiB;IACxC;;;;OAIG;IACc,OAAO,CAAQ;IAChC;;;;OAIG;IACc,OAAO,CAAS;IAEjC;;;;OAIG;IACc,UAAU,CAAS;IAEpC;;;;;;;;OAQG;IACH,YACE,SAA0B,IAAI,YAAY,EAAE,EAC5C,OAAO,GAAG,iBAAiB,EAC3B,OAAO,GAAG,IAAI,EACd,UAAmB;QAEnB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM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,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;oBACtC,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC;wBAC7D,WAAW,EAAE,UAAU,GAAG,OAAO,IAAI,CAAC,OAAO,EAAE;wBAC/C,SAAS;wBACT,MAAM;wBACN,OAAO,EAAE;4BACP,sBAAsB,EAAE,KAAK;yBAC9B;qBACF,CAAC,CAAA;oBACF,IAAI,OAAO,mBAAmB,KAAK,QAAQ,EAAE;wBAC3C,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAA;qBAC/E;oBACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,CAAC,EAAE,CAAC,CAAA;oBACnF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;wBAC5C,SAAS,EAAE,mBAAmB,CAAC,SAAS;wBACxC,MAAM;qBACP,CAAC,CAAA;oBACF,IAAI,IAAI,KAAK,SAAS,EAAE;wBAAE,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAA;qBAAE;oBAClF,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;iBACjB;gBAAC,OAAO,CAAC,EAAE;oBACV,MAAM,IAAI,KAAK,CAAC,aAAa,YAAY,qBAAqB,GAAG,2BAA2B,CAAC,CAAA;iBAC9F;aACF;YACD,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,EAAE;gBAAE,MAAK;aAAE;SAC/C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
@@ -1,12 +1,31 @@
1
1
  import { AuthFetch } from '../auth/clients/AuthFetch.js';
2
2
  import * as StorageUtils from './StorageUtils.js';
3
+ /**
4
+ * The StorageUploader class provides client-side methods for:
5
+ * - Uploading files with a specified retention period
6
+ * - Finding file metadata by UHRP URL
7
+ * - Listing all user uploads
8
+ * - Renewing an existing advertisement's expiry time
9
+ */
3
10
  export class StorageUploader {
4
11
  authFetch;
5
12
  baseURL;
13
+ /**
14
+ * Creates a new StorageUploader instance.
15
+ * @param {UploaderConfig} config - An object containing the storage server's URL and a wallet interface
16
+ */
6
17
  constructor(config) {
7
18
  this.baseURL = config.storageURL;
8
19
  this.authFetch = new AuthFetch(config.wallet);
9
20
  }
21
+ /**
22
+ * Requests information from the server to upload a file (including presigned URL and headers).
23
+ * @private
24
+ * @param {number} fileSize - The size of the file, in bytes
25
+ * @param {number} retentionPeriod - The desired hosting time, in minutes
26
+ * @returns {Promise<{ uploadURL: string; requiredHeaders: Record<string, string>; amount?: number }>}
27
+ * @throws {Error} If the server returns a non-OK response or an error status
28
+ */
10
29
  async getUploadInfo(fileSize, retentionPeriod) {
11
30
  const url = `${this.baseURL}/upload`;
12
31
  const body = { fileSize, retentionPeriod };
@@ -28,6 +47,15 @@ export class StorageUploader {
28
47
  amount: data.amount
29
48
  };
30
49
  }
50
+ /**
51
+ * Performs the actual file upload (HTTP PUT) to the presigned URL returned by the server.
52
+ * @private
53
+ * @param {string} uploadURL - The presigned URL where the file is to be uploaded
54
+ * @param {UploadableFile} file - The file to upload, including its raw data and MIME type
55
+ * @param {Record<string, string>} requiredHeaders - Additional headers required by the server (e.g. content-length)
56
+ * @returns {Promise<UploadFileResult>} An object indicating whether publishing was successful and the resulting UHRP URL
57
+ * @throws {Error} If the server returns a non-OK response
58
+ */
31
59
  async uploadFile(uploadURL, file, requiredHeaders) {
32
60
  const body = Uint8Array.from(file.data);
33
61
  const response = await fetch(uploadURL, {
@@ -48,25 +76,102 @@ export class StorageUploader {
48
76
  };
49
77
  }
50
78
  /**
51
- * Publishes a file to the storage server with the specified retention period.
52
- *
53
- * This will:
54
- * 1. Request an upload URL from the server.
55
- * 2. Perform an HTTP PUT to upload the file’s raw bytes.
56
- * 3. Return a UHRP URL referencing the file once published.
57
- *
58
- * @param params.file - An object describing the file’s data (number[] array of bytes) and mime type.
59
- * @param params.retentionPeriod - Number of minutes to keep the file hosted.
60
- *
61
- * @returns An object indicating whether the file was published successfully and the resulting UHRP URL.
62
- *
63
- * @throws If either the upload info request or the subsequent file upload request fails (non-OK HTTP status).
64
- */
79
+ * Publishes a file to the storage server with the specified retention period.
80
+ *
81
+ * This will:
82
+ * 1. Request an upload URL from the server.
83
+ * 2. Perform an HTTP PUT to upload the file’s raw bytes.
84
+ * 3. Return a UHRP URL referencing the file once published.
85
+ *
86
+ * @param {Object} params
87
+ * @param {UploadableFile} params.file - The file data + type
88
+ * @param {number} params.retentionPeriod - Number of minutes to host the file
89
+ * @returns {Promise<UploadFileResult>} An object with the file's UHRP URL
90
+ * @throws {Error} If the server or upload step returns a non-OK response
91
+ */
65
92
  async publishFile(params) {
66
93
  const { file, retentionPeriod } = params;
67
94
  const fileSize = file.data.length;
68
95
  const { uploadURL, requiredHeaders } = await this.getUploadInfo(fileSize, retentionPeriod);
69
96
  return await this.uploadFile(uploadURL, file, requiredHeaders);
70
97
  }
98
+ /**
99
+ * Retrieves metadata for a file matching the given UHRP URL from the `/find` route.
100
+ * @param {string} uhrpUrl - The UHRP URL, e.g. "uhrp://abcd..."
101
+ * @returns {Promise<FindFileData>} An object with file name, size, MIME type, and expiry time
102
+ * @throws {Error} If the server or the route returns an error
103
+ */
104
+ async findFile(uhrpUrl) {
105
+ const url = new URL(`${this.baseURL}/find`);
106
+ url.searchParams.set('uhrpUrl', uhrpUrl);
107
+ const response = await this.authFetch.fetch(url.toString(), {
108
+ method: 'GET'
109
+ });
110
+ if (!response.ok) {
111
+ throw new Error(`findFile request failed: HTTP ${response.status}`);
112
+ }
113
+ const data = await response.json();
114
+ if (data.status === 'error') {
115
+ const errCode = data.code ?? 'unknown-code';
116
+ const errDesc = data.description ?? 'no-description';
117
+ throw new Error(`findFile returned an error: ${errCode} - ${errDesc}`);
118
+ }
119
+ return data.data;
120
+ }
121
+ /**
122
+ * Lists all advertisements belonging to the user from the `/list` route.
123
+ * @returns {Promise<any>} The array of uploads returned by the server
124
+ * @throws {Error} If the server or the route returns an error
125
+ */
126
+ async listUploads() {
127
+ const url = `${this.baseURL}/list`;
128
+ const response = await this.authFetch.fetch(url, {
129
+ method: 'GET'
130
+ });
131
+ if (!response.ok) {
132
+ throw new Error(`listUploads request failed: HTTP ${response.status}`);
133
+ }
134
+ const data = await response.json();
135
+ if (data.status === 'error') {
136
+ const errCode = data.code ?? 'unknown-code';
137
+ const errDesc = data.description ?? 'no-description';
138
+ throw new Error(`listUploads returned an error: ${errCode} - ${errDesc}`);
139
+ }
140
+ return data.uploads;
141
+ }
142
+ /**
143
+ * Renews the hosting time for an existing file advertisement identified by uhrpUrl.
144
+ * Calls the `/renew` route to add `additionalMinutes` to the GCS customTime
145
+ * and re-mint the advertisement token on-chain.
146
+ *
147
+ * @param {string} uhrpUrl - The UHRP URL of the file (e.g., "uhrp://abcd1234...")
148
+ * @param {number} additionalMinutes - The number of minutes to extend
149
+ * @returns {Promise<RenewFileResult>} An object with the new and previous expiry times, plus any cost
150
+ * @throws {Error} If the request fails or the server returns an error
151
+ */
152
+ async renewFile(uhrpUrl, additionalMinutes) {
153
+ const url = `${this.baseURL}/renew`;
154
+ const body = { uhrpUrl, additionalMinutes };
155
+ const response = await this.authFetch.fetch(url, {
156
+ method: 'POST',
157
+ headers: { 'Content-Type': 'application/json' },
158
+ body: JSON.stringify(body)
159
+ });
160
+ if (!response.ok) {
161
+ throw new Error(`renewFile request failed: HTTP ${response.status}`);
162
+ }
163
+ const data = await response.json();
164
+ if (data.status === 'error') {
165
+ const errCode = data.code ?? 'unknown-code';
166
+ const errDesc = data.description ?? 'no-description';
167
+ throw new Error(`renewFile returned an error: ${errCode} - ${errDesc}`);
168
+ }
169
+ return {
170
+ status: data.status,
171
+ prevExpiryTime: data.prevExpiryTime,
172
+ newExpiryTime: data.newExpiryTime,
173
+ amount: data.amount
174
+ };
175
+ }
71
176
  }
72
177
  //# sourceMappingURL=StorageUploader.js.map
@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