@ardrive/turbo-sdk 1.4.1 → 1.5.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +33 -72
  2. package/bundles/web.bundle.min.js +4116 -348
  3. package/lib/cjs/common/index.js +1 -0
  4. package/lib/cjs/common/payment.js +104 -3
  5. package/lib/cjs/common/signer.js +45 -0
  6. package/lib/cjs/common/token.js +132 -0
  7. package/lib/cjs/common/turbo.js +13 -0
  8. package/lib/cjs/node/factory.js +2 -1
  9. package/lib/cjs/node/signer.js +4 -17
  10. package/lib/cjs/types.js +2 -0
  11. package/lib/cjs/version.js +1 -1
  12. package/lib/cjs/web/factory.js +3 -1
  13. package/lib/cjs/web/signer.js +22 -26
  14. package/lib/esm/common/index.js +1 -0
  15. package/lib/esm/common/payment.js +104 -3
  16. package/lib/esm/common/signer.js +41 -0
  17. package/lib/esm/common/token.js +123 -0
  18. package/lib/esm/common/turbo.js +13 -0
  19. package/lib/esm/node/factory.js +2 -1
  20. package/lib/esm/node/signer.js +5 -18
  21. package/lib/esm/types.js +1 -1
  22. package/lib/esm/version.js +1 -1
  23. package/lib/esm/web/factory.js +3 -1
  24. package/lib/esm/web/signer.js +22 -26
  25. package/lib/types/common/index.d.ts +1 -0
  26. package/lib/types/common/index.d.ts.map +1 -1
  27. package/lib/types/common/payment.d.ts +10 -19
  28. package/lib/types/common/payment.d.ts.map +1 -1
  29. package/lib/types/common/signer.d.ts +16 -0
  30. package/lib/types/common/signer.d.ts.map +1 -0
  31. package/lib/types/common/token.d.ts +56 -0
  32. package/lib/types/common/token.d.ts.map +1 -0
  33. package/lib/types/common/turbo.d.ts +12 -1
  34. package/lib/types/common/turbo.d.ts.map +1 -1
  35. package/lib/types/node/factory.d.ts +1 -1
  36. package/lib/types/node/factory.d.ts.map +1 -1
  37. package/lib/types/node/signer.d.ts +4 -15
  38. package/lib/types/node/signer.d.ts.map +1 -1
  39. package/lib/types/types.d.ts +108 -5
  40. package/lib/types/types.d.ts.map +1 -1
  41. package/lib/types/version.d.ts +1 -1
  42. package/lib/types/web/factory.d.ts +1 -1
  43. package/lib/types/web/factory.d.ts.map +1 -1
  44. package/lib/types/web/signer.d.ts +8 -15
  45. package/lib/types/web/signer.d.ts.map +1 -1
  46. package/package.json +10 -5
