@blindpay/node 2.3.0 → 2.5.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 (71) hide show
  1. package/dist/{api-client-Cw2mNJeR.d.mts → api-client-Drd7alfK.d.mts} +2 -2
  2. package/dist/{api-client-Cw2mNJeR.d.ts → api-client-Drd7alfK.d.ts} +2 -2
  3. package/dist/{chunk-DZ4K6K32.mjs → chunk-CEJF5Y4K.mjs} +27 -24
  4. package/dist/{chunk-E7M4CJKR.mjs → chunk-VRA5HP7F.mjs} +7 -0
  5. package/dist/index.d.mts +11 -11
  6. package/dist/index.d.ts +11 -11
  7. package/dist/index.js +25 -15
  8. package/dist/index.mjs +10 -10
  9. package/dist/resources/api-keys/api-keys.test.js +25 -15
  10. package/dist/resources/api-keys/api-keys.test.mjs +4 -4
  11. package/dist/resources/api-keys/index.d.mts +1 -1
  12. package/dist/resources/api-keys/index.d.ts +1 -1
  13. package/dist/resources/available/available.test.js +25 -15
  14. package/dist/resources/available/available.test.mjs +4 -4
  15. package/dist/resources/available/index.d.mts +1 -1
  16. package/dist/resources/available/index.d.ts +1 -1
  17. package/dist/resources/bank-accounts/bank-accounts.test.js +25 -15
  18. package/dist/resources/bank-accounts/bank-accounts.test.mjs +4 -4
  19. package/dist/resources/bank-accounts/index.d.mts +1 -1
  20. package/dist/resources/bank-accounts/index.d.ts +1 -1
  21. package/dist/resources/instances/index.d.mts +1 -1
  22. package/dist/resources/instances/index.d.ts +1 -1
  23. package/dist/resources/instances/instances.test.js +25 -15
  24. package/dist/resources/instances/instances.test.mjs +4 -4
  25. package/dist/resources/partner-fees/index.d.mts +1 -1
  26. package/dist/resources/partner-fees/index.d.ts +1 -1
  27. package/dist/resources/partner-fees/partner-fees.test.js +25 -15
  28. package/dist/resources/partner-fees/partner-fees.test.mjs +4 -4
  29. package/dist/resources/payins/index.d.mts +1 -1
  30. package/dist/resources/payins/index.d.ts +1 -1
  31. package/dist/resources/payins/payins-quotes.test.js +111 -15
  32. package/dist/resources/payins/payins-quotes.test.mjs +90 -4
  33. package/dist/resources/payins/payins.test.js +27 -17
  34. package/dist/resources/payins/payins.test.mjs +6 -6
  35. package/dist/resources/payins/quotes.d.mts +68 -3
  36. package/dist/resources/payins/quotes.d.ts +68 -3
  37. package/dist/resources/payins/quotes.js +7 -0
  38. package/dist/resources/payins/quotes.mjs +1 -1
  39. package/dist/resources/payouts/index.d.mts +1 -1
  40. package/dist/resources/payouts/index.d.ts +1 -1
  41. package/dist/resources/payouts/payouts.test.js +27 -17
  42. package/dist/resources/payouts/payouts.test.mjs +6 -6
  43. package/dist/resources/quotes/index.d.mts +1 -1
  44. package/dist/resources/quotes/index.d.ts +1 -1
  45. package/dist/resources/quotes/quotes.test.js +25 -15
  46. package/dist/resources/quotes/quotes.test.mjs +4 -4
  47. package/dist/resources/receivers/index.d.mts +1 -1
  48. package/dist/resources/receivers/index.d.ts +1 -1
  49. package/dist/resources/receivers/receivers.test.js +25 -15
  50. package/dist/resources/receivers/receivers.test.mjs +4 -4
  51. package/dist/resources/terms-of-service/index.d.mts +1 -1
  52. package/dist/resources/terms-of-service/index.d.ts +1 -1
  53. package/dist/resources/terms-of-service/terms-of-service.test.js +25 -15
  54. package/dist/resources/terms-of-service/terms-of-service.test.mjs +4 -4
  55. package/dist/resources/virtual-accounts/index.d.mts +1 -1
  56. package/dist/resources/virtual-accounts/index.d.ts +1 -1
  57. package/dist/resources/virtual-accounts/virtual-accounts.test.js +25 -15
  58. package/dist/resources/virtual-accounts/virtual-accounts.test.mjs +4 -4
  59. package/dist/resources/wallets/blockchain.d.mts +1 -1
  60. package/dist/resources/wallets/blockchain.d.ts +1 -1
  61. package/dist/resources/wallets/blockchain.test.js +25 -15
  62. package/dist/resources/wallets/blockchain.test.mjs +4 -4
  63. package/dist/resources/wallets/offramp.d.mts +1 -1
  64. package/dist/resources/wallets/offramp.d.ts +1 -1
  65. package/dist/resources/wallets/offramp.test.js +25 -15
  66. package/dist/resources/wallets/offramp.test.mjs +4 -4
  67. package/dist/resources/webhooks/index.d.mts +1 -1
  68. package/dist/resources/webhooks/index.d.ts +1 -1
  69. package/dist/resources/webhooks/webhooks.test.js +25 -15
  70. package/dist/resources/webhooks/webhooks.test.mjs +4 -4
  71. package/package.json +5 -2
