@vouchfor/sdk 1.1.12 → 1.1.14
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,23 @@
|
|
|
1
1
|
const utils = require('../shared/utils');
|
|
2
2
|
|
|
3
|
+
// set up env for local development
|
|
4
|
+
// set env SDK_LOCAL_DEV to use default local development endpoints
|
|
5
|
+
// set env SDK_LOCAL_REST and/or SDK_LOCAL_APPS to override defaults
|
|
6
|
+
(() => {
|
|
7
|
+
const SDK_LOCAL_REST = 'http://localhost:5050/v1';
|
|
8
|
+
const SDK_LOCAL_APPS = 'http://localhost:8080/v1';
|
|
9
|
+
if (process.env.SDK_LOCAL_DEV) {
|
|
10
|
+
process.env.SDK_LOCAL_REST ||= SDK_LOCAL_REST;
|
|
11
|
+
process.env.SDK_LOCAL_APPS ||= SDK_LOCAL_APPS;
|
|
12
|
+
}
|
|
13
|
+
if (process.env.SDK_LOCAL_REST) {
|
|
14
|
+
console.log(`local REST: ${process.env.SDK_LOCAL_REST}`);
|
|
15
|
+
}
|
|
16
|
+
if (process.env.SDK_LOCAL_APPS) {
|
|
17
|
+
console.log(`local APPS: ${process.env.SDK_LOCAL_APPS}`);
|
|
18
|
+
}
|
|
19
|
+
})();
|
|
20
|
+
|
|
3
21
|
class BaseService {
|
|
4
22
|
constructor(client, config = {}, logger) {
|
|
5
23
|
const basePath = config.basePath ? `/${config.basePath}` : '';
|
|
@@ -5,7 +5,7 @@ class BaseIntegrationService extends BaseService {
|
|
|
5
5
|
constructor(client, config = {}, basePath = '', logger) {
|
|
6
6
|
super(client, {
|
|
7
7
|
apiKey: config.integrationKey,
|
|
8
|
-
baseUrl: `https://apps${utils.getApiSuffix(config.env)}.vouchfor.com/v1`,
|
|
8
|
+
baseUrl: process.env.SDK_LOCAL_APPS || `https://apps${utils.getApiSuffix(config.env)}.vouchfor.com/v1`,
|
|
9
9
|
basePath,
|
|
10
10
|
env: config.env,
|
|
11
11
|
}, logger);
|
|
@@ -6,7 +6,7 @@ class BaseRestService extends BaseService {
|
|
|
6
6
|
super(client, {
|
|
7
7
|
apiKey: config.apiKey,
|
|
8
8
|
integrationKey: config.integrationKey,
|
|
9
|
-
baseUrl: `https://api${utils.getApiSuffix(config.env)}.vouchfor.com/v1`,
|
|
9
|
+
baseUrl: process.env.SDK_LOCAL_REST || `https://api${utils.getApiSuffix(config.env)}.vouchfor.com/v1`,
|
|
10
10
|
basePath,
|
|
11
11
|
env: config.env,
|
|
12
12
|
}, logger);
|
package/lib/shared/events.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
module.exports = {
|
|
2
|
+
APPLICATION_ACTION_INIT: 'application.action.init',
|
|
3
|
+
APPLICATION_ACTION_SUBMIT: 'application.action.submit',
|
|
2
4
|
APPLICATION_INSTALL: 'application.install',
|
|
3
5
|
APPLICATION_DELETE: 'application.delete',
|
|
4
6
|
APPLICATION_CONFIGURE: 'application.configure',
|
package/package.json
CHANGED
package/test.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
})();
|