@@ -0,0 +1,41 @@
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 { randomBytes } from 'crypto';
18
+ import { toB64Url } from '../utils/base64.js';
19
+ export class TurboDataItemAbstractSigner {
20
+ constructor({ signer, logger }) {
21
+ this.logger = logger;
22
+ this.signer = signer;
23
+ }
24
+ async generateSignedRequestHeaders() {
25
+ const nonce = randomBytes(16).toString('hex');
26
+ const buffer = Buffer.from(nonce);
27
+ const signature = await this.signer.sign(buffer);
28
+ const publicKey = toB64Url(this.signer.publicKey);
29
+ return {
30
+ 'x-public-key': publicKey,
31
+ 'x-nonce': nonce,
32
+ 'x-signature': toB64Url(Buffer.from(signature)),
33
+ };
34
+ }
35
+ async getPublicKey() {
36
+ return this.signer.publicKey;
37
+ }
38
+ async signData(dataToSign) {
39
+ return this.signer.sign(dataToSign);
40
+ }
41
+ }
@@ -0,0 +1,123 @@
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 Arweave from 'arweave';
18
+ import { BigNumber } from 'bignumber.js';
19
+ import { sha256B64Url, toB64Url } from '../utils/base64.js';
20
+ import { TurboWinstonLogger } from './logger.js';
21
+ export class ArweaveToken {
22
+ constructor({ arweave = Arweave.init({
23
+ host: 'arweave.net',
24
+ port: 443,
25
+ protocol: 'https',
26
+ }), logger = new TurboWinstonLogger(), mintU = true, pollingOptions = {
27
+ maxAttempts: 10,
28
+ pollingIntervalMs: 3000,
29
+ initialBackoffMs: 7000,
30
+ }, }) {
31
+ this.arweave = arweave;
32
+ this.logger = logger;
33
+ this.mintU = mintU;
34
+ this.pollingOptions = pollingOptions;
35
+ }
36
+ async createTx({ feeMultiplier, target, tokenAmount, }) {
37
+ const tx = await this.arweave.createTransaction({
38
+ target,
39
+ quantity: tokenAmount.toString(),
40
+ data: '',
41
+ });
42
+ if (feeMultiplier !== 1) {
43
+ tx.reward = BigNumber(tx.reward)
44
+ .times(BigNumber(feeMultiplier))
45
+ .toFixed(0, BigNumber.ROUND_UP);
46
+ }
47
+ if (this.mintU) {
48
+ tx.addTag('App-Name', 'SmartWeaveAction');
49
+ tx.addTag('App-Version', '0.3.0'); // cspell:disable
50
+ tx.addTag('Contract', 'KTzTXT_ANmF84fWEKHzWURD1LWd9QaFR9yfYUwH2Lxw'); // cspell:enable
51
+ tx.addTag('Input', JSON.stringify({ function: 'mint' }));
52
+ }
53
+ return tx;
54
+ }
55
+ async signTx({ tx, signer, }) {
56
+ const publicKeyB64Url = toB64Url(await signer.getPublicKey());
57
+ tx.setOwner(publicKeyB64Url);
58
+ const dataToSign = await tx.getSignatureData();
59
+ const signatureBuffer = Buffer.from(await signer.signData(dataToSign));
60
+ const id = sha256B64Url(signatureBuffer);
61
+ tx.setSignature({
62
+ id: id,
63
+ owner: publicKeyB64Url,
64
+ signature: toB64Url(signatureBuffer),
65
+ });
66
+ return tx;
67
+ }
68
+ async pollForTxBeingAvailable({ txId, }) {
69
+ const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
70
+ await new Promise((resolve) => setTimeout(resolve, initialBackoffMs));
71
+ let attempts = 0;
72
+ while (attempts < maxAttempts) {
73
+ const response = await this.arweave.api
74
+ .post('/graphql', {
75
+ query: `
76
+ query {
77
+ transaction(id: "${txId}") {
78
+ recipient
79
+ owner {
80
+ address
81
+ }
82
+ quantity {
83
+ winston
84
+ }
85
+ }
86
+ }
87
+ `,
88
+ })
89
+ .catch((err) => {
90
+ // Continue retries when request errors
91
+ this.logger.error('Failed to poll for transaction...', { err });
92
+ return undefined;
93
+ });
94
+ const transaction = response?.data?.data?.transaction;
95
+ if (transaction) {
96
+ return;
97
+ }
98
+ attempts++;
99
+ this.logger.debug('Transaction not found after polling...', {
100
+ txId,
101
+ attempts,
102
+ });
103
+ await new Promise((resolve) => setTimeout(resolve, pollingIntervalMs));
104
+ }
105
+ throw new Error('Transaction not found after polling, transaction id: ' + txId);
106
+ }
107
+ async submitTx({ tx }) {
108
+ const response = await this.arweave.transactions.post(tx).catch((err) => {
109
+ this.logger.error('Failed to post transaction...', { err });
110
+ return {
111
+ status: 500,
112
+ statusText: err instanceof Error ? err.message : 'Failed to post Arweave Tx!',
113
+ };
114
+ });
115
+ if (response.status !== 200) {
116
+ throw new Error('Failed to post transaction -- ' +
117
+ `Status ${response.status}, ${response.statusText}`);
118
+ }
119
+ this.logger.debug('Posted transaction...', { tx });
120
+ }
121
+ }
122
+ export const WinstonToTokenAmount = (winston) => winston;
123
+ export const ARToTokenAmount = (ar) => new BigNumber(ar).times(1e12).valueOf();
@@ -82,6 +82,12 @@ export class TurboUnauthenticatedClient {
82
82
  createCheckoutSession(params) {
83
83
  return this.paymentService.createCheckoutSession(params);
84
84
  }
85
+ /**
86
+ * Submits a transaction ID to the Turbo Payment Service for processing.
87
+ */
88
+ submitFundTransaction(p) {
89
+ return this.paymentService.submitFundTransaction(p);
90
+ }
85
91
  }
