@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 CHANGED
@@ -1,5 +1,7 @@
1
1
  # @ardriveapp/turbo-sdk 🚀
2
2
 
3
+ [![codecov](https://codecov.io/gh/ardriveapp/turbo-sdk/graph/badge.svg?token=CXS48HM8Y8)](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 from a file or generate a new one
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
- // no timeout or AbortSignal provided
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