@ardrive/turbo-sdk 1.0.0-alpha.9 → 1.0.0-beta.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.
Files changed (98) hide show
  1. package/README.md +169 -28
  2. package/bundles/web.bundle.min.js +55776 -0
  3. package/lib/cjs/common/currency.js +42 -0
  4. package/lib/cjs/common/factory.js +6 -2
  5. package/lib/cjs/common/http.js +16 -29
  6. package/lib/cjs/common/index.js +1 -0
  7. package/lib/cjs/common/payment.js +56 -47
  8. package/lib/cjs/common/turbo.js +24 -40
  9. package/lib/cjs/common/upload.js +27 -34
  10. package/lib/cjs/node/factory.js +8 -2
  11. package/lib/cjs/node/index.js +1 -1
  12. package/lib/cjs/node/signer.js +42 -22
  13. package/lib/cjs/package.json +1 -0
  14. package/lib/cjs/utils/axiosClient.js +18 -9
  15. package/lib/cjs/utils/readableStream.js +13 -22
  16. package/lib/cjs/web/factory.js +8 -2
  17. package/lib/cjs/web/index.js +1 -1
  18. package/lib/cjs/web/signer.js +24 -31
  19. package/lib/esm/common/currency.js +27 -0
  20. package/lib/esm/common/factory.js +6 -2
  21. package/lib/esm/common/http.js +16 -29
  22. package/lib/esm/common/index.js +1 -0
  23. package/lib/esm/common/payment.js +56 -47
  24. package/lib/esm/common/turbo.js +24 -40
  25. package/lib/esm/common/upload.js +27 -34
  26. package/lib/esm/node/factory.js +8 -2
  27. package/lib/esm/node/index.js +1 -1
  28. package/lib/esm/node/signer.js +42 -22
  29. package/lib/esm/utils/axiosClient.js +18 -9
  30. package/lib/esm/utils/readableStream.js +13 -22
  31. package/lib/esm/web/factory.js +8 -2
  32. package/lib/esm/web/index.js +1 -1
  33. package/lib/esm/web/signer.js +24 -31
  34. package/lib/types/common/currency.d.ts +43 -0
  35. package/lib/types/common/currency.d.ts.map +1 -0
  36. package/lib/{cjs → types}/common/factory.d.ts +2 -1
  37. package/lib/types/common/factory.d.ts.map +1 -0
  38. package/lib/{cjs → types}/common/http.d.ts +4 -3
  39. package/lib/types/common/http.d.ts.map +1 -0
  40. package/lib/{esm → types}/common/index.d.ts +2 -0
  41. package/lib/types/common/index.d.ts.map +1 -0
  42. package/lib/{esm/types/arweave.d.ts → types/common/jwk.d.ts} +1 -0
  43. package/lib/types/common/jwk.d.ts.map +1 -0
  44. package/lib/{esm → types}/common/payment.d.ts +14 -6
  45. package/lib/types/common/payment.d.ts.map +1 -0
  46. package/lib/{cjs → types}/common/turbo.d.ts +13 -11
  47. package/lib/types/common/turbo.d.ts.map +1 -0
  48. package/lib/{esm → types}/common/upload.d.ts +4 -4
  49. package/lib/types/common/upload.d.ts.map +1 -0
  50. package/lib/{esm → types}/node/factory.d.ts +2 -1
  51. package/lib/types/node/factory.d.ts.map +1 -0
  52. package/lib/{esm → types}/node/index.d.ts +2 -1
  53. package/lib/types/node/index.d.ts.map +1 -0
  54. package/lib/{cjs → types}/node/signer.d.ts +10 -4
  55. package/lib/types/node/signer.d.ts.map +1 -0
  56. package/lib/{cjs/types/turbo.d.ts → types/types.d.ts} +46 -11
  57. package/lib/types/types.d.ts.map +1 -0
  58. package/lib/{esm → types}/utils/axiosClient.d.ts +3 -2
  59. package/lib/types/utils/axiosClient.d.ts.map +1 -0
  60. package/lib/{cjs → types}/utils/base64.d.ts +3 -2
  61. package/lib/types/utils/base64.d.ts.map +1 -0
  62. package/lib/{esm → types}/utils/errors.d.ts +1 -0
  63. package/lib/types/utils/errors.d.ts.map +1 -0
  64. package/lib/{cjs → types}/utils/readableStream.d.ts +3 -1
  65. package/lib/types/utils/readableStream.d.ts.map +1 -0
  66. package/lib/{cjs → types}/web/factory.d.ts +2 -1
  67. package/lib/types/web/factory.d.ts.map +1 -0
  68. package/lib/{cjs → types}/web/index.d.ts +2 -1
  69. package/lib/types/web/index.d.ts.map +1 -0
  70. package/lib/{cjs → types}/web/signer.d.ts +9 -4
  71. package/lib/types/web/signer.d.ts.map +1 -0
  72. package/package.json +13 -15
  73. package/lib/cjs/common/index.d.ts +0 -19
  74. package/lib/cjs/common/payment.d.ts +0 -41
  75. package/lib/cjs/common/upload.d.ts +0 -29
  76. package/lib/cjs/node/factory.d.ts +0 -22
  77. package/lib/cjs/node/index.d.ts +0 -20
  78. package/lib/cjs/types/arweave.d.ts +0 -29
  79. package/lib/cjs/types/index.d.ts +0 -18
  80. package/lib/cjs/types/index.js +0 -34
  81. package/lib/cjs/utils/axiosClient.d.ts +0 -23
  82. package/lib/cjs/utils/errors.d.ts +0 -22
  83. package/lib/esm/common/factory.d.ts +0 -21
  84. package/lib/esm/common/http.d.ts +0 -44
  85. package/lib/esm/common/turbo.d.ts +0 -73
  86. package/lib/esm/node/signer.d.ts +0 -36
  87. package/lib/esm/types/index.d.ts +0 -18
  88. package/lib/esm/types/index.js +0 -18
  89. package/lib/esm/types/turbo.d.ts +0 -149
  90. package/lib/esm/utils/base64.d.ts +0 -9
  91. package/lib/esm/utils/readableStream.d.ts +0 -22
  92. package/lib/esm/web/factory.d.ts +0 -22
  93. package/lib/esm/web/index.d.ts +0 -20
  94. package/lib/esm/web/signer.d.ts +0 -37
  95. /package/lib/cjs/{types/arweave.js → common/jwk.js} +0 -0
  96. /package/lib/cjs/{types/turbo.js → types.js} +0 -0
  97. /package/lib/esm/{types/arweave.js → common/jwk.js} +0 -0
  98. /package/lib/esm/{types/turbo.js → types.js} +0 -0
