@ardrive/turbo-sdk 1.0.0-alpha.5 → 1.0.0-alpha.7
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/lib/cjs/common/factory.js +17 -0
- package/lib/cjs/common/http.d.ts +44 -0
- package/lib/cjs/common/http.js +49 -0
- package/lib/cjs/common/index.js +35 -0
- package/lib/cjs/common/payment.js +86 -0
- package/lib/cjs/common/turbo.js +105 -0
- package/lib/cjs/common/upload.js +59 -0
- package/lib/cjs/node/factory.js +34 -0
- package/lib/cjs/node/index.js +36 -0
- package/lib/cjs/node/signer.d.ts +36 -0
- package/lib/cjs/node/signer.js +61 -0
- package/lib/cjs/types/arweave.js +2 -0
- package/lib/cjs/types/index.js +34 -0
- package/lib/cjs/types/turbo.d.ts +149 -0
- package/lib/cjs/types/turbo.js +2 -0
- package/lib/cjs/utils/axiosClient.js +60 -0
- package/lib/cjs/utils/base64.d.ts +9 -0
- package/lib/cjs/utils/base64.js +47 -0
- package/lib/cjs/utils/errors.js +33 -0
- package/lib/cjs/utils/readableStream.d.ts +22 -0
- package/lib/cjs/utils/readableStream.js +28 -0
- package/lib/cjs/web/factory.js +34 -0
- package/lib/cjs/web/index.js +36 -0
- package/lib/cjs/web/signer.d.ts +37 -0
- package/lib/cjs/web/signer.js +69 -0
- package/lib/esm/common/factory.d.ts +21 -0
- package/lib/esm/common/index.js +19 -0
- package/lib/esm/common/payment.d.ts +41 -0
- package/lib/esm/common/turbo.d.ts +73 -0
- package/lib/esm/common/upload.d.ts +29 -0
- package/lib/esm/node/factory.d.ts +22 -0
- package/lib/esm/types/arweave.d.ts +29 -0
- package/lib/esm/types/index.js +18 -0
- package/lib/esm/utils/axiosClient.d.ts +23 -0
- package/lib/esm/utils/errors.d.ts +22 -0
- package/lib/esm/web/factory.d.ts +22 -0
- package/lib/esm/web/index.d.ts +20 -0
- package/lib/esm/web/index.js +20 -0
- package/lib/{web → esm/web}/signer.d.ts +1 -1
- package/lib/{web → esm/web}/signer.js +4 -3
- package/package.json +10 -6
- package/bundles/web.bundle.min.js +0 -55438
- /package/lib/{common → cjs/common}/factory.d.ts +0 -0
- /package/lib/{common → cjs/common}/index.d.ts +0 -0
- /package/lib/{common → cjs/common}/payment.d.ts +0 -0
- /package/lib/{common → cjs/common}/turbo.d.ts +0 -0
- /package/lib/{common → cjs/common}/upload.d.ts +0 -0
- /package/lib/{node → cjs/node}/factory.d.ts +0 -0
- /package/lib/{node → cjs/node}/index.d.ts +0 -0
- /package/lib/{types → cjs/types}/arweave.d.ts +0 -0
- /package/lib/{types → cjs/types}/index.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/axiosClient.d.ts +0 -0
- /package/lib/{utils → cjs/utils}/errors.d.ts +0 -0
- /package/lib/{web → cjs/web}/factory.d.ts +0 -0
- /package/lib/{web → cjs/web}/index.d.ts +0 -0
- /package/lib/{common → esm/common}/factory.js +0 -0
- /package/lib/{common → esm/common}/http.d.ts +0 -0
- /package/lib/{common → esm/common}/http.js +0 -0
- /package/lib/{common/index.js → esm/common/index.d.ts} +0 -0
- /package/lib/{common → esm/common}/payment.js +0 -0
- /package/lib/{common → esm/common}/turbo.js +0 -0
- /package/lib/{common → esm/common}/upload.js +0 -0
- /package/lib/{node → esm/node}/factory.js +0 -0
- /package/lib/{node/index.js → esm/node/index.d.ts} +0 -0
- /package/lib/{web → esm/node}/index.js +0 -0
- /package/lib/{node → esm/node}/signer.d.ts +0 -0
- /package/lib/{node → esm/node}/signer.js +0 -0
- /package/lib/{types → esm/types}/arweave.js +0 -0
- /package/lib/{types/index.js → esm/types/index.d.ts} +0 -0
- /package/lib/{types → esm/types}/turbo.d.ts +0 -0
- /package/lib/{types → esm/types}/turbo.js +0 -0
- /package/lib/{utils → esm/utils}/axiosClient.js +0 -0
- /package/lib/{utils → esm/utils}/base64.d.ts +0 -0
- /package/lib/{utils → esm/utils}/base64.js +0 -0
- /package/lib/{utils → esm/utils}/errors.js +0 -0
- /package/lib/{utils → esm/utils}/readableStream.d.ts +0 -0
- /package/lib/{utils → esm/utils}/readableStream.js +0 -0
- /package/lib/{web → esm/web}/factory.js +0 -0
@@ -0,0 +1,73 @@
|
|
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
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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
|
+
}
|
@@ -0,0 +1,22 @@
|
|
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
|
+
}
|
@@ -0,0 +1,29 @@
|
|
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
|
+
}
|
@@ -0,0 +1,18 @@
|
|
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';
|
@@ -0,0 +1,23 @@
|
|
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;
|
@@ -0,0 +1,22 @@
|
|
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
|
+
}
|
@@ -0,0 +1,22 @@
|
|
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
|
+
}
|
@@ -0,0 +1,20 @@
|
|
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';
|
@@ -0,0 +1,20 @@
|
|
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';
|
@@ -16,7 +16,7 @@
|
|
16
16
|
* You should have received a copy of the GNU Affero General Public License
|
17
17
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
18
|
*/
|
19
|
-
import { ArweaveSigner } from 'arbundles
|
19
|
+
import { ArweaveSigner } from 'arbundles';
|
20
20
|
import { ReadableStream } from 'node:stream/web';
|
21
21
|
import { JWKInterface } from '../types/arweave.js';
|
22
22
|
import { TurboWalletSigner } from '../types/turbo.js';
|
@@ -23,8 +23,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
23
23
|
* You should have received a copy of the GNU Affero General Public License
|
24
24
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
25
25
|
*/
|
26
|
-
import { ArweaveSigner, createData } from 'arbundles
|
27
|
-
import Arweave from 'arweave
|
26
|
+
import { ArweaveSigner, createData } from 'arbundles';
|
27
|
+
import Arweave from 'arweave';
|
28
28
|
import { randomBytes } from 'node:crypto';
|
29
29
|
import { toB64Url } from '../utils/base64.js';
|
30
30
|
import { readableStreamToBuffer } from '../utils/readableStream.js';
|
@@ -50,7 +50,8 @@ export class TurboWebArweaveSigner {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
51
51
|
const nonce = randomBytes(16).toString('hex');
|
52
52
|
const buffer = Buffer.from(nonce);
|
53
|
-
|
53
|
+
// a bit hacky - but easiest way to solve web signing issues while still building for cjs
|
54
|
+
const signature = yield Arweave.default.crypto.sign(this.privateKey, buffer, {});
|
54
55
|
return {
|
55
56
|
'x-public-key': this.privateKey.n,
|
56
57
|
'x-nonce': nonce,
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ardrive/turbo-sdk",
|
3
|
-
"version": "1.0.0-alpha.
|
3
|
+
"version": "1.0.0-alpha.7",
|
4
4
|
"main": "./lib/node/index.js",
|
5
5
|
"types": "./lib/types/index.d.ts",
|
6
6
|
"type": "module",
|
@@ -20,9 +20,14 @@
|
|
20
20
|
"website": "https://ardrive.io"
|
21
21
|
},
|
22
22
|
"exports": {
|
23
|
+
".": {
|
24
|
+
"import": "./lib/esm/node/index.js",
|
25
|
+
"require": "./lib/cjs/node/index.js",
|
26
|
+
"types": "./lib/node/index.d.ts"
|
27
|
+
},
|
23
28
|
"./node": {
|
24
|
-
"import": "./lib/node/index.js",
|
25
|
-
"require": "./lib/node/index.js",
|
29
|
+
"import": "./lib/esm/node/index.js",
|
30
|
+
"require": "./lib/cjs/node/index.js",
|
26
31
|
"types": "./lib/node/index.d.ts"
|
27
32
|
},
|
28
33
|
"./web": {
|
@@ -34,7 +39,7 @@
|
|
34
39
|
"./*": {
|
35
40
|
"import": "./*.js",
|
36
41
|
"require": "./*.js",
|
37
|
-
"types": "
|
42
|
+
"types": "./lib/web/index.d.ts"
|
38
43
|
}
|
39
44
|
},
|
40
45
|
"engines": {
|
@@ -43,8 +48,7 @@
|
|
43
48
|
"license": "AGPL-3.0-or-later",
|
44
49
|
"scripts": {
|
45
50
|
"build:web": "node bundle.cjs",
|
46
|
-
"build
|
47
|
-
"build": "yarn clean && yarn build:web && yarn build:esm",
|
51
|
+
"build": "yarn clean && yarn tsc -p tsconfig.json && yarn tsc -p tsconfig.cjs.json",
|
48
52
|
"clean": "rimraf [ lib coverage bundles ]",
|
49
53
|
"lint": "eslint src",
|
50
54
|
"lint:fix": "eslint src --fix",
|