@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.
- package/README.md +169 -28
- package/bundles/web.bundle.min.js +55776 -0
- package/lib/cjs/common/currency.js +42 -0
- package/lib/cjs/common/factory.js +6 -2
- package/lib/cjs/common/http.js +16 -29
- package/lib/cjs/common/index.js +1 -0
- package/lib/cjs/common/payment.js +56 -47
- package/lib/cjs/common/turbo.js +24 -40
- package/lib/cjs/common/upload.js +27 -34
- package/lib/cjs/node/factory.js +8 -2
- package/lib/cjs/node/index.js +1 -1
- package/lib/cjs/node/signer.js +42 -22
- package/lib/cjs/package.json +1 -0
- package/lib/cjs/utils/axiosClient.js +18 -9
- package/lib/cjs/utils/readableStream.js +13 -22
- package/lib/cjs/web/factory.js +8 -2
- package/lib/cjs/web/index.js +1 -1
- package/lib/cjs/web/signer.js +24 -31
- package/lib/esm/common/currency.js +27 -0
- package/lib/esm/common/factory.js +6 -2
- package/lib/esm/common/http.js +16 -29
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/payment.js +56 -47
- package/lib/esm/common/turbo.js +24 -40
- package/lib/esm/common/upload.js +27 -34
- package/lib/esm/node/factory.js +8 -2
- package/lib/esm/node/index.js +1 -1
- package/lib/esm/node/signer.js +42 -22
- package/lib/esm/utils/axiosClient.js +18 -9
- package/lib/esm/utils/readableStream.js +13 -22
- package/lib/esm/web/factory.js +8 -2
- package/lib/esm/web/index.js +1 -1
- package/lib/esm/web/signer.js +24 -31
- package/lib/types/common/currency.d.ts +43 -0
- package/lib/types/common/currency.d.ts.map +1 -0
- package/lib/{cjs → types}/common/factory.d.ts +2 -1
- package/lib/types/common/factory.d.ts.map +1 -0
- package/lib/{cjs → types}/common/http.d.ts +4 -3
- package/lib/types/common/http.d.ts.map +1 -0
- package/lib/{esm → types}/common/index.d.ts +2 -0
- package/lib/types/common/index.d.ts.map +1 -0
- package/lib/{esm/types/arweave.d.ts → types/common/jwk.d.ts} +1 -0
- package/lib/types/common/jwk.d.ts.map +1 -0
- package/lib/{esm → types}/common/payment.d.ts +14 -6
- package/lib/types/common/payment.d.ts.map +1 -0
- package/lib/{cjs → types}/common/turbo.d.ts +13 -11
- package/lib/types/common/turbo.d.ts.map +1 -0
- package/lib/{esm → types}/common/upload.d.ts +4 -4
- package/lib/types/common/upload.d.ts.map +1 -0
- package/lib/{esm → types}/node/factory.d.ts +2 -1
- package/lib/types/node/factory.d.ts.map +1 -0
- package/lib/{esm → types}/node/index.d.ts +2 -1
- package/lib/types/node/index.d.ts.map +1 -0
- package/lib/{cjs → types}/node/signer.d.ts +10 -4
- package/lib/types/node/signer.d.ts.map +1 -0
- package/lib/{cjs/types/turbo.d.ts → types/types.d.ts} +46 -11
- package/lib/types/types.d.ts.map +1 -0
- package/lib/{esm → types}/utils/axiosClient.d.ts +3 -2
- package/lib/types/utils/axiosClient.d.ts.map +1 -0
- package/lib/{cjs → types}/utils/base64.d.ts +3 -2
- package/lib/types/utils/base64.d.ts.map +1 -0
- package/lib/{esm → types}/utils/errors.d.ts +1 -0
- package/lib/types/utils/errors.d.ts.map +1 -0
- package/lib/{cjs → types}/utils/readableStream.d.ts +3 -1
- package/lib/types/utils/readableStream.d.ts.map +1 -0
- package/lib/{cjs → types}/web/factory.d.ts +2 -1
- package/lib/types/web/factory.d.ts.map +1 -0
- package/lib/{cjs → types}/web/index.d.ts +2 -1
- package/lib/types/web/index.d.ts.map +1 -0
- package/lib/{cjs → types}/web/signer.d.ts +9 -4
- package/lib/types/web/signer.d.ts.map +1 -0
- package/package.json +13 -15
- package/lib/cjs/common/index.d.ts +0 -19
- package/lib/cjs/common/payment.d.ts +0 -41
- package/lib/cjs/common/upload.d.ts +0 -29
- package/lib/cjs/node/factory.d.ts +0 -22
- package/lib/cjs/node/index.d.ts +0 -20
- package/lib/cjs/types/arweave.d.ts +0 -29
- package/lib/cjs/types/index.d.ts +0 -18
- package/lib/cjs/types/index.js +0 -34
- package/lib/cjs/utils/axiosClient.d.ts +0 -23
- package/lib/cjs/utils/errors.d.ts +0 -22
- package/lib/esm/common/factory.d.ts +0 -21
- package/lib/esm/common/http.d.ts +0 -44
- package/lib/esm/common/turbo.d.ts +0 -73
- package/lib/esm/node/signer.d.ts +0 -36
- package/lib/esm/types/index.d.ts +0 -18
- package/lib/esm/types/index.js +0 -18
- package/lib/esm/types/turbo.d.ts +0 -149
- package/lib/esm/utils/base64.d.ts +0 -9
- package/lib/esm/utils/readableStream.d.ts +0 -22
- package/lib/esm/web/factory.d.ts +0 -22
- package/lib/esm/web/index.d.ts +0 -20
- package/lib/esm/web/signer.d.ts +0 -37
- /package/lib/cjs/{types/arweave.js → common/jwk.js} +0 -0
- /package/lib/cjs/{types/turbo.js → types.js} +0 -0
- /package/lib/esm/{types/arweave.js → common/jwk.js} +0 -0
- /package/lib/esm/{types/turbo.js → types.js} +0 -0
@@ -14,17 +14,26 @@
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
*/
|
17
|
-
import axios from 'axios';
|
18
|
-
import
|
17
|
+
import axios, { CanceledError } from 'axios';
|
18
|
+
import axiosRetry from 'axios-retry';
|
19
19
|
export const createAxiosInstance = ({ axiosConfig = {}, retryConfig = {
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
retryDelay: axiosRetry.exponentialDelay,
|
21
|
+
retries: 3,
|
22
|
+
retryCondition: (error) => {
|
23
|
+
return (!(error instanceof CanceledError) &&
|
24
|
+
axiosRetry.isNetworkOrIdempotentRequestError(error));
|
25
|
+
},
|
26
|
+
onRetry: (retryCount, error) => {
|
27
|
+
console.debug(`Request failed, ${error}. Retry attempt #${retryCount}...`);
|
25
28
|
},
|
26
29
|
}, }) => {
|
27
|
-
const axiosInstance = axios.create(
|
28
|
-
|
30
|
+
const axiosInstance = axios.create({
|
31
|
+
...axiosConfig,
|
32
|
+
validateStatus: () => true, // don't throw on non-200 status codes
|
33
|
+
});
|
34
|
+
// eslint-disable-next-line
|
35
|
+
if (retryConfig.retries && retryConfig.retries > 0) {
|
36
|
+
axiosRetry(axiosInstance, retryConfig);
|
37
|
+
}
|
29
38
|
return axiosInstance;
|
30
39
|
};
|
@@ -1,24 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const reader = stream.getReader();
|
13
|
-
const chunks = [];
|
14
|
-
let done = false;
|
15
|
-
while (!done) {
|
16
|
-
const { done: streamDone, value } = yield reader.read();
|
17
|
-
done = streamDone;
|
18
|
-
if (!done) {
|
19
|
-
chunks.push(value);
|
20
|
-
}
|
1
|
+
export async function readableStreamToBuffer({ stream, size, }) {
|
2
|
+
const reader = stream.getReader();
|
3
|
+
const buffer = Buffer.alloc(size);
|
4
|
+
let offset = 0;
|
5
|
+
let done = false;
|
6
|
+
while (!done) {
|
7
|
+
const { done: streamDone, value } = await reader.read();
|
8
|
+
done = streamDone;
|
9
|
+
if (!done) {
|
10
|
+
buffer.set(value, offset);
|
11
|
+
offset += value.byteLength;
|
21
12
|
}
|
22
|
-
|
23
|
-
|
13
|
+
}
|
14
|
+
return buffer;
|
24
15
|
}
|
package/lib/esm/web/factory.js
CHANGED
@@ -20,8 +20,14 @@ import { TurboWebArweaveSigner } from './signer.js';
|
|
20
20
|
export class TurboFactory extends TurboBaseFactory {
|
21
21
|
static authenticated({ privateKey, paymentServiceConfig = {}, uploadServiceConfig = {}, }) {
|
22
22
|
const signer = new TurboWebArweaveSigner({ privateKey });
|
23
|
-
const paymentService = new TurboAuthenticatedPaymentService(
|
24
|
-
|
23
|
+
const paymentService = new TurboAuthenticatedPaymentService({
|
24
|
+
...paymentServiceConfig,
|
25
|
+
signer,
|
26
|
+
});
|
27
|
+
const uploadService = new TurboAuthenticatedUploadService({
|
28
|
+
...uploadServiceConfig,
|
29
|
+
signer,
|
30
|
+
});
|
25
31
|
return new TurboAuthenticatedClient({
|
26
32
|
uploadService,
|
27
33
|
paymentService,
|
package/lib/esm/web/index.js
CHANGED
package/lib/esm/web/signer.js
CHANGED
@@ -1,12 +1,3 @@
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
-
});
|
9
|
-
};
|
10
1
|
/**
|
11
2
|
* Copyright (C) 2022-2023 Permanent Data Solutions, Inc. All Rights Reserved.
|
12
3
|
*
|
@@ -33,30 +24,32 @@ export class TurboWebArweaveSigner {
|
|
33
24
|
this.privateKey = privateKey;
|
34
25
|
this.signer = new ArweaveSigner(this.privateKey);
|
35
26
|
}
|
36
|
-
signDataItem({ fileStreamFactory, }) {
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
// TODO: add payload size to get performance improvements
|
42
|
-
});
|
43
|
-
const signedDataItem = createData(buffer, this.signer);
|
44
|
-
yield signedDataItem.sign(this.signer);
|
45
|
-
return signedDataItem.getRaw();
|
27
|
+
async signDataItem({ fileStreamFactory, fileSizeFactory, }) {
|
28
|
+
// TODO: converts the readable stream to a buffer bc incrementally signing ReadableStreams is not trivial
|
29
|
+
const buffer = await readableStreamToBuffer({
|
30
|
+
stream: fileStreamFactory(),
|
31
|
+
size: fileSizeFactory(),
|
46
32
|
});
|
33
|
+
// TODO: support target, anchor and tags for upload
|
34
|
+
const signedDataItem = createData(buffer, this.signer, {});
|
35
|
+
await signedDataItem.sign(this.signer);
|
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
|
+
};
|
47
41
|
}
|
48
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
|
49
|
-
generateSignedRequestHeaders() {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
});
|
43
|
+
async generateSignedRequestHeaders() {
|
44
|
+
// a bit hacky - but arweave exports cause issues in tests vs. browser
|
45
|
+
const arweave = Arweave.default ?? Arweave;
|
46
|
+
const nonce = randomBytes(16).toString('hex');
|
47
|
+
const buffer = Buffer.from(nonce);
|
48
|
+
const signature = await arweave.crypto.sign(this.privateKey, buffer, {});
|
49
|
+
return {
|
50
|
+
'x-public-key': this.privateKey.n,
|
51
|
+
'x-nonce': nonce,
|
52
|
+
'x-signature': toB64Url(Buffer.from(signature)),
|
53
|
+
};
|
61
54
|
}
|
62
55
|
}
|
@@ -0,0 +1,43 @@
|
|
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 } from '../types.js';
|
18
|
+
export interface CurrencyMap {
|
19
|
+
amount: number;
|
20
|
+
type: Currency;
|
21
|
+
}
|
22
|
+
export declare class ZeroDecimalCurrency implements CurrencyMap {
|
23
|
+
readonly amount: number;
|
24
|
+
readonly type: Currency;
|
25
|
+
constructor(amount: number, type: Currency);
|
26
|
+
}
|
27
|
+
export declare class TwoDecimalCurrency implements CurrencyMap {
|
28
|
+
private a;
|
29
|
+
readonly type: Currency;
|
30
|
+
constructor(a: number, type: Currency);
|
31
|
+
get amount(): number;
|
32
|
+
}
|
33
|
+
export declare const USD: (usd: number) => TwoDecimalCurrency;
|
34
|
+
export declare const EUR: (eur: number) => TwoDecimalCurrency;
|
35
|
+
export declare const GBP: (gbp: number) => TwoDecimalCurrency;
|
36
|
+
export declare const CAD: (cad: number) => TwoDecimalCurrency;
|
37
|
+
export declare const AUD: (aud: number) => TwoDecimalCurrency;
|
38
|
+
export declare const INR: (inr: number) => TwoDecimalCurrency;
|
39
|
+
export declare const SGD: (sgd: number) => TwoDecimalCurrency;
|
40
|
+
export declare const HKD: (hkd: number) => TwoDecimalCurrency;
|
41
|
+
export declare const BRL: (brl: number) => TwoDecimalCurrency;
|
42
|
+
export declare const JPY: (jpy: number) => ZeroDecimalCurrency;
|
43
|
+
//# sourceMappingURL=currency.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"currency.d.ts","sourceRoot":"","sources":["../../../src/common/currency.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED,qBAAa,mBAAoB,YAAW,WAAW;aAEnC,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,QAAQ;gBADd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,QAAQ;CAEjC;AAED,qBAAa,kBAAmB,YAAW,WAAW;IAElD,OAAO,CAAC,CAAC;aACO,IAAI,EAAE,QAAQ;gBADtB,CAAC,EAAE,MAAM,EACD,IAAI,EAAE,QAAQ;IAGhC,IAAI,MAAM,WAET;CACF;AAGD,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AACvE,eAAO,MAAM,GAAG,QAAS,MAAM,uBAAuC,CAAC;AAGvE,eAAO,MAAM,GAAG,QAAS,MAAM,wBAAwC,CAAC"}
|
@@ -14,8 +14,9 @@
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
*/
|
17
|
-
import { TurboPublicConfiguration } from '../types
|
17
|
+
import { TurboPublicConfiguration } from '../types.js';
|
18
18
|
import { TurboUnauthenticatedClient } from './turbo.js';
|
19
19
|
export declare class TurboBaseFactory {
|
20
20
|
static unauthenticated({ paymentServiceConfig, uploadServiceConfig, }?: TurboPublicConfiguration): TurboUnauthenticatedClient;
|
21
21
|
}
|
22
|
+
//# sourceMappingURL=factory.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/common/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAGxD,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,eAAe,CAAC,EACrB,oBAAyB,EACzB,mBAAwB,GACzB,GAAE,wBAA6B;CAYjC"}
|
@@ -18,15 +18,15 @@
|
|
18
18
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
*/
|
20
20
|
import { AxiosInstance } from 'axios';
|
21
|
-
import {
|
21
|
+
import { IAxiosRetryConfig } from 'axios-retry';
|
22
22
|
import { Readable } from 'stream';
|
23
23
|
import { ReadableStream } from 'stream/web';
|
24
|
-
import { TurboHTTPServiceInterface, TurboSignedRequestHeaders } from '../types
|
24
|
+
import { TurboHTTPServiceInterface, TurboSignedRequestHeaders } from '../types.js';
|
25
25
|
export declare class TurboHTTPService implements TurboHTTPServiceInterface {
|
26
26
|
protected axios: AxiosInstance;
|
27
27
|
constructor({ url, retryConfig, }: {
|
28
28
|
url: string;
|
29
|
-
retryConfig?:
|
29
|
+
retryConfig?: IAxiosRetryConfig;
|
30
30
|
});
|
31
31
|
get<T>({ endpoint, signal, allowedStatuses, headers, }: {
|
32
32
|
endpoint: string;
|
@@ -42,3 +42,4 @@ export declare class TurboHTTPService implements TurboHTTPServiceInterface {
|
|
42
42
|
data: Readable | Buffer | ReadableStream;
|
43
43
|
}): Promise<T>;
|
44
44
|
}
|
45
|
+
//# sourceMappingURL=http.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/common/http.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,cAAc,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B,cAAc,eAAe,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"jwk.d.ts","sourceRoot":"","sources":["../../../src/common/jwk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AACD,MAAM,WAAW,YAAa,SAAQ,kBAAkB;IACtD,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
|
@@ -14,7 +14,7 @@
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
*/
|
17
|
-
import { Currency, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedPaymentServiceInterfaceConfiguration, TurboBalanceResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboPriceResponse, TurboRatesResponse, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedPaymentServiceInterfaceConfiguration, TurboWalletSigner } from '../types
|
17
|
+
import { Currency, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedPaymentServiceInterfaceConfiguration, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedPaymentServiceInterfaceConfiguration, TurboWalletSigner, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
|
18
18
|
import { TurboHTTPService } from './http.js';
|
19
19
|
export declare class TurboUnauthenticatedPaymentService implements TurboUnauthenticatedPaymentServiceInterface {
|
20
20
|
protected readonly httpService: TurboHTTPService;
|
@@ -28,14 +28,22 @@ export declare class TurboUnauthenticatedPaymentService implements TurboUnauthen
|
|
28
28
|
getUploadCosts({ bytes, }: {
|
29
29
|
bytes: number[];
|
30
30
|
}): Promise<TurboPriceResponse[]>;
|
31
|
-
getWincForFiat({ amount,
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
getWincForFiat({ amount, }: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
32
|
+
protected appendPromoCodesToQuery(promoCodes: string[]): string;
|
33
|
+
protected getCheckout({ amount, owner, promoCodes }: TurboCheckoutSessionParams, headers?: TurboSignedRequestHeaders): Promise<{
|
34
|
+
winc: string;
|
35
|
+
adjustments: import("../types.js").Adjustment[];
|
36
|
+
url: string;
|
37
|
+
paymentAmount: number;
|
38
|
+
quotedPaymentAmount: number;
|
39
|
+
}>;
|
40
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
35
41
|
}
|
36
42
|
export declare class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService implements TurboAuthenticatedPaymentServiceInterface {
|
37
|
-
protected readonly httpService: TurboHTTPService;
|
38
43
|
protected readonly signer: TurboWalletSigner;
|
39
44
|
constructor({ url, retryConfig, signer, }: TurboAuthenticatedPaymentServiceInterfaceConfiguration);
|
40
45
|
getBalance(): Promise<TurboBalanceResponse>;
|
46
|
+
getWincForFiat({ amount, promoCodes, }: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
47
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
41
48
|
}
|
49
|
+
//# sourceMappingURL=payment.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/common/payment.ts"],"names":[],"mappings":"AAAA;;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GD,qBAAa,gCACX,SAAQ,kCACR,YAAW,yCAAyC;IAEpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEjC,EACV,GAAmC,EACnC,WAAW,EACX,MAAM,GACP,EAAE,sDAAsD;IAK5C,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAY3C,cAAc,CAAC,EAC1B,MAAM,EACN,UAAe,GAChB,EAAE,sBAAsB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAShD,qBAAqB,CAChC,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,4BAA4B,CAAC;CAMzC"}
|
@@ -14,10 +14,10 @@
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
*/
|
17
|
-
import { Currency, TurboAbortSignal, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboFileFactory, TurboPriceResponse, TurboPrivateClientConfiguration, TurboPublicClientConfiguration, TurboRatesResponse, TurboSignedDataItemFactory, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse } from '../types
|
17
|
+
import { Currency, TurboAbortSignal, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboFileFactory, TurboPriceResponse, TurboPrivateClientConfiguration, TurboPublicClientConfiguration, TurboRatesResponse, TurboSignedDataItemFactory, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
|
18
18
|
export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedClientInterface {
|
19
|
-
protected
|
20
|
-
protected
|
19
|
+
protected paymentService: TurboUnauthenticatedPaymentServiceInterface;
|
20
|
+
protected uploadService: TurboUnauthenticatedUploadServiceInterface;
|
21
21
|
constructor({ uploadService, paymentService, }: TurboPublicClientConfiguration);
|
22
22
|
/**
|
23
23
|
* Returns the supported fiat currency conversion rate for 1AR based on current market prices.
|
@@ -49,18 +49,19 @@ export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedC
|
|
49
49
|
/**
|
50
50
|
* Determines the amount of 'winc' that would be returned for a given currency and amount, including all Turbo cost adjustments and fees.
|
51
51
|
*/
|
52
|
-
getWincForFiat(
|
53
|
-
amount: number;
|
54
|
-
currency: Currency;
|
55
|
-
}): Promise<Omit<TurboPriceResponse, 'adjustments'>>;
|
52
|
+
getWincForFiat(params: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
56
53
|
/**
|
57
54
|
* Uploads a signed data item to the Turbo Upload Service.
|
58
55
|
*/
|
59
|
-
uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
56
|
+
uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
57
|
+
/**
|
58
|
+
* Creates a Turbo Checkout Session for a given amount and currency.
|
59
|
+
*/
|
60
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
60
61
|
}
|
61
62
|
export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient implements TurboAuthenticatedClientInterface {
|
62
|
-
protected
|
63
|
-
protected
|
63
|
+
protected paymentService: TurboAuthenticatedPaymentServiceInterface;
|
64
|
+
protected uploadService: TurboAuthenticatedUploadServiceInterface;
|
64
65
|
constructor({ paymentService, uploadService, }: TurboPrivateClientConfiguration);
|
65
66
|
/**
|
66
67
|
* Returns the current balance of the user's wallet in 'winc'.
|
@@ -69,5 +70,6 @@ export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient
|
|
69
70
|
/**
|
70
71
|
* Signs and uploads raw data to the Turbo Upload Service.
|
71
72
|
*/
|
72
|
-
uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
73
|
+
uploadFile({ fileStreamFactory, fileSizeFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
73
74
|
}
|
75
|
+
//# sourceMappingURL=turbo.d.ts.map
|
@@ -0,0 +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,0BAA0B,EAC1B,4BAA4B,EAC5B,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,EAC3B,sBAAsB,EACtB,wBAAwB,EACzB,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;IACH,WAAW,CAAC,EACV,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIlC;;;;;OAKG;IACH,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAI3C;;OAEG;IACH,qBAAqB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAIxD;;OAEG;IACH,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAI1D;;OAEG;IACH,cAAc,CAAC,EACb,KAAK,GACN,EAAE;QACD,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAIjC;;OAEG;IACH,cAAc,CACZ,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,wBAAwB,CAAC;IAIpC;;OAEG;IACH,oBAAoB,CAAC,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,GACP,EAAE,0BAA0B,GAC3B,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAQzD;;OAEG;IACH,qBAAqB,CACnB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,4BAA4B,CAAC;CAGzC;AAED,qBAAa,wBACX,SAAQ,0BACR,YAAW,iCAAiC;IAG5C,SAAS,CAAC,cAAc,EAAE,yCAAyC,CAAC;IACpE,SAAS,CAAC,aAAa,EAAE,wCAAwC,CAAC;gBAEtD,EACV,cAAc,EACd,aAAa,GACd,EAAE,+BAA+B;IAIlC;;OAEG;IACH,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAI3C;;OAEG;IACH,UAAU,CAAC,EACT,iBAAiB,EACjB,eAAe,EACf,MAAM,GACP,EAAE,gBAAgB,GACjB,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAO1D"}
|
@@ -14,16 +14,16 @@
|
|
14
14
|
* You should have received a copy of the GNU Affero General Public License
|
15
15
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
*/
|
17
|
-
import { TurboAbortSignal, TurboAuthenticatedUploadServiceConfiguration, TurboAuthenticatedUploadServiceInterface, TurboFileFactory, TurboSignedDataItemFactory, TurboUnauthenticatedUploadServiceInterface, TurboUnauthenticatedUploadServiceInterfaceConfiguration, TurboUploadDataItemResponse, TurboWalletSigner } from '../types
|
17
|
+
import { TurboAbortSignal, TurboAuthenticatedUploadServiceConfiguration, TurboAuthenticatedUploadServiceInterface, TurboFileFactory, TurboSignedDataItemFactory, TurboUnauthenticatedUploadServiceInterface, TurboUnauthenticatedUploadServiceInterfaceConfiguration, TurboUploadDataItemResponse, TurboWalletSigner } from '../types.js';
|
18
18
|
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
|
-
protected httpService: TurboHTTPService;
|
26
25
|
protected signer: TurboWalletSigner;
|
27
26
|
constructor({ url, retryConfig, signer, }: TurboAuthenticatedUploadServiceConfiguration);
|
28
|
-
uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
27
|
+
uploadFile({ fileStreamFactory, fileSizeFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
29
28
|
}
|
29
|
+
//# sourceMappingURL=upload.d.ts.map
|
@@ -0,0 +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,MAAM,WAAW,CAAC;AAE7C,qBAAa,iCACX,YAAW,0CAA0C;IAErD,SAAS,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAE5B,EACV,GAAkC,EAClC,WAAW,GACZ,EAAE,uDAAuD;IAOpD,oBAAoB,CAAC,EACzB,qBAAqB,EACrB,mBAAmB,EACnB,MAAM,GACP,EAAE,0BAA0B,GAC3B,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;CAa1D;AAGD,qBAAa,+BACX,SAAQ,iCACR,YAAW,wCAAwC;IAEnD,SAAS,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAExB,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"}
|
@@ -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
|
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/node/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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,oBAAoB,CAAC"}
|
@@ -17,20 +17,26 @@
|
|
17
17
|
*/
|
18
18
|
import { ArweaveSigner } from 'arbundles';
|
19
19
|
import { Readable } from 'node:stream';
|
20
|
-
import { JWKInterface } from '../
|
21
|
-
import { TurboWalletSigner } from '../types
|
20
|
+
import { JWKInterface } from '../common/jwk.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
|
-
|
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
|
}
|
42
|
+
//# sourceMappingURL=signer.d.ts.map
|
@@ -0,0 +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,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"}
|
@@ -17,17 +17,25 @@
|
|
17
17
|
* You should have received a copy of the GNU Affero General Public License
|
18
18
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
19
|
*/
|
20
|
+
import { IAxiosRetryConfig } from 'axios-retry';
|
20
21
|
import { Readable } from 'node:stream';
|
21
22
|
import { ReadableStream } from 'node:stream/web';
|
22
|
-
import { RetryConfig } from 'retry-axios';
|
23
23
|
import winston from 'winston';
|
24
|
-
import {
|
24
|
+
import { CurrencyMap } from './common/currency.js';
|
25
|
+
import { JWKInterface } from './common/jwk.js';
|
25
26
|
export type Base64String = string;
|
26
27
|
export type PublicArweaveAddress = Base64String;
|
27
28
|
export type TransactionId = Base64String;
|
28
29
|
export type UserAddress = string | PublicArweaveAddress;
|
29
|
-
export type Currency = 'usd' | 'eur' | 'gbp' | 'cad' | 'aud' | '
|
30
|
+
export type Currency = 'usd' | 'eur' | 'gbp' | 'cad' | 'aud' | 'jpy' | 'inr' | 'sgd' | 'hkd' | 'brl';
|
30
31
|
export type Country = 'United States' | 'United Kingdom' | 'Canada';
|
32
|
+
export type Adjustment = {
|
33
|
+
name: string;
|
34
|
+
description: string;
|
35
|
+
operatorMagnitude: number;
|
36
|
+
operator: 'multiply' | 'add';
|
37
|
+
adjustmentAmount: string;
|
38
|
+
};
|
31
39
|
export type CurrencyLimit = {
|
32
40
|
minimumPaymentAmount: number;
|
33
41
|
maximumPaymentAmount: number;
|
@@ -36,7 +44,32 @@ export type CurrencyLimit = {
|
|
36
44
|
};
|
37
45
|
export type TurboPriceResponse = {
|
38
46
|
winc: string;
|
39
|
-
adjustments:
|
47
|
+
adjustments: Adjustment[];
|
48
|
+
};
|
49
|
+
export type TurboWincForFiatResponse = TurboPriceResponse & {
|
50
|
+
paymentAmount: number;
|
51
|
+
quotedPaymentAmount: number;
|
52
|
+
};
|
53
|
+
export type TurboWincForFiatParams = {
|
54
|
+
amount: CurrencyMap;
|
55
|
+
promoCodes?: string[];
|
56
|
+
};
|
57
|
+
export type TurboCheckoutSessionParams = TurboWincForFiatParams & {
|
58
|
+
owner: PublicArweaveAddress;
|
59
|
+
};
|
60
|
+
export type TopUpRawResponse = {
|
61
|
+
topUpQuote: {
|
62
|
+
paymentAmount: number;
|
63
|
+
quotedPaymentAmount: number;
|
64
|
+
winstonCreditAmount: string;
|
65
|
+
};
|
66
|
+
paymentSession: {
|
67
|
+
url: string;
|
68
|
+
};
|
69
|
+
adjustments: Adjustment[];
|
70
|
+
};
|
71
|
+
export type TurboCheckoutSessionResponse = TurboWincForFiatResponse & {
|
72
|
+
url: string;
|
40
73
|
};
|
41
74
|
export type TurboBalanceResponse = Omit<TurboPriceResponse, 'adjustments'>;
|
42
75
|
export type TurboFiatToArResponse = {
|
@@ -66,7 +99,7 @@ type TurboAuthConfiguration = {
|
|
66
99
|
};
|
67
100
|
type TurboServiceConfiguration = {
|
68
101
|
url?: string;
|
69
|
-
retryConfig?:
|
102
|
+
retryConfig?: IAxiosRetryConfig;
|
70
103
|
logger?: winston.Logger;
|
71
104
|
};
|
72
105
|
export type TurboUnauthenticatedUploadServiceInterfaceConfiguration = TurboServiceConfiguration;
|
@@ -90,11 +123,14 @@ export type TurboPrivateClientConfiguration = {
|
|
90
123
|
};
|
91
124
|
export type FileStreamFactory = (() => Readable) | (() => ReadableStream) | (() => Buffer);
|
92
125
|
export type SignedDataStreamFactory = FileStreamFactory;
|
126
|
+
export type StreamSizeFactory = () => number;
|
93
127
|
export type TurboFileFactory = {
|
94
128
|
fileStreamFactory: FileStreamFactory;
|
129
|
+
fileSizeFactory: StreamSizeFactory;
|
95
130
|
};
|
96
131
|
export type TurboSignedDataItemFactory = {
|
97
132
|
dataItemStreamFactory: SignedDataStreamFactory;
|
133
|
+
dataItemSizeFactory: StreamSizeFactory;
|
98
134
|
};
|
99
135
|
export type TurboAbortSignal = {
|
100
136
|
signal?: AbortSignal;
|
@@ -115,7 +151,7 @@ export interface TurboHTTPServiceInterface {
|
|
115
151
|
}): Promise<T>;
|
116
152
|
}
|
117
153
|
export interface TurboWalletSigner {
|
118
|
-
signDataItem({ fileStreamFactory, }: TurboFileFactory): Promise<
|
154
|
+
signDataItem({ fileStreamFactory, fileSizeFactory, }: TurboFileFactory): Promise<TurboSignedDataItemFactory>;
|
119
155
|
generateSignedRequestHeaders(): Promise<TurboSignedRequestHeaders>;
|
120
156
|
}
|
121
157
|
export interface TurboUnauthenticatedPaymentServiceInterface {
|
@@ -125,13 +161,11 @@ export interface TurboUnauthenticatedPaymentServiceInterface {
|
|
125
161
|
currency: Currency;
|
126
162
|
}): Promise<TurboFiatToArResponse>;
|
127
163
|
getFiatRates(): Promise<TurboRatesResponse>;
|
128
|
-
getWincForFiat(
|
129
|
-
amount: number;
|
130
|
-
currency: Currency;
|
131
|
-
}): Promise<Omit<TurboPriceResponse, 'adjustments'>>;
|
164
|
+
getWincForFiat(params: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
132
165
|
getUploadCosts({ bytes }: {
|
133
166
|
bytes: number[];
|
134
167
|
}): Promise<TurboPriceResponse[]>;
|
168
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
135
169
|
}
|
136
170
|
export interface TurboAuthenticatedPaymentServiceInterface extends TurboUnauthenticatedPaymentServiceInterface {
|
137
171
|
getBalance: () => Promise<TurboBalanceResponse>;
|
@@ -140,10 +174,11 @@ export interface TurboUnauthenticatedUploadServiceInterface {
|
|
140
174
|
uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
141
175
|
}
|
142
176
|
export interface TurboAuthenticatedUploadServiceInterface extends TurboUnauthenticatedUploadServiceInterface {
|
143
|
-
uploadFile({ fileStreamFactory, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
177
|
+
uploadFile({ fileStreamFactory, fileSizeFactory, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
144
178
|
}
|
145
179
|
export interface TurboUnauthenticatedClientInterface extends TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface {
|
146
180
|
}
|
147
181
|
export interface TurboAuthenticatedClientInterface extends TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface {
|
148
182
|
}
|
149
183
|
export {};
|
184
|
+
//# sourceMappingURL=types.d.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