@ardrive/turbo-sdk 1.0.0-beta.1 → 1.0.0-beta.3
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 +58 -15
- package/bundles/web.bundle.min.js +171 -37
- package/lib/cjs/common/currency.js +42 -0
- package/lib/cjs/common/index.js +1 -0
- package/lib/cjs/common/payment.js +43 -9
- package/lib/cjs/common/turbo.js +45 -12
- package/lib/cjs/common/upload.js +13 -5
- package/lib/cjs/node/signer.js +33 -2
- package/lib/cjs/utils/readableStream.js +6 -4
- package/lib/cjs/web/signer.js +9 -4
- package/lib/esm/common/currency.js +27 -0
- package/lib/esm/common/index.js +1 -0
- package/lib/esm/common/payment.js +42 -8
- package/lib/esm/common/turbo.js +46 -13
- package/lib/esm/common/upload.js +12 -4
- package/lib/esm/node/signer.js +33 -2
- package/lib/esm/utils/readableStream.js +6 -4
- package/lib/esm/web/signer.js +9 -4
- package/lib/types/common/currency.d.ts +43 -0
- package/lib/types/common/currency.d.ts.map +1 -0
- package/lib/types/common/factory.d.ts +2 -2
- package/lib/types/common/factory.d.ts.map +1 -1
- package/lib/types/common/index.d.ts +1 -0
- package/lib/types/common/index.d.ts.map +1 -1
- package/lib/types/common/payment.d.ts +17 -7
- package/lib/types/common/payment.d.ts.map +1 -1
- package/lib/types/common/turbo.d.ts +32 -9
- package/lib/types/common/turbo.d.ts.map +1 -1
- package/lib/types/common/upload.d.ts +6 -4
- package/lib/types/common/upload.d.ts.map +1 -1
- package/lib/types/node/factory.d.ts +2 -2
- package/lib/types/node/factory.d.ts.map +1 -1
- package/lib/types/node/signer.d.ts +8 -3
- package/lib/types/node/signer.d.ts.map +1 -1
- package/lib/types/types.d.ts +52 -18
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/utils/readableStream.d.ts +2 -1
- package/lib/types/utils/readableStream.d.ts.map +1 -1
- package/lib/types/web/factory.d.ts +2 -2
- package/lib/types/web/factory.d.ts.map +1 -1
- package/lib/types/web/signer.d.ts +7 -3
- package/lib/types/web/signer.d.ts.map +1 -1
- package/package.json +1 -1
package/lib/esm/node/signer.js
CHANGED
@@ -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
|
-
|
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
|
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
|
-
|
10
|
+
buffer.set(value, offset);
|
11
|
+
offset += value.byteLength;
|
10
12
|
}
|
11
13
|
}
|
12
|
-
return
|
14
|
+
return buffer;
|
13
15
|
}
|
package/lib/esm/web/signer.js
CHANGED
@@ -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
|
-
|
31
|
+
size: fileSizeFactory(),
|
32
32
|
});
|
33
|
-
|
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
|
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() {
|
@@ -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,9 +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 {
|
17
|
+
import { TurboUnauthenticatedConfiguration } from '../types.js';
|
18
18
|
import { TurboUnauthenticatedClient } from './turbo.js';
|
19
19
|
export declare class TurboBaseFactory {
|
20
|
-
static unauthenticated({ paymentServiceConfig, uploadServiceConfig, }?:
|
20
|
+
static unauthenticated({ paymentServiceConfig, uploadServiceConfig, }?: TurboUnauthenticatedConfiguration): TurboUnauthenticatedClient;
|
21
21
|
}
|
22
22
|
//# sourceMappingURL=factory.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/common/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/common/factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,iCAAiC,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AAGxD,qBAAa,gBAAgB;IAC3B,MAAM,CAAC,eAAe,CAAC,EACrB,oBAAyB,EACzB,mBAAwB,GACzB,GAAE,iCAAsC;CAY1C"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
@@ -14,11 +14,13 @@
|
|
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,
|
17
|
+
import { Currency, TurboAuthenticatedPaymentServiceConfiguration, TurboAuthenticatedPaymentServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboUnauthenticatedPaymentServiceConfiguration, TurboUnauthenticatedPaymentServiceInterface, TurboWalletSigner, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
|
18
18
|
import { TurboHTTPService } from './http.js';
|
19
|
+
export declare const developmentPaymentServiceURL = "https://payment.ardrive.dev";
|
20
|
+
export declare const defaultPaymentServiceURL = "https://payment.ardrive.io";
|
19
21
|
export declare class TurboUnauthenticatedPaymentService implements TurboUnauthenticatedPaymentServiceInterface {
|
20
22
|
protected readonly httpService: TurboHTTPService;
|
21
|
-
constructor({ url, retryConfig, }:
|
23
|
+
constructor({ url, retryConfig, }: TurboUnauthenticatedPaymentServiceConfiguration);
|
22
24
|
getFiatRates(): Promise<TurboRatesResponse>;
|
23
25
|
getFiatToAR({ currency, }: {
|
24
26
|
currency: Currency;
|
@@ -28,14 +30,22 @@ export declare class TurboUnauthenticatedPaymentService implements TurboUnauthen
|
|
28
30
|
getUploadCosts({ bytes, }: {
|
29
31
|
bytes: number[];
|
30
32
|
}): Promise<TurboPriceResponse[]>;
|
31
|
-
getWincForFiat({ amount,
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
getWincForFiat({ amount, }: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
34
|
+
protected appendPromoCodesToQuery(promoCodes: string[]): string;
|
35
|
+
protected getCheckout({ amount, owner, promoCodes }: TurboCheckoutSessionParams, headers?: TurboSignedRequestHeaders): Promise<{
|
36
|
+
winc: string;
|
37
|
+
adjustments: import("../types.js").Adjustment[];
|
38
|
+
url: string;
|
39
|
+
paymentAmount: number;
|
40
|
+
quotedPaymentAmount: number;
|
41
|
+
}>;
|
42
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
35
43
|
}
|
36
44
|
export declare class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService implements TurboAuthenticatedPaymentServiceInterface {
|
37
45
|
protected readonly signer: TurboWalletSigner;
|
38
|
-
constructor({ url, retryConfig, signer, }:
|
46
|
+
constructor({ url, retryConfig, signer, }: TurboAuthenticatedPaymentServiceConfiguration);
|
39
47
|
getBalance(): Promise<TurboBalanceResponse>;
|
48
|
+
getWincForFiat({ amount, promoCodes, }: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
49
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
40
50
|
}
|
41
51
|
//# sourceMappingURL=payment.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/common/payment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,QAAQ,
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../../../src/common/payment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,QAAQ,EAER,6CAA6C,EAC7C,yCAAyC,EACzC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,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C,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;gBAEjC,EACV,GAA8B,EAC9B,WAAW,EACX,MAAM,GACP,EAAE,6CAA6C;IAKnC,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,11 +14,33 @@
|
|
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,
|
17
|
+
import { Currency, TurboAbortSignal, TurboAuthenticatedClientConfiguration, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboFileFactory, TurboPriceResponse, TurboRatesResponse, TurboSignedDataItemFactory, TurboUnauthenticatedClientConfiguration, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
|
18
|
+
/**
|
19
|
+
* Testing configuration.
|
20
|
+
*/
|
21
|
+
export declare const developmentTurboConfiguration: {
|
22
|
+
paymentServiceConfig: {
|
23
|
+
url: string;
|
24
|
+
};
|
25
|
+
uploadServiceConfig: {
|
26
|
+
url: string;
|
27
|
+
};
|
28
|
+
};
|
29
|
+
/**
|
30
|
+
* Production configuration.
|
31
|
+
*/
|
32
|
+
export declare const defaultTurboConfiguration: {
|
33
|
+
paymentServiceConfig: {
|
34
|
+
url: string;
|
35
|
+
};
|
36
|
+
uploadServiceConfig: {
|
37
|
+
url: string;
|
38
|
+
};
|
39
|
+
};
|
18
40
|
export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedClientInterface {
|
19
41
|
protected paymentService: TurboUnauthenticatedPaymentServiceInterface;
|
20
42
|
protected uploadService: TurboUnauthenticatedUploadServiceInterface;
|
21
|
-
constructor({ uploadService, paymentService, }:
|
43
|
+
constructor({ uploadService, paymentService, }: TurboUnauthenticatedClientConfiguration);
|
22
44
|
/**
|
23
45
|
* Returns the supported fiat currency conversion rate for 1AR based on current market prices.
|
24
46
|
*/
|
@@ -49,19 +71,20 @@ export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedC
|
|
49
71
|
/**
|
50
72
|
* Determines the amount of 'winc' that would be returned for a given currency and amount, including all Turbo cost adjustments and fees.
|
51
73
|
*/
|
52
|
-
getWincForFiat(
|
53
|
-
amount: number;
|
54
|
-
currency: Currency;
|
55
|
-
}): Promise<Omit<TurboPriceResponse, 'adjustments'>>;
|
74
|
+
getWincForFiat(params: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
|
56
75
|
/**
|
57
76
|
* Uploads a signed data item to the Turbo Upload Service.
|
58
77
|
*/
|
59
|
-
uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
78
|
+
uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
79
|
+
/**
|
80
|
+
* Creates a Turbo Checkout Session for a given amount and currency.
|
81
|
+
*/
|
82
|
+
createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
|
60
83
|
}
|
61
84
|
export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient implements TurboAuthenticatedClientInterface {
|
62
85
|
protected paymentService: TurboAuthenticatedPaymentServiceInterface;
|
63
86
|
protected uploadService: TurboAuthenticatedUploadServiceInterface;
|
64
|
-
constructor({ paymentService, uploadService, }:
|
87
|
+
constructor({ paymentService, uploadService, }: TurboAuthenticatedClientConfiguration);
|
65
88
|
/**
|
66
89
|
* Returns the current balance of the user's wallet in 'winc'.
|
67
90
|
*/
|
@@ -69,6 +92,6 @@ export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient
|
|
69
92
|
/**
|
70
93
|
* Signs and uploads raw data to the Turbo Upload Service.
|
71
94
|
*/
|
72
|
-
uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
95
|
+
uploadFile({ fileStreamFactory, fileSizeFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
73
96
|
}
|
74
97
|
//# 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
|
1
|
+
{"version":3,"file":"turbo.d.ts","sourceRoot":"","sources":["../../../src/common/turbo.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,qCAAqC,EACrC,iCAAiC,EACjC,yCAAyC,EACzC,wCAAwC,EACxC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,EACvB,qBAA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B,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,qCAAqC;IAIxC;;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,18 @@
|
|
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,
|
17
|
+
import { TurboAbortSignal, TurboAuthenticatedUploadServiceConfiguration, TurboAuthenticatedUploadServiceInterface, TurboFileFactory, TurboSignedDataItemFactory, TurboUnauthenticatedUploadServiceConfiguration, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboWalletSigner } from '../types.js';
|
18
18
|
import { TurboHTTPService } from './http.js';
|
19
|
+
export declare const defaultUploadServiceURL = "https://upload.ardrive.io";
|
20
|
+
export declare const developmentUploadServiceURL = "https://upload.ardrive.dev";
|
19
21
|
export declare class TurboUnauthenticatedUploadService implements TurboUnauthenticatedUploadServiceInterface {
|
20
22
|
protected httpService: TurboHTTPService;
|
21
|
-
constructor({ url, retryConfig, }:
|
22
|
-
uploadSignedDataItem({ dataItemStreamFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
23
|
+
constructor({ url, retryConfig, }: TurboUnauthenticatedUploadServiceConfiguration);
|
24
|
+
uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal, }: TurboSignedDataItemFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
23
25
|
}
|
24
26
|
export declare class TurboAuthenticatedUploadService extends TurboUnauthenticatedUploadService implements TurboAuthenticatedUploadServiceInterface {
|
25
27
|
protected signer: TurboWalletSigner;
|
26
28
|
constructor({ url, retryConfig, signer, }: TurboAuthenticatedUploadServiceConfiguration);
|
27
|
-
uploadFile({ fileStreamFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
29
|
+
uploadFile({ fileStreamFactory, fileSizeFactory, signal, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
|
28
30
|
}
|
29
31
|
//# 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,
|
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,8CAA8C,EAC9C,0CAA0C,EAC1C,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AACnE,eAAO,MAAM,2BAA2B,+BAA+B,CAAC;AAExE,qBAAa,iCACX,YAAW,0CAA0C;IAErD,SAAS,CAAC,WAAW,EAAE,gBAAgB,CAAC;gBAE5B,EACV,GAA6B,EAC7B,WAAW,GACZ,EAAE,8CAA8C;IAO3C,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,8 +16,8 @@
|
|
16
16
|
*/
|
17
17
|
import { TurboBaseFactory } from '../common/factory.js';
|
18
18
|
import { TurboAuthenticatedClient } from '../common/index.js';
|
19
|
-
import {
|
19
|
+
import { TurboAuthenticatedConfiguration } from '../types.js';
|
20
20
|
export declare class TurboFactory extends TurboBaseFactory {
|
21
|
-
static authenticated({ privateKey, paymentServiceConfig, uploadServiceConfig, }:
|
21
|
+
static authenticated({ privateKey, paymentServiceConfig, uploadServiceConfig, }: TurboAuthenticatedConfiguration): TurboAuthenticatedClient;
|
22
22
|
}
|
23
23
|
//# sourceMappingURL=factory.d.ts.map
|
@@ -1 +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,
|
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,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAG9D,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,MAAM,CAAC,aAAa,CAAC,EACnB,UAAU,EACV,oBAAyB,EACzB,mBAAwB,GACzB,EAAE,+BAA+B;CAenC"}
|
@@ -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
|
-
|
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;
|
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"}
|
package/lib/types/types.d.ts
CHANGED
@@ -21,13 +21,21 @@ import { IAxiosRetryConfig } from 'axios-retry';
|
|
21
21
|
import { Readable } from 'node:stream';
|
22
22
|
import { ReadableStream } from 'node:stream/web';
|
23
23
|
import winston from 'winston';
|
24
|
+
import { CurrencyMap } from './common/currency.js';
|
24
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 = {
|
@@ -69,32 +102,35 @@ type TurboServiceConfiguration = {
|
|
69
102
|
retryConfig?: IAxiosRetryConfig;
|
70
103
|
logger?: winston.Logger;
|
71
104
|
};
|
72
|
-
export type
|
73
|
-
export type TurboAuthenticatedUploadServiceConfiguration =
|
74
|
-
export type
|
75
|
-
export type
|
76
|
-
export type
|
77
|
-
paymentServiceConfig?:
|
78
|
-
uploadServiceConfig?:
|
105
|
+
export type TurboUnauthenticatedUploadServiceConfiguration = TurboServiceConfiguration;
|
106
|
+
export type TurboAuthenticatedUploadServiceConfiguration = TurboUnauthenticatedUploadServiceConfiguration & TurboAuthConfiguration;
|
107
|
+
export type TurboUnauthenticatedPaymentServiceConfiguration = TurboServiceConfiguration;
|
108
|
+
export type TurboAuthenticatedPaymentServiceConfiguration = TurboUnauthenticatedPaymentServiceConfiguration & TurboAuthConfiguration;
|
109
|
+
export type TurboUnauthenticatedConfiguration = {
|
110
|
+
paymentServiceConfig?: TurboUnauthenticatedPaymentServiceConfiguration;
|
111
|
+
uploadServiceConfig?: TurboUnauthenticatedUploadServiceConfiguration;
|
79
112
|
};
|
80
|
-
export type
|
113
|
+
export type TurboAuthenticatedConfiguration = TurboUnauthenticatedConfiguration & {
|
81
114
|
privateKey: TurboWallet;
|
82
115
|
};
|
83
|
-
export type
|
116
|
+
export type TurboUnauthenticatedClientConfiguration = {
|
84
117
|
paymentService: TurboUnauthenticatedPaymentServiceInterface;
|
85
118
|
uploadService: TurboUnauthenticatedUploadServiceInterface;
|
86
119
|
};
|
87
|
-
export type
|
120
|
+
export type TurboAuthenticatedClientConfiguration = {
|
88
121
|
paymentService: TurboAuthenticatedPaymentServiceInterface;
|
89
122
|
uploadService: TurboAuthenticatedUploadServiceInterface;
|
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,7 +174,7 @@ 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
|
}
|
package/lib/types/types.d.ts.map
CHANGED
@@ -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,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC;AAChD,MAAM,MAAM,aAAa,GAAG,YAAY,CAAC;AACzC,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,oBAAoB,CAAC;AACxD,MAAM,MAAM,QAAQ,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CA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AAM,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,
|
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,8 +16,8 @@
|
|
16
16
|
*/
|
17
17
|
import { TurboBaseFactory } from '../common/factory.js';
|
18
18
|
import { TurboAuthenticatedClient } from '../common/index.js';
|
19
|
-
import {
|
19
|
+
import { TurboAuthenticatedConfiguration } from '../types.js';
|
20
20
|
export declare class TurboFactory extends TurboBaseFactory {
|
21
|
-
static authenticated({ privateKey, paymentServiceConfig, uploadServiceConfig, }:
|
21
|
+
static authenticated({ privateKey, paymentServiceConfig, uploadServiceConfig, }: TurboAuthenticatedConfiguration): TurboAuthenticatedClient;
|
22
22
|
}
|
23
23
|
//# sourceMappingURL=factory.d.ts.map
|
@@ -1 +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,
|
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,+BAA+B,EAAE,MAAM,aAAa,CAAC;AAG9D,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,MAAM,CAAC,aAAa,CAAC,EACnB,UAAU,EACV,oBAAyB,EACzB,mBAAwB,GACzB,EAAE,+BAA+B;CAenC"}
|