@@ -15,9 +15,10 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  import { AxiosInstance, AxiosRequestConfig } from 'axios';
18
- import * as rax from 'retry-axios';
18
+ import { IAxiosRetryConfig } from 'axios-retry';
19
19
  export interface AxiosInstanceParameters {
20
20
  axiosConfig?: Omit<AxiosRequestConfig, 'validateStatus'>;
21
- retryConfig?: rax.RetryConfig;
21
+ retryConfig?: IAxiosRetryConfig;
22
22
  }
23
23
  export declare const createAxiosInstance: ({ axiosConfig, retryConfig, }: AxiosInstanceParameters) => AxiosInstance;
24
+ //# sourceMappingURL=axiosClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axiosClient.d.ts","sourceRoot":"","sources":["../../../src/utils/axiosClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAc,EAAE,aAAa,EAAE,kBAAkB,EAAiB,MAAM,OAAO,CAAC;AAChF,OAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAE5D,MAAM,WAAW,uBAAuB;IACtC,WAAW,CAAC,EAAE,IAAI,CAAC,kBAAkB,EAAE,gBAAgB,CAAC,CAAC;IACzD,WAAW,CAAC,EAAE,iBAAiB,CAAC;CACjC;AAED,eAAO,MAAM,mBAAmB,kCAiB7B,uBAAuB,KAAG,aAU5B,CAAC"}
@@ -1,9 +1,10 @@
1
1
  /// <reference types="node" />
2
- import { JWKInterface } from '../types/index.js';
3
- import { Base64String, PublicArweaveAddress } from '../types/index.js';
2
+ import { JWKInterface } from '../common/jwk.js';
3
+ import { Base64String, PublicArweaveAddress } from '../types.js';
4
4
  export declare const base64URLRegex: RegExp;