@@ -18699,10 +18699,10 @@ function getImporter(name) {
18699
18699
  var import_expect_type = __toESM(require_dist(), 1);
18700
18700
 
18701
18701
  // src/client.ts
18702
- var import_node_crypto = require("crypto");
18702
+ var import_svix = require("svix");
18703
18703
 
18704
18704
  // package.json
18705
- var version = "2.3.0";
18705
+ var version = "2.5.0";
18706
18706
 
18707
18707
  // src/internal/blindpay-error.ts
18708
18708
  var BlindPayError = class extends Error {
@@ -18928,6 +18928,13 @@ function createPayinQuotesResource(instanceId, client) {
18928
18928
  getFxRate(_b) {
18929
18929
  var data = __objRest(_b, []);
18930
18930
  return client.post(`/instances/${instanceId}/payin-quotes/fx`, data);
18931
+ },
18932
+ get(id) {
18933
+ return client.get(`/instances/${instanceId}/payin-quotes/${id}`);
18934
+ },
18935
+ list(params) {
18936
+ const queryParams = params ? `?${new URLSearchParams(params)}` : "";
18937
+ return client.get(`/instances/${instanceId}/payin-quotes${queryParams}`);
18931
18938
  }
18932
18939
  };
18933
18940
  }
@@ -19333,26 +19340,29 @@ var BlindPay = class {
19333
19340
  });
19334
19341
  }
19335
19342
  /**
19336
- * Verifies the BlindPay webhook signature
19343
+ * Verifies the BlindPay webhook signature using Svix
19337
19344
  *
19338
19345
  * @param params.secret The webhook secret from BlindPay dashboard
19339
- * @param params.id The value of the `svix-id` header
19340
- * @param params.timestamp The value of the `svix-timestamp` header
19341
- * @param params.payload The raw request body
19342
- * @param params.svixSignature The value of the `svix-signature` header
19346
+ * @param params.headers The webhook headers object containing svix-id, svix-timestamp, and svix-signature
19347
+ * @param params.payload The raw request body as a string
19343
19348
  * @returns {boolean} True if the signature is valid, false otherwise
19344
19349
  */
19345
19350
  verifyWebhookSignature({
19346
19351
  secret,
19347
- id,
19348
- timestamp,
19349
- payload,
19350
- svixSignature
19352
+ headers,
19353
+ payload
19351
19354
  }) {
19352
- const signedContent = `${id}.${timestamp}.${payload}`;
19353
- const secretBytes = Buffer.from(secret.split("_")[1], "base64");
19354
- const expectedSignature = (0, import_node_crypto.createHmac)("sha256", secretBytes).update(signedContent).digest("base64");
19355
- return svixSignature.length === expectedSignature.length && (0, import_node_crypto.timingSafeEqual)(Buffer.from(svixSignature), Buffer.from(expectedSignature));
19355
+ try {
19356
+ const webhook = new import_svix.Webhook(secret);
19357
+ webhook.verify(payload, {
19358
+ "svix-id": headers.id,
19359
+ "svix-timestamp": headers.timestamp,
19360
+ "svix-signature": headers.signature
19361
+ });
19362
+ return true;
19363
+ } catch (e) {
19364
+ return false;
19365
+ }
19356
19366
  }
19357
19367
  };
19358
19368
 
@@ -8,20 +8,20 @@ import {
8
8
  import {
9
9
  BlindPay,
10
10
  init_client
11
- } from "../../chunk-DZ4K6K32.mjs";
11
+ } from "../../chunk-CEJF5Y4K.mjs";
12
+ import "../../chunk-UC57SCKQ.mjs";
12
13
  import "../../chunk-FG25JHDX.mjs";
