@ardrive/turbo-sdk 1.2.0-alpha.1 → 1.3.0-alpha.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.
- package/README.md +30 -4
- package/bundles/web.bundle.min.js +46326 -48343
- package/lib/cjs/node/factory.js +16 -5
- package/lib/cjs/node/signer.js +5 -10
- package/lib/cjs/version.js +1 -1
- package/lib/cjs/web/factory.js +16 -5
- package/lib/cjs/web/signer.js +15 -12
- package/lib/esm/node/factory.js +16 -5
- package/lib/esm/node/signer.js +6 -8
- package/lib/esm/version.js +1 -1
- package/lib/esm/web/factory.js +16 -5
- package/lib/esm/web/signer.js +16 -10
- package/lib/types/common/payment.d.ts +2 -2
- package/lib/types/common/payment.d.ts.map +1 -1
- package/lib/types/common/upload.d.ts +2 -2
- package/lib/types/common/upload.d.ts.map +1 -1
- package/lib/types/node/factory.d.ts +1 -17
- package/lib/types/node/factory.d.ts.map +1 -1
- package/lib/types/node/signer.d.ts +5 -22
- package/lib/types/node/signer.d.ts.map +1 -1
- package/lib/types/types.d.ts +6 -4
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/version.d.ts +1 -1
- package/lib/types/version.d.ts.map +1 -1
- package/lib/types/web/factory.d.ts +1 -17
- package/lib/types/web/factory.d.ts.map +1 -1
- package/lib/types/web/signer.d.ts +5 -22
- package/lib/types/web/signer.d.ts.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# @ardriveapp/turbo-sdk 🚀
|
2
2
|
|
3
|
+
[](https://codecov.io/gh/ardriveapp/turbo-sdk)
|
4
|
+
|
3
5
|
Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interacting with the Turbo Upload and Payment Services and is available for both NodeJS and Web environments.
|
4
6
|
|
5
7
|
## Table of Contents
|
@@ -47,11 +49,15 @@ yarn add @ardrive/turbo-sdk
|
|
47
49
|
```typescript
|
48
50
|
import { TurboFactory } from '@ardrive/turbo-sdk';
|
49
51
|
|
50
|
-
// load your JWK
|
52
|
+
// load your JWK directly to authenticate
|
51
53
|
const jwk = fs.readFileSync('./my-jwk.json');
|
52
54
|
const address = arweave.wallets.jwkToAddress(jwk);
|
53
55
|
const turbo = TurboFactory.authenticated({ privateKey: jwk });
|
54
56
|
|
57
|
+
// or provide your own signer
|
58
|
+
const signer = new ArweaveSigner(jwk);
|
59
|
+
const turbo = TurboFactory.authenticated({ signer });
|
60
|
+
|
55
61
|
// get the wallet balance
|
56
62
|
const { winc: balance } = await turbo.getBalance();
|
57
63
|
|
@@ -227,13 +233,20 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa
|
|
227
233
|
const turbo = TurboFactory.unauthenticated();
|
228
234
|
```
|
229
235
|
|
230
|
-
- `authenticated()` - Creates an instance of a client that accesses Turbo's authenticated and unauthenticated services.
|
236
|
+
- `authenticated()` - Creates an instance of a client that accesses Turbo's authenticated and unauthenticated services. Requires either a signer, or private key to be provided.
|
231
237
|
|
232
238
|
```typescript
|
233
239
|
const jwk = await arweave.crypto.generateJWK();
|
234
240
|
const turbo = TurboFactory.authenticated({ privateKey: jwk });
|
235
241
|
```
|
236
242
|
|
243
|
+
or
|
244
|
+
|
245
|
+
```typescript
|
246
|
+
const signer = new ArweaveSigner(jwk);
|
247
|
+
const turbo = TurboFactory.authenticated({ signer });
|
248
|
+
```
|
249
|
+
|
237
250
|
### TurboUnauthenticatedClient
|
238
251
|
|
239
252
|
- `getSupportedCurrencies()` - Returns the list of currencies supported by the Turbo Payment Service for topping up a user balance of AR Credits (measured in Winston Credits, or winc).
|
@@ -353,7 +366,7 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa
|
|
353
366
|
}
|
354
367
|
```
|
355
368
|
|
356
|
-
- `uploadFile({ fileStreamFactory, fileSizeFactory, signal })` - Signs and uploads a raw file. The provided `fileStreamFactory` should produce a NEW file data stream each time is it invoked. The `fileSizeFactory` is a function that returns the size of the file. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request.
|
369
|
+
- `uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts })` - Signs and uploads a raw file. The provided `fileStreamFactory` should produce a NEW file data stream each time is it invoked. The `fileSizeFactory` is a function that returns the size of the file. The `signal` is an optional [AbortSignal] that can be used to cancel the upload or timeout the request. `dataItemOpts` is an optional object that can be used to configure tags, target, and anchor for the data item upload.
|
357
370
|
|
358
371
|
```typescript
|
359
372
|
const filePath = path.join(__dirname, './my-unsigned-file.txt');
|
@@ -361,7 +374,20 @@ Types are exported from `./lib/types/[node/web]/index.d.ts` and should be automa
|
|
361
374
|
const uploadResult = await turbo.uploadFile({
|
362
375
|
fileStreamFactory: () => fs.createReadStream(filePath),
|
363
376
|
fileSizeFactory: () => fileSize,
|
364
|
-
|
377
|
+
dataItemOpts: {
|
378
|
+
// optional
|
379
|
+
tags: [
|
380
|
+
{
|
381
|
+
name: 'Content-Type',
|
382
|
+
value: 'text/plain',
|
383
|
+
},
|
384
|
+
{
|
385
|
+
name: 'My-Custom-Tag',
|
386
|
+
value: 'my-custom-value',
|
387
|
+
},
|
388
|
+
],
|
389
|
+
// no timeout or AbortSignal provided
|
390
|
+
},
|
365
391
|
});
|
366
392
|
```
|
367
393
|
|