5
5
  export declare function jwkToPublicArweaveAddress(jwk: JWKInterface): PublicArweaveAddress;
6
6
  export declare function ownerToAddress(owner: Base64String): PublicArweaveAddress;
7
7
  export declare function fromB64Url(input: Base64String): Buffer;
8
8
  export declare function toB64Url(buffer: Buffer): Base64String;
9
9
  export declare function sha256B64Url(input: Buffer): Base64String;
10
+ //# sourceMappingURL=base64.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base64.d.ts","sourceRoot":"","sources":["../../../src/utils/base64.ts"],"names":[],"mappings":";AAmBA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEjE,eAAO,MAAM,cAAc,QAAwB,CAAC;AAEpD,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,YAAY,GAChB,oBAAoB,CAEtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,GAAG,oBAAoB,CAExE;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,CAStD;AAED,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,CAErD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAExD"}
@@ -20,3 +20,4 @@ export declare class UnauthenticatedRequestError extends Error {
20
20
  export declare class FailedRequestError extends Error {
21
21
  constructor(status: number, message: string);
22
22
  }
23
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/utils/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;;CAKrD;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI5C"}
@@ -17,6 +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>;
24
+ //# sourceMappingURL=readableStream.d.ts.map
@@ -0,0 +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,EACN,IAAI,GACL,EAAE;IACD,MAAM,EAAE,cAAc,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,OAAO,CAAC,MAAM,CAAC,CAelB"}
@@ -16,7 +16,8 @@
16
16
  */
17
17
  import { TurboBaseFactory } from '../common/factory.js';
18
18
  import { TurboAuthenticatedClient } from '../common/index.js';
19
- import { TurboPrivateConfiguration } from '../types/index.js';
19
+ import { TurboPrivateConfiguration } from '../types.js';
20
20
  export declare class TurboFactory extends TurboBaseFactory {
21
21
  static authenticated({ privateKey, paymentServiceConfig, uploadServiceConfig, }: TurboPrivateConfiguration): TurboAuthenticatedClient;
22
22
  }
23
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/web/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,wBAAwB,EAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAGxD,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,MAAM,CAAC,aAAa,CAAC,EACnB,UAAU,EACV,oBAAyB,EACzB,mBAAwB,GACzB,EAAE,yBAAyB;CAe7B"}
@@ -17,4 +17,5 @@
17
17
  export * from './factory.js';
18
18
  export * from './signer.js';
19
19
  export * from '../common/index.js';
20
- export * from '../types/index.js';
20
+ export * from '../types.js';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC;AACnC,cAAc,aAAa,CAAC"}
@@ -18,20 +18,25 @@
18
18
  */
19
19
  import { ArweaveSigner } from 'arbundles';
20
20
  import { ReadableStream } from 'node:stream/web';
21
- import { JWKInterface } from '../types/arweave.js';
22
- import { TurboWalletSigner } from '../types/turbo.js';
21
+ import { JWKInterface } from '../common/jwk.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;
35
39
  'x-signature': string;
36
40
  }>;
37
41
  }
42
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +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,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,11 +1,11 @@
1
1
  {
2
2
  "name": "@ardrive/turbo-sdk",
3
- "version": "1.0.0-alpha.9",
4
- "type": "module",
3
+ "version": "1.0.0-beta.2",
5
4
  "main": "./lib/cjs/node/index.js",
6
- "types": "./lib/cjs/node/types/index.d.ts",
5
+ "types": "./lib/types/node/index.d.ts",
7
6
  "module": "./lib/esm/node/index.js",
8
7
  "browser": "./bundles/web.bundle.min.js",
8
+ "type": "module",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "https://github.com/ardriveapp/turbo-sdk.git"
@@ -25,23 +25,18 @@
25
25
  ".": {
26
26
  "import": "./lib/esm/node/index.js",
27
27
  "require": "./lib/cjs/node/index.js",
28
- "types": "./lib/node/index.d.ts"
28
+ "types": "./lib/types/node/index.d.ts"
29
29
  },
30
30
  "./node": {
31
31
  "import": "./lib/esm/node/index.js",
32
32
  "require": "./lib/cjs/node/index.js",
33
- "types": "./lib/node/index.d.ts"
33
+ "types": "./lib/types/node/index.d.ts"
34
34
  },
35
35
  "./web": {
36
36
  "import": "./lib/web/index.js",
37
37
  "require": "./lib/web/index.js",
38
- "types": "./lib/web/index.d.ts",
38
+ "types": "./lib/types/web/index.d.ts",
39
39
  "browser": "./bundles/web.bundle.min.js"
40
- },
41
- "./*": {
42
- "import": "./*.js",
43
- "require": "./*.js",
44
- "types": "./lib/web/index.d.ts"
45
40
  }
46
41
  },