13
14
  import "../../chunk-QGNLMN6Z.mjs";
14
- import "../../chunk-UC57SCKQ.mjs";
15
15
  import "../../chunk-TBTA7A2P.mjs";
16
16
  import "../../chunk-67XECGMJ.mjs";
17
17
  import "../../chunk-Z6EYX4D3.mjs";
18
18
  import "../../chunk-5XJJKYXE.mjs";
19
+ import "../../chunk-U7CKUUO7.mjs";
19
20
  import "../../chunk-RC5NN5UF.mjs";
20
21
  import "../../chunk-W7NJUABI.mjs";
21
- import "../../chunk-E7M4CJKR.mjs";
22
+ import "../../chunk-VRA5HP7F.mjs";
22
23
  import "../../chunk-3QQCDR3E.mjs";
23
24
  import "../../chunk-LRHWT4JU.mjs";
24
- import "../../chunk-U7CKUUO7.mjs";
25
25
  import "../../chunk-CPOSU35L.mjs";
26
26
  import "../../chunk-B5T7AQLH.mjs";
27
27
  import {
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, B as BlindpayApiResponse, R as Rail, a as BankAccountType, A as AccountClass, C as Country } from '../../api-client-Cw2mNJeR.mjs';
1
+ import { I as InternalApiClient, B as BlindpayApiResponse, R as Rail, a as BankAccountType, A as AccountClass, C as Country } from '../../api-client-Drd7alfK.mjs';
2
2
  import { SpeiProtocol } from '../payouts/index.mjs';
3
3
 
4
4
  type ArgentinaTransfers = "CVU" | "CBU" | "ALIAS";
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, B as BlindpayApiResponse, R as Rail, a as BankAccountType, A as AccountClass, C as Country } from '../../api-client-Cw2mNJeR.js';
1
+ import { I as InternalApiClient, B as BlindpayApiResponse, R as Rail, a as BankAccountType, A as AccountClass, C as Country } from '../../api-client-Drd7alfK.js';
2
2
  import { SpeiProtocol } from '../payouts/index.js';
3
3
 
4
4
  type ArgentinaTransfers = "CVU" | "CBU" | "ALIAS";
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Cw2mNJeR.mjs';
1
+ import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Drd7alfK.mjs';
2
2
 
3
3
  type InstanceMemberRole = "owner" | "admin" | "finance" | "checker" | "operations" | "developer" | "viewer";
4
4
  type GetInstanceMembersResponse = Array<{
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Cw2mNJeR.js';
1
+ import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Drd7alfK.js';
2
2
 
3
3
  type InstanceMemberRole = "owner" | "admin" | "finance" | "checker" | "operations" | "developer" | "viewer";
4
4
  type GetInstanceMembersResponse = Array<{
@@ -18699,10 +18699,10 @@ function getImporter(name) {
18699
18699
  var import_expect_type = __toESM(require_dist(), 1);
18700
18700
 
18701
18701
  // src/client.ts
18702
- var import_node_crypto = require("crypto");
18702
+ var import_svix = require("svix");
18703
18703
 
18704
18704
  // package.json
18705
- var version = "2.3.0";
18705
+ var version = "2.5.0";
18706
18706
 
18707
18707
  // src/internal/blindpay-error.ts
18708
18708
  var BlindPayError = class extends Error {
@@ -18928,6 +18928,13 @@ function createPayinQuotesResource(instanceId, client) {
18928
18928
  getFxRate(_b) {
18929
18929
  var data = __objRest(_b, []);
18930
18930
  return client.post(`/instances/${instanceId}/payin-quotes/fx`, data);
18931
+ },
18932
+ get(id) {
18933
+ return client.get(`/instances/${instanceId}/payin-quotes/${id}`);
18934
+ },
18935
+ list(params) {
18936
+ const queryParams = params ? `?${new URLSearchParams(params)}` : "";
18937
+ return client.get(`/instances/${instanceId}/payin-quotes${queryParams}`);
18931
18938
  }
18932
18939
  };
18933
18940
  }
@@ -19333,26 +19340,29 @@ var BlindPay = class {
19333
19340
  });
19334
19341
  }
19335
19342
  /**
19336
- * Verifies the BlindPay webhook signature
19343
+ * Verifies the BlindPay webhook signature using Svix
19337
19344
  *
19338
19345
  * @param params.secret The webhook secret from BlindPay dashboard
19339
- * @param params.id The value of the `svix-id` header
19340
- * @param params.timestamp The value of the `svix-timestamp` header
19341
- * @param params.payload The raw request body
19342
- * @param params.svixSignature The value of the `svix-signature` header
19346
+ * @param params.headers The webhook headers object containing svix-id, svix-timestamp, and svix-signature
19347
+ * @param params.payload The raw request body as a string
19343
19348
  * @returns {boolean} True if the signature is valid, false otherwise
19344
19349
  */
19345
19350
  verifyWebhookSignature({
19346
19351
  secret,
19347
- id,
19348
- timestamp,
19349
- payload,
19350
- svixSignature
19352
+ headers,
19353
+ payload
19351
19354
  }) {
19352
- const signedContent = `${id}.${timestamp}.${payload}`;
19353
- const secretBytes = Buffer.from(secret.split("_")[1], "base64");
19354
- const expectedSignature = (0, import_node_crypto.createHmac)("sha256", secretBytes).update(signedContent).digest("base64");
19355
- return svixSignature.length === expectedSignature.length && (0, import_node_crypto.timingSafeEqual)(Buffer.from(svixSignature), Buffer.from(expectedSignature));
19355
+ try {
19356
+ const webhook = new import_svix.Webhook(secret);
19357
+ webhook.verify(payload, {
19358
+ "svix-id": headers.id,
19359
+ "svix-timestamp": headers.timestamp,
19360
+ "svix-signature": headers.signature
19361
+ });
19362
+ return true;
19363
+ } catch (e) {
19364
+ return false;
19365
+ }
19356
19366
  }
19357
19367
  };
