@ardrive/turbo-sdk 1.43.0 → 1.44.0-alpha.2
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.
- package/lib/cjs/common/chunked.js +10 -1
- package/lib/cjs/common/http.js +24 -0
- package/lib/cjs/common/payment.js +8 -1
- package/lib/cjs/common/turbo.js +28 -0
- package/lib/cjs/common/upload.js +295 -23
- package/lib/esm/common/chunked.js +10 -1
- package/lib/esm/common/http.js +24 -0
- package/lib/esm/common/payment.js +8 -1
- package/lib/esm/common/turbo.js +28 -0
- package/lib/esm/common/upload.js +295 -23
- package/lib/types/common/chunked.d.ts +25 -8
- package/lib/types/common/chunked.d.ts.map +1 -1
- package/lib/types/common/http.d.ts +8 -0
- package/lib/types/common/http.d.ts.map +1 -1
- package/lib/types/common/payment.d.ts +2 -9
- package/lib/types/common/payment.d.ts.map +1 -1
- package/lib/types/common/turbo.d.ts +22 -9
- package/lib/types/common/turbo.d.ts.map +1 -1
- package/lib/types/common/upload.d.ts +55 -1
- package/lib/types/common/upload.d.ts.map +1 -1
- package/lib/types/types.d.ts +143 -8
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +2 -1
package/lib/esm/common/turbo.js
CHANGED
|
@@ -190,6 +190,20 @@ export class TurboUnauthenticatedClient {
|
|
|
190
190
|
maxMUSDCAmount,
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Price a signed data item for an x402 upload without sending it. See
|
|
195
|
+
* `TurboUnauthenticatedUploadService.getX402PriceForDataItem`.
|
|
196
|
+
*/
|
|
197
|
+
getX402PriceForDataItem(p) {
|
|
198
|
+
return this.uploadService.getX402PriceForDataItem(p);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Price raw data for an x402 upload, including the data-item wrapping
|
|
202
|
+
* overhead. See `TurboUnauthenticatedUploadService.getX402PriceForRawData`.
|
|
203
|
+
*/
|
|
204
|
+
getX402PriceForRawData(p) {
|
|
205
|
+
return this.uploadService.getX402PriceForRawData(p);
|
|
206
|
+
}
|
|
193
207
|
}
|
|
194
208
|
export class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
|
|
195
209
|
constructor({ paymentService, uploadService, signer, }) {
|
|
@@ -377,4 +391,18 @@ export class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
|
|
|
377
391
|
maxMUSDCAmount,
|
|
378
392
|
});
|
|
379
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* Price a signed data item for an x402 upload without sending it. See
|
|
396
|
+
* `TurboUnauthenticatedUploadService.getX402PriceForDataItem`.
|
|
397
|
+
*/
|
|
398
|
+
getX402PriceForDataItem(p) {
|
|
399
|
+
return this.uploadService.getX402PriceForDataItem(p);
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Price raw data for an x402 upload, including the data-item wrapping
|
|
403
|
+
* overhead. See `TurboUnauthenticatedUploadService.getX402PriceForRawData`.
|
|
404
|
+
*/
|
|
405
|
+
getX402PriceForRawData(p) {
|
|
406
|
+
return this.uploadService.getX402PriceForRawData(p);
|
|
407
|
+
}
|
|
380
408
|
}
|
package/lib/esm/common/upload.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { BigNumber } from 'bignumber.js';
|
|
17
|
+
import { Readable } from 'node:stream';
|
|
17
18
|
import { pLimit } from 'plimit-lit';
|
|
18
19
|
import { ExistingBalanceFunding, OnDemandFunding, X402Funding, } from '../types.js';
|
|
19
20
|
import { isBlob, isValidArweaveBase64URL, sleep } from '../utils/common.js';
|
|
@@ -77,6 +78,29 @@ export class TurboUnauthenticatedUploadService {
|
|
|
77
78
|
headers['x-paid-by'] = paidBy;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
81
|
+
if (x402Options !== undefined) {
|
|
82
|
+
/*
|
|
83
|
+
x402 needs a body fetch can measure, and one it can send twice.
|
|
84
|
+
|
|
85
|
+
`content-length` is a forbidden header, so setting it above does
|
|
86
|
+
nothing: a streamed body goes out chunked with no length. The service
|
|
87
|
+
prices from that header, so without it there is no 402 challenge — and
|
|
88
|
+
the protocol's paid retry has a spent stream to replay, which fails
|
|
89
|
+
outright. Buffering fixes both: the length is declared honestly and the
|
|
90
|
+
body can be re-sent.
|
|
91
|
+
|
|
92
|
+
Bounded by the chunking decision above — anything over two chunks took
|
|
93
|
+
the chunked path, which pays at create and never reaches here.
|
|
94
|
+
*/
|
|
95
|
+
const body = await streamToBuffer(streamWithUploadEvents, dataItemSize, resume, signal);
|
|
96
|
+
return this.httpService.post({
|
|
97
|
+
endpoint: `/tx/${this.token}`,
|
|
98
|
+
signal,
|
|
99
|
+
data: body,
|
|
100
|
+
headers,
|
|
101
|
+
x402Options,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
80
104
|
// setup the post request using the stream with upload events
|
|
81
105
|
const postPromise = this.httpService.post({
|
|
82
106
|
endpoint: `/tx/${this.token}`,
|
|
@@ -89,6 +113,46 @@ export class TurboUnauthenticatedUploadService {
|
|
|
89
113
|
resume();
|
|
90
114
|
return postPromise;
|
|
91
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Price a SIGNED data item for an x402 upload, without sending it.
|
|
118
|
+
*
|
|
119
|
+
* The only other way to learn an x402 price is to POST the payload and read
|
|
120
|
+
* the 402 challenge, which means transmitting it to find out what it costs.
|
|
121
|
+
*
|
|
122
|
+
* `byteCount` is the size of the signed data item — what
|
|
123
|
+
* `dataItemSizeFactory()` returns — not the payload inside it. Use
|
|
124
|
+
* `getX402PriceForRawData` when the service does the wrapping.
|
|
125
|
+
*
|
|
126
|
+
* `network` names the x402 network, not the SDK token: the route builds its
|
|
127
|
+
* token as `usdc-{network}`. `base-usdc` is accepted on mainnet only because
|
|
128
|
+
* the network there is literally `base`, so a testnet caller must pass
|
|
129
|
+
* `base-sepolia` explicitly.
|
|
130
|
+
*/
|
|
131
|
+
async getX402PriceForDataItem({ byteCount, network = 'base', }) {
|
|
132
|
+
return this.httpService.get({
|
|
133
|
+
endpoint: `/price/x402/data-item/usdc-${network}/${byteCount}`,
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Price RAW data for an x402 upload, where the service wraps it into a data
|
|
138
|
+
* item itself.
|
|
139
|
+
*
|
|
140
|
+
* Also reports the wrapping overhead — a data item is larger than its
|
|
141
|
+
* payload by its header, signature and tags — which the caller has no way to
|
|
142
|
+
* compute. `tagCount` and `contentType` feed that estimate, so pass what the
|
|
143
|
+
* upload will actually carry or the quote will read low.
|
|
144
|
+
*/
|
|
145
|
+
async getX402PriceForRawData({ byteCount, network = 'base', tagCount, contentType, }) {
|
|
146
|
+
const query = new URLSearchParams();
|
|
147
|
+
if (tagCount !== undefined)
|
|
148
|
+
query.set('tags', `${tagCount}`);
|
|
149
|
+
if (contentType !== undefined)
|
|
150
|
+
query.set('contentType', contentType);
|
|
151
|
+
const qs = query.toString();
|
|
152
|
+
return this.httpService.get({
|
|
153
|
+
endpoint: `/price/x402/data/usdc-${network}/${byteCount}${qs ? `?${qs}` : ''}`,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
92
156
|
async uploadRawX402Data({ data, tags, signal, maxMUSDCAmount, signer, }) {
|
|
93
157
|
if (!this.x402EnabledTokens.includes(this.token)) {
|
|
94
158
|
throw new Error('x402 uploads are not supported for token: ' + this.token);
|
|
@@ -222,8 +286,30 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
222
286
|
!this.x402EnabledTokens.includes(this.token)) {
|
|
223
287
|
throw new Error('x402 uploads are not supported for token: ' + this.token);
|
|
224
288
|
}
|
|
289
|
+
/*
|
|
290
|
+
Buffering the single request is only safe because anything larger chunks.
|
|
291
|
+
`chunkingMode: 'disabled'` removes that guarantee, so an arbitrarily large
|
|
292
|
+
item would be pulled into memory — and the service caps single-request
|
|
293
|
+
items anyway, so it would be refused after the fact. Check before signing:
|
|
294
|
+
signing a large item only to reject it wastes the expensive part.
|
|
295
|
+
*/
|
|
296
|
+
if (fundingMode instanceof X402Funding &&
|
|
297
|
+
params.chunkingMode === 'disabled' &&
|
|
298
|
+
fileSizeFactory() + x402SignedItemOverheadByteCount >
|
|
299
|
+
maxX402SingleRequestByteCount) {
|
|
300
|
+
throw new Error(`An x402 upload of ${fileSizeFactory()} bytes must be chunked: the ` +
|
|
301
|
+
`single-request path buffers the SIGNED item in memory and is ` +
|
|
302
|
+
`limited to ${maxX402SingleRequestByteCount} bytes, of which ` +
|
|
303
|
+
`signing claims about ${x402SignedItemOverheadByteCount}. Remove ` +
|
|
304
|
+
`chunkingMode: 'disabled' to upload this item.`);
|
|
305
|
+
}
|
|
225
306
|
this.logger.debug('Starting file upload', { params });
|
|
226
307
|
let retries = 0;
|
|
308
|
+
// Carried ACROSS retry attempts. A paid chunked upload is bought before any
|
|
309
|
+
// chunk is accepted, so an attempt that fails after paying must hand its
|
|
310
|
+
// upload id to the next attempt. Rebuilding the uploader with no id is how
|
|
311
|
+
// a single upload gets billed once per retry.
|
|
312
|
+
let paidUploadId;
|
|
227
313
|
const maxRetries = this.retryConfig.retries ?? 3;
|
|
228
314
|
const retryDelay = this.retryConfig.retryDelay ??
|
|
229
315
|
((retryNumber) => retryNumber * 1000);
|
|
@@ -246,9 +332,8 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
246
332
|
});
|
|
247
333
|
if (fundingMode instanceof OnDemandFunding &&
|
|
248
334
|
cryptoFundResult === undefined) {
|
|
249
|
-
const totalByteCount = dataItemSizeFactory();
|
|
250
335
|
cryptoFundResult = await this.onDemand({
|
|
251
|
-
|
|
336
|
+
itemByteCounts: [dataItemSizeFactory()],
|
|
252
337
|
onDemandFunding: fundingMode,
|
|
253
338
|
});
|
|
254
339
|
}
|
|
@@ -279,6 +364,7 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
279
364
|
dataItemByteCount: dataItemSizeFactory(),
|
|
280
365
|
chunkingMode: params.chunkingMode,
|
|
281
366
|
maxFinalizeMs: params.maxFinalizeMs,
|
|
367
|
+
paidUploadId,
|
|
282
368
|
...(x402Options ? { x402: x402Options } : {}),
|
|
283
369
|
...(x402Options
|
|
284
370
|
? {
|
|
@@ -290,14 +376,21 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
290
376
|
: {}),
|
|
291
377
|
});
|
|
292
378
|
if (chunkedUploader.shouldUseChunkUploader) {
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
379
|
+
try {
|
|
380
|
+
const response = await chunkedUploader.upload({
|
|
381
|
+
dataItemStreamFactory,
|
|
382
|
+
dataItemSizeFactory,
|
|
383
|
+
dataItemOpts,
|
|
384
|
+
signal,
|
|
385
|
+
events,
|
|
386
|
+
});
|
|
387
|
+
return { ...response, cryptoFundResult };
|
|
388
|
+
}
|
|
389
|
+
finally {
|
|
390
|
+
// Read on the way out, success or failure. On failure this is the
|
|
391
|
+
// whole point: the next attempt resumes what this one paid for.
|
|
392
|
+
paidUploadId = chunkedUploader.currentPaidUploadId ?? paidUploadId;
|
|
393
|
+
}
|
|
301
394
|
}
|
|
302
395
|
const response = await this.uploadSignedDataItem({
|
|
303
396
|
dataItemStreamFactory,
|
|
@@ -342,6 +435,28 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
342
435
|
}
|
|
343
436
|
throw new FailedRequestError(msg, lastStatusCode);
|
|
344
437
|
}
|
|
438
|
+
/**
|
|
439
|
+
* Returns an upper bound on the bytes in a folder's manifest, if every file
|
|
440
|
+
* lands. Data item ids are always 43 characters, so placeholder ids give the
|
|
441
|
+
* real length, except for the index path: without an index file, the
|
|
442
|
+
* manifest indexes whichever file finished first, so the estimate allows for
|
|
443
|
+
* the longest path there.
|
|
444
|
+
*/
|
|
445
|
+
async plannedManifestByteCount({ relativePaths, indexFile, fallbackFile, }) {
|
|
446
|
+
const placeholder = { id: 'x'.repeat(43) };
|
|
447
|
+
const paths = {};
|
|
448
|
+
let longestPathByteCount = 0;
|
|
449
|
+
for (const path of relativePaths) {
|
|
450
|
+
paths[path] = placeholder;
|
|
451
|
+
longestPathByteCount = Math.max(longestPathByteCount, Buffer.byteLength(JSON.stringify(path)));
|
|
452
|
+
}
|
|
453
|
+
const manifest = await this.generateManifest({
|
|
454
|
+
paths,
|
|
455
|
+
indexFile,
|
|
456
|
+
fallbackFile,
|
|
457
|
+
});
|
|
458
|
+
return Buffer.byteLength(JSON.stringify(manifest)) + longestPathByteCount;
|
|
459
|
+
}
|
|
345
460
|
async generateManifest({ paths, indexFile, fallbackFile, }) {
|
|
346
461
|
const indexPath =
|
|
347
462
|
// Use the user provided index file if it exists,
|
|
@@ -746,11 +861,20 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
746
861
|
};
|
|
747
862
|
let cryptoFundResult;
|
|
748
863
|
if (fundingMode instanceof OnDemandFunding) {
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
864
|
+
// allow extra per item for ANS-104 headers
|
|
865
|
+
const headerByteCount = 1200;
|
|
866
|
+
const itemByteCounts = filesToUpload.map((file) => this.getFileSize(file) + headerByteCount);
|
|
867
|
+
// The manifest spends the same balance. Left out of the estimate, it
|
|
868
|
+
// needed a second top-up of its own.
|
|
869
|
+
if (!disableManifest && files.length > 0) {
|
|
870
|
+
itemByteCounts.push((await this.plannedManifestByteCount({
|
|
871
|
+
relativePaths: files.map((file) => this.getRelativePath(file, params)),
|
|
872
|
+
indexFile,
|
|
873
|
+
fallbackFile,
|
|
874
|
+
})) + headerByteCount);
|
|
875
|
+
}
|
|
752
876
|
cryptoFundResult = await this.onDemand({
|
|
753
|
-
|
|
877
|
+
itemByteCounts,
|
|
754
878
|
onDemandFunding: fundingMode,
|
|
755
879
|
});
|
|
756
880
|
}
|
|
@@ -882,6 +1006,54 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
882
1006
|
}
|
|
883
1007
|
return revokedApprovals;
|
|
884
1008
|
}
|
|
1009
|
+
/**
|
|
1010
|
+
* The winc the service will charge for the given items. Never less.
|
|
1011
|
+
*
|
|
1012
|
+
* The service prices an item as a per-byte rate plus a fixed per-item
|
|
1013
|
+
* charge, rounded up per item: a zero-byte item costs about 8M winc. Scaling
|
|
1014
|
+
* the 1 GiB price down to the item size dropped that fixed part, so a small
|
|
1015
|
+
* upload was under funded by up to ~38%, a folder by roughly the fixed charge
|
|
1016
|
+
* per file, and `topUpBufferMultiplier: 1` could never succeed.
|
|
1017
|
+
*
|
|
1018
|
+
* Items from 1 byte to 1 GiB are priced from two quotes, at 1 byte and 1 GiB.
|
|
1019
|
+
* The line through those two (already rounded up) prices never falls below
|
|
1020
|
+
* the service's unrounded price anywhere between them, so rounding each item
|
|
1021
|
+
* up keeps every estimate, and their sum, at or above what the service
|
|
1022
|
+
* charges. Rounding only the total could not promise that. Anything the line
|
|
1023
|
+
* would have to extrapolate to, and a lone item, is quoted exactly.
|
|
1024
|
+
*
|
|
1025
|
+
* The two quotes are made once per estimate. Each file of a folder still
|
|
1026
|
+
* checks its own price when it uploads.
|
|
1027
|
+
*/
|
|
1028
|
+
async estimateUploadWinc(itemByteCounts) {
|
|
1029
|
+
const oneGiB = 2 ** 30;
|
|
1030
|
+
const inModelRange = (bytes) => bytes >= 1 && bytes <= oneGiB;
|
|
1031
|
+
const useModel = itemByteCounts.filter(inModelRange).length > 1;
|
|
1032
|
+
const modelled = useModel ? itemByteCounts.filter(inModelRange) : [];
|
|
1033
|
+
const quoted = useModel
|
|
1034
|
+
? itemByteCounts.filter((bytes) => !inModelRange(bytes))
|
|
1035
|
+
: itemByteCounts;
|
|
1036
|
+
const bytes = useModel ? [1, oneGiB, ...quoted] : quoted;
|
|
1037
|
+
if (bytes.length === 0) {
|
|
1038
|
+
return '0';
|
|
1039
|
+
}
|
|
1040
|
+
const quotes = await this.paymentService.getUploadCosts({ bytes });
|
|
1041
|
+
let total = (useModel ? quotes.slice(2) : quotes).reduce((sum, { winc }) => sum.plus(winc), new BigNumber(0));
|
|
1042
|
+
if (useModel) {
|
|
1043
|
+
const [oneByte, gibibyte] = quotes;
|
|
1044
|
+
const perByte = new BigNumber(gibibyte.winc)
|
|
1045
|
+
.minus(oneByte.winc)
|
|
1046
|
+
.dividedBy(oneGiB - 1);
|
|
1047
|
+
const perItem = new BigNumber(oneByte.winc).minus(perByte);
|
|
1048
|
+
for (const itemBytes of modelled) {
|
|
1049
|
+
total = total.plus(perByte
|
|
1050
|
+
.multipliedBy(itemBytes)
|
|
1051
|
+
.plus(perItem)
|
|
1052
|
+
.integerValue(BigNumber.ROUND_UP));
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
return total.toFixed(0);
|
|
1056
|
+
}
|
|
885
1057
|
/**
|
|
886
1058
|
* Triggers an upload that will top-up the wallet with Credits for the amount before uploading.
|
|
887
1059
|
* First, it calculates the expected cost of the upload. Next, it checks the wallet for existing
|
|
@@ -889,16 +1061,10 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
889
1061
|
* and await for the balance to be credited.
|
|
890
1062
|
* Note: Only `ario`, `solana`, and `base-eth` tokens are currently supported for on-demand uploads.
|
|
891
1063
|
*/
|
|
892
|
-
async onDemand({
|
|
1064
|
+
async onDemand({ itemByteCounts, onDemandFunding, }) {
|
|
893
1065
|
const { maxTokenAmount, topUpBufferMultiplier } = onDemandFunding;
|
|
894
1066
|
const currentBalance = await this.paymentService.getBalance();
|
|
895
|
-
const
|
|
896
|
-
bytes: [2 ** 30],
|
|
897
|
-
}))[0].winc;
|
|
898
|
-
const expectedWincPrice = new BigNumber(wincPriceForOneGiB)
|
|
899
|
-
.multipliedBy(totalByteCount)
|
|
900
|
-
.dividedBy(2 ** 30)
|
|
901
|
-
.toFixed(0, BigNumber.ROUND_UP);
|
|
1067
|
+
const expectedWincPrice = await this.estimateUploadWinc(itemByteCounts);
|
|
902
1068
|
if (BigNumber(currentBalance.effectiveBalance).isGreaterThanOrEqualTo(expectedWincPrice)) {
|
|
903
1069
|
this.logger.debug('Sufficient balance for on demand upload', {
|
|
904
1070
|
currentBalance,
|
|
@@ -926,7 +1092,15 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
926
1092
|
.toFixed(0, BigNumber.ROUND_UP);
|
|
927
1093
|
if (maxTokenAmount !== undefined) {
|
|
928
1094
|
if (new BigNumber(topUpTokenAmount).isGreaterThan(maxTokenAmount)) {
|
|
929
|
-
|
|
1095
|
+
// Both amounts are in base units. Report them in whole tokens: the
|
|
1096
|
+
// exponent is the number of decimals, so divide by 10 to that power.
|
|
1097
|
+
const baseUnitsPerToken = new BigNumber(10).pow(exponentMap[this.token]);
|
|
1098
|
+
throw new Error(`Top up token amount ${new BigNumber(topUpTokenAmount)
|
|
1099
|
+
.div(baseUnitsPerToken)
|
|
1100
|
+
.toFixed()} ${this.token} is greater than the maximum allowed ` +
|
|
1101
|
+
`amount of ${new BigNumber(maxTokenAmount)
|
|
1102
|
+
.div(baseUnitsPerToken)
|
|
1103
|
+
.toFixed()} ${this.token}`);
|
|
930
1104
|
}
|
|
931
1105
|
}
|
|
932
1106
|
this.logger.debug(`Topping up wallet with ${topUpTokenAmount} ${this.token} for ${topUpWincAmount} winc`);
|
|
@@ -978,3 +1152,101 @@ export class TurboAuthenticatedBaseUploadService extends TurboUnauthenticatedUpl
|
|
|
978
1152
|
});
|
|
979
1153
|
}
|
|
980
1154
|
}
|
|
1155
|
+
/**
|
|
1156
|
+
* The largest data item the x402 single-request path will buffer.
|
|
1157
|
+
*
|
|
1158
|
+
* Normally unreachable: anything over two chunks takes the chunked path, which
|
|
1159
|
+
* pays at create and streams. It bites only when chunking is explicitly
|
|
1160
|
+
* disabled, and it exists so that case fails with an explanation rather than
|
|
1161
|
+
* by exhausting memory.
|
|
1162
|
+
*/
|
|
1163
|
+
const maxX402SingleRequestByteCount = 100 * 1024 * 1024;
|
|
1164
|
+
/**
|
|
1165
|
+
* Headroom for what signing ADDS, so the guard measures the thing that is
|
|
1166
|
+
* actually buffered.
|
|
1167
|
+
*
|
|
1168
|
+
* The limit applies to the signed data item, not the file: ANS-104 headers,
|
|
1169
|
+
* the signature and the caller's tags all ride along. Checking the raw size
|
|
1170
|
+
* let a file in the top of the range through, to be signed, buffered, and then
|
|
1171
|
+
* refused by the service — wasting precisely the expensive step the guard
|
|
1172
|
+
* exists to skip.
|
|
1173
|
+
*
|
|
1174
|
+
* Same allowance folder uploads already use for the same overhead.
|
|
1175
|
+
*/
|
|
1176
|
+
const x402SignedItemOverheadByteCount = 1200;
|
|
1177
|
+
/**
|
|
1178
|
+
* Drain a data-item stream into a Buffer, resuming it once the reader is
|
|
1179
|
+
* attached so upload-progress events still fire.
|
|
1180
|
+
*
|
|
1181
|
+
* Checks the running total as it fills rather than at the end: a stream that
|
|
1182
|
+
* overruns its declared size would otherwise be held in memory in full before
|
|
1183
|
+
* anything objected.
|
|
1184
|
+
*/
|
|
1185
|
+
async function streamToBuffer(stream, byteCount, resume, signal) {
|
|
1186
|
+
// A closure, so TypeScript does not narrow `aborted` away for the whole
|
|
1187
|
+
// function — it genuinely can flip while the stream is draining.
|
|
1188
|
+
const isAborted = () => signal?.aborted === true;
|
|
1189
|
+
if (isAborted()) {
|
|
1190
|
+
throw new AbortError();
|
|
1191
|
+
}
|
|
1192
|
+
const chunks = [];
|
|
1193
|
+
let received = 0;
|
|
1194
|
+
const take = (chunk) => {
|
|
1195
|
+
received += chunk.byteLength;
|
|
1196
|
+
if (received > byteCount) {
|
|
1197
|
+
throw new Error(`Data item stream exceeded its declared size of ${byteCount} bytes`);
|
|
1198
|
+
}
|
|
1199
|
+
chunks.push(chunk);
|
|
1200
|
+
};
|
|
1201
|
+
if (stream instanceof Readable) {
|
|
1202
|
+
const done = new Promise((resolve, reject) => {
|
|
1203
|
+
const onAbort = () => {
|
|
1204
|
+
stream.destroy();
|
|
1205
|
+
reject(new AbortError());
|
|
1206
|
+
};
|
|
1207
|
+
signal?.addEventListener('abort', onAbort, { once: true });
|
|
1208
|
+
stream.on('data', (c) => {
|
|
1209
|
+
try {
|
|
1210
|
+
take(Buffer.from(c));
|
|
1211
|
+
}
|
|
1212
|
+
catch (error) {
|
|
1213
|
+
stream.destroy();
|
|
1214
|
+
reject(error);
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
stream.on('end', () => {
|
|
1218
|
+
signal?.removeEventListener('abort', onAbort);
|
|
1219
|
+
resolve();
|
|
1220
|
+
});
|
|
1221
|
+
stream.on('error', reject);
|
|
1222
|
+
});
|
|
1223
|
+
resume();
|
|
1224
|
+
await done;
|
|
1225
|
+
}
|
|
1226
|
+
else {
|
|
1227
|
+
const reader = stream.getReader();
|
|
1228
|
+
resume();
|
|
1229
|
+
try {
|
|
1230
|
+
for (;;) {
|
|
1231
|
+
if (isAborted()) {
|
|
1232
|
+
await reader.cancel();
|
|
1233
|
+
throw new AbortError();
|
|
1234
|
+
}
|
|
1235
|
+
const { done, value } = await reader.read();
|
|
1236
|
+
if (done)
|
|
1237
|
+
break;
|
|
1238
|
+
if (value !== undefined)
|
|
1239
|
+
take(Buffer.from(value));
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
catch (error) {
|
|
1243
|
+
await reader.cancel().catch(() => undefined);
|
|
1244
|
+
throw error;
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
const buf = Buffer.concat(chunks);
|
|
1248
|
+
if (buf.byteLength !== byteCount) {
|
|
1249
|
+
throw new Error(`Data item stream produced ${buf.byteLength} bytes, expected ${byteCount}`);
|
|
1250
|
+
}
|
|
1251
|
+
return buf;
|
|
1252
|
+
}
|
|
@@ -16,13 +16,18 @@ export declare class ChunkedUploader {
|
|
|
16
16
|
/**
|
|
17
17
|
* The upload id of an x402 upload we have ALREADY PAID FOR.
|
|
18
18
|
*
|
|
19
|
-
* `uploadFile` retries a failed upload up to 6 times
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
19
|
+
* `uploadFile` retries a failed upload up to 6 times. Without this memo each
|
|
20
|
+
* retry opens a NEW paid upload, so one 12 MiB upload whose finalization
|
|
21
|
+
* timed out billed the customer five times over — observed, not theoretical.
|
|
22
|
+
* The payment is bound to an upload id, so a retry must resume THAT upload,
|
|
23
|
+
* never buy another. Deliberately not reset on failure: re-paying is never
|
|
24
|
+
* the right recovery, and an upload that cannot be resumed is refunded
|
|
25
|
+
* server-side.
|
|
26
|
+
*
|
|
27
|
+
* A retry does NOT re-enter `upload()` on this instance: `uploadFile`
|
|
28
|
+
* constructs a fresh uploader each attempt, so this memo only survives
|
|
29
|
+
* because that caller reads {@link currentPaidUploadId} and hands it back
|
|
30
|
+
* through the constructor.
|
|
26
31
|
*/
|
|
27
32
|
private paidUploadId;
|
|
28
33
|
private readonly http;
|
|
@@ -38,7 +43,7 @@ export declare class ChunkedUploader {
|
|
|
38
43
|
* that actually arrive and penalises an under-declaration.
|
|
39
44
|
*/
|
|
40
45
|
private dataItemByteCount;
|
|
41
|
-
constructor({ http, token, maxChunkConcurrency, maxFinalizeMs, chunkByteCount, logger, chunkingMode, dataItemByteCount, x402, x402RefundIdentity, }: {
|
|
46
|
+
constructor({ http, token, maxChunkConcurrency, maxFinalizeMs, chunkByteCount, logger, chunkingMode, dataItemByteCount, x402, x402RefundIdentity, paidUploadId, }: {
|
|
42
47
|
maxFinalizeMs?: number;
|
|
43
48
|
http: TurboHTTPService;
|
|
44
49
|
token: string;
|
|
@@ -60,6 +65,12 @@ export declare class ChunkedUploader {
|
|
|
60
65
|
address: string;
|
|
61
66
|
signatureType: number;
|
|
62
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* An upload this caller has ALREADY PAID FOR. `uploadFile` builds a new
|
|
70
|
+
* uploader per retry attempt, so the in-instance memo below cannot survive
|
|
71
|
+
* a retry on its own: the id has to be handed back in.
|
|
72
|
+
*/
|
|
73
|
+
paidUploadId?: string;
|
|
63
74
|
});
|
|
64
75
|
private shouldChunkUpload;
|
|
65
76
|
private assertChunkParams;
|
|
@@ -78,6 +89,12 @@ export declare class ChunkedUploader {
|
|
|
78
89
|
* spend cap behave identically on both paths.
|
|
79
90
|
*/
|
|
80
91
|
private initPaidUpload;
|
|
92
|
+
/**
|
|
93
|
+
* The paid upload id, once one has been bought. `uploadFile` reads this after
|
|
94
|
+
* a failed attempt so the next attempt resumes the upload already paid for
|
|
95
|
+
* rather than buying a second one.
|
|
96
|
+
*/
|
|
97
|
+
get currentPaidUploadId(): string | undefined;
|
|
81
98
|
private initUpload;
|
|
82
99
|
upload({ dataItemSizeFactory, dataItemStreamFactory, dataItemOpts, signal, events, }: UploadSignedDataItemParams): Promise<TurboUploadDataItemResponse>;
|
|
83
100
|
private toGiB;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunked.d.ts","sourceRoot":"","sources":["../../../src/common/chunked.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EACL,SAAS,EAET,iBAAiB,EACjB,WAAW,EAEX,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EAGvB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAK7C,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAK5C,eAAO,MAAM,iBAAiB,QAAiB,CAAC;AAChD,eAAO,MAAM,iBAAiB,QAAU,CAAC;AACzC,eAAO,MAAM,qBAAqB,QAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,aAAa,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AAI,EAAE,OAAO,CAAC,CAyDvC"}
|
|
@@ -42,6 +42,14 @@ export declare class TurboHTTPService implements TurboHTTPServiceInterface {
|
|
|
42
42
|
retryConfig: RetryConfig;
|
|
43
43
|
logger: TurboLogger;
|
|
44
44
|
});
|
|
45
|
+
/**
|
|
46
|
+
* Refuse to pay over cleartext.
|
|
47
|
+
*
|
|
48
|
+
* An x402 payment authorization is a bearer credential: anyone who observes
|
|
49
|
+
* it can submit it. Sending one over `http:` hands it to the network, so a
|
|
50
|
+
* misconfigured service URL must fail loudly rather than quietly leak.
|
|
51
|
+
*/
|
|
52
|
+
private assertSecureForPayment;
|
|
45
53
|
get<T>({ endpoint, signal, allowedStatuses, headers, x402Options, }: {
|
|
46
54
|
endpoint: `/${string}`;
|
|
47
55
|
signal?: AbortSignal;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/common/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,MAAM,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACvD;AAED,eAAO,MAAM,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,WAQzD,CAAC;AAOH;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;CAGtB,CAAC;AAEX,qBAAa,gBAAiB,YAAW,yBAAyB;IAChE,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,MAAM,EAAE,WAAW,CA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AAW,GACZ,EAAE;QACD,QAAQ,EAAE,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtE;;;;;;;;WAQG;QACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;KACtC,GAAG,OAAO,CAAC,CAAC,CAAC;IAyCR,IAAI,CAAC,CAAC,EAAE,EACZ,QAAQ,EACR,MAAM,EACN,eAA4B,EAC5B,OAAO,EACP,IAAI,EACJ,WAAW,EACX,KAAY,GACb,EAAE;QACD,QAAQ,EAAE,IAAI,MAAM,EAAE,CAAC;QACvB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,cAAc,GAAG,UAAU,CAAC;QACtD,WAAW,CAAC,EAAE,sBAAsB,CAAC;QAIrC,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,CAAC,CAAC;YAmCA,UAAU;YA6BV,SAAS;YAsCT,QAAQ;CAgDvB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArNSAction, ArNSActionCompleted, ArNSActionPriceResponse, ArNSActionResult, ArNSFiatPurchaseQuoteParams, ArNSFiatPurchaseQuoteResponse,
|
|
1
|
+
import { ArNSAction, ArNSActionCompleted, ArNSActionPriceResponse, ArNSActionResult, ArNSBuyNameActionParams, ArNSFiatPurchaseQuoteParams, ArNSFiatPurchaseQuoteResponse, ArNSOwnerSigner, ArNSPriceParams, ArNSPriceResponse, ArNSPurchaseParams, ArNSPurchaseStatusResponse, AuthenticatedArNSFiatPurchaseQuoteParams, Currency, GetCreditShareApprovalsResponse, TokenTools, TokenType, TurboArNSNamesResponse, TurboAuthenticatedPaymentServiceConfiguration, TurboAuthenticatedPaymentServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatEstimateForBytesResponse, TurboFiatToArResponse, TurboFreeStatusResponse, TurboFundWithTokensParams, TurboLogger, TurboPaymentHistoryParams, TurboPaymentHistoryResponse, TurboPaymentIntentParams, TurboPaymentIntentResponse, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboSubmitFundTxResponse, TurboTokenPriceForBytesResponse, TurboUnauthenticatedPaymentServiceConfiguration, TurboUnauthenticatedPaymentServiceInterface, TurboWincForFiatParams, TurboWincForFiatResponse, TurboWincForTokenParams, TurboWincForTokenResponse, UserAddress } from '../types.js';
|
|
2
2
|
import { TurboHTTPService } from './http.js';
|
|
3
3
|
export declare const developmentPaymentServiceURL = "https://payment.ardrive.dev";
|
|
4
4
|
export declare const defaultPaymentServiceURL = "https://payment.ardrive.io";
|
|
@@ -187,14 +187,7 @@ export declare class TurboAuthenticatedPaymentService extends TurboUnauthenticat
|
|
|
187
187
|
* The owner needs a Solana key to sign with, NOT a funded one — Turbo pays
|
|
188
188
|
* every lamport of fee and rent.
|
|
189
189
|
*/
|
|
190
|
-
buyArNSName({ name, owner, type, years, paidBy, onNonce, }:
|
|
191
|
-
name: string;
|
|
192
|
-
owner: ArNSOwnerSigner;
|
|
193
|
-
type?: ArNSNameType;
|
|
194
|
-
years?: number;
|
|
195
|
-
paidBy?: UserAddress | UserAddress[];
|
|
196
|
-
onNonce?: (nonce: string) => void | Promise<void>;
|
|
197
|
-
}): Promise<ArNSActionCompleted>;
|
|
190
|
+
buyArNSName({ name, owner, type, years, paidBy, onNonce, antState, }: ArNSBuyNameActionParams): Promise<ArNSActionCompleted>;
|
|
198
191
|
/** Extend a lease. Permissionless on chain — no owner signature needed. */
|
|
199
192
|
extendArNSLease({ name, years, paidBy, onNonce, }: {
|
|
200
193
|
name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/common/payment.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,2BAA2B,EAC3B,6BAA6B,
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/common/payment.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,2BAA2B,EAC3B,6BAA6B,EAE7B,eAAe,EAEf,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,0BAA0B,EAC1B,wCAAwC,EACxC,QAAQ,EACR,+BAA+B,EAE/B,UAAU,EACV,SAAS,EAET,sBAAsB,EACtB,6CAA6C,EAC7C,yCAAyC,EACzC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,iCAAiC,EACjC,qBAAqB,EACrB,uBAAuB,EACvB,yBAAyB,EAEzB,WAAW,EACX,yBAAyB,EACzB,2BAA2B,EAC3B,wBAAwB,EACxB,0BAA0B,EAE1B,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,+BAA+B,EAC/B,+CAA+C,EAC/C,2CAA2C,EAC3C,sBAAsB,EACtB,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,WAAW,EAIZ,MAAM,aAAa,CAAC;AAgBrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C,eAAO,MAAM,4BAA4B,gCAAgC,CAAC;AAC1E,eAAO,MAAM,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