@blindpay/node 1.0.0

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 (139) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/api-client-Cw2mNJeR.d.mts +349 -0
  4. package/dist/api-client-Cw2mNJeR.d.ts +349 -0
  5. package/dist/chunk-2DAKB5XK.mjs +212 -0
  6. package/dist/chunk-3CZJEDS5.mjs +41 -0
  7. package/dist/chunk-CNNEROQ7.mjs +46 -0
  8. package/dist/chunk-ES7RXEM7.mjs +245 -0
  9. package/dist/chunk-GCCHFONX.mjs +17893 -0
  10. package/dist/chunk-GEDDLCJY.mjs +77 -0
  11. package/dist/chunk-GNDAATIJ.mjs +35 -0
  12. package/dist/chunk-HKFAJXJG.mjs +65 -0
  13. package/dist/chunk-LK3JPQ6I.mjs +49 -0
  14. package/dist/chunk-LLWEHHKB.mjs +47 -0
  15. package/dist/chunk-LUDGZPXY.mjs +51 -0
  16. package/dist/chunk-M6IYYMRW.mjs +35 -0
  17. package/dist/chunk-OBKEW4AQ.mjs +91 -0
  18. package/dist/chunk-QHMIK7U3.mjs +24 -0
  19. package/dist/chunk-QVOSGLUO.mjs +36 -0
  20. package/dist/chunk-UCAW3RTZ.mjs +47 -0
  21. package/dist/chunk-VKN2AMCW.mjs +57 -0
  22. package/dist/index.d.mts +81 -0
  23. package/dist/index.d.ts +81 -0
  24. package/dist/index.js +895 -0
  25. package/dist/index.mjs +95 -0
  26. package/dist/magic-string.es-6D2DRE4K.mjs +1325 -0
  27. package/dist/resources/api-keys/api-keys.test.d.mts +2 -0
  28. package/dist/resources/api-keys/api-keys.test.d.ts +2 -0
  29. package/dist/resources/api-keys/api-keys.test.js +19881 -0
  30. package/dist/resources/api-keys/api-keys.test.mjs +130 -0
  31. package/dist/resources/api-keys/index.d.mts +45 -0
  32. package/dist/resources/api-keys/index.d.ts +45 -0
  33. package/dist/resources/api-keys/index.js +64 -0
  34. package/dist/resources/api-keys/index.mjs +9 -0
  35. package/dist/resources/available/available.test.d.mts +2 -0
  36. package/dist/resources/available/available.test.d.ts +2 -0
  37. package/dist/resources/available/available.test.js +19877 -0
  38. package/dist/resources/available/available.test.mjs +122 -0
  39. package/dist/resources/available/index.d.mts +25 -0
  40. package/dist/resources/available/index.d.ts +25 -0
  41. package/dist/resources/available/index.js +39 -0
  42. package/dist/resources/available/index.mjs +9 -0
  43. package/dist/resources/bank-accounts/bank-accounts.test.d.mts +2 -0
  44. package/dist/resources/bank-accounts/bank-accounts.test.d.ts +2 -0
  45. package/dist/resources/bank-accounts/bank-accounts.test.js +20173 -0
  46. package/dist/resources/bank-accounts/bank-accounts.test.mjs +418 -0
  47. package/dist/resources/bank-accounts/index.d.mts +414 -0
  48. package/dist/resources/bank-accounts/index.d.ts +414 -0
  49. package/dist/resources/bank-accounts/index.js +227 -0
  50. package/dist/resources/bank-accounts/index.mjs +9 -0
  51. package/dist/resources/instances/index.d.mts +42 -0
  52. package/dist/resources/instances/index.d.ts +42 -0
  53. package/dist/resources/instances/index.js +75 -0
  54. package/dist/resources/instances/index.mjs +9 -0
  55. package/dist/resources/instances/instances.test.d.mts +2 -0
  56. package/dist/resources/instances/instances.test.d.ts +2 -0
  57. package/dist/resources/instances/instances.test.js +19873 -0
  58. package/dist/resources/instances/instances.test.mjs +118 -0
  59. package/dist/resources/partner-fees/index.d.mts +65 -0
  60. package/dist/resources/partner-fees/index.d.ts +65 -0
  61. package/dist/resources/partner-fees/index.js +69 -0
  62. package/dist/resources/partner-fees/index.mjs +9 -0
  63. package/dist/resources/partner-fees/partner-fees.test.d.mts +2 -0
  64. package/dist/resources/partner-fees/partner-fees.test.d.ts +2 -0
  65. package/dist/resources/partner-fees/partner-fees.test.js +19889 -0
  66. package/dist/resources/partner-fees/partner-fees.test.mjs +134 -0
  67. package/dist/resources/payins/index.d.mts +200 -0
  68. package/dist/resources/payins/index.d.ts +200 -0
  69. package/dist/resources/payins/index.js +75 -0
  70. package/dist/resources/payins/index.mjs +9 -0
  71. package/dist/resources/payins/payins-quotes.test.d.mts +2 -0
  72. package/dist/resources/payins/payins-quotes.test.d.ts +2 -0
  73. package/dist/resources/payins/payins-quotes.test.js +19852 -0
  74. package/dist/resources/payins/payins-quotes.test.mjs +97 -0
  75. package/dist/resources/payins/payins.test.d.mts +2 -0
  76. package/dist/resources/payins/payins.test.d.ts +2 -0
  77. package/dist/resources/payins/payins.test.js +20268 -0
  78. package/dist/resources/payins/payins.test.mjs +513 -0
  79. package/dist/resources/payins/quotes.d.mts +45 -0
  80. package/dist/resources/payins/quotes.d.ts +45 -0
  81. package/dist/resources/payins/quotes.js +63 -0
  82. package/dist/resources/payins/quotes.mjs +9 -0
  83. package/dist/resources/payouts/index.d.mts +155 -0
  84. package/dist/resources/payouts/index.d.ts +155 -0
  85. package/dist/resources/payouts/index.js +93 -0
  86. package/dist/resources/payouts/index.mjs +9 -0
  87. package/dist/resources/payouts/payouts.test.d.mts +2 -0
  88. package/dist/resources/payouts/payouts.test.d.ts +2 -0
  89. package/dist/resources/payouts/payouts.test.js +20346 -0
  90. package/dist/resources/payouts/payouts.test.mjs +591 -0
  91. package/dist/resources/quotes/index.d.mts +59 -0
  92. package/dist/resources/quotes/index.d.ts +59 -0
  93. package/dist/resources/quotes/index.js +63 -0
  94. package/dist/resources/quotes/index.mjs +9 -0
  95. package/dist/resources/quotes/quotes.test.d.mts +2 -0
  96. package/dist/resources/quotes/quotes.test.d.ts +2 -0
  97. package/dist/resources/quotes/quotes.test.js +19866 -0
  98. package/dist/resources/quotes/quotes.test.mjs +111 -0
  99. package/dist/resources/receivers/index.d.mts +205 -0
  100. package/dist/resources/receivers/index.d.ts +205 -0
  101. package/dist/resources/receivers/index.js +85 -0
  102. package/dist/resources/receivers/index.mjs +9 -0
  103. package/dist/resources/receivers/receivers.test.d.mts +2 -0
  104. package/dist/resources/receivers/receivers.test.d.ts +2 -0
  105. package/dist/resources/receivers/receivers.test.js +20145 -0
  106. package/dist/resources/receivers/receivers.test.mjs +390 -0
  107. package/dist/resources/virtual-accounts/index.d.mts +58 -0
  108. package/dist/resources/virtual-accounts/index.d.ts +58 -0
  109. package/dist/resources/virtual-accounts/index.js +79 -0
  110. package/dist/resources/virtual-accounts/index.mjs +9 -0
  111. package/dist/resources/virtual-accounts/virtual-accounts.test.d.mts +2 -0
  112. package/dist/resources/virtual-accounts/virtual-accounts.test.d.ts +2 -0
  113. package/dist/resources/virtual-accounts/virtual-accounts.test.js +19902 -0
  114. package/dist/resources/virtual-accounts/virtual-accounts.test.mjs +147 -0
  115. package/dist/resources/wallets/blockchain.d.mts +83 -0
  116. package/dist/resources/wallets/blockchain.d.ts +83 -0
  117. package/dist/resources/wallets/blockchain.js +105 -0
  118. package/dist/resources/wallets/blockchain.mjs +9 -0
  119. package/dist/resources/wallets/blockchain.test.d.mts +2 -0
  120. package/dist/resources/wallets/blockchain.test.d.ts +2 -0
  121. package/dist/resources/wallets/blockchain.test.js +19897 -0
  122. package/dist/resources/wallets/blockchain.test.mjs +142 -0
  123. package/dist/resources/wallets/offramp.d.mts +46 -0
  124. package/dist/resources/wallets/offramp.d.ts +46 -0
  125. package/dist/resources/wallets/offramp.js +77 -0
  126. package/dist/resources/wallets/offramp.mjs +9 -0
  127. package/dist/resources/wallets/offramp.test.d.mts +2 -0
  128. package/dist/resources/wallets/offramp.test.d.ts +2 -0
  129. package/dist/resources/wallets/offramp.test.js +19872 -0
  130. package/dist/resources/wallets/offramp.test.mjs +117 -0
  131. package/dist/resources/webhooks/index.d.mts +49 -0
  132. package/dist/resources/webhooks/index.d.ts +49 -0
  133. package/dist/resources/webhooks/index.js +74 -0
  134. package/dist/resources/webhooks/index.mjs +9 -0
  135. package/dist/resources/webhooks/webhooks.test.d.mts +2 -0
  136. package/dist/resources/webhooks/webhooks.test.d.ts +2 -0
  137. package/dist/resources/webhooks/webhooks.test.js +19878 -0
  138. package/dist/resources/webhooks/webhooks.test.mjs +123 -0
  139. package/package.json +65 -0