19358
19368
 
@@ -8,20 +8,20 @@ import {
8
8
  import {
9
9
  BlindPay,
10
10
  init_client
11
- } from "../../chunk-DZ4K6K32.mjs";
11
+ } from "../../chunk-CEJF5Y4K.mjs";
12
+ import "../../chunk-UC57SCKQ.mjs";
12
13
  import "../../chunk-FG25JHDX.mjs";
13
14
  import "../../chunk-QGNLMN6Z.mjs";
14
- import "../../chunk-UC57SCKQ.mjs";
15
15
  import "../../chunk-TBTA7A2P.mjs";
16
16
  import "../../chunk-67XECGMJ.mjs";
17
17
  import "../../chunk-Z6EYX4D3.mjs";
18
18
  import "../../chunk-5XJJKYXE.mjs";
19
+ import "../../chunk-U7CKUUO7.mjs";
19
20
  import "../../chunk-RC5NN5UF.mjs";
20
21
  import "../../chunk-W7NJUABI.mjs";
21
- import "../../chunk-E7M4CJKR.mjs";
22
+ import "../../chunk-VRA5HP7F.mjs";
22
23
  import "../../chunk-3QQCDR3E.mjs";
23
24
  import "../../chunk-LRHWT4JU.mjs";
24
- import "../../chunk-U7CKUUO7.mjs";
25
25
  import "../../chunk-CPOSU35L.mjs";
26
26
  import "../../chunk-B5T7AQLH.mjs";
