@vouchfor/sdk 1.1.11 → 1.1.12

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,5 +1,5 @@
1
1
  const followRedirects = require('follow-redirects');
2
- const { https } = followRedirects;
2
+ const { http, https } = followRedirects;
3
3
 
4
4
  followRedirects.maxRedirects = 10;
5
5
  followRedirects.maxBodyLength = Infinity;
@@ -52,13 +52,14 @@ module.exports = {
52
52
  return isProd ? '' : `-${env}`;
53
53
  },
54
54
  request({ body, headers, method, url, logger }) {
55
- const { host, pathname, search = '' } = new URL(url);
55
+ const { protocol, hostname, port, pathname, search = '' } = new URL(url);
56
56
 
57
57
  return new Promise((resolve, reject) => {
58
58
  let result = '';
59
- const req = https
59
+ const req = (protocol === 'https:' ? https : http)
60
60
  .request({
61
- host,
61
+ hostname,
62
+ port,
62
63
  path: `${pathname}${search}`,
63
64
  headers,
64
65
  method: method ? method : body ? 'POST' : 'GET',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vouchfor/sdk",
3
- "version": "1.1.11",
3
+ "version": "1.1.12",
4
4
  "description": "Vouch API SDK",
5
5
  "main": "lib/index.js",
6
6
  "repository": {
package/test.js ADDED
@@ -0,0 +1,23 @@
1
+ const Vouch = require("./lib/vouch");
2
+
3
+ const vouchClient = new Vouch({
4
+ env: 'dev',
5
+ integrationKey: 'b0883f06-84af-4108-8543-31874c335c36-kkr3Wy4CLY8C2g65UT79sgUfOIR2ZzkA9uQam3bTs4ZNdlSs7M'
6
+ });
7
+
8
+ (async () => {
9
+ const response = await vouchClient.integrations.applications.list();
10
+ console.log(typeof response);
11
+ const items = await response.applications.reduce(async (ac, application) => {
12
+ const arr = await ac;
13
+ console.log(`id => ${application.id}`);
14
+ try {
15
+ const credentials = await vouchClient.integrations.authenticate({ entityId: application.entity.id });
16
+ arr.push(credentials);
17
+ } catch (err) {
18
+ console.error(`failed to get credentials ${err} - ${application.id}`);
19
+ }
20
+
21
+ return arr;
22
+ }, Promise.resolve([]));
23
+ })();