@@ -0,0 +1,245 @@
1
+ import {
2
+ createBlockchainWalletsResource,
3
+ init_blockchain
4
+ } from "./chunk-GEDDLCJY.mjs";
5
+ import {
6
+ createOfframpWalletsResource,
7
+ init_offramp
8
+ } from "./chunk-LK3JPQ6I.mjs";
9
+ import {
10
+ createWebhookEndpointsResource,
11
+ init_webhooks
12
+ } from "./chunk-CNNEROQ7.mjs";
13
+ import {
14
+ createQuotesResource,
15
+ init_quotes as init_quotes2
16
+ } from "./chunk-GNDAATIJ.mjs";
17
+ import {
18
+ createReceiversResource,
19
+ init_receivers
20
+ } from "./chunk-VKN2AMCW.mjs";
21
+ import {
22
+ createVirtualAccountsResource,
23
+ init_virtual_accounts
24
+ } from "./chunk-LUDGZPXY.mjs";
25
+ import {
26
+ createPartnerFeesResource,
27
+ init_partner_fees
28
+ } from "./chunk-3CZJEDS5.mjs";
29
+ import {
30
+ createPayinsResource,
31
+ init_payins
32
+ } from "./chunk-UCAW3RTZ.mjs";
33
+ import {
34
+ createPayinQuotesResource,
35
+ init_quotes
36
+ } from "./chunk-M6IYYMRW.mjs";
37
+ import {
38
+ createPayoutsResource,
39
+ init_payouts
40
+ } from "./chunk-HKFAJXJG.mjs";
41
+ import {
42
+ createApiKeysResource,
43
+ init_api_keys
44
+ } from "./chunk-QVOSGLUO.mjs";
45
+ import {
46
+ createBankAccountsResource,
47
+ init_bank_accounts
48
+ } from "./chunk-2DAKB5XK.mjs";
49
+ import {
50
+ createAvailableResource,
51
+ init_available
52
+ } from "./chunk-QHMIK7U3.mjs";
53
+ import {
54
+ createInstancesResource,
55
+ init_instances
56
+ } from "./chunk-LLWEHHKB.mjs";
57
+ import {
58
+ __async,
59
+ __esm,
60
+ __spreadProps,
61
+ __spreadValues
62
+ } from "./chunk-OBKEW4AQ.mjs";
63
+
64
+ // package.json
65
+ var version;
66
+ var init_package = __esm({
67
+ "package.json"() {
68
+ version = "1.0.0";
69
+ }
70
+ });
71
+
72
+ // src/internal/blindpay-error.ts
73
+ var BlindpayError;
74
+ var init_blindpay_error = __esm({
75
+ "src/internal/blindpay-error.ts"() {
76
+ "use strict";
77
+ BlindpayError = class extends Error {
78
+ constructor(message) {
79
+ super(message);
80
+ this.name = "BlindpayError";
81
+ }
82
+ };
83
+ }
84
+ });
85
+
86
+ // src/client.ts
87
+ import { createHmac, timingSafeEqual } from "crypto";
88
+ var Blindpay;
89
+ var init_client = __esm({
90
+ "src/client.ts"() {
91
+ "use strict";
92
+ init_package();
93
+ init_blindpay_error();
94
+ init_api_keys();
95
+ init_available();
96
+ init_bank_accounts();
97
+ init_instances();
98
+ init_partner_fees();
99
+ init_payins();
100
+ init_quotes();
101
+ init_payouts();
102
+ init_quotes2();
103
+ init_receivers();
104
+ init_virtual_accounts();
105
+ init_blockchain();
106
+ init_offramp();
107
+ init_webhooks();
108
+ Blindpay = class {
109
+ constructor(apiKey) {
110
+ // Options
111
+ this.baseUrl = "https://api.blindpay.com/v1";
112
+ if (!apiKey) {
113
+ throw new BlindpayError("Api key not provided, get your api key on blindpay dashboard");
114
+ }
115
+ this.apiKey = apiKey;
116
+ this.headers = {
117
+ "Content-Type": "application/json",
118
+ Accept: "application/json",
119
+ "User-Agent": `blindpay-node/${version}`,
120
+ Authorization: `Bearer ${this.apiKey}`
121
+ };
122
+ this.api = {
123
+ get: this.get.bind(this),
124
+ post: this.post.bind(this),
125
+ put: this.put.bind(this),
126
+ patch: this.patch.bind(this),
127
+ delete: this.delete.bind(this)
128
+ };
129
+ this.available = createAvailableResource(this.api);
130
+ this.instances = __spreadProps(__spreadValues({}, createInstancesResource(this.api)), {
131
+ apiKeys: createApiKeysResource(this.api),
132
+ webhookEndpoints: createWebhookEndpointsResource(this.api)
133
+ });
134
+ this.partnerFees = createPartnerFeesResource(this.api);
135
+ this.payins = __spreadProps(__spreadValues({}, createPayinsResource(this.api)), {
136
+ quotes: createPayinQuotesResource(this.api)
137
+ });
138
+ this.quotes = createQuotesResource(this.api);
139
+ this.payouts = createPayoutsResource(this.api);
140
+ this.receivers = __spreadProps(__spreadValues({}, createReceiversResource(this.api)), {
141
+ bankAccounts: createBankAccountsResource(this.api)
142
+ });
143
+ this.virtualAccounts = createVirtualAccountsResource(this.api);
144
+ this.wallets = {
145
+ blockchain: createBlockchainWalletsResource(this.api),
146
+ offramp: createOfframpWalletsResource(this.api)
147
+ };
148
+ }
149
+ request(method, path, body) {
150
+ return __async(this, null, function* () {
151
+ var _a;
152
+ try {
153
+ const response = yield fetch(`${this.baseUrl}${path}`, {
154
+ method,
155
+ headers: this.headers,
156
+ body: body ? JSON.stringify(body) : void 0
157
+ });
158
+ if (!response.ok) {
159
+ const error = yield response.json();
160
+ return {
161
+ data: null,
162
+ error: {
163
+ message: (_a = error == null ? void 0 : error.message) != null ? _a : "Unknown error"
164
+ }
165
+ };
166
+ }
167
+ const data = yield response.json();
168
+ return {
169
+ data,
170
+ error: null
171
+ };
172
+ } catch (error) {
173
+ if (error instanceof Error) {
174
+ return {
175
+ data: null,
176
+ error: {
177
+ message: error.message
178
+ }
179
+ };
180
+ }
181
+ const errorMessage = error && typeof error === "object" && "message" in error && typeof error.message === "string" ? error.message : "Unknown error";
182
+ return {
183
+ data: null,
184
+ error: {
185
+ message: errorMessage
186
+ }
187
+ };
188
+ }
189
+ });
190
+ }
191
+ get(path) {
192
+ return __async(this, null, function* () {
193
+ return this.request("GET", path);
194
+ });
195
+ }
196
+ post(path, body) {
197
+ return __async(this, null, function* () {
198
+ return this.request("POST", path, body);
199
+ });
200
+ }
201
+ put(path, body) {
202
+ return __async(this, null, function* () {
203
+ return this.request("PUT", path, body);
204
+ });
205
+ }
206
+ patch(path, body) {
207
+ return __async(this, null, function* () {
208
+ return this.request("PATCH", path, body);
209
+ });
210
+ }
211
+ delete(path, body) {
212
+ return __async(this, null, function* () {
213
+ return this.request("DELETE", path, body);
214
+ });
215
+ }
216
+ /**
217
+ * Verifies the BlindPay webhook signature
218
+ *
219
+ * @param params.secret The webhook secret from BlindPay dashboard
220
+ * @param params.id The value of the `svix-id` header
221
+ * @param params.timestamp The value of the `svix-timestamp` header
222
+ * @param params.payload The raw request body
223
+ * @param params.svixSignature The value of the `svix-signature` header
224
+ * @returns {boolean} True if the signature is valid, false otherwise
225
+ */
226
+ verifyWebhookSignature({
227
+ secret,
228
+ id,
229
+ timestamp,
230
+ payload,
231
+ svixSignature
232
+ }) {
233
+ const signedContent = `${id}.${timestamp}.${payload}`;
234
+ const secretBytes = Buffer.from(secret.split("_")[1], "base64");
235
+ const expectedSignature = createHmac("sha256", secretBytes).update(signedContent).digest("base64");
236
+ return svixSignature.length === expectedSignature.length && timingSafeEqual(Buffer.from(svixSignature), Buffer.from(expectedSignature));
237
+ }
238
+ };
239
+ }
240
+ });
241
+
242
+ export {
243
+ Blindpay,
244
+ init_client
245
+ };