@ardrive/turbo-sdk 1.0.0-alpha.21 → 1.0.0-alpha.22

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,12 +1,11 @@
1
1
  # @ardriveapp/turbo-sdk 🚀
2
2
 
3
- Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionalities for interacting with the Turbo Upload and Payment Services. It is available in both NodeJS and Web environments.
3
+ 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
4
 
5
5
  ## Table of Contents
6
6
 
7
7
  - [Installation](#installation)
8
- - [Usage](#usage):
9
-
8
+ - [Usage](#usage)
10
9
  - [NodeJS Environments](#nodejs)
11
10
  - [CommonJS](#commonjs)
12
11
  - [ESM](#esm)
@@ -15,7 +14,6 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionalities for inter
15
14
  - [Browser](#browser)
16
15
  - [Typescript](#typescript)
17
16
  - [Examples](./examples)
18
-
19
17
  - [Contributions](#contributions)
20
18
 
21
19
  ## Installation
@@ -32,14 +30,14 @@ yarn add @ardrive/turbo-sdk
32
30
 
33
31
  ## Usage
34
32
 
35
- The SDK is available in both CommonJS and ESM formats and is compatible with bundlers such as Webpack, Rollup, and ESbuild.
33
+ The SDK is provided in both CommonJS and ESM formats, and it's compatible with bundlers such as Webpack, Rollup, and ESbuild. Utilize the appropriate named exports provided by this SDK's [package.json] based on your project's configuration. Refer to the [examples] directory to see how to use the SDK in various environments.
36
34
 
37
35
  ### Web
38
36
 
39
37
  #### Bundlers (Webpack, Rollup, ESbuild, etc.)
40
38
 
41
39
  ```javascript
42
- import { TurboFactory } from '@ardrive/turbo-sdk/web';
40
+ import { TurboFactory } from '@ardrive/turbo-sdk';
43
41
 
44
42
  const turbo = TurboFactory.unauthenticated({});
45
43
  const rates = await turbo.getFiatRates();
@@ -59,14 +57,58 @@ const rates = await turbo.getFiatRates();
59
57
 
60
58
  #### CommonJS
61
59
 
60
+ Project's `package.json`:
61
+
62
+ ```json
63
+ {
64
+ "type": "commonjs" // or absent
65
+ }
66
+ ```
67
+
68
+ tsconfig's `tsconfig.json`:
69
+
70
+ ```json
71
+ {
72
+ "compilerOptions": {
73
+ "module": "CommonJS",
74
+ "moduleResolution": "Node",
75
+ "skipLibCheck": true
76
+ }
77
+ }
78
+ ```
79
+
80
+ Usage:
81
+
62
82
  ```javascript
63
- const { TurboFactory } = require('@ardrive/turbo-sdk/node');
83
+ const { TurboFactory } = require('@ardrive/turbo-sdk');
64
84
 
65
85
  const turbo = TurboFactory.unauthenticated({});
66
86
  const rates = await turbo.getFiatRates();
67
87
  ```
68
88
 
69
- ### ESM
89
+ #### ESM
90
+
91
+ Project's `package.json`:
92
+
93
+ ```json
94
+ {
95
+ "type": "module"
96
+ }
97
+ ```
98
+
99
+ tsconfig's `tsconfig.json`:
100
+
101
+ ```json
102
+ {
103
+ "compilerOptions": {
104
+ "module": "NodeNext",
105
+ "moduleResolution": "NodeNext",
106
+ "skipLibCheck": true
107
+ }
108
+ }
109
+ ```
110
+
111
+ Usage:
70
112
 
71
113
  ```javascript
72
114
  import { TurboFactory } from '@ardrive/turbo-sdk/node';
@@ -77,7 +119,7 @@ const rates = await turbo.getFiatRates();
77
119
 
78
120
  ### Typescript
79
121
 
80
- The SDK provides TypeScript typings. When you import the SDK in a TypeScript project:
122
+ The SDK provides TypeScript types. When you import the SDK in a TypeScript project:
81
123
 
82
124
  ```typescript
83
125
  import Ardrive from '@ardrive/turbo-sdk/web';
@@ -85,30 +127,99 @@ import Ardrive from '@ardrive/turbo-sdk/web';
85
127
  // or '@ardrive/turbo-sdk/node' for Node.js projects
86
128
  ```
87
129
 
88
- The provided typings (`./lib/types/index.d.ts`) will be automatically recognized, offering type checking and autocompletion benefits.
130
+ Types are exported from `./lib/types/index.d.ts` and should be automatically recognized, offering benefits such as type-checking and autocompletion.
89
131
 
90
- ## APIs (WIP)
132
+ ## APIs
91
133
 
92
134
  ### TurboFactory
93
135
 
94
- - `public()`
95
- - `private()`
136
+ - `unauthenticated()` - Creates an instance of a client that accesses Turbo's unauthenticated services.
137
+
138
+ ```typescript
139
+ const turbo = TurboFactory.unauthenticated({});
140
+ ```
141
+
142
+ - `authenticated()` - Creates an instance of a client that accesses Turbo's authenticated and unauthenticated services.
143
+
144
+ ```typescript
145
+ const jwk = await arweave.crypto.generateJWK();
146
+ const turbo = TurboFactory.authenticated({ privateKey: jwk });
147
+ ```
96
148
 
97
149
  ### TurboUnauthenticatedClient
98
150
 
99
- - `getFiatRates()`
100
- - `getFiatToAR()`
101
- - `getSupportedCountries()`
102
- - `getSupportedCurrencies()`
103
- - `getWincForFiat()`
104
- - `getUploadCosts()`
105
- - `uploadSignedDataItem()`
151
+ - `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).
152
+
153
+ ```typescript
154
+ const currencies = await turbo.getSupportedCurrencies();
155
+ ```
156
+
157
+ - `getSupportedCountries()` - Returns the list of countries supported by the Turbo Payment Service's top up workflow.
158
+
159
+ ```typescript
160
+ const countries = await turbo.getSupportedCountries();
161
+ ```
162
+
163
+ - `getFiatToAR()` - Returns the current raw fiat to AR conversion rate for a specific currency as reported by third-party pricing oracles.
164
+
165
+ ```typescript
166
+ const fiatToAR = await turbo.getFiatToAR({ currency: 'USD' });
167
+ ```
168
+
169
+ - `getFiatRates()` - Returns the current fiat rates for 1 GiB of data for supported currencies, including all top-up adjustments and fees.
170
+
171
+ ```typescript
172
+ const rates = await turbo.getFiatRates();
173
+ ```
174
+
175
+ - `getWincForFiat({ amount, currency })` - Returns the current conversion rate for Winston Credits for the provided fiat currency and amount, including all top-up adjustments and fees.
176
+
177
+ ```typescript
178
+ const winc = await turbo.getWincForFiat({ amount: 100, currency: 'USD' });
179
+ ```
180
+
181
+ - `getUploadCosts({ bytes })` - Returns the estimated cost in Winston Credits for the provided file sizes, including all upload adjustments and fees.
182
+
183
+ ```typescript
184
+ const costs = await turbo.getUploadCosts({ bytes: [1000, 2000] });
185
+ ```
186
+
187
+ - `uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal })` - Uploads a signed data item. The provided dataItemStreamFactory should produce a NEW signed data item stream each time is it invoked. The `dataItemSizeFactory` is a function that returns the size of the file.
188
+
189
+ ```typescript
190
+ const filePath = path.join(__dirname, './my-signed-data-item');
191
+ const dataItemSize = fs.statSync(filePath).size;
192
+ const uploadResponse = await turbo.uploadSignedDataItem({
193
+ dataItemStreamFactory: () => fs.createReadStream(filePath),
194
+ dataItemSizeFactory: () => dataItemSize,
195
+ signal: AbortSignal.timeout(10_000), // cancel the upload after 10 seconds
196
+ });
197
+ ```
106
198
 
107
199
  ### TurboAuthenticatedClient
108
200
 
109
- - `getBalance()`
110
- - `uploadFile()`
201
+ - `getBalance()` - Issues a signed request to get the credit balance of a wallet measured in AR (measured in Winston Credits, or winc).
202
+
203
+ ```typescript
204
+ const balance = await turbo.getBalance();
205
+ ```
206
+
207
+ - `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.
208
+
209
+ ```typescript
210
+ const filePath = path.join(__dirname, './my-unsigned-file.txt');
211
+ const fileSize = fs.stateSync(filePath).size;
212
+ const uploadResult = await turboAuthClient.uploadFile({
213
+ fileStreamFactory: () => fs.createReadStream(filePath),
214
+ fileSizeFactory: () => fileSize,
215
+ });
216
+ ```
111
217
 
112
218
  ## Contributions
113
219
 
114
- If you encounter any issues or have feature requests, please file an issue on our GitHub repository. Contributions, pull requests, and feedback are welcome and encouraged.
220
+ If you encounter any issues or have feature requests, please file an issue on our GitHub repository. Contributions, pull requests, and feedback are both welcome and encouraged.
221
+
222
+ [package.json]: ./package.json
223
+ [examples]: ./examples
224
+ [TurboUnauthenticatedClient]: #turboUnauthenticatedClient
225
+ [TurboAuthenticatedClient]: #turboAuthenticatedClient
@@ -47480,14 +47480,17 @@ var TurboUnauthenticatedUploadService = class {
47480
47480
  }
47481
47481
  async uploadSignedDataItem({
47482
47482
  dataItemStreamFactory,
47483
+ dataItemSizeFactory,
47483
47484
  signal
47484
47485
  }) {
47486
+ const fileSize = dataItemSizeFactory();
47485
47487
  return this.httpService.post({
47486
47488
  endpoint: `/tx`,
47487
47489
  signal,
47488
47490
  data: dataItemStreamFactory(),
47489
47491
  headers: {
47490
- "content-type": "application/octet-stream"
47492
+ "content-type": "application/octet-stream",
47493
+ "content-length": `${fileSize}`
47491
47494
  }
47492
47495
  });
47493
47496
  }
@@ -47503,17 +47506,22 @@ var TurboAuthenticatedUploadService = class extends TurboUnauthenticatedUploadSe
47503
47506
  }
47504
47507
  async uploadFile({
47505
47508
  fileStreamFactory,
47509
+ fileSizeFactory,
47506
47510
  signal
47507
47511
  }) {
47508
- const signedDataItem = await this.signer.signDataItem({
47509
- fileStreamFactory
47512
+ const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
47513
+ fileStreamFactory,
47514
+ fileSizeFactory
47510
47515
  });
47516
+ const signedDataItem = dataItemStreamFactory();
47517
+ const fileSize = dataItemSizeFactory();
47511
47518
  return this.httpService.post({
47512
47519
  endpoint: `/tx`,
47513
47520
  signal,
47514
47521
  data: signedDataItem,
47515
47522
  headers: {
47516
- "content-type": "application/octet-stream"
47523
+ "content-type": "application/octet-stream",
47524
+ "content-length": `${fileSize}`
47517
47525
  }
47518
47526
  });
47519
47527
  }
@@ -47579,10 +47587,12 @@ var TurboUnauthenticatedClient = class {
47579
47587
  */
47580
47588
  async uploadSignedDataItem({
47581
47589
  dataItemStreamFactory,
47590
+ dataItemSizeFactory,
47582
47591
  signal
47583
47592
  }) {
47584
47593
  return this.uploadService.uploadSignedDataItem({
47585
47594
  dataItemStreamFactory,
47595
+ dataItemSizeFactory,
47586
47596
  signal
47587
47597
  });
47588
47598
  }
@@ -47605,9 +47615,14 @@ var TurboAuthenticatedClient = class extends TurboUnauthenticatedClient {
47605
47615
  */
47606
47616
  async uploadFile({
47607
47617
  fileStreamFactory,
47618
+ fileSizeFactory,
47608
47619
  signal
47609
47620
  }) {
47610
- return this.uploadService.uploadFile({ fileStreamFactory, signal });
47621
+ return this.uploadService.uploadFile({
47622
+ fileStreamFactory,
47623
+ fileSizeFactory,
47624
+ signal
47625
+ });
47611
47626
  }
47612
47627
  };
47613
47628
 
@@ -55555,19 +55570,22 @@ function toB64Url(buffer) {
55555
55570
  // src/utils/readableStream.ts
55556
55571
  init_shim();
55557
55572
  async function readableStreamToBuffer({
55558
- stream
55573
+ stream,
55574
+ size
55559
55575
  }) {
55560
55576
  const reader = stream.getReader();
55561
- const chunks = [];
55577
+ const buffer = import_buffer.Buffer.alloc(size);
55578
+ let offset = 0;
55562
55579
  let done = false;
55563
55580
  while (!done) {
55564
55581
  const { done: streamDone, value } = await reader.read();
55565
55582
  done = streamDone;
55566
55583
  if (!done) {
55567
- chunks.push(value);
55584
+ buffer.set(value, offset);
55585
+ offset += value.byteLength;
55568
55586
  }
55569
55587
  }
55570
- return import_buffer.Buffer.concat(chunks);
55588
+ return buffer;
55571
55589
  }
55572
55590
 
55573
55591
  // src/web/signer.ts
@@ -55578,15 +55596,20 @@ var TurboWebArweaveSigner = class {
55578
55596
  this.signer = new ArweaveSigner(this.privateKey);
55579
55597
  }
55580
55598
  async signDataItem({
55581
- fileStreamFactory
55599
+ fileStreamFactory,
55600
+ fileSizeFactory
55582
55601
  }) {
55583
55602
  const buffer = await readableStreamToBuffer({
55584
- stream: fileStreamFactory()
55585
- // TODO: add payload size to get performance improvements
55603
+ stream: fileStreamFactory(),
55604
+ size: fileSizeFactory()
55586
55605
  });
55587
- const signedDataItem = createData(buffer, this.signer);
55606
+ const signedDataItem = createData(buffer, this.signer, {});
55588
55607
  await signedDataItem.sign(this.signer);
55589
- return signedDataItem.getRaw();
55608
+ return {
55609
+ // while this returns a Buffer - it needs to match our return type for uploading
55610
+ dataItemStreamFactory: () => signedDataItem.getRaw(),
55611
+ dataItemSizeFactory: () => signedDataItem.getRaw().length
55612
+ };
55590
55613
  }
55591
55614
  // NOTE: this might be better in a parent class or elsewhere - easy enough to leave in here now and does require specific environment version of crypto
55592
55615
  async generateSignedRequestHeaders() {
@@ -50,9 +50,10 @@ class TurboUnauthenticatedClient {
50
50
  /**
51
51
  * Uploads a signed data item to the Turbo Upload Service.
52
52
  */
53
- async uploadSignedDataItem({ dataItemStreamFactory, signal, }) {
53
+ async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
54
54
  return this.uploadService.uploadSignedDataItem({
55
55
  dataItemStreamFactory,
56
+ dataItemSizeFactory,
56
57
  signal,
57
58
  });
58
59
  }
@@ -71,8 +72,12 @@ class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
71
72
  /**
72
73
  * Signs and uploads raw data to the Turbo Upload Service.
73
74
  */
74
- async uploadFile({ fileStreamFactory, signal, }) {
75
- return this.uploadService.uploadFile({ fileStreamFactory, signal });
75
+ async uploadFile({ fileStreamFactory, fileSizeFactory, signal, }) {
76
+ return this.uploadService.uploadFile({
77
+ fileStreamFactory,
78
+ fileSizeFactory,
79
+ signal,
80
+ });
76
81
  }
77
82
  }
78
83
  exports.TurboAuthenticatedClient = TurboAuthenticatedClient;
@@ -9,7 +9,8 @@ class TurboUnauthenticatedUploadService {
9
9
  retryConfig,
10
10
  });
11
11
  }
12
- async uploadSignedDataItem({ dataItemStreamFactory, signal, }) {
12
+ async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
13
+ const fileSize = dataItemSizeFactory();
13
14
  // TODO: add p-limit constraint or replace with separate upload class
14
15
  return this.httpService.post({
15
16
  endpoint: `/tx`,
@@ -17,6 +18,7 @@ class TurboUnauthenticatedUploadService {
17
18
  data: dataItemStreamFactory(),
18
19
  headers: {
19
20
  'content-type': 'application/octet-stream',
21
+ 'content-length': `${fileSize}`,
20
22
  },
21
23
  });
22
24
  }
@@ -28,10 +30,13 @@ class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadService
28
30
  super({ url, retryConfig });
29
31
  this.signer = signer;
30
32
  }
31
- async uploadFile({ fileStreamFactory, signal, }) {
32
- const signedDataItem = await this.signer.signDataItem({
33
+ async uploadFile({ fileStreamFactory, fileSizeFactory, signal, }) {
34
+ const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
33
35
  fileStreamFactory,
36
+ fileSizeFactory,
34
37
  });
38
+ const signedDataItem = dataItemStreamFactory();
39
+ const fileSize = dataItemSizeFactory();
35
40
  // TODO: add p-limit constraint or replace with separate upload class
36
41
  return this.httpService.post({
37
42
  endpoint: `/tx`,
@@ -39,6 +44,7 @@ class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadService
39
44
  data: signedDataItem,
40
45
  headers: {
41
46
  'content-type': 'application/octet-stream',
47
+ 'content-length': `${fileSize}`,
42
48
  },
43
49
  });
44
50
  }
@@ -30,10 +30,18 @@ class TurboNodeArweaveSigner {
30
30
  this.privateKey = privateKey;
31
31
  this.signer = new arbundles_1.ArweaveSigner(this.privateKey);
32
32
  }
33
- signDataItem({ fileStreamFactory, }) {
33
+ async signDataItem({ fileStreamFactory, fileSizeFactory, }) {
34
34
  // TODO: replace with our own signer implementation
35
35
  const [stream1, stream2] = [fileStreamFactory(), fileStreamFactory()];
36
- return (0, arbundles_1.streamSigner)(stream1, stream2, this.signer);
36
+ const signedDataItem = await (0, arbundles_1.streamSigner)(stream1, stream2, this.signer);
37
+ // TODO: support target, anchor, and tags
38
+ const signedDataItemSize = this.calculateSignedDataHeadersSize({
39
+ dataSize: fileSizeFactory(),
40
+ });
41
+ return {
42
+ dataItemStreamFactory: () => signedDataItem,
43
+ dataItemSizeFactory: () => signedDataItemSize,
44
+ };
37
45
  }
38
46
  // NOTE: this might be better in a parent class or elsewhere - easy enough to leave in here now and does require specific environment version of crypto
39
47
  async generateSignedRequestHeaders() {
@@ -46,5 +54,28 @@ class TurboNodeArweaveSigner {
46
54
  'x-signature': (0, base64_js_1.toB64Url)(Buffer.from(signature)),
47
55
  };
48
56
  }
57
+ // TODO: make dynamic that accepts anchor and target and tags to return the size of the headers + data
58
+ // reference https://github.com/ArweaveTeam/arweave-standards/blob/master/ans/ANS-104.md#13-dataitem-format
59
+ calculateSignedDataHeadersSize({ dataSize }) {
60
+ const anchor = 1; // + whatever they provide (max of 33)
61
+ const target = 1; // + whatever they provide (max of 33)
62
+ const tags = 0;
63
+ const signatureLength = 512;
64
+ const ownerLength = 512;
65
+ const signatureTypeLength = 2;
66
+ const numOfTagsLength = 8; // https://github.com/Bundlr-Network/arbundles/blob/master/src/tags.ts#L191-L198
67
+ const numOfTagsBytesLength = 8;
68
+ return [
69
+ anchor,
70
+ target,
71
+ tags,
72
+ signatureLength,
73
+ ownerLength,
74
+ signatureTypeLength,
75
+ numOfTagsLength,
76
+ numOfTagsBytesLength,
77
+ dataSize,
78
+ ].reduce((totalSize, currentSize) => (totalSize += currentSize));
79
+ }
49
80
  }
50
81
  exports.TurboNodeArweaveSigner = TurboNodeArweaveSigner;
@@ -1,17 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.readableStreamToBuffer = void 0;
4
- async function readableStreamToBuffer({ stream, }) {
4
+ async function readableStreamToBuffer({ stream, size, }) {
5
5
  const reader = stream.getReader();
6
- const chunks = [];
6
+ const buffer = Buffer.alloc(size);
7
+ let offset = 0;
7
8
  let done = false;
8
9
  while (!done) {
9
10
  const { done: streamDone, value } = await reader.read();
10
11
  done = streamDone;
11
12
  if (!done) {
12
- chunks.push(value);
13
+ buffer.set(value, offset);
14
+ offset += value.byteLength;
13
15
  }
14
16
  }
15
- return Buffer.concat(chunks);
17
+ return buffer;
16
18
  }
17
19
  exports.readableStreamToBuffer = readableStreamToBuffer;
@@ -30,15 +30,20 @@ class TurboWebArweaveSigner {
30
30
  this.privateKey = privateKey;
31
31
  this.signer = new arbundles_1.ArweaveSigner(this.privateKey);
32
32
  }
33
- async signDataItem({ fileStreamFactory, }) {
33
+ async signDataItem({ fileStreamFactory, fileSizeFactory, }) {
34
34
  // TODO: converts the readable stream to a buffer bc incrementally signing ReadableStreams is not trivial
35
35
  const buffer = await (0, readableStream_js_1.readableStreamToBuffer)({
36
36
  stream: fileStreamFactory(),
37
- // TODO: add payload size to get performance improvements
37
+ size: fileSizeFactory(),
38
38
  });
39
- const signedDataItem = (0, arbundles_1.createData)(buffer, this.signer);
39
+ // TODO: support target, anchor and tags for upload
40
+ const signedDataItem = (0, arbundles_1.createData)(buffer, this.signer, {});
40
41
  await signedDataItem.sign(this.signer);
41
- return signedDataItem.getRaw();
42
+ return {
43
+ // while this returns a Buffer - it needs to match our return type for uploading
44
+ dataItemStreamFactory: () => signedDataItem.getRaw(),
45
+ dataItemSizeFactory: () => signedDataItem.getRaw().length,
46
+ };
42
47
  }
43
48
  // NOTE: this might be better in a parent class or elsewhere - easy enough to leave in here now and does require specific environment version of crypto
44
49
  async generateSignedRequestHeaders() {
@@ -47,9 +47,10 @@ export class TurboUnauthenticatedClient {
47
47
  /**
48
48
  * Uploads a signed data item to the Turbo Upload Service.
49
49
  */
50
- async uploadSignedDataItem({ dataItemStreamFactory, signal, }) {
50
+ async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
51
51
  return this.uploadService.uploadSignedDataItem({
52
52
  dataItemStreamFactory,
53
+ dataItemSizeFactory,
53
54
  signal,
54
55
  });
55
56
  }
@@ -67,7 +68,11 @@ export class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
67
68
  /**
68
69
  * Signs and uploads raw data to the Turbo Upload Service.
69
70
  */
70
- async uploadFile({ fileStreamFactory, signal, }) {
71
- return this.uploadService.uploadFile({ fileStreamFactory, signal });
71
+ async uploadFile({ fileStreamFactory, fileSizeFactory, signal, }) {
72
+ return this.uploadService.uploadFile({
73
+ fileStreamFactory,
74
+ fileSizeFactory,
75
+ signal,
76
+ });
72
77
  }
73
78
  }
@@ -6,7 +6,8 @@ export class TurboUnauthenticatedUploadService {
6
6
  retryConfig,
7
7
  });
8
8
  }
9
- async uploadSignedDataItem({ dataItemStreamFactory, signal, }) {
9
+ async uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }) {
10
+ const fileSize = dataItemSizeFactory();
10
11
  // TODO: add p-limit constraint or replace with separate upload class
11
12
  return this.httpService.post({
12
13
  endpoint: `/tx`,
@@ -14,6 +15,7 @@ export class TurboUnauthenticatedUploadService {
14
15
  data: dataItemStreamFactory(),
15
16
  headers: {
16
17
  'content-type': 'application/octet-stream',
18
+ 'content-length': `${fileSize}`,
17
19
  },
18
20
  });
19
21
  }
@@ -24,10 +26,13 @@ export class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadS
24
26
  super({ url, retryConfig });
25
27
  this.signer = signer;
26
28
  }
27
- async uploadFile({ fileStreamFactory, signal, }) {
28
- const signedDataItem = await this.signer.signDataItem({
29
+ async uploadFile({ fileStreamFactory, fileSizeFactory, signal, }) {
30
+ const { dataItemStreamFactory, dataItemSizeFactory } = await this.signer.signDataItem({
29
31
  fileStreamFactory,
32
+ fileSizeFactory,
30
33
  });
34
+ const signedDataItem = dataItemStreamFactory();
35
+ const fileSize = dataItemSizeFactory();
31
36
  // TODO: add p-limit constraint or replace with separate upload class
32
37
  return this.httpService.post({
33
38
  endpoint: `/tx`,
@@ -35,6 +40,7 @@ export class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadS
35
40
  data: signedDataItem,
36
41
  headers: {
37
42
  'content-type': 'application/octet-stream',
43
+ 'content-length': `${fileSize}`,
38
44
  },
39
45
  });
40
46
  }
@@ -24,10 +24,18 @@ export class TurboNodeArweaveSigner {
24
24
  this.privateKey = privateKey;
25
25
  this.signer = new ArweaveSigner(this.privateKey);
26
26
  }
27
- signDataItem({ fileStreamFactory, }) {
27
+ async signDataItem({ fileStreamFactory, fileSizeFactory, }) {
28
28
  // TODO: replace with our own signer implementation
29
29
  const [stream1, stream2] = [fileStreamFactory(), fileStreamFactory()];
30
- return streamSigner(stream1, stream2, this.signer);
30
+ const signedDataItem = await streamSigner(stream1, stream2, this.signer);
31
+ // TODO: support target, anchor, and tags
32
+ const signedDataItemSize = this.calculateSignedDataHeadersSize({
33
+ dataSize: fileSizeFactory(),
34
+ });
35
+ return {
36
+ dataItemStreamFactory: () => signedDataItem,
37
+ dataItemSizeFactory: () => signedDataItemSize,
38
+ };
31
39
  }
32
40
  // NOTE: this might be better in a parent class or elsewhere - easy enough to leave in here now and does require specific environment version of crypto
33
41
  async generateSignedRequestHeaders() {
@@ -40,4 +48,27 @@ export class TurboNodeArweaveSigner {
40
48
  'x-signature': toB64Url(Buffer.from(signature)),
41
49
  };
42
50
  }
51
+ // TODO: make dynamic that accepts anchor and target and tags to return the size of the headers + data
52
+ // reference https://github.com/ArweaveTeam/arweave-standards/blob/master/ans/ANS-104.md#13-dataitem-format
53
+ calculateSignedDataHeadersSize({ dataSize }) {
54
+ const anchor = 1; // + whatever they provide (max of 33)
55
+ const target = 1; // + whatever they provide (max of 33)
56
+ const tags = 0;
57
+ const signatureLength = 512;
58
+ const ownerLength = 512;
59
+ const signatureTypeLength = 2;
60
+ const numOfTagsLength = 8; // https://github.com/Bundlr-Network/arbundles/blob/master/src/tags.ts#L191-L198
61
+ const numOfTagsBytesLength = 8;
62
+ return [
63
+ anchor,
64
+ target,
65
+ tags,
66
+ signatureLength,
67
+ ownerLength,
68
+ signatureTypeLength,
69
+ numOfTagsLength,
70
+ numOfTagsBytesLength,
71
+ dataSize,
72
+ ].reduce((totalSize, currentSize) => (totalSize += currentSize));
73
+ }
43
74
  }
@@ -1,13 +1,15 @@
1
- export async function readableStreamToBuffer({ stream, }) {
1
+ export async function readableStreamToBuffer({ stream, size, }) {
2
2
  const reader = stream.getReader();
3
- const chunks = [];
3
+ const buffer = Buffer.alloc(size);
4
+ let offset = 0;
4
5
  let done = false;
5
6
  while (!done) {
6
7
  const { done: streamDone, value } = await reader.read();
7
8
  done = streamDone;
8
9
  if (!done) {
9
- chunks.push(value);
10
+ buffer.set(value, offset);
11
+ offset += value.byteLength;
10
12
  }
11
13
  }
12
- return Buffer.concat(chunks);
14
+ return buffer;
13
15
  }
@@ -24,15 +24,20 @@ export class TurboWebArweaveSigner {
24
24
  this.privateKey = privateKey;
25
25
  this.signer = new ArweaveSigner(this.privateKey);
26
26
  }
27
- async signDataItem({ fileStreamFactory, }) {
27
+ async signDataItem({ fileStreamFactory, fileSizeFactory, }) {
28
28
  // TODO: converts the readable stream to a buffer bc incrementally signing ReadableStreams is not trivial
29
29
  const buffer = await readableStreamToBuffer({
30
30
  stream: fileStreamFactory(),
31
- // TODO: add payload size to get performance improvements
31
+ size: fileSizeFactory(),
32
32
  });
33
- const signedDataItem = createData(buffer, this.signer);
33
+ // TODO: support target, anchor and tags for upload
34
+ const signedDataItem = createData(buffer, this.signer, {});
34
35
  await signedDataItem.sign(this.signer);
35
- return signedDataItem.getRaw();
36
+ return {
37
+ // while this returns a Buffer - it needs to match our return type for uploading
38
+ dataItemStreamFactory: () => signedDataItem.getRaw(),
39
+ dataItemSizeFactory: () => signedDataItem.getRaw().length,
40
+ };
36
41
  }
37
42
  // NOTE: this might be better in a parent class or elsewhere - easy enough to leave in here now and does require specific environment version of crypto
38
43
  async generateSignedRequestHeaders() {
@@ -56,7 +56,7 @@ export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedC
56
56
  /**
57
57
  * Uploads a signed data item to the Turbo Upload Service.
58
58
  */
59
- uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
59
+ uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
60
60
  }
61
61
  export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient implements TurboAuthenticatedClientInterface {
62
62
  protected paymentService: TurboAuthenticatedPaymentServiceInterface;
@@ -69,6 +69,6 @@ export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient
69
69
  /**
70
70
  * Signs and uploads raw data to the Turbo Upload Service.
71
71
  */
72
- uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
72
+ uploadFile({ fileStreamFactory, fileSizeFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
73
73
  }
74
74
  //# sourceMappingURL=turbo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"turbo.d.ts","sourceRoot":"","sources":["../../../src/common/turbo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,iCAAiC,EACjC,yCAAyC,EACzC,wCAAwC,EACxC,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,+BAA+B,EAC/B,8BAA8B,EAC9B,kBAAkB,EAClB,0BAA0B,EAC1B,mCAAmC,EACnC,2CAA2C,EAC3C,0CAA0C,EAC1C,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAIrB,qBAAa,0BACX,YAAW,mCAAmC;IAE9C,SAAS,CAAC,cAAc,EAAE,2CAA2C,CAAC;IACtE,SAAS,CAAC,aAAa,EAAE,0CAA0C,CAAC;gBAExD,EACV,aAAyD,EACzD,cAA2D,GAC5D,EAAE,8BAA8B;IAKjC;;OAEG;IACG,WAAW,CAAC,EAChB,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIlC;;;;;OAKG;IACG,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAIjD;;OAEG;IACG,qBAAqB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAI9D;;OAEG;IACG,sBAAsB,IAA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OAAO,CAAC,oBAAoB,CAAC;IAIjD;;OAEG;IACG,UAAU,CAAC,EACf,iBAAiB,EACjB,eAAe,EACf,MAAM,GACP,EAAE,gBAAgB,GACjB,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAO1D"}
@@ -19,11 +19,11 @@ import { TurboHTTPService } from './http.js';
19
19
  export declare class TurboUnauthenticatedUploadService implements TurboUnauthenticatedUploadServiceInterface {
20
20
  protected httpService: TurboHTTPService;
21
21
  constructor({ url, retryConfig, }: TurboUnauthenticatedUploadServiceInterfaceConfiguration);
22
- uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
22
+ uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
23
23
  }
24
24
  export declare class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadService implements TurboAuthenticatedUploadServiceInterface {
25
25
  protected signer: TurboWalletSigner;
26
26
  constructor({ url, retryConfig, signer, }: TurboAuthenticatedUploadServiceConfiguration);
27
- uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
27
+ uploadFile({ fileStreamFactory, fileSizeFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
28
28
  }
29
29
  //# sourceMappingURL=upload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"upload.d.ts","sourceRoot":"","sources":["../../../src/common/upload.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,gBAAgB,EAChB,4CAA4C,EAC5C,wCAAwC,EACxC,gBAAgB,EAChB,0BAA0B,EAC1B,0CAA0C,EAC1C,uDAAuD,EACvD,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,M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ExB,EACV,GAAkC,EAClC,WAAW,EACX,MAAM,GACP,EAAE,4CAA4C;IAKzC,UAAU,CAAC,EACf,iBAAiB,EACjB,eAAe,EACf,MAAM,GACP,EAAE,gBAAgB,GACjB,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAmB1D"}
@@ -18,20 +18,25 @@
18
18
  import { ArweaveSigner } from 'arbundles';
19
19
  import { Readable } from 'node:stream';
20
20
  import { JWKInterface } from '../common/jwk.js';
21
- import { TurboWalletSigner } from '../types.js';
21
+ import { StreamSizeFactory, TurboWalletSigner } from '../types.js';
22
22
  export declare class TurboNodeArweaveSigner implements TurboWalletSigner {
23
23
  protected privateKey: JWKInterface;
24
24
  protected signer: ArweaveSigner;
25
25
  constructor({ privateKey }: {
26
26
  privateKey: JWKInterface;
27
27
  });
28
- signDataItem({ fileStreamFactory, }: {
28
+ signDataItem({ fileStreamFactory, fileSizeFactory, }: {
29
29
  fileStreamFactory: () => Readable;
30
- }): Promise<Readable>;
30
+ fileSizeFactory: StreamSizeFactory;
31
+ }): Promise<{
32
+ dataItemStreamFactory: () => Readable;
33
+ dataItemSizeFactory: StreamSizeFactory;
34
+ }>;
31
35
  generateSignedRequestHeaders(): Promise<{
32
36
  'x-public-key': string;
33
37
  'x-nonce': string;
34
38
  'x-signature': string;
35
39
  }>;
40
+ private calculateSignedDataHeadersSize;
36
41
  }
37
42
  //# sourceMappingURL=signer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/node/signer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAgB,MAAM,WAAW,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;gBAGpB,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,YAAY,CAAA;KAAE;IAKxD,YAAY,CAAC,EACX,iBAAiB,GAClB,EAAE;QACD,iBAAiB,EAAE,MAAM,QAAQ,CAAC;KACnC,GAAG,OAAO,CAAC,QAAQ,CAAC;IAOf,4BAA4B;;;;;CAWnC"}
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/node/signer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAgB,MAAM,WAAW,CAAC;AAGxD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGnE,qBAAa,sBAAuB,YAAW,iBAAiB;IAC9D,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;gBAGpB,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,YAAY,CAAA;KAAE;IAKlD,YAAY,CAAC,EACjB,iBAAiB,EACjB,eAAe,GAChB,EAAE;QACD,iBAAiB,EAAE,MAAM,QAAQ,CAAC;QAClC,eAAe,EAAE,iBAAiB,CAAC;KACpC,GAAG,OAAO,CAAC;QACV,qBAAqB,EAAE,MAAM,QAAQ,CAAC;QACtC,mBAAmB,EAAE,iBAAiB,CAAC;KACxC,CAAC;IAeI,4BAA4B;;;;;IAclC,OAAO,CAAC,8BAA8B;CAqBvC"}
@@ -90,11 +90,14 @@ export type TurboPrivateClientConfiguration = {
90
90
  };
91
91
  export type FileStreamFactory = (() => Readable) | (() => ReadableStream) | (() => Buffer);
92
92
  export type SignedDataStreamFactory = FileStreamFactory;
93
+ export type StreamSizeFactory = () => number;
93
94
  export type TurboFileFactory = {
94
95
  fileStreamFactory: FileStreamFactory;
96
+ fileSizeFactory: StreamSizeFactory;
95
97
  };
96
98
  export type TurboSignedDataItemFactory = {
97
99
  dataItemStreamFactory: SignedDataStreamFactory;
100
+ dataItemSizeFactory: StreamSizeFactory;
98
101
  };
99
102
  export type TurboAbortSignal = {
100
103
  signal?: AbortSignal;
@@ -115,7 +118,7 @@ export interface TurboHTTPServiceInterface {
115
118
  }): Promise<T>;
116
119
  }
117
120
  export interface TurboWalletSigner {
118
- signDataItem({ fileStreamFactory, }: TurboFileFactory): Promise<Readable> | Promise<Buffer>;
121
+ signDataItem({ fileStreamFactory, fileSizeFactory, }: TurboFileFactory): Promise<TurboSignedDataItemFactory>;
119
122
  generateSignedRequestHeaders(): Promise<TurboSignedRequestHeaders>;
120
123
  }
121
124
  export interface TurboUnauthenticatedPaymentServiceInterface {
@@ -140,7 +143,7 @@ export interface TurboUnauthenticatedUploadServiceInterface {
140
143
  uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
141
144
  }
142
145
  export interface TurboAuthenticatedUploadServiceInterface extends TurboUnauthenticatedUploadServiceInterface {
143
- uploadFile({ fileStreamFactory, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
146
+ uploadFile({ fileStreamFactory, fileSizeFactory, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
144
147
  }
145
148
  export interface TurboUnauthenticatedClientInterface extends TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface {
146
149
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO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AAC;IACrD,cAAc,CAAC,EAAE,KAAK,EAAE,EAAE;QAAE,KAAK,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,yCACf,SAAQ,2CAA2C;IACnD,UAAU,EAAE,MAAM,OAAO,CAAC,oBAAoB,CAAC,CAAC;CACjD;AAED,MAAM,WAAW,0CAA0C;IACzD,oBAAoB,CAAC,EACnB,qBAAqB,EACrB,MAAM,GACP,EAAE,0BAA0B,GAC3B,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;CAC3D;AAED,MAAM,WAAW,wCACf,SAAQ,0CAA0C;IAElD,UAAU,CAAC,EACT,iBAAiB,EACjB,eAAe,GAChB,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;CAC/E;AAED,MAAM,WAAW,mCACf,SAAQ,2CAA2C,EACjD,0CAA0C;CAAG;AACjD,MAAM,WAAW,iCACf,SAAQ,yCAAyC,EAC/C,wCAAwC;CAAG"}
@@ -17,7 +17,8 @@
17
17
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
  */
19
19
  import { ReadableStream } from 'node:stream/web';
20
- export declare function readableStreamToBuffer({ stream, }: {
20
+ export declare function readableStreamToBuffer({ stream, size, }: {
21
21
  stream: ReadableStream;
22
+ size: number;
22
23
  }): Promise<Buffer>;
23
24
  //# sourceMappingURL=readableStream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"readableStream.d.ts","sourceRoot":"","sources":["../../../src/utils/readableStream.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,wBAAsB,sBAAsB,CAAC,EAC3C,MAAM,GACP,EAAE;IACD,MAAM,EAAE,cAAc,CAAC;CACxB,GAAG,OAAO,CAAC,MAAM,CAAC,CAalB"}
1
+ {"version":3,"file":"readableStream.d.ts","sourceRoot":"","sources":["../../../src/utils/readableStream.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,wBAAsB,sBAAsB,CAAC,EAC3C,MAAM,EACN,IAAI,GACL,EAAE;IACD,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAelB"}
@@ -19,16 +19,20 @@
19
19
  import { ArweaveSigner } from 'arbundles';
20
20
  import { ReadableStream } from 'node:stream/web';
21
21
  import { JWKInterface } from '../common/jwk.js';
22
- import { TurboWalletSigner } from '../types.js';
22
+ import { StreamSizeFactory, TurboWalletSigner } from '../types.js';
23
23
  export declare class TurboWebArweaveSigner implements TurboWalletSigner {
24
24
  protected privateKey: JWKInterface;
25
25
  protected signer: ArweaveSigner;
26
26
  constructor({ privateKey }: {
27
27
  privateKey: JWKInterface;
28
28
  });
29
- signDataItem({ fileStreamFactory, }: {
29
+ signDataItem({ fileStreamFactory, fileSizeFactory, }: {
30
30
  fileStreamFactory: () => ReadableStream;
31
- }): Promise<Buffer>;
31
+ fileSizeFactory: StreamSizeFactory;
32
+ }): Promise<{
33
+ dataItemStreamFactory: () => Buffer;
34
+ dataItemSizeFactory: StreamSizeFactory;
35
+ }>;
32
36
  generateSignedRequestHeaders(): Promise<{
33
37
  'x-public-key': string;
34
38
  'x-nonce': string;
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/web/signer.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAc,MAAM,WAAW,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;gBAEpB,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,YAAY,CAAA;KAAE;IAKlD,YAAY,CAAC,EACjB,iBAAiB,GAClB,EAAE;QACD,iBAAiB,EAAE,MAAM,cAAc,CAAC;KACzC,GAAG,OAAO,CAAC,MAAM,CAAC;IAYb,4BAA4B;;;;;CAanC"}
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/web/signer.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAc,MAAM,WAAW,CAAC;AAGtD,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAInE,qBAAa,qBAAsB,YAAW,iBAAiB;IAC7D,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,aAAa,CAAC;gBAEpB,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,YAAY,CAAA;KAAE;IAKlD,YAAY,CAAC,EACjB,iBAAiB,EACjB,eAAe,GAChB,EAAE;QACD,iBAAiB,EAAE,MAAM,cAAc,CAAC;QACxC,eAAe,EAAE,iBAAiB,CAAC;KACpC,GAAG,OAAO,CAAC;QAEV,qBAAqB,EAAE,MAAM,MAAM,CAAC;QACpC,mBAAmB,EAAE,iBAAiB,CAAC;KACxC,CAAC;IAiBI,4BAA4B;;;;;CAanC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.0.0-alpha.21",
3
+ "version": "1.0.0-alpha.22",
4
4
  "main": "./lib/cjs/node/index.js",
5
5
  "types": "./lib/types/node/index.d.ts",
6
6
  "module": "./lib/esm/node/index.js",