47
42
  "engines": {
@@ -50,7 +45,10 @@
50
45
  "license": "AGPL-3.0-or-later",
51
46
  "scripts": {
52
47
  "build:web": "node bundle.cjs",
53
- "build": "yarn clean && yarn tsc -p tsconfig.json && yarn tsc -p tsconfig.cjs.json",
48
+ "build:esm": "yarn tsc -p tsconfig.json",
49
+ "build:cjs": "yarn tsc -p tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > lib/cjs/package.json",
50
+ "build:types": "yarn tsc -p tsconfig.types.json",
51
+ "build": "yarn clean && yarn build:web && yarn build:esm && yarn build:cjs && yarn build:types",
54
52
  "clean": "rimraf [ lib coverage bundles ]",
55
53
  "lint": "eslint src",
56
54
  "lint:fix": "eslint src --fix",
@@ -60,15 +58,15 @@
60
58
  "test:web": "c8 mocha --config .mocharc --exclude tests/**/*.node.test.ts --exit",
61
59
  "test:node": "c8 mocha --config .mocharc --exclude tests/**/*.web.test.ts --exit",
62
60
  "prepare": "husky install",
63
- "example:mjs": "yarn build:esm && node examples/node/index.mjs",
64
- "example:cjs": "yarn build:esm && node examples/node/index.cjs",
61
+ "example:mjs": "cd examples/mjs && yarn && node index.mjs",
62
+ "example:cjs": "cd examples/cjs && yarn && node index.cjs",
65
63
  "example:web": "yarn build:web && cp -r bundles/* examples/web && http-server --port 8080 --host -o examples/web"
66
64
  },
67
65
  "dependencies": {
68
66
  "arbundles": "^0.9.9",
69
67
  "arweave": "^1.14.4",
70
68
  "axios": "^1.4.0",
71
- "retry-axios": "^3.0.0",
69
+ "axios-retry": "^3.7.0",
72
70
  "winston": "^3.10.0"
73
71
  },
74
72
  "devDependencies": {
@@ -1,19 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- export * from './upload.js';
18
- export * from './payment.js';
19
- export * from './turbo.js';
@@ -1,41 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import { Currency, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedPaymentServiceInterfaceConfiguration, TurboBalanceResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboPriceResponse, TurboRatesResponse, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedPaymentServiceInterfaceConfiguration, TurboWalletSigner } from '../types/turbo.js';
18
- import { TurboHTTPService } from './http.js';
19
- export declare class TurboUnauthenticatedPaymentService implements TurboUnauthenticatedPaymentServiceInterface {
20
- protected readonly httpService: TurboHTTPService;
21
- constructor({ url, retryConfig, }: TurboUnauthenticatedPaymentServiceInterfaceConfiguration);
22
- getFiatRates(): Promise<TurboRatesResponse>;
23
- getFiatToAR({ currency, }: {
24
- currency: Currency;
25
- }): Promise<TurboFiatToArResponse>;
26
- getSupportedCountries(): Promise<TurboCountriesResponse>;
27
- getSupportedCurrencies(): Promise<TurboCurrenciesResponse>;
28
- getUploadCosts({ bytes, }: {
29
- bytes: number[];
30
- }): Promise<TurboPriceResponse[]>;
31
- getWincForFiat({ amount, currency }: {
32
- amount: any;
33
- currency: any;
34
- }): Promise<TurboPriceResponse>;
35
- }
36
- export declare class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService implements TurboAuthenticatedPaymentServiceInterface {
37
- protected readonly httpService: TurboHTTPService;
38
- protected readonly signer: TurboWalletSigner;
39
- constructor({ url, retryConfig, signer, }: TurboAuthenticatedPaymentServiceInterfaceConfiguration);
40
- getBalance(): Promise<TurboBalanceResponse>;
41
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import { TurboAbortSignal, TurboAuthenticatedUploadServiceConfiguration, TurboAuthenticatedUploadServiceInterface, TurboFileFactory, TurboSignedDataItemFactory, TurboUnauthenticatedUploadServiceInterface, TurboUnauthenticatedUploadServiceInterfaceConfiguration, TurboUploadDataItemResponse, TurboWalletSigner } from '../types/turbo.js';
18
- import { TurboHTTPService } from './http.js';
19
- export declare class TurboUnauthenticatedUploadService implements TurboUnauthenticatedUploadServiceInterface {
20
- protected httpService: TurboHTTPService;
21
- constructor({ url, retryConfig, }: TurboUnauthenticatedUploadServiceInterfaceConfiguration);
22
- uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
23
- }
24
- export declare class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadService implements TurboAuthenticatedUploadServiceInterface {
25
- protected httpService: TurboHTTPService;
26
- protected signer: TurboWalletSigner;
27
- constructor({ url, retryConfig, signer, }: TurboAuthenticatedUploadServiceConfiguration);
28
- uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
29
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import { TurboBaseFactory } from '../common/factory.js';
18
- import { TurboAuthenticatedClient } from '../common/index.js';
19
- import { TurboPrivateConfiguration } from '../types/index.js';
20
- export declare class TurboFactory extends TurboBaseFactory {
21
- static authenticated({ privateKey, paymentServiceConfig, uploadServiceConfig, }: TurboPrivateConfiguration): TurboAuthenticatedClient;
22
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- export * from './factory.js';
18
- export * from './signer.js';
19
- export * from '../common/index.js';
20
- export * from '../types/index.js';
@@ -1,29 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- export interface JWKPublicInterface {
18
- kty: string;
19
- e: string;
20
- n: string;
21
- }
22
- export interface JWKInterface extends JWKPublicInterface {
23
- d?: string;
24
- p?: string;
25
- q?: string;
26
- dp?: string;
27
- dq?: string;
28
- qi?: string;
29
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- export * from './arweave.js';
18
- export * from './turbo.js';
@@ -1,34 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- /**
18
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
19
- *
20
- * This program is free software: you can redistribute it and/or modify
21
- * it under the terms of the GNU Affero General Public License as published by
22
- * the Free Software Foundation, either version 3 of the License, or
23
- * (at your option) any later version.
24
- *
25
- * This program is distributed in the hope that it will be useful,
26
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28
- * GNU Affero General Public License for more details.
29
- *
30
- * You should have received a copy of the GNU Affero General Public License
31
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
32
- */
33
- __exportStar(require("./arweave.js"), exports);
34
- __exportStar(require("./turbo.js"), exports);
@@ -1,23 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import { AxiosInstance, AxiosRequestConfig } from 'axios';
18
- import * as rax from 'retry-axios';
19
- export interface AxiosInstanceParameters {
20
- axiosConfig?: Omit<AxiosRequestConfig, 'validateStatus'>;
21
- retryConfig?: rax.RetryConfig;
22
- }
23
- export declare const createAxiosInstance: ({ axiosConfig, retryConfig, }: AxiosInstanceParameters) => AxiosInstance;
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- export declare class UnauthenticatedRequestError extends Error {
18
- constructor();
19
- }
20
- export declare class FailedRequestError extends Error {
21
- constructor(status: number, message: string);
22
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import { TurboPublicConfiguration } from '../types/turbo.js';
18
- import { TurboUnauthenticatedClient } from './turbo.js';
19
- export declare class TurboBaseFactory {
20
- static unauthenticated({ paymentServiceConfig, uploadServiceConfig, }?: TurboPublicConfiguration): TurboUnauthenticatedClient;
21
- }
@@ -1,44 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- /// <reference types="node" resolution-mode="require"/>
4
- /**
5
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Affero General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Affero General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Affero General Public License
18
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- */
20
- import { AxiosInstance } from 'axios';
21
- import { RetryConfig } from 'retry-axios';
22
- import { Readable } from 'stream';
23
- import { ReadableStream } from 'stream/web';
24
- import { TurboHTTPServiceInterface, TurboSignedRequestHeaders } from '../types/turbo.js';
25
- export declare class TurboHTTPService implements TurboHTTPServiceInterface {
26
- protected axios: AxiosInstance;
27
- constructor({ url, retryConfig, }: {
28
- url: string;
29
- retryConfig?: RetryConfig;
30
- });
31
- get<T>({ endpoint, signal, allowedStatuses, headers, }: {
32
- endpoint: string;
33
- signal?: AbortSignal;
34
- allowedStatuses?: number[];
35
- headers?: Partial<TurboSignedRequestHeaders> & Record<string, string>;
36
- }): Promise<T>;
37
- post<T>({ endpoint, signal, allowedStatuses, headers, data, }: {
38
- endpoint: string;
39
- signal?: AbortSignal;
40
- allowedStatuses?: number[];
41
- headers?: Partial<TurboSignedRequestHeaders> & Record<string, string>;
42
- data: Readable | Buffer | ReadableStream;
43
- }): Promise<T>;
44
- }
@@ -1,73 +0,0 @@
1
- /**
2
- * Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
3
- *
4
- * This program is free software: you can redistribute it and/or modify
5
- * it under the terms of the GNU Affero General Public License as published by
6
- * the Free Software Foundation, either version 3 of the License, or
7
- * (at your option) any later version.
8
- *
9
- * This program is distributed in the hope that it will be useful,
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
- * GNU Affero General Public License for more details.
13
- *
14
- * You should have received a copy of the GNU Affero General Public License
15
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
- */
17
- import { Currency, TurboAbortSignal, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboFileFactory, TurboPriceResponse, TurboPrivateClientConfiguration, TurboPublicClientConfiguration, TurboRatesResponse, TurboSignedDataItemFactory, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse } from '../types/index.js';
18
- export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedClientInterface {
19
- protected readonly paymentService: TurboUnauthenticatedPaymentServiceInterface;
20
- protected readonly uploadService: TurboUnauthenticatedUploadServiceInterface;
21
- constructor({ uploadService, paymentService, }: TurboPublicClientConfiguration);
22
- /**
23
- * Returns the supported fiat currency conversion rate for 1AR based on current market prices.
24
- */
25
- getFiatToAR({ currency, }: {
26
- currency: Currency;
27
- }): Promise<TurboFiatToArResponse>;
28
- /**
29
- * Returns the latest conversion rates to purchase 1GiB of data for all supported currencies, including all adjustments and fees.
30
- *
31
- * Note: this does not take into account varying adjustments and promotions for different sizes of data. If you want to calculate the total
32
- * cost in 'winc' for a given number of bytes, use getUploadCosts.
33
- */
34
- getFiatRates(): Promise<TurboRatesResponse>;
35
- /**
36
- * Returns a comprehensive list of supported countries that can purchase credits through the Turbo Payment Service.
37
- */
38
- getSupportedCountries(): Promise<TurboCountriesResponse>;
39
- /**
40
- * Returns a list of all supported fiat currencies.
41
- */
42
- getSupportedCurrencies(): Promise<TurboCurrenciesResponse>;
43
- /**
44
- * Determines the price in 'winc' to upload one data item of a specific size in bytes, including all Turbo cost adjustments and fees.
45
- */
46
- getUploadCosts({ bytes, }: {
47
- bytes: number[];
48
- }): Promise<TurboPriceResponse[]>;
49
- /**
50
- * Determines the amount of 'winc' that would be returned for a given currency and amount, including all Turbo cost adjustments and fees.
51
- */
52
- getWincForFiat({ amount, currency, }: {
53
- amount: number;
54
- currency: Currency;
55
- }): Promise<Omit<TurboPriceResponse, 'adjustments'>>;
56
- /**
57
- * Uploads a signed data item to the Turbo Upload Service.
58
- */
59
- uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
60
- }
61
- export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient implements TurboAuthenticatedClientInterface {
62
- protected readonly paymentService: TurboAuthenticatedPaymentServiceInterface;
63
- protected readonly uploadService: TurboAuthenticatedUploadServiceInterface;
64
- constructor({ paymentService, uploadService, }: TurboPrivateClientConfiguration);
65
- /**
66
- * Returns the current balance of the user's wallet in 'winc'.
67
- */
68
- getBalance(): Promise<TurboBalanceResponse>;
69
- /**
70
- * Signs and uploads raw data to the Turbo Upload Service.
71
- */
72
- uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
73
- }