@ardrive/turbo-sdk 1.4.2 → 1.5.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/README.md +27 -1
  2. package/bundles/web.bundle.min.js +7491 -1388
  3. package/lib/cjs/common/http.js +6 -2
  4. package/lib/cjs/common/index.js +1 -0
  5. package/lib/cjs/common/payment.js +106 -3
  6. package/lib/cjs/common/signer.js +45 -0
  7. package/lib/cjs/common/token.js +132 -0
  8. package/lib/cjs/common/turbo.js +13 -0
  9. package/lib/cjs/node/factory.js +2 -1
  10. package/lib/cjs/node/signer.js +4 -17
  11. package/lib/cjs/types.js +2 -0
  12. package/lib/cjs/utils/common.js +23 -0
  13. package/lib/cjs/version.js +1 -1
  14. package/lib/cjs/web/factory.js +3 -1
  15. package/lib/cjs/web/signer.js +22 -26
  16. package/lib/esm/common/http.js +6 -2
  17. package/lib/esm/common/index.js +1 -0
  18. package/lib/esm/common/payment.js +106 -3
  19. package/lib/esm/common/signer.js +41 -0
  20. package/lib/esm/common/token.js +123 -0
  21. package/lib/esm/common/turbo.js +13 -0
  22. package/lib/esm/node/factory.js +2 -1
  23. package/lib/esm/node/signer.js +5 -18
  24. package/lib/esm/types.js +1 -1
  25. package/lib/esm/utils/common.js +19 -0
  26. package/lib/esm/version.js +1 -1
  27. package/lib/esm/web/factory.js +3 -1
  28. package/lib/esm/web/signer.js +22 -26
  29. package/lib/types/common/http.d.ts.map +1 -1
  30. package/lib/types/common/index.d.ts +1 -0
  31. package/lib/types/common/index.d.ts.map +1 -1
  32. package/lib/types/common/logger.d.ts +4 -4
  33. package/lib/types/common/logger.d.ts.map +1 -1
  34. package/lib/types/common/payment.d.ts +10 -19
  35. package/lib/types/common/payment.d.ts.map +1 -1
  36. package/lib/types/common/signer.d.ts +16 -0
  37. package/lib/types/common/signer.d.ts.map +1 -0
  38. package/lib/types/common/token.d.ts +47 -0
  39. package/lib/types/common/token.d.ts.map +1 -0
  40. package/lib/types/common/turbo.d.ts +12 -1
  41. package/lib/types/common/turbo.d.ts.map +1 -1
  42. package/lib/types/node/factory.d.ts +1 -1
  43. package/lib/types/node/factory.d.ts.map +1 -1
  44. package/lib/types/node/signer.d.ts +4 -15
  45. package/lib/types/node/signer.d.ts.map +1 -1
  46. package/lib/types/types.d.ts +105 -5
  47. package/lib/types/types.d.ts.map +1 -1
  48. package/lib/types/utils/common.d.ts +18 -0
  49. package/lib/types/utils/common.d.ts.map +1 -0
  50. package/lib/types/version.d.ts +1 -1
  51. package/lib/types/version.d.ts.map +1 -1
  52. package/lib/types/web/factory.d.ts +1 -1
  53. package/lib/types/web/factory.d.ts.map +1 -1
  54. package/lib/types/web/signer.d.ts +8 -15
  55. package/lib/types/web/signer.d.ts.map +1 -1
  56. package/package.json +10 -5
@@ -1,15 +1,34 @@
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 { BigNumber } from 'bignumber.js';
1
18
  import { TurboHTTPService } from './http.js';
2
19
  import { TurboWinstonLogger } from './logger.js';
20
+ import { ArweaveToken } from './token.js';
3
21
  export const developmentPaymentServiceURL = 'https://payment.ardrive.dev';
4
22
  export const defaultPaymentServiceURL = 'https://payment.ardrive.io';