27
27
  import {
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Cw2mNJeR.mjs';
1
+ import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Drd7alfK.mjs';
2
2
 
3
3
  type ListPartnerFeesResponse = Array<{
4
4
  id: string;
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Cw2mNJeR.js';
1
+ import { I as InternalApiClient, B as BlindpayApiResponse } from '../../api-client-Drd7alfK.js';
2
2
 
3
3
  type ListPartnerFeesResponse = Array<{
4
4
  id: string;
@@ -18699,10 +18699,10 @@ function getImporter(name) {
18699
18699
  var import_expect_type = __toESM(require_dist(), 1);
18700
18700
 
18701
18701
  // src/client.ts
18702
- var import_node_crypto = require("crypto");
18702
+ var import_svix = require("svix");
18703
18703
 
18704
18704
  // package.json
18705
- var version = "2.3.0";
18705
+ var version = "2.5.0";
18706
18706
 
18707
18707
  // src/internal/blindpay-error.ts
18708
18708
  var BlindPayError = class extends Error {
@@ -18928,6 +18928,13 @@ function createPayinQuotesResource(instanceId, client) {
18928
18928
  getFxRate(_b) {
18929
18929
  var data = __objRest(_b, []);
18930
18930
  return client.post(`/instances/${instanceId}/payin-quotes/fx`, data);
18931
+ },
18932
+ get(id) {
18933
+ return client.get(`/instances/${instanceId}/payin-quotes/${id}`);
18934
+ },
18935
+ list(params) {
18936
+ const queryParams = params ? `?${new URLSearchParams(params)}` : "";
18937
+ return client.get(`/instances/${instanceId}/payin-quotes${queryParams}`);
18931
18938
  }
18932
18939
  };
18933
18940
  }
@@ -19333,26 +19340,29 @@ var BlindPay = class {
19333
19340
  });
19334
19341
  }
19335
19342
  /**
19336
- * Verifies the BlindPay webhook signature
19343
+ * Verifies the BlindPay webhook signature using Svix
19337
19344
  *
19338
19345
  * @param params.secret The webhook secret from BlindPay dashboard
19339
- * @param params.id The value of the `svix-id` header
19340
- * @param params.timestamp The value of the `svix-timestamp` header
19341
- * @param params.payload The raw request body
19342
- * @param params.svixSignature The value of the `svix-signature` header
19346
+ * @param params.headers The webhook headers object containing svix-id, svix-timestamp, and svix-signature
19347
+ * @param params.payload The raw request body as a string
19343
19348
  * @returns {boolean} True if the signature is valid, false otherwise
19344
19349
  */
19345
19350
  verifyWebhookSignature({
19346
19351
  secret,
19347
- id,
19348
- timestamp,
19349
- payload,
19350
- svixSignature
19352
+ headers,
19353
+ payload
19351
19354
  }) {
19352
- const signedContent = `${id}.${timestamp}.${payload}`;
19353
- const secretBytes = Buffer.from(secret.split("_")[1], "base64");
19354
- const expectedSignature = (0, import_node_crypto.createHmac)("sha256", secretBytes).update(signedContent).digest("base64");
19355
- return svixSignature.length === expectedSignature.length && (0, import_node_crypto.timingSafeEqual)(Buffer.from(svixSignature), Buffer.from(expectedSignature));
19355
+ try {
19356
+ const webhook = new import_svix.Webhook(secret);
19357
+ webhook.verify(payload, {
19358
+ "svix-id": headers.id,
19359
+ "svix-timestamp": headers.timestamp,
19360
+ "svix-signature": headers.signature
19361
+ });
19362
+ return true;
19363
+ } catch (e) {
19364
+ return false;
19365
+ }
19356
19366
  }
19357
19367
  };
19358
19368
 
@@ -8,20 +8,20 @@ import {
8
8
  import {
9
9
  BlindPay,
10
10
  init_client
11
- } from "../../chunk-DZ4K6K32.mjs";
11
+ } from "../../chunk-CEJF5Y4K.mjs";
12
+ import "../../chunk-UC57SCKQ.mjs";
12
13
  import "../../chunk-FG25JHDX.mjs";
13
14
  import "../../chunk-QGNLMN6Z.mjs";
14
- import "../../chunk-UC57SCKQ.mjs";
15
15
  import "../../chunk-TBTA7A2P.mjs";
16
16
  import "../../chunk-67XECGMJ.mjs";
17
17
  import "../../chunk-Z6EYX4D3.mjs";
18
18
  import "../../chunk-5XJJKYXE.mjs";
19
+ import "../../chunk-U7CKUUO7.mjs";
19
20
  import "../../chunk-RC5NN5UF.mjs";
20
21
  import "../../chunk-W7NJUABI.mjs";
21
- import "../../chunk-E7M4CJKR.mjs";
22
+ import "../../chunk-VRA5HP7F.mjs";
22
23
  import "../../chunk-3QQCDR3E.mjs";
23
24
  import "../../chunk-LRHWT4JU.mjs";
24
- import "../../chunk-U7CKUUO7.mjs";
25
25
  import "../../chunk-CPOSU35L.mjs";
26
26
  import "../../chunk-B5T7AQLH.mjs";
27
27
  import {
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, P as PaginationParams, T as TransactionStatus, B as BlindpayApiResponse, b as TrackingTransaction, c as TrackingPayment, d as TrackingComplete, e as TrackingPartnerFee, S as StablecoinToken, N as Network, f as PaginationMetadata } from '../../api-client-Cw2mNJeR.mjs';
1
+ import { I as InternalApiClient, P as PaginationParams, T as TransactionStatus, B as BlindpayApiResponse, b as TrackingTransaction, c as TrackingPayment, d as TrackingComplete, e as TrackingPartnerFee, S as StablecoinToken, N as Network, f as PaginationMetadata } from '../../api-client-Drd7alfK.mjs';
2
2
 
3
3
  type Payin = {
4
4
  receiver_id: string;
@@ -1,4 +1,4 @@
1
- import { I as InternalApiClient, P as PaginationParams, T as TransactionStatus, B as BlindpayApiResponse, b as TrackingTransaction, c as TrackingPayment, d as TrackingComplete, e as TrackingPartnerFee, S as StablecoinToken, N as Network, f as PaginationMetadata } from '../../api-client-Cw2mNJeR.js';
1
+ import { I as InternalApiClient, P as PaginationParams, T as TransactionStatus, B as BlindpayApiResponse, b as TrackingTransaction, c as TrackingPayment, d as TrackingComplete, e as TrackingPartnerFee, S as StablecoinToken, N as Network, f as PaginationMetadata } from '../../api-client-Drd7alfK.js';
2
2
 
3
3
  type Payin = {
4
4
  receiver_id: string;
@@ -18699,10 +18699,10 @@ function getImporter(name) {
18699
18699
  var import_expect_type = __toESM(require_dist(), 1);
18700
18700
 
18701
18701
  // src/client.ts
18702
- var import_node_crypto = require("crypto");
18702
+ var import_svix = require("svix");
18703
18703
 
18704
18704
  // package.json
18705
- var version = "2.3.0";
18705
+ var version = "2.5.0";
18706
18706
 
18707
18707
  // src/internal/blindpay-error.ts
18708
18708
  var BlindPayError = class extends Error {
@@ -18928,6 +18928,13 @@ function createPayinQuotesResource(instanceId, client) {
18928
18928
  getFxRate(_b) {
18929
18929
  var data = __objRest(_b, []);
18930
18930
  return client.post(`/instances/${instanceId}/payin-quotes/fx`, data);
18931
+ },
18932
+ get(id) {
18933
+ return client.get(`/instances/${instanceId}/payin-quotes/${id}`);
18934
+ },
18935
+ list(params) {
18936
+ const queryParams = params ? `?${new URLSearchParams(params)}` : "";
18937
+ return client.get(`/instances/${instanceId}/payin-quotes${queryParams}`);
18931
18938
  }
18932
18939
  };
18933
18940
  }
@@ -19333,26 +19340,29 @@ var BlindPay = class {
19333
19340
  });
19334
19341
  }
19335
19342
  /**
19336
- * Verifies the BlindPay webhook signature
19343
+ * Verifies the BlindPay webhook signature using Svix
19337
19344
  *
19338
19345
  * @param params.secret The webhook secret from BlindPay dashboard
19339
- * @param params.id The value of the `svix-id` header
19340
- * @param params.timestamp The value of the `svix-timestamp` header
19341
- * @param params.payload The raw request body
19342
- * @param params.svixSignature The value of the `svix-signature` header
19346
+ * @param params.headers The webhook headers object containing svix-id, svix-timestamp, and svix-signature
19347
+ * @param params.payload The raw request body as a string
19343
19348
  * @returns {boolean} True if the signature is valid, false otherwise
19344
19349
  */
19345
19350
  verifyWebhookSignature({
19346
19351
  secret,
19347
- id,
19348
- timestamp,
19349
- payload,
19350
- svixSignature
19352
+ headers,
19353
+ payload
19351
19354
  }) {
19352
- const signedContent = `${id}.${timestamp}.${payload}`;
19353
- const secretBytes = Buffer.from(secret.split("_")[1], "base64");
19354
- const expectedSignature = (0, import_node_crypto.createHmac)("sha256", secretBytes).update(signedContent).digest("base64");
19355
- return svixSignature.length === expectedSignature.length && (0, import_node_crypto.timingSafeEqual)(Buffer.from(svixSignature), Buffer.from(expectedSignature));
19355
+ try {
19356
+ const webhook = new import_svix.Webhook(secret);
19357
+ webhook.verify(payload, {
19358
+ "svix-id": headers.id,
19359
+ "svix-timestamp": headers.timestamp,
19360
+ "svix-signature": headers.signature
19361
+ });
19362
+ return true;
19363
+ } catch (e) {
19364
+ return false;
19365
+ }
19356
19366
  }
19357
19367
  };
19358
19368
 
@@ -19413,6 +19423,92 @@ describe("Payin quotes", () => {
19413
19423
  globalExpect(data).toEqual(mockedFxRate);
19414
19424
  }));
