@internxt/sdk 1.10.10 → 1.10.12

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.
@@ -67,7 +67,7 @@ var FileVersionOneError = /** @class */ (function (_super) {
67
67
  exports.FileVersionOneError = FileVersionOneError;
68
68
  function downloadFile(fileId, bucketId, mnemonic, network, crypto, toBinaryData, downloadFile, decryptFile, opts) {
69
69
  return __awaiter(this, void 0, void 0, function () {
70
- var iv, indexHex, key, mnemonicIsValid, _a, index, shards, version, size, downloadables, err_1, context;
70
+ var iv, key, mnemonicIsValid, _a, index, shards, version, size, downloadables, err_1, context;
71
71
  return __generator(this, function (_b) {
72
72
  switch (_b.label) {
73
73
  case 0:
@@ -102,12 +102,7 @@ function downloadFile(fileId, bucketId, mnemonic, network, crypto, toBinaryData,
102
102
  bucketId: bucketId,
103
103
  fileId: fileId,
104
104
  user: network.credentials.username,
105
- pass: network.credentials.password,
106
- token: (opts === null || opts === void 0 ? void 0 : opts.token) || 'none',
107
105
  crypto: {
108
- index: indexHex ? indexHex.toString('hex') : 'none',
109
- iv: iv ? iv.toString('hex') : 'none',
110
- key: key ? key.toString('hex') : 'none',
111
106
  mnemonic: mnemonic,
112
107
  },
113
108
  }, err_1);
@@ -1,35 +1,22 @@
1
- import { DownloadInvalidMnemonicError } from './download';
2
- import { UploadInvalidMnemonicError } from './upload';
3
- type NetworkError = UploadInvalidMnemonicError | DownloadInvalidMnemonicError | Error;
4
1
  export type NetworkUploadContext = {
5
2
  bucketId: string;
6
3
  fileSize: number;
7
4
  user: string;
8
- pass: string;
9
5
  crypto: {
10
- index: string;
11
6
  mnemonic?: string;
12
- key: string;
13
- iv: string;
14
7
  };
15
8
  };
16
9
  export type NetworkDownloadContext = {
17
10
  bucketId: string;
18
11
  fileId: string;
19
12
  user: string;
20
- pass: string;
21
- token: string;
22
13
  crypto: {
23
- index: string;
24
14
  mnemonic?: string;
25
- key: string;
26
- iv: string;
27
15
  };
28
16
  };
29
17
  export type NetworkContext = NetworkUploadContext | NetworkDownloadContext;
30
18
  export declare class ErrorWithContext extends Error {
31
- context: Partial<NetworkContext>;
32
- constructor(context: Partial<NetworkContext>);
19
+ context: NetworkContext;
20
+ constructor(context: NetworkContext);
33
21
  }
34
- export declare function getNetworkErrorContext(input: NetworkContext, err: NetworkError): Partial<NetworkContext>;
35
- export {};
22
+ export declare function getNetworkErrorContext(input: NetworkContext, err: unknown): NetworkContext;
@@ -89,11 +89,7 @@ function uploadFile(network, crypto, bucketId, mnemonic, fileSize, encryptFile,
89
89
  bucketId: bucketId,
90
90
  fileSize: fileSize,
91
91
  user: network.credentials.username,
92
- pass: network.credentials.password,
93
92
  crypto: {
94
- index: index ? index.toString('hex') : 'none',
95
- iv: iv ? iv.toString('hex') : 'none',
96
- key: key ? key.toString('hex') : 'none',
97
93
  mnemonic: mnemonic,
98
94
  },
99
95
  }, err_1);
@@ -1,6 +1,6 @@
1
- import { CreatedPaymentIntent, CreatedSubscriptionData } from '../drive/payments/types/types';
1
+ import { CreatedSubscriptionData } from '../drive/payments/types/types';
2
2
  import { ApiSecurity, ApiUrl, AppDetails } from '../shared';
3
- import { CreatePaymentIntentPayload, CreateSubscriptionPayload, GetPriceByIdPayload, PriceWithTax } from './types';
3
+ import { CreatePaymentIntentPayload, CreateSubscriptionPayload, CryptoCurrency, GetPriceByIdPayload, PaymentIntent, PriceWithTax } from './types';
4
4
  export declare class Checkout {
5
5
  private readonly client;
6
6
  private readonly appDetails;
@@ -49,8 +49,13 @@ export declare class Checkout {
49
49
  * - `clientSecret`: The client secret for the invoice to be used with Stripe Elements
50
50
  * - `id`: The ID of the invoice
51
51
  * - `invoiceStatus`: The status of the invoice (only when the status is 'paid')
52
+ * - `type`: The type of the currency - 'fiat' or 'crypto'
53
+ * - `payload`: The payload of the invoice if the type is 'crypto' containing { paymentRequestUri, url, qrUrl }
54
+ * - `payload.paymentRequestUri`: The payment request URI for the invoice
55
+ * - `payload.url`: The URL of the invoice
56
+ * - `payload.qrUrl`: The QR code URL of the invoice
52
57
  */
53
- createPaymentIntent({ customerId, priceId, token, currency, promoCodeId, }: CreatePaymentIntentPayload): Promise<CreatedPaymentIntent>;
58
+ createPaymentIntent({ customerId, priceId, token, currency, promoCodeId, }: CreatePaymentIntentPayload): Promise<PaymentIntent>;
54
59
  /**
55
60
  * @description Fetch a requested price by its ID and its tax rate
56
61
  * @param priceId - The ID of the price
@@ -59,6 +64,17 @@ export declare class Checkout {
59
64
  * @returns The price object containing the details of the requested price
60
65
  */
61
66
  getPriceById({ priceId, promoCodeName, userAddress, currency, postalCode, country, }: GetPriceByIdPayload): Promise<PriceWithTax>;
67
+ /**
68
+ * @description Fetches all available cryptocurrencies for the checkout module
69
+ * @returns A promise which resolves to an array of available cryptocurrencies
70
+ */
71
+ getAvailableCryptoCurrencies(): Promise<CryptoCurrency[]>;
72
+ /**
73
+ * @description Verifies a cryptocurrency payment
74
+ * @param token - The encoded token we need to verify the payment
75
+ * @returns A promise that resolves to a boolean indicating whether the payment is verified
76
+ */
77
+ verifyCryptoPayment(token: string): Promise<boolean>;
62
78
  /**
63
79
  * Returns the needed headers with authorization header for the module requests
64
80
  * @private
@@ -76,6 +76,11 @@ var Checkout = /** @class */ (function () {
76
76
  * - `clientSecret`: The client secret for the invoice to be used with Stripe Elements
77
77
  * - `id`: The ID of the invoice
78
78
  * - `invoiceStatus`: The status of the invoice (only when the status is 'paid')
79
+ * - `type`: The type of the currency - 'fiat' or 'crypto'
80
+ * - `payload`: The payload of the invoice if the type is 'crypto' containing { paymentRequestUri, url, qrUrl }
81
+ * - `payload.paymentRequestUri`: The payment request URI for the invoice
82
+ * - `payload.url`: The URL of the invoice
83
+ * - `payload.qrUrl`: The QR code URL of the invoice
79
84
  */
80
85
  Checkout.prototype.createPaymentIntent = function (_a) {
81
86
  var customerId = _a.customerId, priceId = _a.priceId, token = _a.token, currency = _a.currency, promoCodeId = _a.promoCodeId;
@@ -110,6 +115,23 @@ var Checkout = /** @class */ (function () {
110
115
  query.set('country', country);
111
116
  return this.client.get("/checkout/price-by-id?".concat(query.toString()), this.headers());
112
117
  };
118
+ /**
119
+ * @description Fetches all available cryptocurrencies for the checkout module
120
+ * @returns A promise which resolves to an array of available cryptocurrencies
121
+ */
122
+ Checkout.prototype.getAvailableCryptoCurrencies = function () {
123
+ return this.client.get('/checkout/crypto/currencies', this.headers());
124
+ };
125
+ /**
126
+ * @description Verifies a cryptocurrency payment
127
+ * @param token - The encoded token we need to verify the payment
128
+ * @returns A promise that resolves to a boolean indicating whether the payment is verified
129
+ */
130
+ Checkout.prototype.verifyCryptoPayment = function (token) {
131
+ return this.client.post('/checkout/crypto/verify/payment', {
132
+ token: token,
133
+ }, this.headers());
134
+ };
113
135
  /**
114
136
  * Returns the needed headers with authorization header for the module requests
115
137
  * @private
@@ -11,7 +11,7 @@ export interface CreatePaymentIntentPayload {
11
11
  customerId: string;
12
12
  priceId: string;
13
13
  token: string;
14
- currency?: string;
14
+ currency: string;
15
15
  promoCodeId?: string;
16
16
  }
17
17
  export interface PaymentMethodVerificationPayload {
@@ -56,3 +56,34 @@ export type PriceWithTax = {
56
56
  price: Price;
57
57
  taxes: Taxes;
58
58
  };
59
+ export interface CryptoCurrency {
60
+ currencyId: string;
61
+ name: string;
62
+ type: 'crypto' | 'fiat';
63
+ receiveType: boolean;
64
+ networks: {
65
+ platformId: string;
66
+ name: string;
67
+ }[];
68
+ imageUrl: string;
69
+ }
70
+ export interface PaymentIntentCrypto {
71
+ id: string;
72
+ type: 'crypto';
73
+ token: string;
74
+ payload: {
75
+ paymentRequestUri: string;
76
+ payAmount: number;
77
+ payCurrency: string;
78
+ paymentAddress: string;
79
+ url: string;
80
+ qrUrl: string;
81
+ };
82
+ }
83
+ export interface PaymentIntentFiat {
84
+ id: string;
85
+ type: 'fiat';
86
+ clientSecret: string | null;
87
+ invoiceStatus?: string;
88
+ }
89
+ export type PaymentIntent = PaymentIntentCrypto | PaymentIntentFiat;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@internxt/sdk",
3
3
  "author": "Internxt <hello@internxt.com>",
4
- "version": "1.10.10",
4
+ "version": "1.10.12",
5
5
  "description": "An sdk for interacting with Internxt's services",
6
6
  "repository": {
7
7
  "type": "git",