@rebound-dlq/node 0.2.2 → 0.2.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.
@@ -1,4 +1,4 @@
1
1
  export declare const REBOUND_API_ENDPOINTS: {
2
- readonly TEST: "https://rebound-dlq-api-2.vercel.app/api/v1";
3
- readonly PRODUCTION: "https://rebound-dlq-api-2.vercel.app/api/v1";
2
+ readonly TEST: "https://api.rebound-dlq.com/api/v1";
3
+ readonly PRODUCTION: "https://api.rebound-dlq.com/api/v1";
4
4
  };
@@ -2,6 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.REBOUND_API_ENDPOINTS = void 0;
4
4
  exports.REBOUND_API_ENDPOINTS = {
5
- TEST: 'https://rebound-dlq-api-2.vercel.app/api/v1',
6
- PRODUCTION: 'https://rebound-dlq-api-2.vercel.app/api/v1'
5
+ TEST: 'https://api.rebound-dlq.com/api/v1',
6
+ PRODUCTION: 'https://api.rebound-dlq.com/api/v1'
7
7
  };
@@ -1,6 +1,40 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.MemoryQueue = void 0;
37
+ const crypto = __importStar(require("crypto"));
4
38
  class MemoryQueue {
5
39
  constructor() {
6
40
  this.queue = [];
@@ -35,13 +69,22 @@ class MemoryQueue {
35
69
  while (this.queue.length > 0) {
36
70
  const item = this.queue[0]; // FIFO
37
71
  try {
72
+ const timestamp = Date.now().toString();
73
+ const payloadString = JSON.stringify(item.payload);
74
+ const dataToSign = `${timestamp}.${payloadString}`;
75
+ const signature = crypto
76
+ .createHmac('sha256', item.apiKey)
77
+ .update(dataToSign)
78
+ .digest('hex');
38
79
  const response = await fetch(item.endpoint, {
39
80
  method: 'POST',
40
81
  headers: {
41
82
  'Content-Type': 'application/json',
42
- 'x-api-key': `Bearer ${item.apiKey}`
83
+ 'x-api-key': `Bearer ${item.apiKey}`,
84
+ 'x-sdk-timestamp': timestamp,
85
+ 'x-sdk-signature': signature
43
86
  },
44
- body: JSON.stringify(item.payload),
87
+ body: payloadString,
45
88
  });
46
89
  if (response.ok) {
47
90
  if (item.retryCount > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rebound-dlq/node",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": ["dist"],