@vouchfor/sdk 1.1.25 → 1.1.27

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.
@@ -25,6 +25,12 @@ class IntegrationService extends BaseIntegrationService {
25
25
  throw new Error('Failed to authenticate integration');
26
26
  }
27
27
  }
28
+
29
+ commit() {
30
+ return this._request({
31
+ path: 'commit', // no slash needed here
32
+ });
33
+ }
28
34
  }
29
35
 
30
36
  module.exports = IntegrationService;
@@ -26,7 +26,8 @@ function elapsedTimeInSeconds(start) {
26
26
 
27
27
  function logHttpResponse({ req, res, body, result, start, logger }) {
28
28
  const elapsed = elapsedTimeInSeconds(start);
29
- const { protocol, method, host, _header: header } = req._currentRequest;
29
+ const { protocol, method, _header: header } = req._currentRequest;
30
+ const host = req.getHeader('host');
30
31
  const get = req.type === 'GET';
31
32
  const type = res.headers['content-type'] ?? 'application/json';
32
33
  const data = (typeof body === 'object' ? JSON.stringify(body) : body || '') + '\n';
@@ -53,7 +54,8 @@ function logHttpResponse({ req, res, body, result, start, logger }) {
53
54
 
54
55
  function logHttpError({ req, err, body, start, logger }) {
55
56
  const elapsed = elapsedTimeInSeconds(start);
56
- const { protocol, method, host, _header: header } = req._currentRequest;
57
+ const { protocol, method, _header: header } = req._currentRequest;
58
+ const host = req.getHeader('host');
57
59
  const res = { headers: parseHttpHeaders(header) };
58
60
  const get = req.type === 'GET';
59
61
  const type = res.headers['content-type'] ?? 'application/json';
package/lib/vouch.js CHANGED
@@ -13,6 +13,13 @@ class Vouch {
13
13
  }
14
14
  );
15
15
  }
16
+
17
+ poll() {
18
+ return Promise.all([
19
+ this.utilities.commit().catch(() => undefined),
20
+ this.integrations.commit().catch(() => undefined),
21
+ ]);
22
+ }
16
23
  }
17
24
 
18
25
  module.exports = Vouch;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchfor/sdk",
3
- "version": "1.1.25",
3
+ "version": "1.1.27",
4
4
  "description": "Vouch API SDK",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
package/test-commit.js CHANGED
@@ -6,5 +6,6 @@ const vouchClient = new Vouch({
6
6
  }, console);
7
7
 
8
8
  (async () => {
9
- vouchClient.utilities.commit();
9
+ vouchClient.utilities.commit().catch(() => undefined);
10
+ vouchClient.integrations.commit().catch(() => undefined);
10
11
  })();
package/test-poll.js ADDED
@@ -0,0 +1,10 @@
1
+ const Vouch = require("./lib/vouch");
2
+
3
+ const vouchClient = new Vouch({
4
+ env: 'dev',
5
+ integrationKey: 'b0883f06-84af-4108-8543-31874c335c36-kkr3Wy4CLY8C2g65UT79sgUfOIR2ZzkA9uQam3bTs4ZNdlSs7M',
6
+ }, console);
7
+
8
+ (async () => {
9
+ vouchClient.poll();
10
+ })();