19415
19425
  });
19426
+ describe("Get payin quote", () => {
19427
+ it("should get a payin quote", () => __async(null, null, function* () {
19428
+ const mockedPayinQuote = {
19429
+ id: "qu_000000000000",
19430
+ payment_method: "pix",
19431
+ token: "USDC",
19432
+ request_amount: 1e3,
19433
+ cover_fees: true,
19434
+ currency_type: "sender",
19435
+ expires_at: 1712958191,
19436
+ currency: "BRL",
19437
+ commercial_quotation: 495,
19438
+ blindpay_quotation: 505,
19439
+ receiver_amount: 1010,
19440
+ sender_amount: 5240,
19441
+ partner_fee_amount: 150,
19442
+ flat_fee: 50,
19443
+ total_fee_amount: 1.53,
19444
+ payer_rules: {
19445
+ pix_allowed_tax_ids: ["149.476.037-68"]
19446
+ },
19447
+ blockchain_wallet_id: "bw_000000000000",
19448
+ instance_id: "in_000000000000",
19449
+ partner_fee_id: "pf_000000000000",
19450
+ billing_fee: 100,
19451
+ created_at: "2021-01-01T00:00:00Z",
19452
+ updated_at: "2021-01-01T00:00:00Z"
19453
+ };
19454
+ fetchMock.mockResponseOnce(JSON.stringify(mockedPayinQuote), {
19455
+ headers: { "Content-Type": "application/json" }
19456
+ });
19457
+ const { data, error } = yield blindpay.payins.quotes.get("qu_000000000000");
19458
+ globalExpect(error).toBeNull();
19459
+ globalExpect(data).toEqual(mockedPayinQuote);
19460
+ }));
19461
+ });
19462
+ describe("List payin quotes", () => {
19463
+ it("should get a payin quote", () => __async(null, null, function* () {
19464
+ const mockedPayinQuote = {
19465
+ data: [
19466
+ {
19467
+ id: "qu_000000000000",
19468
+ payment_method: "pix",
19469
+ token: "USDC",
19470
+ request_amount: 1e3,
19471
+ cover_fees: true,
19472
+ currency_type: "sender",
19473
+ expires_at: 1712958191,
19474
+ currency: "BRL",
19475
+ commercial_quotation: 495,
19476
+ blindpay_quotation: 505,
19477
+ receiver_amount: 1010,
19478
+ sender_amount: 5240,
19479
+ partner_fee_amount: 150,
19480
+ flat_fee: 50,
19481
+ total_fee_amount: 1.53,
19482
+ payer_rules: {
19483
+ pix_allowed_tax_ids: ["149.476.037-68"]
19484
+ },
19485
+ blockchain_wallet_id: "bw_000000000000",
19486
+ instance_id: "in_000000000000",
19487
+ partner_fee_id: "pf_000000000000",
19488
+ billing_fee: 100,
19489
+ created_at: "2021-01-01T00:00:00Z",
19490
+ updated_at: "2021-01-01T00:00:00Z"
19491
+ }
19492
+ ],
19493
+ pagination: {
19494
+ has_more: true,
19495
+ next_page: "qu_123",
19496
+ prev_page: "qu_123"
19497
+ }
19498
+ };
19499
+ fetchMock.mockResponseOnce(JSON.stringify(mockedPayinQuote), {
19500
+ headers: { "Content-Type": "application/json" }
19501
+ });
19502
+ const { data, error } = yield blindpay.payins.quotes.list({
19503
+ blockchain_wallet_id: "bw_000000000000",
19504
+ payment_method: "pix",
19505
+ token: "USDC",
19506
+ receiver_id: "re_000000000000"
19507
+ });
19508
+ globalExpect(error).toBeNull();
19509
+ globalExpect(data).toEqual(mockedPayinQuote);
19510
+ }));
19511
+ });
19416
19512
  });
