@abacatepay/types 2.0.2 → 2.0.3

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.
package/dist/index.d.ts CHANGED
@@ -5,3 +5,15 @@ export { API_VERSION, version } from './version';
5
5
  * @see {@link https://docs.abacatepay.com/}
6
6
  */
7
7
  export declare const API_BASE_URL = "https://api.abacatepay.com/";
8
+ /**
9
+ * Official URL for the AbacatePay API Documentation
10
+ */
11
+ export declare const ABACATEPAY_DOCS_URL = "https://docs.abacatepay.com/";
12
+ export declare const ABACATEPAY_SHARED_KEY = "t9dXRhHHo3yDEj5pVDYz0frf7q6bMKyMRmxxCPIPp3RCplBfXRxqlC6ZpiWmOqj4L63qEaeUOtrCI8P0VMUgo6iIga2ri9ogaHFs0WIIywSMg0q7RmBfybe1E5XJcfC4IW3alNqym0tXoAKkzvfEjZxV6bE0oG2zJrNNYmUCKZyV0KZ3JS8Votf9EAWWYdiDkMkpbMdPggfh1EqHlVkMiTady6jOR3hyzGEHrIz2Ret0xHKMbiqkr9HS1JhNHDX9";
13
+ /**
14
+ * Verify whether the signature is valid or not.
15
+ * @param raw Raw body response (string).
16
+ * @param signature The content of the`X-Webhook-Signature` header.
17
+ * @returns A boolean that indicates if the signature is valid.
18
+ */
19
+ export declare const verifyWebhookSignature: (raw: string, signature: string) => boolean;
package/dist/index.js CHANGED
@@ -1,7 +1,28 @@
1
1
  export { API_VERSION, version } from './version';
2
+ import { createHmac, timingSafeEqual } from 'node:crypto';
2
3
  /**
3
4
  * Base URL for the AbacatePay API (Version not included).
4
5
  *
5
6
  * @see {@link https://docs.abacatepay.com/}
6
7
  */
7
8
  export const API_BASE_URL = 'https://api.abacatepay.com/';
9
+ /**
10
+ * Official URL for the AbacatePay API Documentation
11
+ */
12
+ export const ABACATEPAY_DOCS_URL = 'https://docs.abacatepay.com/';
13
+ export const ABACATEPAY_SHARED_KEY = 't9dXRhHHo3yDEj5pVDYz0frf7q6bMKyMRmxxCPIPp3RCplBfXRxqlC6ZpiWmOqj4L63qEaeUOtrCI8P0VMUgo6iIga2ri9ogaHFs0WIIywSMg0q7RmBfybe1E5XJcfC4IW3alNqym0tXoAKkzvfEjZxV6bE0oG2zJrNNYmUCKZyV0KZ3JS8Votf9EAWWYdiDkMkpbMdPggfh1EqHlVkMiTady6jOR3hyzGEHrIz2Ret0xHKMbiqkr9HS1JhNHDX9';
14
+ /**
15
+ * Verify whether the signature is valid or not.
16
+ * @param raw Raw body response (string).
17
+ * @param signature The content of the`X-Webhook-Signature` header.
18
+ * @returns A boolean that indicates if the signature is valid.
19
+ */
20
+ export const verifyWebhookSignature = (raw, signature) => {
21
+ const bodyBuffer = Buffer.from(raw, 'utf8');
22
+ const expectedSig = createHmac('sha256', ABACATEPAY_SHARED_KEY)
23
+ .update(bodyBuffer)
24
+ .digest('base64');
25
+ const A = Buffer.from(expectedSig);
26
+ const B = Buffer.from(signature);
27
+ return A.length === B.length && timingSafeEqual(A, B);
28
+ };
@@ -17,10 +17,3 @@ export declare function isPayoutFailedWebhookEvent(event: WebhookEvent): event i
17
17
  * @returns A boolean that indicates if the webhook is a billing paid webhook.
18
18
  */
19
19
  export declare function isBillingPaidWebhookEvent(event: WebhookEvent): event is import("./webhook").WebhookBillingPaidEvent;
20
- /**
21
- * Verify whether the signature is valid or not.
22
- * @param raw Raw body response (string).
23
- * @param signature The content of the`X-Webhook-Signature` header.
24
- * @returns A boolean that indicates if the signature is valid.
25
- */
26
- export declare const verifyWebhookSignature: (raw: string, signature: string) => boolean;
package/dist/v2/utils.js CHANGED
@@ -1,4 +1,3 @@
1
- import { createHmac, timingSafeEqual } from 'node:crypto';
2
1
  import { WebhookEventType } from './webhook';
3
2
  /**
4
3
  * A type guard check for `payout.done` webhook events.
@@ -24,19 +23,3 @@ export function isPayoutFailedWebhookEvent(event) {
24
23
  export function isBillingPaidWebhookEvent(event) {
25
24
  return event.event === WebhookEventType.BillingPaid;
26
25
  }
27
- const ABACATEPAY_PUBLIC_KEY = 't9dXRhHHo3yDEj5pVDYz0frf7q6bMKyMRmxxCPIPp3RCplBfXRxqlC6ZpiWmOqj4L63qEaeUOtrCI8P0VMUgo6iIga2ri9ogaHFs0WIIywSMg0q7RmBfybe1E5XJcfC4IW3alNqym0tXoAKkzvfEjZxV6bE0oG2zJrNNYmUCKZyV0KZ3JS8Votf9EAWWYdiDkMkpbMdPggfh1EqHlVkMiTady6jOR3hyzGEHrIz2Ret0xHKMbiqkr9HS1JhNHDX9';
28
- /**
29
- * Verify whether the signature is valid or not.
30
- * @param raw Raw body response (string).
31
- * @param signature The content of the`X-Webhook-Signature` header.
32
- * @returns A boolean that indicates if the signature is valid.
33
- */
34
- export const verifyWebhookSignature = (raw, signature) => {
35
- const bodyBuffer = Buffer.from(raw, 'utf8');
36
- const expectedSig = createHmac('sha256', ABACATEPAY_PUBLIC_KEY)
37
- .update(bodyBuffer)
38
- .digest('base64');
39
- const A = Buffer.from(expectedSig);
40
- const B = Buffer.from(signature);
41
- return A.length === B.length && timingSafeEqual(A, B);
42
- };
package/dist/version.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Current version of [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types).
3
3
  */
4
- export declare const version: "2.0.2";
4
+ export declare const version: "2.0.3";
5
5
  /**
6
6
  * Current version of the AbacatePay API.
7
7
  */
package/dist/version.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Current version of [@abacatepay/types](https://www.npmjs.com/package/@abacatepay/types).
4
4
  */
5
- export const version = '2.0.2';
5
+ export const version = '2.0.3';
6
6
  /**
7
7
  * Current version of the AbacatePay API.
8
8
  */
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.0.2",
2
+ "version": "2.0.3",
3
3
  "name": "@abacatepay/types",
4
4
  "description": "Abacate Pay API typings that are always up to date.",
5
5
  "type": "module",