bitapy-sdk 6.2.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 (252) hide show
  1. package/4tjtyyj8.cjs +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +49 -0
  4. package/dist/Client/BillClient.d.ts +60 -0
  5. package/dist/Client/BillClient.js +117 -0
  6. package/dist/Client/BitPayClient.d.ts +51 -0
  7. package/dist/Client/BitPayClient.js +186 -0
  8. package/dist/Client/CurrencyClient.d.ts +13 -0
  9. package/dist/Client/CurrencyClient.js +30 -0
  10. package/dist/Client/InvoiceClient.d.ts +108 -0
  11. package/dist/Client/InvoiceClient.js +222 -0
  12. package/dist/Client/LedgerClient.d.ts +26 -0
  13. package/dist/Client/LedgerClient.js +51 -0
  14. package/dist/Client/PayoutClient.d.ts +51 -0
  15. package/dist/Client/PayoutClient.js +106 -0
  16. package/dist/Client/PayoutGroupClient.d.ts +25 -0
  17. package/dist/Client/PayoutGroupClient.js +44 -0
  18. package/dist/Client/PayoutRecipientClient.d.ts +65 -0
  19. package/dist/Client/PayoutRecipientClient.js +132 -0
  20. package/dist/Client/RateClient.d.ts +25 -0
  21. package/dist/Client/RateClient.js +51 -0
  22. package/dist/Client/RefundClient.d.ts +92 -0
  23. package/dist/Client/RefundClient.js +207 -0
  24. package/dist/Client/SettlementClient.d.ts +36 -0
  25. package/dist/Client/SettlementClient.js +71 -0
  26. package/dist/Client/WalletClient.d.ts +13 -0
  27. package/dist/Client/WalletClient.js +27 -0
  28. package/dist/Client/index.d.ts +13 -0
  29. package/dist/Client/index.js +28 -0
  30. package/dist/Client.d.ts +445 -0
  31. package/dist/Client.js +685 -0
  32. package/dist/Config.d.ts +5 -0
  33. package/dist/Config.js +8 -0
  34. package/dist/Currency.d.ts +178 -0
  35. package/dist/Currency.js +193 -0
  36. package/dist/Env.d.ts +8 -0
  37. package/dist/Env.js +22 -0
  38. package/dist/Environment.d.ts +4 -0
  39. package/dist/Environment.js +9 -0
  40. package/dist/Exceptions/BitPayApiException.d.ts +13 -0
  41. package/dist/Exceptions/BitPayApiException.js +21 -0
  42. package/dist/Exceptions/BitPayException.d.ts +12 -0
  43. package/dist/Exceptions/BitPayException.js +17 -0
  44. package/dist/Exceptions/BitPayExceptionProvider.d.ts +14 -0
  45. package/dist/Exceptions/BitPayExceptionProvider.js +81 -0
  46. package/dist/Exceptions/BitPayGenericException.d.ts +4 -0
  47. package/dist/Exceptions/BitPayGenericException.js +9 -0
  48. package/dist/Exceptions/BitPayValidationException.d.ts +4 -0
  49. package/dist/Exceptions/BitPayValidationException.js +9 -0
  50. package/dist/Exceptions/index.d.ts +4 -0
  51. package/dist/Exceptions/index.js +24 -0
  52. package/dist/Facade.d.ts +5 -0
  53. package/dist/Facade.js +10 -0
  54. package/dist/Logger/BitPayLogger.d.ts +5 -0
  55. package/dist/Logger/BitPayLogger.js +3 -0
  56. package/dist/Logger/EmptyLogger.d.ts +6 -0
  57. package/dist/Logger/EmptyLogger.js +11 -0
  58. package/dist/Logger/LoggerProvider.d.ts +11 -0
  59. package/dist/Logger/LoggerProvider.js +23 -0
  60. package/dist/Logger/WinstonLoggerExample.d.ts +0 -0
  61. package/dist/Logger/WinstonLoggerExample.js +29 -0
  62. package/dist/Model/Bill/Bill.d.ts +58 -0
  63. package/dist/Model/Bill/Bill.js +30 -0
  64. package/dist/Model/Bill/Bill.zod.d.ts +93 -0
  65. package/dist/Model/Bill/Bill.zod.js +29 -0
  66. package/dist/Model/Bill/BillStatus.d.ts +5 -0
  67. package/dist/Model/Bill/BillStatus.js +9 -0
  68. package/dist/Model/Bill/Item.d.ts +13 -0
  69. package/dist/Model/Bill/Item.js +8 -0
  70. package/dist/Model/Bill/Item.zod.d.ts +17 -0
  71. package/dist/Model/Bill/Item.zod.js +11 -0
  72. package/dist/Model/Currency/Currency.d.ts +28 -0
  73. package/dist/Model/Currency/Currency.js +7 -0
  74. package/dist/Model/Currency/Currency.zod.d.ts +41 -0
  75. package/dist/Model/Currency/Currency.zod.js +19 -0
  76. package/dist/Model/Invoice/Buyer.d.ts +25 -0
  77. package/dist/Model/Invoice/Buyer.js +8 -0
  78. package/dist/Model/Invoice/Buyer.zod.d.ts +35 -0
  79. package/dist/Model/Invoice/Buyer.zod.js +17 -0
  80. package/dist/Model/Invoice/Invoice.d.ts +147 -0
  81. package/dist/Model/Invoice/Invoice.js +29 -0
  82. package/dist/Model/Invoice/Invoice.zod.d.ts +419 -0
  83. package/dist/Model/Invoice/Invoice.zod.js +74 -0
  84. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.d.ts +9 -0
  85. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.js +3 -0
  86. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.zod.d.ts +26 -0
  87. package/dist/Model/Invoice/InvoiceBuyerProvidedInfo.zod.js +14 -0
  88. package/dist/Model/Invoice/InvoiceEventToken.d.ts +12 -0
  89. package/dist/Model/Invoice/InvoiceEventToken.js +7 -0
  90. package/dist/Model/Invoice/InvoiceEventToken.zod.d.ts +17 -0
  91. package/dist/Model/Invoice/InvoiceEventToken.zod.js +11 -0
  92. package/dist/Model/Invoice/InvoiceRefundAddresses.d.ts +6 -0
  93. package/dist/Model/Invoice/InvoiceRefundAddresses.js +3 -0
  94. package/dist/Model/Invoice/InvoiceRefundAddresses.zod.d.ts +17 -0
  95. package/dist/Model/Invoice/InvoiceRefundAddresses.zod.js +11 -0
  96. package/dist/Model/Invoice/InvoiceStatus.d.ts +6 -0
  97. package/dist/Model/Invoice/InvoiceStatus.js +10 -0
  98. package/dist/Model/Invoice/InvoiceTransaction.d.ts +9 -0
  99. package/dist/Model/Invoice/InvoiceTransaction.js +3 -0
  100. package/dist/Model/Invoice/InvoiceTransaction.zod.d.ts +26 -0
  101. package/dist/Model/Invoice/InvoiceTransaction.zod.js +14 -0
  102. package/dist/Model/Invoice/InvoiceUniversalCodes.d.ts +4 -0
  103. package/dist/Model/Invoice/InvoiceUniversalCodes.js +3 -0
  104. package/dist/Model/Invoice/InvoiceUniversalCodes.zod.d.ts +11 -0
  105. package/dist/Model/Invoice/InvoiceUniversalCodes.zod.js +9 -0
  106. package/dist/Model/Invoice/MinerFeesItem.d.ts +5 -0
  107. package/dist/Model/Invoice/MinerFeesItem.js +3 -0
  108. package/dist/Model/Invoice/MinerFeesItem.zod.d.ts +14 -0
  109. package/dist/Model/Invoice/MinerFeesItem.zod.js +10 -0
  110. package/dist/Model/Invoice/Refund.d.ts +54 -0
  111. package/dist/Model/Invoice/Refund.js +12 -0
  112. package/dist/Model/Invoice/Refund.zod.d.ts +122 -0
  113. package/dist/Model/Invoice/Refund.zod.js +32 -0
  114. package/dist/Model/Invoice/RefundInfo.d.ts +5 -0
  115. package/dist/Model/Invoice/RefundInfo.js +3 -0
  116. package/dist/Model/Invoice/RefundInfo.zod.d.ts +14 -0
  117. package/dist/Model/Invoice/RefundInfo.zod.js +10 -0
  118. package/dist/Model/Invoice/RefundParams.d.ts +10 -0
  119. package/dist/Model/Invoice/RefundParams.js +3 -0
  120. package/dist/Model/Invoice/RefundParams.zod.d.ts +29 -0
  121. package/dist/Model/Invoice/RefundParams.zod.js +15 -0
  122. package/dist/Model/Invoice/RefundStatus.d.ts +3 -0
  123. package/dist/Model/Invoice/RefundStatus.js +7 -0
  124. package/dist/Model/Invoice/Shopper.d.ts +3 -0
  125. package/dist/Model/Invoice/Shopper.js +3 -0
  126. package/dist/Model/Invoice/Shopper.zod.d.ts +8 -0
  127. package/dist/Model/Invoice/Shopper.zod.js +8 -0
  128. package/dist/Model/Invoice/SupportedTransactionCurrency.d.ts +4 -0
  129. package/dist/Model/Invoice/SupportedTransactionCurrency.js +3 -0
  130. package/dist/Model/Invoice/SupportedTransactionCurrency.zod.d.ts +11 -0
  131. package/dist/Model/Invoice/SupportedTransactionCurrency.zod.js +9 -0
  132. package/dist/Model/Ledger/BuyerFields.d.ts +25 -0
  133. package/dist/Model/Ledger/BuyerFields.js +8 -0
  134. package/dist/Model/Ledger/BuyerFields.zod.d.ts +35 -0
  135. package/dist/Model/Ledger/BuyerFields.zod.js +17 -0
  136. package/dist/Model/Ledger/Ledger.d.ts +9 -0
  137. package/dist/Model/Ledger/Ledger.js +8 -0
  138. package/dist/Model/Ledger/Ledger.zod.d.ts +11 -0
  139. package/dist/Model/Ledger/Ledger.zod.js +9 -0
  140. package/dist/Model/Ledger/LedgerEntry.d.ts +34 -0
  141. package/dist/Model/Ledger/LedgerEntry.js +8 -0
  142. package/dist/Model/Ledger/LedgerEntry.zod.d.ts +102 -0
  143. package/dist/Model/Ledger/LedgerEntry.zod.js +22 -0
  144. package/dist/Model/Payout/Payout.d.ts +59 -0
  145. package/dist/Model/Payout/Payout.js +20 -0
  146. package/dist/Model/Payout/Payout.zod.d.ts +99 -0
  147. package/dist/Model/Payout/Payout.zod.js +31 -0
  148. package/dist/Model/Payout/PayoutGroup.d.ts +11 -0
  149. package/dist/Model/Payout/PayoutGroup.js +11 -0
  150. package/dist/Model/Payout/PayoutGroup.zod.d.ts +186 -0
  151. package/dist/Model/Payout/PayoutGroup.zod.js +11 -0
  152. package/dist/Model/Payout/PayoutGroupFailed.d.ts +10 -0
  153. package/dist/Model/Payout/PayoutGroupFailed.js +10 -0
  154. package/dist/Model/Payout/PayoutGroupFailed.zod.d.ts +14 -0
  155. package/dist/Model/Payout/PayoutGroupFailed.zod.js +10 -0
  156. package/dist/Model/Payout/PayoutRecipient.d.ts +29 -0
  157. package/dist/Model/Payout/PayoutRecipient.js +12 -0
  158. package/dist/Model/Payout/PayoutRecipient.zod.d.ts +29 -0
  159. package/dist/Model/Payout/PayoutRecipient.zod.js +15 -0
  160. package/dist/Model/Payout/PayoutRecipients.d.ts +17 -0
  161. package/dist/Model/Payout/PayoutRecipients.js +15 -0
  162. package/dist/Model/Payout/PayoutRecipients.zod.d.ts +59 -0
  163. package/dist/Model/Payout/PayoutRecipients.zod.js +11 -0
  164. package/dist/Model/Payout/PayoutStatus.d.ts +8 -0
  165. package/dist/Model/Payout/PayoutStatus.js +12 -0
  166. package/dist/Model/Payout/PayoutTransaction.d.ts +13 -0
  167. package/dist/Model/Payout/PayoutTransaction.js +8 -0
  168. package/dist/Model/Payout/PayoutTransaction.zod.d.ts +17 -0
  169. package/dist/Model/Payout/PayoutTransaction.zod.js +11 -0
  170. package/dist/Model/Payout/RecipientReferenceMethod.d.ts +3 -0
  171. package/dist/Model/Payout/RecipientReferenceMethod.js +7 -0
  172. package/dist/Model/Payout/RecipientStatus.d.ts +6 -0
  173. package/dist/Model/Payout/RecipientStatus.js +10 -0
  174. package/dist/Model/Rates/Rate.d.ts +5 -0
  175. package/dist/Model/Rates/Rate.js +3 -0
  176. package/dist/Model/Rates/Rate.zod.d.ts +14 -0
  177. package/dist/Model/Rates/Rate.zod.js +10 -0
  178. package/dist/Model/Rates/Rates.d.ts +11 -0
  179. package/dist/Model/Rates/Rates.js +40 -0
  180. package/dist/Model/Settlement/InvoiceData.d.ts +20 -0
  181. package/dist/Model/Settlement/InvoiceData.js +8 -0
  182. package/dist/Model/Settlement/InvoiceData.zod.d.ts +51 -0
  183. package/dist/Model/Settlement/InvoiceData.zod.js +15 -0
  184. package/dist/Model/Settlement/PayoutInfo.d.ts +53 -0
  185. package/dist/Model/Settlement/PayoutInfo.js +8 -0
  186. package/dist/Model/Settlement/PayoutInfo.zod.d.ts +77 -0
  187. package/dist/Model/Settlement/PayoutInfo.zod.js +31 -0
  188. package/dist/Model/Settlement/RefundInfo.d.ts +13 -0
  189. package/dist/Model/Settlement/RefundInfo.js +8 -0
  190. package/dist/Model/Settlement/RefundInfo.zod.d.ts +17 -0
  191. package/dist/Model/Settlement/RefundInfo.zod.js +11 -0
  192. package/dist/Model/Settlement/Settlement.d.ts +40 -0
  193. package/dist/Model/Settlement/Settlement.js +8 -0
  194. package/dist/Model/Settlement/Settlement.zod.d.ts +349 -0
  195. package/dist/Model/Settlement/Settlement.zod.js +26 -0
  196. package/dist/Model/Settlement/SettlementLedgerEntry.d.ts +18 -0
  197. package/dist/Model/Settlement/SettlementLedgerEntry.js +8 -0
  198. package/dist/Model/Settlement/SettlementLedgerEntry.zod.d.ts +98 -0
  199. package/dist/Model/Settlement/SettlementLedgerEntry.zod.js +14 -0
  200. package/dist/Model/Settlement/WithHoldings.d.ts +17 -0
  201. package/dist/Model/Settlement/WithHoldings.js +8 -0
  202. package/dist/Model/Settlement/WithHoldings.zod.d.ts +23 -0
  203. package/dist/Model/Settlement/WithHoldings.zod.js +13 -0
  204. package/dist/Model/Wallet/Currencies.d.ts +26 -0
  205. package/dist/Model/Wallet/Currencies.js +7 -0
  206. package/dist/Model/Wallet/Currencies.zod.d.ts +44 -0
  207. package/dist/Model/Wallet/Currencies.zod.js +16 -0
  208. package/dist/Model/Wallet/CurrencyQr.d.ts +13 -0
  209. package/dist/Model/Wallet/CurrencyQr.js +7 -0
  210. package/dist/Model/Wallet/CurrencyQr.zod.d.ts +11 -0
  211. package/dist/Model/Wallet/CurrencyQr.zod.js +9 -0
  212. package/dist/Model/Wallet/Wallet.d.ts +22 -0
  213. package/dist/Model/Wallet/Wallet.js +7 -0
  214. package/dist/Model/Wallet/Wallet.zod.d.ts +89 -0
  215. package/dist/Model/Wallet/Wallet.zod.js +14 -0
  216. package/dist/Model/Webhook/InvoiceBuyerFields.zod.d.ts +35 -0
  217. package/dist/Model/Webhook/InvoiceBuyerFields.zod.js +17 -0
  218. package/dist/Model/Webhook/InvoiceWebhook.d.ts +21 -0
  219. package/dist/Model/Webhook/InvoiceWebhook.js +3 -0
  220. package/dist/Model/Webhook/InvoiceWebhook.zod.d.ts +114 -0
  221. package/dist/Model/Webhook/InvoiceWebhook.zod.js +26 -0
  222. package/dist/Model/Webhook/InvoiceWebhookBuyerFields.d.ts +12 -0
  223. package/dist/Model/Webhook/InvoiceWebhookBuyerFields.js +3 -0
  224. package/dist/Model/Webhook/PayoutWebhook.d.ts +22 -0
  225. package/dist/Model/Webhook/PayoutWebhook.js +3 -0
  226. package/dist/Model/Webhook/PayoutWebhook.zod.d.ts +87 -0
  227. package/dist/Model/Webhook/PayoutWebhook.zod.js +27 -0
  228. package/dist/Model/Webhook/RefundWebhook.d.ts +21 -0
  229. package/dist/Model/Webhook/RefundWebhook.js +3 -0
  230. package/dist/Model/Webhook/RefundWebhook.zod.d.ts +62 -0
  231. package/dist/Model/Webhook/RefundWebhook.zod.js +26 -0
  232. package/dist/Model/index.d.ts +12 -0
  233. package/dist/Model/index.js +32 -0
  234. package/dist/PosToken.d.ts +13 -0
  235. package/dist/PosToken.js +21 -0
  236. package/dist/PrivateKey.d.ts +9 -0
  237. package/dist/PrivateKey.js +18 -0
  238. package/dist/TokenContainer.d.ts +39 -0
  239. package/dist/TokenContainer.js +71 -0
  240. package/dist/index.d.ts +15 -0
  241. package/dist/index.js +46 -0
  242. package/dist/setup/BitPaySetup.d.ts +1 -0
  243. package/dist/setup/BitPaySetup.js +295 -0
  244. package/dist/util/BitPayResponseParser.d.ts +4 -0
  245. package/dist/util/BitPayResponseParser.js +67 -0
  246. package/dist/util/GuidGenerator.d.ts +3 -0
  247. package/dist/util/GuidGenerator.js +10 -0
  248. package/dist/util/KeyUtils.d.ts +12 -0
  249. package/dist/util/KeyUtils.js +47 -0
  250. package/dist/util/ParamsRemover.d.ts +3 -0
  251. package/dist/util/ParamsRemover.js +11 -0
  252. package/package.json +64 -0
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.refundWebhookSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.refundWebhookSchema = zod_1.z.object({
6
+ amount: zod_1.z.number().nullable(),
7
+ buyerPaysRefundFee: zod_1.z.boolean().nullable(),
8
+ currency: zod_1.z.string().nullable(),
9
+ id: zod_1.z.string().nullable(),
10
+ immediate: zod_1.z.boolean().nullable(),
11
+ invoice: zod_1.z.string().nullable(),
12
+ lastRefundNotification: zod_1.z.string().nullable(),
13
+ refundFee: zod_1.z.number().nullable(),
14
+ requestDate: zod_1.z.string().nullable(),
15
+ status: zod_1.z.string().nullable(),
16
+ supportRequest: zod_1.z.string().nullable(),
17
+ reference: zod_1.z.string().nullable(),
18
+ guid: zod_1.z.string().nullable(),
19
+ refundAddress: zod_1.z.string().nullable(),
20
+ type: zod_1.z.string().nullable(),
21
+ txid: zod_1.z.string().nullable(),
22
+ transactionCurrency: zod_1.z.string().nullable(),
23
+ transactionAmount: zod_1.z.number().nullable(),
24
+ transactionRefundFee: zod_1.z.number().nullable()
25
+ });
26
+ //# sourceMappingURL=RefundWebhook.zod.js.map
@@ -0,0 +1,12 @@
1
+ import { Invoice, InvoiceInterface } from './Invoice/Invoice';
2
+ import { RateInterface } from './Rates/Rate';
3
+ import { Rates } from './Rates/Rates';
4
+ import { Bill, BillInterface } from './Bill/Bill';
5
+ import { Item as BillItem } from './Bill/Item';
6
+ import { LedgerInterface } from './Ledger/Ledger';
7
+ import { LedgerEntryInterface } from './Ledger/LedgerEntry';
8
+ import { PayoutRecipient, PayoutRecipientInterface } from './Payout/PayoutRecipient';
9
+ import { PayoutRecipients, PayoutRecipientsInterface } from './Payout/PayoutRecipients';
10
+ import { Payout, PayoutInterface } from './Payout/Payout';
11
+ import { PayoutGroupInterface } from './Payout/PayoutGroup';
12
+ export { Invoice, InvoiceInterface, RateInterface, Rates, Bill, BillInterface, BillItem, LedgerInterface, LedgerEntryInterface, PayoutRecipient, PayoutRecipientInterface, PayoutRecipients, PayoutRecipientsInterface, Payout, PayoutInterface, PayoutGroupInterface };
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ /*
3
+ * __ _ __
4
+ * / /_ (_) /_____ ____ ___ __
5
+ * / __ \/ / __/ __ \/ __ `/ / / /
6
+ * / /_/ / / /_/ /_/ / /_/ / /_/ /
7
+ * /_.___/_/\__/ .___/\__,_/\__, /
8
+ * /_/ /____/
9
+ *
10
+ * BitPay NodeJS Client
11
+ *
12
+ * Copyright (c) 2020 BitPay inc.
13
+ * This file is open source and available under the MIT license.
14
+ * See the LICENSE file for more info.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Payout = exports.PayoutRecipients = exports.PayoutRecipient = exports.BillItem = exports.Bill = exports.Rates = exports.Invoice = void 0;
18
+ const Invoice_1 = require("./Invoice/Invoice");
19
+ Object.defineProperty(exports, "Invoice", { enumerable: true, get: function () { return Invoice_1.Invoice; } });
20
+ const Rates_1 = require("./Rates/Rates");
21
+ Object.defineProperty(exports, "Rates", { enumerable: true, get: function () { return Rates_1.Rates; } });
22
+ const Bill_1 = require("./Bill/Bill");
23
+ Object.defineProperty(exports, "Bill", { enumerable: true, get: function () { return Bill_1.Bill; } });
24
+ const Item_1 = require("./Bill/Item");
25
+ Object.defineProperty(exports, "BillItem", { enumerable: true, get: function () { return Item_1.Item; } });
26
+ const PayoutRecipient_1 = require("./Payout/PayoutRecipient");
27
+ Object.defineProperty(exports, "PayoutRecipient", { enumerable: true, get: function () { return PayoutRecipient_1.PayoutRecipient; } });
28
+ const PayoutRecipients_1 = require("./Payout/PayoutRecipients");
29
+ Object.defineProperty(exports, "PayoutRecipients", { enumerable: true, get: function () { return PayoutRecipients_1.PayoutRecipients; } });
30
+ const Payout_1 = require("./Payout/Payout");
31
+ Object.defineProperty(exports, "Payout", { enumerable: true, get: function () { return Payout_1.Payout; } });
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,13 @@
1
+ export declare class PosToken {
2
+ private readonly value;
3
+ /**
4
+ *
5
+ * @param value
6
+ */
7
+ constructor(value: string);
8
+ /**
9
+ *
10
+ * @returns string
11
+ */
12
+ getValue(): string;
13
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PosToken = void 0;
4
+ class PosToken {
5
+ /**
6
+ *
7
+ * @param value
8
+ */
9
+ constructor(value) {
10
+ this.value = value;
11
+ }
12
+ /**
13
+ *
14
+ * @returns string
15
+ */
16
+ getValue() {
17
+ return this.value;
18
+ }
19
+ }
20
+ exports.PosToken = PosToken;
21
+ //# sourceMappingURL=PosToken.js.map
@@ -0,0 +1,9 @@
1
+ export declare class PrivateKey {
2
+ private readonly value;
3
+ constructor(value: string);
4
+ /**
5
+ *
6
+ * @returns string
7
+ */
8
+ getValue(): string;
9
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PrivateKey = void 0;
4
+ class PrivateKey {
5
+ constructor(value) {
6
+ value = value.replace('"', '');
7
+ this.value = value;
8
+ }
9
+ /**
10
+ *
11
+ * @returns string
12
+ */
13
+ getValue() {
14
+ return this.value;
15
+ }
16
+ }
17
+ exports.PrivateKey = PrivateKey;
18
+ //# sourceMappingURL=PrivateKey.js.map
@@ -0,0 +1,39 @@
1
+ import { Facade } from './Facade';
2
+ export declare class TokenContainer {
3
+ private readonly data;
4
+ constructor(tokens?: object);
5
+ /**
6
+ *
7
+ * @param key
8
+ * @returns string
9
+ * @throws BitPayGenericException BitPayGenericException class
10
+ */
11
+ getToken(key: string): string;
12
+ /**
13
+ *
14
+ * @param token
15
+ */
16
+ addPos(token: string): void;
17
+ /**
18
+ *
19
+ * @param token
20
+ */
21
+ addMerchant(token: string): void;
22
+ /**
23
+ *
24
+ * @param token
25
+ */
26
+ addPayout(token: string): void;
27
+ /**
28
+ *
29
+ * @param facade
30
+ * @returns
31
+ */
32
+ isTokenExist(facade: Facade): boolean;
33
+ /**
34
+ *
35
+ * @param facade
36
+ * @param token
37
+ */
38
+ private add;
39
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenContainer = void 0;
4
+ const Facade_1 = require("./Facade");
5
+ const BitPayExceptionProvider_1 = require("./Exceptions/BitPayExceptionProvider");
6
+ class TokenContainer {
7
+ constructor(tokens) {
8
+ this.data = new Map();
9
+ if (tokens !== undefined) {
10
+ Object.keys(tokens).forEach((key) => {
11
+ this.add(key, String(tokens[key]));
12
+ });
13
+ }
14
+ }
15
+ /**
16
+ *
17
+ * @param key
18
+ * @returns string
19
+ * @throws BitPayGenericException BitPayGenericException class
20
+ */
21
+ getToken(key) {
22
+ if (!this.data.has(key)) {
23
+ BitPayExceptionProvider_1.BitPayExceptionProvider.throwGenericExceptionWithMessage('There is no token for the specified key : ' + key);
24
+ throw new Error();
25
+ }
26
+ const value = this.data.get(key);
27
+ if (value === undefined) {
28
+ throw new Error();
29
+ }
30
+ return value;
31
+ }
32
+ /**
33
+ *
34
+ * @param token
35
+ */
36
+ addPos(token) {
37
+ this.data.set(Facade_1.Facade.Pos, token);
38
+ }
39
+ /**
40
+ *
41
+ * @param token
42
+ */
43
+ addMerchant(token) {
44
+ this.data.set(Facade_1.Facade.Merchant, token);
45
+ }
46
+ /**
47
+ *
48
+ * @param token
49
+ */
50
+ addPayout(token) {
51
+ this.data.set(Facade_1.Facade.Payout, token);
52
+ }
53
+ /**
54
+ *
55
+ * @param facade
56
+ * @returns
57
+ */
58
+ isTokenExist(facade) {
59
+ return this.data.has(facade);
60
+ }
61
+ /**
62
+ *
63
+ * @param facade
64
+ * @param token
65
+ */
66
+ add(facade, token) {
67
+ this.data.set(facade, token);
68
+ }
69
+ }
70
+ exports.TokenContainer = TokenContainer;
71
+ //# sourceMappingURL=TokenContainer.js.map
@@ -0,0 +1,15 @@
1
+ import { KeyUtils } from './util/KeyUtils';
2
+ import * as BitPayExceptions from './Exceptions/index';
3
+ import * as Models from './Model/index';
4
+ import { Client } from './Client';
5
+ import { Config } from './Config';
6
+ import { Currency } from './Currency';
7
+ import { Facade } from './Facade';
8
+ import * as Env from './Env';
9
+ import * as Invoice from './Model/Invoice/Invoice';
10
+ import * as InvoiceStatus from './Model/Invoice/InvoiceStatus';
11
+ import * as RefundStatus from './Model/Invoice/RefundStatus';
12
+ import * as RecipientStatus from './Model/Payout/RecipientStatus';
13
+ import * as RecipientReferenceMethod from './Model/Payout/RecipientReferenceMethod';
14
+ import * as PayoutStatus from './Model/Payout/PayoutStatus';
15
+ export { KeyUtils, BitPayExceptions, Models, Config, Env, Facade, Currency, Client, Invoice, InvoiceStatus, RefundStatus, RecipientStatus, RecipientReferenceMethod, PayoutStatus };
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ /*
3
+ * __ _ __
4
+ * / /_ (_) /_____ ____ ___ __
5
+ * / __ \/ / __/ __ \/ __ `/ / / /
6
+ * / /_/ / / /_/ /_/ / /_/ / /_/ /
7
+ * /_.___/_/\__/ .___/\__,_/\__, /
8
+ * /_/ /____/
9
+ *
10
+ * BitPay NodeJS Client
11
+ *
12
+ * Copyright (c) 2020 BitPay inc.
13
+ * This file is open source and available under the MIT license.
14
+ * See the LICENSE file for more info.
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.PayoutStatus = exports.RecipientReferenceMethod = exports.RecipientStatus = exports.RefundStatus = exports.InvoiceStatus = exports.Invoice = exports.Client = exports.Currency = exports.Facade = exports.Env = exports.Config = exports.Models = exports.BitPayExceptions = exports.KeyUtils = void 0;
18
+ const KeyUtils_1 = require("./util/KeyUtils");
19
+ Object.defineProperty(exports, "KeyUtils", { enumerable: true, get: function () { return KeyUtils_1.KeyUtils; } });
20
+ const BitPayExceptions = require("./Exceptions/index");
21
+ exports.BitPayExceptions = BitPayExceptions;
22
+ const Models = require("./Model/index");
23
+ exports.Models = Models;
24
+ const Client_1 = require("./Client");
25
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return Client_1.Client; } });
26
+ const Config_1 = require("./Config");
27
+ Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
28
+ const Currency_1 = require("./Currency");
29
+ Object.defineProperty(exports, "Currency", { enumerable: true, get: function () { return Currency_1.Currency; } });
30
+ const Facade_1 = require("./Facade");
31
+ Object.defineProperty(exports, "Facade", { enumerable: true, get: function () { return Facade_1.Facade; } });
32
+ const Env = require("./Env");
33
+ exports.Env = Env;
34
+ const Invoice = require("./Model/Invoice/Invoice");
35
+ exports.Invoice = Invoice;
36
+ const InvoiceStatus = require("./Model/Invoice/InvoiceStatus");
37
+ exports.InvoiceStatus = InvoiceStatus;
38
+ const RefundStatus = require("./Model/Invoice/RefundStatus");
39
+ exports.RefundStatus = RefundStatus;
40
+ const RecipientStatus = require("./Model/Payout/RecipientStatus");
41
+ exports.RecipientStatus = RecipientStatus;
42
+ const RecipientReferenceMethod = require("./Model/Payout/RecipientReferenceMethod");
43
+ exports.RecipientReferenceMethod = RecipientReferenceMethod;
44
+ const PayoutStatus = require("./Model/Payout/PayoutStatus");
45
+ exports.PayoutStatus = PayoutStatus;
46
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const fs = require("fs");
4
+ const BitPaySDK = require("../index");
5
+ const readline = require("readline");
6
+ const privateKeyPath = __dirname + '/../secure/private_key';
7
+ const ConfFilePath = __dirname + '/../secure/BitPay.config.json';
8
+ const keyUtils = new BitPaySDK.KeyUtils();
9
+ let keyPair;
10
+ let ecKey;
11
+ let environment;
12
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
13
+ let storeFile = true;
14
+ let apiUrl;
15
+ let merchantToken;
16
+ let merchantPairCode;
17
+ let payoutToken;
18
+ let payoutPairCode;
19
+ let keyPath = '';
20
+ let keyPlain = '';
21
+ const rl = readline.createInterface({
22
+ input: process.stdin,
23
+ output: process.stdout
24
+ });
25
+ const main = function () {
26
+ selectEnv();
27
+ };
28
+ const selectEnv = async () => {
29
+ try {
30
+ console.log('Select target environment:');
31
+ rl.question('Press T for testing or P for production: \n', async (answer) => {
32
+ switch (answer.toLowerCase()) {
33
+ case 't':
34
+ environment = 'Test';
35
+ await setEnv(environment);
36
+ selectCreateKey();
37
+ break;
38
+ case 'p':
39
+ environment = 'Prod';
40
+ await setEnv(environment);
41
+ selectCreateKey();
42
+ break;
43
+ default:
44
+ selectEnv();
45
+ }
46
+ });
47
+ }
48
+ catch (e) {
49
+ console.log(e);
50
+ }
51
+ };
52
+ const setEnv = async (env) => {
53
+ if (env == 'Test') {
54
+ apiUrl = 'https://test.bitpay.com';
55
+ return;
56
+ }
57
+ apiUrl = 'https://bitpay.com';
58
+ };
59
+ const selectCreateKey = async () => {
60
+ try {
61
+ console.log('Enter your private key or its location');
62
+ rl.question('Or press Enter to generate a brand new key: ', async (answer) => {
63
+ switch (answer.toLowerCase()) {
64
+ case '':
65
+ await createNewKey();
66
+ break;
67
+ default:
68
+ await loadKey(answer);
69
+ break;
70
+ }
71
+ });
72
+ }
73
+ catch (e) {
74
+ console.log(e);
75
+ }
76
+ };
77
+ const createNewKey = async () => {
78
+ try {
79
+ console.log('Generating private key... \n');
80
+ keyPair = keyUtils.generate_keypair();
81
+ ecKey = keyUtils.load_keypair(keyPair);
82
+ await sleep(2000);
83
+ console.log('Generated Private Key: ' + ecKey.getPrivate('hex'));
84
+ console.log('With Public Key: ' + ecKey.getPublic('hex') + '\n');
85
+ await storeKey();
86
+ }
87
+ catch (e) {
88
+ console.log(e);
89
+ }
90
+ };
91
+ const loadKey = async (privateKey) => {
92
+ try {
93
+ if (fs.existsSync(privateKey)) {
94
+ console.log('Loading private key... \n');
95
+ await sleep(2000);
96
+ ecKey = keyUtils.load_keypair(fs.readFileSync(privateKey).toString().trim());
97
+ console.log('Loaded Private Key: ' + ecKey.getPrivate('hex'));
98
+ console.log('With Public Key: ' + keyUtils.getPublicKeyFromPrivateKey(ecKey));
99
+ console.log('From: ' + privateKey);
100
+ console.log('\n');
101
+ selectTokens();
102
+ }
103
+ else {
104
+ ecKey = keyUtils.load_keypair(privateKey);
105
+ console.log('Loading private key... \n');
106
+ await sleep(2000);
107
+ console.log('Loaded Private Key: ' + ecKey.getPrivate('hex'));
108
+ console.log('With Public Key: ' + keyUtils.getPublicKeyFromPrivateKey(ecKey));
109
+ console.log('From: ' + privateKey);
110
+ console.log('\n');
111
+ selectTokens();
112
+ }
113
+ }
114
+ catch (e) {
115
+ console.log(e);
116
+ }
117
+ };
118
+ const storeKey = async () => {
119
+ try {
120
+ if (!fs.existsSync(__dirname + '/../secure')) {
121
+ fs.mkdirSync(__dirname + '/../secure');
122
+ }
123
+ console.log('Select the way you want to store your private key:');
124
+ rl.question('Press F for storing in a text file or T for plain text in your config file: ', async (answer) => {
125
+ switch (answer.toLowerCase()) {
126
+ case 'f':
127
+ storeFile = true;
128
+ keyPath = privateKeyPath + '_' + environment.toLowerCase() + '.key';
129
+ console.log('Saving private key... \n');
130
+ sleep(500);
131
+ fs.writeFile(privateKeyPath + '_' + environment.toLowerCase() + '.key', ecKey.getPrivate('hex'), { mode: 0o755 }, function (err) {
132
+ if (err)
133
+ throw err;
134
+ console.log('Private key saved in file: ' + keyPath + '\n');
135
+ });
136
+ await sleep(1000);
137
+ selectTokens();
138
+ break;
139
+ case 't':
140
+ storeFile = false;
141
+ keyPlain = ecKey.getPrivate('hex');
142
+ console.log('Saving private key... \n');
143
+ await sleep(1000);
144
+ selectTokens();
145
+ break;
146
+ default:
147
+ storeKey();
148
+ }
149
+ });
150
+ }
151
+ catch (e) {
152
+ console.log(e);
153
+ }
154
+ };
155
+ const selectTokens = async () => {
156
+ try {
157
+ console.log('Select the tokens that you would like to request:');
158
+ rl.question('Press M for merchant, P for payout, or B for both: \n', async (answer) => {
159
+ switch (answer.toLowerCase()) {
160
+ case 'm':
161
+ case 'p':
162
+ case 'b':
163
+ console.log('Requesting tokens... \n');
164
+ await sleep(500);
165
+ await requestTokens(answer);
166
+ break;
167
+ default:
168
+ selectTokens();
169
+ }
170
+ });
171
+ }
172
+ catch (e) {
173
+ console.log(e);
174
+ }
175
+ };
176
+ const requestTokens = async (option) => {
177
+ async function requestMerchantToken(options) {
178
+ console.log('Requesting Merchant token... \n');
179
+ options.body['facade'] = 'merchant';
180
+ let result = await fetch(apiUrl + '/tokens', {
181
+ method: options.method,
182
+ headers: options.headers,
183
+ body: JSON.stringify(options.body)
184
+ })
185
+ .then((response) => {
186
+ return response.json();
187
+ })
188
+ .catch((e) => {
189
+ console.log(e.message);
190
+ });
191
+ result = result.data[0];
192
+ merchantToken = result.token;
193
+ merchantPairCode = result.pairingCode;
194
+ await sleep(2000);
195
+ }
196
+ async function requestPayoutToken(options) {
197
+ console.log('Requesting Payout token... \n');
198
+ options.body['facade'] = 'payout';
199
+ let result = await fetch(options.url, {
200
+ method: options.method,
201
+ headers: options.headers,
202
+ body: JSON.stringify(options.body)
203
+ })
204
+ .then((response) => {
205
+ return response.json();
206
+ })
207
+ .catch((e) => {
208
+ console.log(e.message);
209
+ });
210
+ result = result.data[0];
211
+ payoutToken = result.token;
212
+ payoutPairCode = result.pairingCode;
213
+ await sleep(2000);
214
+ }
215
+ try {
216
+ let reqMerchant = false;
217
+ let reqPayout = false;
218
+ switch (option.toLowerCase()) {
219
+ case 'm':
220
+ reqMerchant = true;
221
+ reqPayout = false;
222
+ break;
223
+ case 'p':
224
+ reqMerchant = false;
225
+ reqPayout = true;
226
+ break;
227
+ case 'b':
228
+ reqMerchant = true;
229
+ reqPayout = true;
230
+ break;
231
+ }
232
+ const headers = {
233
+ 'x-accept-version': '2.0.0',
234
+ 'Content-type': 'application/json'
235
+ };
236
+ const options = {
237
+ url: apiUrl + '/tokens',
238
+ method: 'POST',
239
+ body: { id: keyUtils.get_sin_from_key(ecKey) },
240
+ headers: headers
241
+ };
242
+ if (reqMerchant) {
243
+ await requestMerchantToken(options);
244
+ }
245
+ if (reqPayout) {
246
+ await requestPayoutToken(options);
247
+ }
248
+ await updateConfigFile();
249
+ }
250
+ catch (e) {
251
+ console.log(e);
252
+ }
253
+ };
254
+ const updateConfigFile = async () => {
255
+ const configurationObject = {
256
+ BitPayConfiguration: {
257
+ Environment: environment,
258
+ EnvConfig: {
259
+ [environment]: {
260
+ PrivateKeyPath: keyPath,
261
+ PrivateKey: keyPlain,
262
+ ApiTokens: {
263
+ merchant: merchantToken,
264
+ payout: payoutToken
265
+ }
266
+ }
267
+ }
268
+ }
269
+ };
270
+ fs.writeFile(ConfFilePath, JSON.stringify(configurationObject, null, 4), function (err) {
271
+ if (err)
272
+ throw err;
273
+ console.log('Generated configuration file');
274
+ console.log('And saved in file: ' + ConfFilePath + '\n');
275
+ });
276
+ await sleep(5000);
277
+ console.log('Configuration generated successfully! \n');
278
+ console.log('To complete your setup, Go to ' +
279
+ apiUrl +
280
+ '/dashboard/merchant/api-tokens and pair this client with your merchant account using the pairing codes:');
281
+ if (merchantToken) {
282
+ console.log(merchantPairCode + ' for the Merchant facade.');
283
+ }
284
+ if (payoutToken) {
285
+ console.log(payoutPairCode + ' for the Payout facade ONLY if you have requested access for this role.');
286
+ }
287
+ process.exit();
288
+ };
289
+ function sleep(ms) {
290
+ return new Promise((resolve) => {
291
+ setTimeout(resolve, ms);
292
+ });
293
+ }
294
+ main();
295
+ //# sourceMappingURL=BitPaySetup.js.map
@@ -0,0 +1,4 @@
1
+ export declare class BitPayResponseParser {
2
+ getJsonDataFromJsonResponse(responseObj: object): Promise<string | undefined>;
3
+ static jsonToBoolean(json: string): boolean;
4
+ }