19417
19513
  /*! Bundled license information:
19418
19514
 
@@ -8,20 +8,20 @@ import {
8
8
  import {
9
9
  BlindPay,
10
10
  init_client
11
- } from "../../chunk-DZ4K6K32.mjs";
11
+ } from "../../chunk-CEJF5Y4K.mjs";
12
+ import "../../chunk-UC57SCKQ.mjs";
12
13
  import "../../chunk-FG25JHDX.mjs";
13
14
  import "../../chunk-QGNLMN6Z.mjs";
14
- import "../../chunk-UC57SCKQ.mjs";
15
15
  import "../../chunk-TBTA7A2P.mjs";
16
16
  import "../../chunk-67XECGMJ.mjs";
17
17
  import "../../chunk-Z6EYX4D3.mjs";
18
18
  import "../../chunk-5XJJKYXE.mjs";
19
+ import "../../chunk-U7CKUUO7.mjs";
19
20
  import "../../chunk-RC5NN5UF.mjs";
20
21
  import "../../chunk-W7NJUABI.mjs";
21
- import "../../chunk-E7M4CJKR.mjs";
22
+ import "../../chunk-VRA5HP7F.mjs";
22
23
  import "../../chunk-3QQCDR3E.mjs";
23
24
  import "../../chunk-LRHWT4JU.mjs";
24
- import "../../chunk-U7CKUUO7.mjs";
25
25
  import "../../chunk-CPOSU35L.mjs";
26
26
  import "../../chunk-B5T7AQLH.mjs";
27
27
  import {
@@ -90,6 +90,92 @@ var require_payins_quotes_test = __commonJS({
90
90
  globalExpect(data).toEqual(mockedFxRate);
91
91
  }));
92
92
  });
93
+ describe("Get payin quote", () => {
94
+ it("should get a payin quote", () => __async(null, null, function* () {
95
+ const mockedPayinQuote = {
96
+ id: "qu_000000000000",
97
+ payment_method: "pix",
98
+ token: "USDC",
99
+ request_amount: 1e3,
100
+ cover_fees: true,
101
+ currency_type: "sender",
102
+ expires_at: 1712958191,
103
+ currency: "BRL",
104
+ commercial_quotation: 495,
105
+ blindpay_quotation: 505,
106
+ receiver_amount: 1010,
107
+ sender_amount: 5240,
108
+ partner_fee_amount: 150,
109
+ flat_fee: 50,
110
+ total_fee_amount: 1.53,
111
+ payer_rules: {
112
+ pix_allowed_tax_ids: ["149.476.037-68"]
113
+ },
114
+ blockchain_wallet_id: "bw_000000000000",
115
+ instance_id: "in_000000000000",
116
+ partner_fee_id: "pf_000000000000",
117
+ billing_fee: 100,
118
+ created_at: "2021-01-01T00:00:00Z",
119
+ updated_at: "2021-01-01T00:00:00Z"
120
+ };
121
+ fetchMock.mockResponseOnce(JSON.stringify(mockedPayinQuote), {
122
+ headers: { "Content-Type": "application/json" }
123
+ });
124
+ const { data, error } = yield blindpay.payins.quotes.get("qu_000000000000");
125
+ globalExpect(error).toBeNull();
126
+ globalExpect(data).toEqual(mockedPayinQuote);
127
+ }));
128
+ });
129
+ describe("List payin quotes", () => {
130
+ it("should get a payin quote", () => __async(null, null, function* () {
131
+ const mockedPayinQuote = {
132
+ data: [
133
+ {
134
+ id: "qu_000000000000",
135
+ payment_method: "pix",
136
+ token: "USDC",
137
+ request_amount: 1e3,
138
+ cover_fees: true,
139
+ currency_type: "sender",
140
+ expires_at: 1712958191,
141
+ currency: "BRL",
142
+ commercial_quotation: 495,
143
+ blindpay_quotation: 505,
144
+ receiver_amount: 1010,
145
+ sender_amount: 5240,
146
+ partner_fee_amount: 150,
147
+ flat_fee: 50,
148
+ total_fee_amount: 1.53,
149
+ payer_rules: {
150
+ pix_allowed_tax_ids: ["149.476.037-68"]
151
+ },
152
+ blockchain_wallet_id: "bw_000000000000",
153
+ instance_id: "in_000000000000",
154
+ partner_fee_id: "pf_000000000000",
155
+ billing_fee: 100,
156
+ created_at: "2021-01-01T00:00:00Z",
157
+ updated_at: "2021-01-01T00:00:00Z"
158
+ }
159
+ ],
160
+ pagination: {
161
+ has_more: true,
162
+ next_page: "qu_123",
163
+ prev_page: "qu_123"
164
+ }
165
+ };
166
+ fetchMock.mockResponseOnce(JSON.stringify(mockedPayinQuote), {
167
+ headers: { "Content-Type": "application/json" }
168
+ });
169
+ const { data, error } = yield blindpay.payins.quotes.list({
170
+ blockchain_wallet_id: "bw_000000000000",
171
+ payment_method: "pix",
172
+ token: "USDC",
173
+ receiver_id: "re_000000000000"
174
+ });
175
+ globalExpect(error).toBeNull();
176
+ globalExpect(data).toEqual(mockedPayinQuote);
177
+ }));
178
+ });
93
179
  });
94
180
  }
95
181
  });