5
23
  export class TurboUnauthenticatedPaymentService {
6
- constructor({ url = defaultPaymentServiceURL, retryConfig, logger = new TurboWinstonLogger(), }) {
24
+ constructor({ url = defaultPaymentServiceURL, retryConfig, logger = new TurboWinstonLogger(), token = 'arweave', }) {
7
25
  this.logger = logger;
8
26
  this.httpService = new TurboHTTPService({
9
27
  url: `${url}/v1`,
10
28
  retryConfig,
11
29
  logger: this.logger,
12
30
  });
31
+ this.token = token;
13
32
  }
14
33
  getFiatRates() {
15
34
  return this.httpService.get({
@@ -70,12 +89,55 @@ export class TurboUnauthenticatedPaymentService {
70
89
  createCheckoutSession(params) {
71
90
  return this.getCheckout(params);
72
91
  }
92
+ async submitFundTransaction({ txId, }) {
93
+ const response = await this.httpService.post({
94
+ endpoint: `/account/balance/${this.token}`,
95
+ data: Buffer.from(JSON.stringify({ tx_id: txId })),
96
+ });
97
+ if ('creditedTransaction' in response) {
98
+ return {
99
+ id: response.creditedTransaction.transactionId,
100
+ quantity: response.creditedTransaction.transactionQuantity,
101
+ owner: response.creditedTransaction.destinationAddress,
102
+ winc: response.creditedTransaction.winstonCreditAmount,
103
+ token: response.creditedTransaction.tokenType,
104
+ status: 'confirmed',
105
+ block: response.creditedTransaction.blockHeight,
106
+ };
107
+ }
108
+ else if ('pendingTransaction' in response) {
109
+ return {
110
+ id: response.pendingTransaction.transactionId,
111
+ quantity: response.pendingTransaction.transactionQuantity,
112
+ owner: response.pendingTransaction.destinationAddress,
113
+ winc: response.pendingTransaction.winstonCreditAmount,
114
+ token: response.pendingTransaction.tokenType,
115
+ status: 'pending',
116
+ };
117
+ }
118
+ else if ('failedTransaction' in response) {
119
+ return {
120
+ id: response.failedTransaction.transactionId,
121
+ quantity: response.failedTransaction.transactionQuantity,
122
+ owner: response.failedTransaction.destinationAddress,
123
+ winc: response.failedTransaction.winstonCreditAmount,
124
+ token: response.failedTransaction.tokenType,
125
+ status: 'failed',
126
+ };
127
+ }
128
+ throw new Error('Unknown response from payment service: ' + response);
129
+ }
73
130
  }
74
131
  // NOTE: to avoid redundancy, we use inheritance here - but generally prefer composition over inheritance
75
132
  export class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymentService {
76
- constructor({ url = defaultPaymentServiceURL, retryConfig, signer, logger, }) {
77
- super({ url, retryConfig, logger });
133
+ constructor({ url = defaultPaymentServiceURL, retryConfig, signer, logger = new TurboWinstonLogger(), token = 'arweave', tokenMap = {
134
+ arweave: new ArweaveToken({
135
+ logger,
136
+ }),
137
+ }, }) {
138
+ super({ url, retryConfig, logger, token });
78
139
  this.signer = signer;
140
+ this.tokenMap = tokenMap;
79
141
  }
80
142
  async getBalance() {
81
143
  const headers = await this.signer.generateSignedRequestHeaders();
@@ -96,4 +158,45 @@ export class TurboAuthenticatedPaymentService extends TurboUnauthenticatedPaymen
96
158
  async createCheckoutSession(params) {
97
159
  return this.getCheckout(params, await this.signer.generateSignedRequestHeaders());
98
160
  }
161
+ async getTargetWalletForFund() {
162
+ const { addresses } = await this.httpService.get({
163
+ endpoint: '/info',
164
+ });
165
+ const walletAddress = addresses[this.token];
166
+ if (!walletAddress) {
167
+ throw new Error(`No wallet address found for token type: ${this.token}`);
168
+ }
169
+ return walletAddress;
170
+ }
171
+ async topUpWithTokens({ feeMultiplier = 1, tokenAmount: tokenAmountV, }) {
172
+ const tokenAmount = new BigNumber(tokenAmountV);
173
+ const target = await this.getTargetWalletForFund();
174
+ this.logger.debug('Funding account...', {
175
+ feeMultiplier,
176
+ tokenAmount,
177
+ target,
178
+ });
179
+ const fundTx = await this.tokenMap[this.token].createSignedTx({
180
+ target,
181
+ tokenAmount,
182
+ feeMultiplier,
183
+ signer: this.signer,
184
+ });
185
+ const txId = fundTx.id;
186
+ this.logger.debug('Submitting fund transaction...', { txId });
187
+ await this.tokenMap[this.token].submitTx({ tx: fundTx });
188
+ try {
189
+ // Let transaction settle some time
190
+ await this.tokenMap[this.token].pollForTxBeingAvailable({ txId });
191
+ return {
192
+ ...(await this.submitFundTransaction({ txId })),
193
+ target: fundTx.target,
194
+ reward: fundTx.reward,
195
+ };
196
+ }
197
+ catch (e) {
198
+ this.logger.debug('Failed to submit fund transaction...', e);
199
+ throw Error(`Failed to submit fund transaction! Save this Transaction ID and try again with 'turbo.submitFundTransaction(id)': ${txId}`);
200
+ }
201
+ }
99
202
  }
@@ -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 '@irys/arweave';
18
+ import { BigNumber } from 'bignumber.js';
19
+ import { sha256B64Url, toB64Url } from '../utils/base64.js';
20
+ import { sleep } from '../utils/common.js';
21
+ import { TurboWinstonLogger } from './logger.js';
22
+ export class ArweaveToken {
23
+ constructor({ arweave = Arweave.init({
24
+ url: 'https://arweave.net',
25
+ }), logger = new TurboWinstonLogger(), mintU = true, pollingOptions = {
26
+ maxAttempts: 10,
27
+ pollingIntervalMs: 3000,
28
+ initialBackoffMs: 7000,
29
+ }, }) {
30
+ this.arweave = arweave;
31
+ this.logger = logger;
32
+ this.mintU = mintU;
33
+ this.pollingOptions = pollingOptions;
34
+ }
35
+ async createSignedTx({ feeMultiplier, target, tokenAmount, signer, }) {
36
+ const tx = await this.arweave.createTransaction({
37
+ target,
38
+ quantity: tokenAmount.toString(),
39
+ data: '',
40
+ });
41
+ if (feeMultiplier !== 1) {
42
+ tx.reward = BigNumber(tx.reward)
43
+ .times(BigNumber(feeMultiplier))
44
+ .toFixed(0, BigNumber.ROUND_UP);
45
+ }
46
+ if (this.mintU) {
47
+ tx.addTag('App-Name', 'SmartWeaveAction');
48
+ tx.addTag('App-Version', '0.3.0'); // cspell:disable
49
+ tx.addTag('Contract', 'KTzTXT_ANmF84fWEKHzWURD1LWd9QaFR9yfYUwH2Lxw'); // cspell:enable
50
+ tx.addTag('Input', JSON.stringify({ function: 'mint' }));
51
+ }
52
+ const publicKeyB64Url = toB64Url(await signer.getPublicKey());
53
+ tx.setOwner(publicKeyB64Url);
54
+ const dataToSign = await tx.getSignatureData();
55
+ const signatureBuffer = Buffer.from(await signer.signData(dataToSign));
56
+ const id = sha256B64Url(signatureBuffer);
57
+ tx.setSignature({
58
+ id: id,
59
+ owner: publicKeyB64Url,
60
+ signature: toB64Url(signatureBuffer),
61
+ });
62
+ return tx;
63
+ }
64
+ async pollForTxBeingAvailable({ txId, }) {
65
+ const { maxAttempts, pollingIntervalMs, initialBackoffMs } = this.pollingOptions;
66
+ this.logger.debug('Polling for transaction...', { txId });
67
+ await sleep(initialBackoffMs);
68
+ let attempts = 0;
69
+ while (attempts < maxAttempts) {
70
+ let transaction;
71
+ attempts++;
72
+ try {
73
+ const response = await this.arweave.api.post('/graphql', {
74
+ query: `
75
+ query {
76
+ transaction(id: "${txId}") {
77
+ recipient
78
+ owner {
79
+ address
80
+ }
81
+ quantity {
82
+ winston
83
+ }
84
+ }
85
+ }
86
+ `,
87
+ });
88
+ transaction = response?.data?.data?.transaction;
89
+ }
90
+ catch (err) {
91
+ // Continue retries when request errors
92
+ this.logger.debug('Failed to poll for transaction...', { err });
93
+ }
94
+ if (transaction) {
95
+ return;
96
+ }
97
+ this.logger.debug('Transaction not found...', {
98
+ txId,
99
+ attempts,
100
+ maxAttempts,
101
+ pollingIntervalMs,
102
+ });
103
+ await sleep(pollingIntervalMs);
104
+ }
105
+ throw new Error('Transaction not found after polling, transaction id: ' + txId);
106
+ }
107
+ async submitTx({ tx }) {
108
+ try {
109
+ const response = await this.arweave.transactions.post(tx);
110
+ if (response.status !== 200) {
111
+ throw new Error('Failed to post transaction -- ' +
112
+ `Status ${response.status}, ${response.statusText}`);
113
+ }
114
+ this.logger.debug('Successfully posted fund transaction...', { tx });
115
+ }
116
+ catch (err) {
117
+ throw new Error(`Failed to post transaction -- ${err instanceof Error ? err.message : err}`);
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'*/];
@@ -0,0 +1,19 @@
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 function sleep(ms) {
18
+ return new Promise((resolve) => setTimeout(resolve, ms));
19
+ }
@@ -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.2';
18
+ export const version = '1.5.0-alpha.2';
@@ -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
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/common/http.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jB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3B,OAAO,CAAC,EAAE,OAAO,CAAC,yBAAyB,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACtE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,cAAc,CAAC;KAC1C,GAAG,OAAO,CAAC,CAAC,CAAC;CAoBf"}
@@ -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"}
@@ -22,10 +22,10 @@ export declare class TurboWinstonLogger implements TurboLogger {
22
22
  level?: 'info' | 'debug' | 'error' | 'none' | undefined;
23
23
  logFormat?: 'simple' | 'json' | undefined;
24
24
  });
25
- info(message: string, ...args: any[]): void;
26
- warn(message: string, ...args: any[]): void;
27
- error(message: string, ...args: any[]): void;
28
- debug(message: string, ...args: any[]): void;
25
+ info(message: string, ...args: unknown[]): void;
26
+ warn(message: string, ...args: unknown[]): void;
27
+ error(message: string, ...args: unknown[]): void;
28
+ debug(message: string, ...args: unknown[]): void;
29
29
  setLogLevel(level: string): void;
30
30
  setLogFormat(logFormat: string): void;
31
31
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAA6C,MAAM,SAAS,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,qBAAa,kBAAmB,YAAW,WAAW;IACpD,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;gBACrB,EACV,KAAc,EACd,SAAoB,GACrB,GAAE;QACD,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;QACxD,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;KACtC;IAUN,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIpC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIrC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE;IAIrC,WAAW,CAAC,KAAK,EAAE,MAAM;IAIzB,YAAY,CAAC,SAAS,EAAE,MAAM;CAG/B"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/common/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,OAA6C,MAAM,SAAS,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,qBAAa,kBAAmB,YAAW,WAAW;IACpD,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;gBACrB,EACV,KAAc,EACd,SAAoB,GACrB,GAAE;QACD,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;QACxD,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;KACtC;IAUN,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIxC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE;IAIzC,WAAW,CAAC,KAAK,EAAE,MAAM;IAIzB,YAAY,CAAC,SAAS,EAAE,MAAM;CAG/B"}
@@ -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,OAA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AAC,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM;cAK/C,WAAW,CACzB,EACE,MAAM,EACN,KAAK,EACL,UAAe,EACf,MAAiB,GAClB,EAAE,0BAA0B,EAC7B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,4BAA4B,CAAC;IA0BjC,qBAAqB,CAC1B,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,4BAA4B,CAAC;IAI3B,qBAAqB,CAAC,EACjC,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,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;CAuChE"}
@@ -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"}