86
92
  export class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
87
93
  constructor({ paymentService, uploadService, }) {
@@ -104,4 +110,11 @@ export class TurboAuthenticatedClient extends TurboUnauthenticatedClient {
104
110
  dataItemOpts,
105
111
  });
106
112
  }
113
+ /**
114
+ * Submits fund transaction to the token's blockchain then sends
115
+ * the transaction ID to the Turbo Payment Service for processing.
116
+ */
117
+ topUpWithTokens(p) {
118
+ return this.paymentService.topUpWithTokens(p);
119
+ }
107
120
  }
@@ -19,7 +19,7 @@ import { TurboBaseFactory } from '../common/factory.js';
19
19
  import { TurboAuthenticatedClient, TurboAuthenticatedPaymentService, TurboAuthenticatedUploadService, } from '../common/index.js';
20
20
  import { TurboNodeArweaveSigner } from './signer.js';
21
21
  export class TurboFactory extends TurboBaseFactory {
22
- static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, }) {
22
+ static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, tokenMap, }) {
23
23
  let signer;
24
24
  if (providedSigner) {
25
25
  signer = providedSigner;
@@ -38,6 +38,7 @@ export class TurboFactory extends TurboBaseFactory {
38
38
  ...paymentServiceConfig,
39
39
  signer: turboSigner,
40
40
  logger: this.logger,
41
+ tokenMap,
41
42
  });
42
43
  const uploadService = new TurboAuthenticatedUploadService({
43
44
  ...uploadServiceConfig,
@@ -15,12 +15,11 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  import { serializeTags, streamSigner } from 'arbundles';
18
- import { randomBytes } from 'node:crypto';
19
- import { fromB64Url, toB64Url } from '../utils/base64.js';
20
- export class TurboNodeArweaveSigner {
21
- constructor({ signer, logger, }) {
22
- this.logger = logger;
23
- this.signer = signer;
18
+ import { TurboDataItemAbstractSigner } from '../common/signer.js';
19
+ import { fromB64Url } from '../utils/base64.js';
20
+ export class TurboNodeArweaveSigner extends TurboDataItemAbstractSigner {
21
+ constructor(p) {
22
+ super(p);
24
23
  }
25
24
  async signDataItem({ fileStreamFactory, fileSizeFactory, dataItemOpts, }) {
26
25
  // TODO: replace with our own signer implementation
@@ -38,18 +37,6 @@ export class TurboNodeArweaveSigner {
38
37
  dataItemSizeFactory: () => signedDataItemSize,
39
38
  };
40
39
  }
41
- // 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
42
- async generateSignedRequestHeaders() {
43
- const nonce = randomBytes(16).toString('hex');
44
- const buffer = Buffer.from(nonce);
45
- const signature = await this.signer.sign(buffer);
46
- const publicKey = toB64Url(this.signer.publicKey);
47
- return {
48
- 'x-public-key': publicKey,
49
- 'x-nonce': nonce,
50
- 'x-signature': toB64Url(Buffer.from(signature)),
51
- };
52
- }
53
40
  // TODO: make dynamic that accepts anchor and target and tags to return the size of the headers + data
54
41
  // reference https://github.com/ArweaveTeam/arweave-standards/blob/master/ans/ANS-104.md#13-dataitem-format
55
42
  calculateSignedDataHeadersSize({ dataSize, dataItemOpts, }) {
package/lib/esm/types.js CHANGED
@@ -1 +1 @@
1
- export {};
1
+ export const tokenTypes = ['arweave' /*'solana', 'ethereum'*/];
@@ -15,4 +15,4 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  // AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
18
- export const version = '1.4.1';
18
+ export const version = '1.5.0-alpha.1';
@@ -19,7 +19,7 @@ import { TurboBaseFactory } from '../common/factory.js';
19
19
  import { TurboAuthenticatedClient, TurboAuthenticatedPaymentService, TurboAuthenticatedUploadService, } from '../common/index.js';
20
20
  import { TurboWebArweaveSigner } from './signer.js';
21
21
  export class TurboFactory extends TurboBaseFactory {
22
- static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, }) {
22
+ static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig = {}, uploadServiceConfig = {}, tokenMap, token, }) {
23
23
  let signer;
24
24
  if (providedSigner) {
25
25
  signer = providedSigner;
@@ -38,6 +38,8 @@ export class TurboFactory extends TurboBaseFactory {
38
38
  ...paymentServiceConfig,
39
39
  signer: turboSigner,
40
40
  logger: this.logger,
41
+ tokenMap,
42
+ token,
41
43
  });
42
44
  const uploadService = new TurboAuthenticatedUploadService({
43
45
  ...uploadServiceConfig,
@@ -15,25 +15,30 @@
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
17
17
  import { ArconnectSigner, createData } from 'arbundles';
18
- import { randomBytes } from 'crypto';
19
- import { toB64Url } from '../utils/base64.js';
18
+ import { TurboDataItemAbstractSigner } from '../common/signer.js';
20
19
  import { readableStreamToBuffer } from '../utils/readableStream.js';
21
- export class TurboWebArweaveSigner {
22
- constructor({ logger, signer, }) {
23
- this.logger = logger;
24
- this.signer = signer;
20
+ export class TurboWebArweaveSigner extends TurboDataItemAbstractSigner {
21
+ constructor(p) {
22
+ super(p);
23
+ }
24
+ async setPublicKey() {
25
+ // for arconnect, we need to make sure we have the public key before create data
26
+ if (this.signer.publicKey === undefined &&
27
+ this.signer instanceof ArconnectSigner) {
28
+ await this.signer.setPublicKey();
29
+ }
30
+ }
31
+ async getPublicKey() {
32
+ await this.setPublicKey();
33
+ return super.getPublicKey();
25
34
  }
26
35
  async signDataItem({ fileStreamFactory, fileSizeFactory, dataItemOpts, }) {
36
+ await this.setPublicKey();
27
37
  // TODO: converts the readable stream to a buffer bc incrementally signing ReadableStreams is not trivial
28
38
  const buffer = await readableStreamToBuffer({
29
39
  stream: fileStreamFactory(),
30
40
  size: fileSizeFactory(),
31
41
  });
32
- // for arconnect, we need to make sure we have the public key before create data
33
- if (this.signer.publicKey === undefined &&
34
- this.signer instanceof ArconnectSigner) {
35
- await this.signer.setPublicKey();
36
- }
37
42
  this.logger.debug('Signing data item...');
38
43
  const signedDataItem = createData(buffer, this.signer, dataItemOpts);
39
44
  await signedDataItem.sign(this.signer);
@@ -44,21 +49,12 @@ export class TurboWebArweaveSigner {
44
49
  dataItemSizeFactory: () => signedDataItem.getRaw().length,
45
50
  };
46
51
  }
47
- // 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
48
52
  async generateSignedRequestHeaders() {
49
- const nonce = randomBytes(16).toString('hex');
50
- const buffer = Buffer.from(nonce);
51
- const signature = await this.signer.sign(buffer);
52
- // for arconnect, we need to make sure we have the public key
53
- if (this.signer.publicKey === undefined &&
54
- this.signer instanceof ArconnectSigner) {
55
- await this.signer.setPublicKey();
56
- }
57
- const publicKey = toB64Url(this.signer.publicKey);
58
- return {
59
- 'x-public-key': publicKey,
60
- 'x-nonce': nonce,
61
- 'x-signature': toB64Url(Buffer.from(signature)),
62
- };
53
+ await this.setPublicKey();
54
+ return super.generateSignedRequestHeaders();
55
+ }
56
+ async signData(dataToSign) {
57
+ await this.setPublicKey();
58
+ return super.signData(dataToSign);
63
59
  }
64
60
  }
@@ -18,4 +18,5 @@ export * from './upload.js';
18
18
  export * from './payment.js';
19
19
  export * from './turbo.js';
20
20
  export * from './currency.js';
21
+ export * from './token.js';
21
22
  //# sourceMappingURL=index.d.ts.map
@@ -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;AAC3B,cAAc,eAAe,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;AAC9B,cAAc,YAAY,CAAC"}
@@ -1,27 +1,12 @@
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, TurboAuthenticatedPaymentServiceConfiguration, TurboAuthenticatedPaymentServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatToArResponse, TurboLogger, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboUnauthenticatedPaymentServiceConfiguration, TurboUnauthenticatedPaymentServiceInterface, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
1
+ import { Currency, TokenMap, TokenType, TurboAuthenticatedPaymentServiceConfiguration, TurboAuthenticatedPaymentServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboDataItemSigner, TurboFiatToArResponse, TurboFundWithTokensParams, TurboLogger, TurboPriceResponse, TurboRatesResponse, TurboSignedRequestHeaders, TurboSubmitFundTxResponse, TurboUnauthenticatedPaymentServiceConfiguration, TurboUnauthenticatedPaymentServiceInterface, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
18
2
  import { TurboHTTPService } from './http.js';
19
3
  export declare const developmentPaymentServiceURL = "https://payment.ardrive.dev";
20
4
  export declare const defaultPaymentServiceURL = "https://payment.ardrive.io";
21
5
  export declare class TurboUnauthenticatedPaymentService implements TurboUnauthenticatedPaymentServiceInterface {
22
6
  protected readonly httpService: TurboHTTPService;
23
7
  protected logger: TurboLogger;
24
- constructor({ url, retryConfig, logger, }: TurboUnauthenticatedPaymentServiceConfiguration);
8
+ protected readonly token: TokenType;
9
+ constructor({ url, retryConfig, logger, token, }: TurboUnauthenticatedPaymentServiceConfiguration);
25
10
  getFiatRates(): Promise<TurboRatesResponse>;
26
11
  getFiatToAR({ currency, }: {
27
12
  currency: Currency;
@@ -35,12 +20,18 @@ export declare class TurboUnauthenticatedPaymentService implements TurboUnauthen
35
20
  protected appendPromoCodesToQuery(promoCodes: string[]): string;
36
21
  protected getCheckout({ amount, owner, promoCodes, uiMode, }: TurboCheckoutSessionParams, headers?: TurboSignedRequestHeaders): Promise<TurboCheckoutSessionResponse>;
37
22
  createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
23
+ submitFundTransaction({ txId, }: {
24
+ txId: string;
25
+ }): Promise<TurboSubmitFundTxResponse>;
38
26
  }
39
27
  export declare class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService implements TurboAuthenticatedPaymentServiceInterface {
40
28
  protected readonly signer: TurboDataItemSigner;
41
- constructor({ url, retryConfig, signer, logger, }: TurboAuthenticatedPaymentServiceConfiguration);
29
+ protected readonly tokenMap: TokenMap;
30
+ constructor({ url, retryConfig, signer, logger, token, tokenMap, }: TurboAuthenticatedPaymentServiceConfiguration);
42
31
  getBalance(): Promise<TurboBalanceResponse>;
43
32
  getWincForFiat({ amount, promoCodes, }: TurboWincForFiatParams): Promise<TurboWincForFiatResponse>;
44
33
  createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
34
+ private getTargetWalletForFund;
35
+ topUpWithTokens({ feeMultiplier, tokenAmount: tokenAmountV, }: TurboFundWithTokensParams): Promise<TurboCryptoFundResponse>;
45
36
  }
46
37
  //# 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,EAER,6CAA6C,EAC7C,yCAAyC,EACzC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,+CAA+C,EAC/C,2CAA2C,EAC3C,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAG7C,eAAO,MAAM,4BAA4B,gCAAgC,CAAC;AAC1E,eAAO,MAAM,wBAAwB,+BAA+B,CAAC;AAErE,qBAAa,kCACX,YAAW,2CAA2C;IAEtD,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACjD,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;gBAElB,EACV,GAA8B,EAC9B,WAAW,EACX,MAAiC,GAClC,EAAE,+CAA+C;IAS3C,YAAY,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAM3C,WAAW,CAAC,EACjB,QAAQ,GACT,EAAE;QACD,QAAQ,EAAE,QAAQ,CAAC;KACpB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAM3B,qBAAqB,IAAI,OAAO,CAAC,sBAAsB,CAAC;IAMxD,sBAAsB,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAMpD,cAAc,CAAC,EAC1B,KAAK,GACN,EAAE;QACD,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,GAAG,OAAO,CAAC,kBAAkB,EAAE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M,CAAC;KACd,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAqCvC;AAED,qBAAa,gCACX,SAAQ,kCACR,YAAW,yCAAyC;IAEpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,mBAAmB,CAAC;IAC/C,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;gBAE1B,EACV,GAA8B,EAC9B,WAAW,EACX,MAAM,EACN,MAAiC,EACjC,KAAiB,EACjB,QAIC,GACF,EAAE,6CAA6C;IAMnC,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;YAO1B,sBAAsB;IAYvB,eAAe,CAAC,EAC3B,aAAiB,EACjB,WAAW,EAAE,YAAY,GAC1B,EAAE,yBAAyB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAmChE"}
@@ -0,0 +1,16 @@
1
+ /// <reference types="node" />
2
+ import { FileStreamFactory, TurboDataItemSigner, TurboDataItemSignerParams, TurboFileFactory, TurboLogger, TurboSignedDataItemFactory, TurboSigner } from '../types.js';
3
+ export declare abstract class TurboDataItemAbstractSigner implements TurboDataItemSigner {
4
+ abstract signDataItem({ fileStreamFactory, fileSizeFactory, dataItemOpts, }: TurboFileFactory<FileStreamFactory>): Promise<TurboSignedDataItemFactory>;
5
+ protected logger: TurboLogger;
6
+ protected signer: TurboSigner;
7
+ constructor({ signer, logger }: TurboDataItemSignerParams);
8
+ generateSignedRequestHeaders(): Promise<{
9
+ 'x-public-key': string;
10
+ 'x-nonce': string;
11
+ 'x-signature': string;
12
+ }>;
13
+ getPublicKey(): Promise<Buffer>;
14
+ signData(dataToSign: Uint8Array): Promise<Uint8Array>;
15
+ }
16
+ //# sourceMappingURL=signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/common/signer.ts"],"names":[],"mappings":";AAkBA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,WAAW,EACX,0BAA0B,EAC1B,WAAW,EACZ,MAAM,aAAa,CAAC;AAGrB,8BAAsB,2BACpB,YAAW,mBAAmB;IAE9B,QAAQ,CAAC,YAAY,CAAC,EACpB,iBAAiB,EACjB,eAAe,EACf,YAAY,GACb,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAE5E,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAC9B,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;gBAElB,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,yBAAyB;IAK5C,4BAA4B;;;;;IAY5B,YAAY,IAAI,OAAO,CAAC,MAAM,CAAC;IAI/B,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;CAGnE"}
@@ -0,0 +1,56 @@
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 Arweave from 'arweave';
18
+ import * as Transaction from 'arweave/node/lib/transaction.js';
19
+ import { BigNumber } from 'bignumber.js';
20
+ import { TokenTools, TurboDataItemSigner, TurboLogger } from '../types.js';
21
+ type PollingOptions = {
22
+ maxAttempts: number;
23
+ pollingIntervalMs: number;
24
+ initialBackoffMs: number;
25
+ };
26
+ export declare class ArweaveToken implements TokenTools<Transaction.default> {
27
+ protected logger: TurboLogger;
28
+ protected arweave: Arweave;
29
+ protected mintU: boolean;
30
+ protected pollingOptions: PollingOptions;
31
+ constructor({ arweave, logger, mintU, pollingOptions, }: {
32
+ arweave?: Arweave;
33
+ logger?: TurboLogger;
34
+ mintU?: boolean;
35
+ pollingOptions?: PollingOptions;
36
+ });
37
+ createTx({ feeMultiplier, target, tokenAmount, }: {
38
+ target: string;
39
+ tokenAmount: BigNumber;
40
+ feeMultiplier: number;
41
+ }): Promise<Transaction.default>;
42
+ signTx({ tx, signer, }: {
43
+ tx: Transaction.default;
44
+ signer: TurboDataItemSigner;
45
+ }): Promise<Transaction.default>;
46
+ pollForTxBeingAvailable({ txId, }: {
47
+ txId: string;
48
+ }): Promise<void>;
49
+ submitTx({ tx }: {
50
+ tx: Transaction.default;
51
+ }): Promise<void>;
52
+ }
53
+ export declare const WinstonToTokenAmount: (winston: BigNumber.Value) => BigNumber.Value;
54
+ export declare const ARToTokenAmount: (ar: BigNumber.Value) => string;
55
+ export {};
56
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/common/token.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,WAAW,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI3E,KAAK,cAAc,GAAG;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC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
15
15
  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16
16
  */
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';
17
+ import { Currency, TurboAbortSignal, TurboAuthenticatedClientConfiguration, TurboAuthenticatedClientInterface, TurboAuthenticatedPaymentServiceInterface, TurboAuthenticatedUploadServiceInterface, TurboBalanceResponse, TurboCheckoutSessionParams, TurboCheckoutSessionResponse, TurboCountriesResponse, TurboCryptoFundResponse, TurboCurrenciesResponse, TurboFiatToArResponse, TurboFileFactory, TurboFundWithTokensParams, TurboPriceResponse, TurboRatesResponse, TurboSignedDataItemFactory, TurboSubmitFundTxResponse, TurboUnauthenticatedClientConfiguration, TurboUnauthenticatedClientInterface, TurboUnauthenticatedPaymentServiceInterface, TurboUnauthenticatedUploadServiceInterface, TurboUploadDataItemResponse, TurboWincForFiatParams, TurboWincForFiatResponse } from '../types.js';
18
18
  /**
19
19
  * Testing configuration.
20
20
  */
@@ -80,6 +80,12 @@ export declare class TurboUnauthenticatedClient implements TurboUnauthenticatedC
80
80
  * Creates a Turbo Checkout Session for a given amount and currency.
81
81
  */
82
82
  createCheckoutSession(params: TurboCheckoutSessionParams): Promise<TurboCheckoutSessionResponse>;
83
+ /**
84
+ * Submits a transaction ID to the Turbo Payment Service for processing.
85
+ */
86
+ submitFundTransaction(p: {
87
+ txId: string;
88
+ }): Promise<TurboSubmitFundTxResponse>;
83
89
  }
84
90
  export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient implements TurboAuthenticatedClientInterface {
85
91
  protected paymentService: TurboAuthenticatedPaymentServiceInterface;
@@ -93,5 +99,10 @@ export declare class TurboAuthenticatedClient extends TurboUnauthenticatedClient
93
99
  * Signs and uploads raw data to the Turbo Upload Service.
94
100
  */
95
101
  uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts, }: TurboFileFactory & TurboAbortSignal): Promise<TurboUploadDataItemResponse>;
102
+ /**
103
+ * Submits fund transaction to the token's blockchain then sends
104
+ * the transaction ID to the Turbo Payment Service for processing.
105
+ */
106
+ topUpWithTokens(p: TurboFundWithTokensParams): Promise<TurboCryptoFundResponse>;
96
107
  }
97
108
  //# 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,qCAAqC,EACrC,iCAAiC,EACjC,yCAAyC,EACzC,wCAAwC,EACxC,oBAAoB,EACpB,0BAA0B,EAC1B,4BAA4B,EAC5B,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,0BAA0B,EAC1B,uCAAuC,EACvC,mCAAmC,EACnC,2CAA2C,EAC3C,0CAA0C,EAC1C,2BAA2B,EAC3B,sBAAsB,EACtB,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAYrB;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;CAOzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;CAOrC,CAAC;AAEF,qBAAa,0BACX,YAAW,mCAAmC;IAE9C,SAAS,CAAC,cAAc,EAAE,2CAA2C,CAAC;IACtE,SAAS,CAAC,aAAa,EAAE,0CAA0C,CAAC;gBAExD,EACV,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G;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;IAIxC;;OAEG;IACH,qBAAqB,CAAC,CAAC,EAAE;QACvB,IAAI,EAAE,MAAM,CAAC;KACd,GAAG,OAAO,CAAC,yBAAyB,CAAC;CAGvC;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,EACN,YAAY,GACb,EAAE,gBAAgB,GACjB,gBAAgB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IASzD;;;OAGG;IACH,eAAe,CACb,CAAC,EAAE,yBAAyB,GAC3B,OAAO,CAAC,uBAAuB,CAAC;CAGpC"}
@@ -2,6 +2,6 @@ import { TurboBaseFactory } from '../common/factory.js';
2
2
  import { TurboAuthenticatedClient } from '../common/index.js';
3
3
  import { TurboAuthenticatedConfiguration } from '../types.js';
4
4
  export declare class TurboFactory extends TurboBaseFactory {
5
- static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig, uploadServiceConfig, }: TurboAuthenticatedConfiguration): TurboAuthenticatedClient;
5
+ static authenticated({ privateKey, signer: providedSigner, paymentServiceConfig, uploadServiceConfig, tokenMap, }: TurboAuthenticatedConfiguration): TurboAuthenticatedClient;
6
6
  }
7
7
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/node/factory.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,wBAAwB,EAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,+BAA+B,EAAe,MAAM,aAAa,CAAC;AAG3E,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,MAAM,CAAC,aAAa,CAAC,EACnB,UAAU,EACV,MAAM,EAAE,cAAc,EACtB,oBAAyB,EACzB,mBAAwB,GACzB,EAAE,+BAA+B;CA8BnC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/node/factory.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EACL,wBAAwB,EAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,+BAA+B,EAAe,MAAM,aAAa,CAAC;AAG3E,qBAAa,YAAa,SAAQ,gBAAgB;IAChD,MAAM,CAAC,aAAa,CAAC,EACnB,UAAU,EACV,MAAM,EAAE,cAAc,EACtB,oBAAyB,EACzB,mBAAwB,EACxB,QAAQ,GACT,EAAE,+BAA+B;CA+BnC"}
@@ -1,15 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { Readable } from 'node:stream';
3
- import { JWKInterface } from '../common/jwk.js';
4
- import { DataItemOptions, StreamSizeFactory, TurboDataItemSigner, TurboLogger, TurboSigner } from '../types.js';
5
- export declare class TurboNodeArweaveSigner implements TurboDataItemSigner {
6
- protected privateKey: JWKInterface;
7
- protected signer: TurboSigner;
8
- protected logger: TurboLogger;
9
- constructor({ signer, logger, }: {
10
- signer: TurboSigner;
11
- logger: TurboLogger;
12
- });
3
+ import { TurboDataItemAbstractSigner } from '../common/signer.js';
4
+ import { DataItemOptions, StreamSizeFactory, TurboDataItemSignerParams } from '../types.js';
5
+ export declare class TurboNodeArweaveSigner extends TurboDataItemAbstractSigner {
6
+ constructor(p: TurboDataItemSignerParams);
13
7
  signDataItem({ fileStreamFactory, fileSizeFactory, dataItemOpts, }: {
14
8
  fileStreamFactory: () => Readable;
15
9
  fileSizeFactory: StreamSizeFactory;
@@ -18,11 +12,6 @@ export declare class TurboNodeArweaveSigner implements TurboDataItemSigner {
18
12
  dataItemStreamFactory: () => Readable;
19
13
  dataItemSizeFactory: StreamSizeFactory;
20
14
  }>;
21
- generateSignedRequestHeaders(): Promise<{
22
- 'x-public-key': string;
23
- 'x-nonce': string;
24
- 'x-signature': string;
25
- }>;
26
15
  private calculateSignedDataHeadersSize;
27
16
  }
28
17
  //# sourceMappingURL=signer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/node/signer.ts"],"names":[],"mappings":";AAkBA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,WAAW,EACX,WAAW,EACZ,MAAM,aAAa,CAAC;AAGrB,qBAAa,sBAAuB,YAAW,mBAAmB;IAChE,SAAS,CAAC,UAAU,EAAE,YAAY,CAAC;IACnC,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;IAC9B,SAAS,CAAC,MAAM,EAAE,WAAW,CAAC;gBAClB,EACV,MAAM,EACN,MAAM,GACP,EAAE;QACD,MAAM,EAAE,WAAW,CAAC;QACpB,MAAM,EAAE,WAAW,CAAC;KACrB;IAKK,YAAY,CAAC,EACjB,iBAAiB,EACjB,eAAe,EACf,YAAY,GACb,EAAE;QACD,iBAAiB,EAAE,MAAM,QAAQ,CAAC;QAClC,eAAe,EAAE,iBAAiB,CAAC;QACnC,YAAY,CAAC,EAAE,eAAe,C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