@aloma.io/integration-sdk 3.4.13 → 3.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.
@@ -1,13 +1,11 @@
1
1
  import { init } from "@paralleldrive/cuid2";
2
2
  import express from "express";
3
- import fetch from "node-fetch";
4
3
  import PromClient from "prom-client";
5
4
  import { Dispatcher } from "./dispatcher/index.mjs";
6
5
  import JWE from "./util/jwe/index.mjs";
7
6
  import { Config } from "./websocket/config.mjs";
8
7
  import { WebsocketConnector } from "./websocket/index.mjs";
9
8
  const cuid = init({ length: 32 });
10
- // TODO fetch with retry
11
9
  const handlePacketError = (packet, e, transport) => {
12
10
  if (!packet.cb()) {
13
11
  console.dir({ msg: "packet error", e, packet }, { depth: null });
@@ -97,7 +95,7 @@ class Fetcher {
97
95
  options?.headers?.["Content-type"] === "application/json") {
98
96
  options.body = JSON.stringify(options.body);
99
97
  }
100
- const ret = await fetch(theURL, options);
98
+ const ret = await fetch(theURL, { ...options, signal: AbortSignal.timeout(30 * 60 * 1000) });
101
99
  const status = await ret.status;
102
100
  if (status > 399) {
103
101
  const text = await ret.text();
@@ -407,6 +405,7 @@ ${text}
407
405
  method: "POST",
408
406
  body: new URLSearchParams(body),
409
407
  headers,
408
+ signal: AbortSignal.timeout(60 * 1000)
410
409
  });
411
410
  const status = await response.status;
412
411
  const text = await response.text();
@@ -482,6 +481,7 @@ ${text}
482
481
  Accept: "application/json",
483
482
  ...headers,
484
483
  },
484
+ signal: AbortSignal.timeout(60 * 1000)
485
485
  });
486
486
  const status = await response.status;
487
487
  const text = await response.text();
@@ -1,4 +1,3 @@
1
- import fetch from "node-fetch";
2
1
  import { Registration } from "./registration.mjs";
3
2
  import C from "./constants.mjs";
4
3
  class Connection {
@@ -13,6 +12,7 @@ class Connection {
13
12
  method: "POST",
14
13
  body: JSON.stringify({}),
15
14
  headers: { "Content-Type": "application/json" },
15
+ signal: AbortSignal.timeout(60 * 1000)
16
16
  }, config));
17
17
  if (response.status === 401) {
18
18
  config.setToken(await new Registration(local.config).run());
@@ -41,6 +41,7 @@ class Connection {
41
41
  method: "POST",
42
42
  body: JSON.stringify({}),
43
43
  headers: { "Content-Type": "application/json" },
44
+ signal: AbortSignal.timeout(60 * 1000)
44
45
  }, this.config));
45
46
  }
46
47
  catch (e) {
@@ -1,4 +1,3 @@
1
- import fetch from "node-fetch";
2
1
  import C from "./constants.mjs";
3
2
  class Registration {
4
3
  constructor(config) {
@@ -22,6 +21,7 @@ class Registration {
22
21
  icon,
23
22
  }),
24
23
  headers: { "Content-Type": "application/json" },
24
+ signal: AbortSignal.timeout(60 * 1000)
25
25
  }, config));
26
26
  if (response.status === 200)
27
27
  return (await response.json()).key;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aloma.io/integration-sdk",
3
- "version": "3.4.13",
3
+ "version": "3.5.0",
4
4
  "description": "",
5
5
  "author": "aloma.io",
6
6
  "license": "Apache-2.0",
@@ -32,7 +32,6 @@
32
32
  "dotenv": "*",
33
33
  "express": "^4",
34
34
  "jose": "^5",
35
- "node-fetch": "^3",
36
35
  "prom-client": "^15",
37
36
  "typescript": "^5",
38
37
  "ws": "^8",
@@ -1,6 +1,5 @@
1
1
  import { init } from "@paralleldrive/cuid2";
2
2
  import express from "express";
3
- import fetch from "node-fetch";
4
3
  import PromClient from "prom-client";
5
4
  import { Dispatcher } from "./dispatcher/index.mjs";
6
5
  import JWE from "./util/jwe/index.mjs";
@@ -8,8 +7,6 @@ import { Config } from "./websocket/config.mjs";
8
7
  import { WebsocketConnector } from "./websocket/index.mjs";
9
8
  const cuid = init({ length: 32 });
10
9
 
11
- // TODO fetch with retry
12
-
13
10
  const handlePacketError = (packet, e, transport) => {
14
11
  if (!packet.cb()) {
15
12
  console.dir({ msg: "packet error", e, packet }, { depth: null });
@@ -126,7 +123,7 @@ class Fetcher {
126
123
  options.body = JSON.stringify(options.body);
127
124
  }
128
125
 
129
- const ret = await fetch(theURL, options);
126
+ const ret = await fetch(theURL, {...options, signal: AbortSignal.timeout(30 * 60 * 1000)});
130
127
  const status = await ret.status;
131
128
 
132
129
  if (status > 399) {
@@ -510,6 +507,7 @@ ${text}
510
507
  method: "POST",
511
508
  body: new URLSearchParams(body),
512
509
  headers,
510
+ signal: AbortSignal.timeout(60 * 1000)
513
511
  });
514
512
 
515
513
  const status = await response.status;
@@ -602,6 +600,7 @@ ${text}
602
600
  Accept: "application/json",
603
601
  ...headers,
604
602
  },
603
+ signal: AbortSignal.timeout(60 * 1000)
605
604
  });
606
605
 
607
606
  const status = await response.status;
@@ -1,4 +1,4 @@
1
- import fetch from "node-fetch";
1
+
2
2
  import { Registration } from "./registration.mjs";
3
3
  import C from "./constants.mjs";
4
4
 
@@ -20,8 +20,10 @@ class Connection {
20
20
  method: "POST",
21
21
  body: JSON.stringify({}),
22
22
  headers: { "Content-Type": "application/json" },
23
+ signal: AbortSignal.timeout(60 * 1000)
23
24
  },
24
25
  config,
26
+
25
27
  ),
26
28
  );
27
29
 
@@ -57,6 +59,7 @@ class Connection {
57
59
  method: "POST",
58
60
  body: JSON.stringify({}),
59
61
  headers: { "Content-Type": "application/json" },
62
+ signal: AbortSignal.timeout(60 * 1000)
60
63
  },
61
64
  this.config,
62
65
  ),
@@ -1,4 +1,3 @@
1
- import fetch from "node-fetch";
2
1
  import C from "./constants.mjs";
3
2
 
4
3
  class Registration {
@@ -28,6 +27,7 @@ class Registration {
28
27
  icon,
29
28
  }),
30
29
  headers: { "Content-Type": "application/json" },
30
+ signal: AbortSignal.timeout(60 * 1000)
31
31
  },
32
32
  config,
33
33
  ),