Skip to content

Commit 7e5b58d

Browse files
authored
Merge pull request #19 from polarityio/develop
Add page size option and bump dependencies
2 parents 6204dda + 17d253c commit 7e5b58d

File tree

5 files changed

+45
-28
lines changed

5 files changed

+45
-28
lines changed

config/config.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,17 @@ module.exports = {
9191
description: 'HYAS Api Key',
9292
default: '',
9393
type: 'password',
94-
userCanEdit: true,
95-
adminOnly: false
94+
userCanEdit: false,
95+
adminOnly: true
96+
},
97+
{
98+
"key": "maxResults",
99+
"name": "Maximum Results",
100+
"description": "Maximum number of results to return.",
101+
"default": 5,
102+
"type": "number",
103+
"userCanEdit": false,
104+
"adminOnly": false
96105
},
97106
{
98107
key: 'blocklist',

config/config.json

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,16 @@
5454
"description": "HYAS Api Key",
5555
"default": "",
5656
"type": "password",
57-
"userCanEdit": true,
57+
"userCanEdit": false,
58+
"adminOnly": true
59+
},
60+
{
61+
"key": "maxResults",
62+
"name": "Maximum Results",
63+
"description": "Maximum number of results to return.",
64+
"default": 5,
65+
"type": "number",
66+
"userCanEdit": false,
5867
"adminOnly": false
5968
},
6069
{

integration.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ let ipBlocklistRegex = null;
2121
const MAX_DOMAIN_LABEL_LENGTH = 63;
2222
const MAX_ENTITY_LENGTH = 100;
2323
const MAX_PARALLEL_LOOKUPS = 10;
24-
const PAGE_SIZE = 5;
2524
const IGNORED_IPS = new Set(['127.0.0.1', '255.255.255.255', '0.0.0.0']);
2625
const url = 'https://insight.hyas.com/api/ext';
2726
const uiurl = 'https://apps.hyas.com';
@@ -98,7 +97,7 @@ function doLookup(entities, options, cb) {
9897

9998
tasks.push(function (done) {
10099
requestWithDefaults(requestOptions, function (error, res, body) {
101-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
100+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
102101
let processedResult = handleRestError(error, entity, res, body);
103102

104103
if (processedResult.error) {
@@ -136,7 +135,7 @@ function doLookup(entities, options, cb) {
136135

137136
tasks.push(function (done) {
138137
requestWithDefaults(requestOptions, function (error, res, body) {
139-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
138+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
140139
let processedResult = handleRestError(error, entity, res, body);
141140

142141
if (processedResult.error) {
@@ -173,7 +172,7 @@ function doLookup(entities, options, cb) {
173172

174173
tasks.push(function (done) {
175174
requestWithDefaults(requestOptions, function (error, res, body) {
176-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
175+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
177176
let processedResult = handleRestError(error, entity, res, body);
178177
if (processedResult.error) {
179178
done(processedResult);
@@ -211,7 +210,7 @@ function doLookup(entities, options, cb) {
211210

212211
tasks.push(function (done) {
213212
requestWithDefaults(requestOptions, function (error, res, body) {
214-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
213+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
215214
let processedResult = handleRestError(error, entity, res, body);
216215
if (processedResult.error) {
217216
done(processedResult);
@@ -247,7 +246,7 @@ function doLookup(entities, options, cb) {
247246

248247
tasks.push(function (done) {
249248
requestWithDefaults(requestOptions, function (error, res, body) {
250-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
249+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
251250
let processedResult = handleRestError(error, entity, res, body);
252251
if (processedResult.error) {
253252
done(processedResult);
@@ -322,7 +321,7 @@ function doLookup(entities, options, cb) {
322321
details: {
323322
result: resultWithFormatedPhoneNumber,
324323
link: result.link,
325-
pageSize: PAGE_SIZE
324+
pageSize: options.maxResults
326325
}
327326
}
328327
});
@@ -407,7 +406,7 @@ function doDeviceGeoIpLookup(entity, options) {
407406
};
408407

409408
requestWithDefaults(requestOptions, (error, response, body) => {
410-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
409+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
411410
let processedResult = handleRestError(error, entity, response, body);
412411
if (processedResult.error) return done(processedResult);
413412
done(null, processedResult.body);
@@ -432,13 +431,13 @@ function doDomainPassiveLookup(entity, options) {
432431
applied_filters: {
433432
domain: entity.value
434433
},
435-
paging: { order: 'desc', sort: 'datetime', page_number: 0, page_size: 10 }
434+
paging: { order: 'desc', sort: 'datetime', page_number: 0, page_size: options.maxResults }
436435
},
437436
json: true
438437
};
439438

440439
requestWithDefaults(requestOptions, (error, response, body) => {
441-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
440+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
442441
let processedResult = handleRestError(error, entity, response, body);
443442
if (processedResult.error) return done(processedResult);
444443
done(null, processedResult.body);
@@ -468,7 +467,7 @@ function doIpSampleLookup(entity, options) {
468467
};
469468

470469
requestWithDefaults(requestOptions, (error, response, body) => {
471-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
470+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
472471
let processedResult = handleRestError(error, entity, response, body);
473472
if (processedResult.error) return done(processedResult);
474473
done(null, processedResult.body);
@@ -498,7 +497,7 @@ function doDomainSampleLookup(entity, options) {
498497
};
499498

500499
requestWithDefaults(requestOptions, (error, response, body) => {
501-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
500+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
502501
let processedResult = handleRestError(error, entity, response, body);
503502
if (processedResult.error) return done(processedResult);
504503
done(null, processedResult.body);
@@ -528,7 +527,7 @@ function doDomainSSlLookup(entity, options) {
528527
};
529528

530529
requestWithDefaults(requestOptions, (error, response, body) => {
531-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
530+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
532531
let processedResult = handleRestError(error, entity, response, body);
533532
if (processedResult.error) return done(processedResult);
534533
done(null, processedResult.body);
@@ -558,7 +557,7 @@ function doDynamicDNSLookup(entity, options) {
558557
};
559558

560559
requestWithDefaults(requestOptions, (error, response, body) => {
561-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
560+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
562561
let processedResult = handleRestError(error, entity, response, body);
563562
if (processedResult.error) return done(processedResult);
564563
done(null, processedResult.body);
@@ -593,7 +592,7 @@ function doDeviceGeoLookup(entity, options) {
593592
Logger.trace({ options: requestOptions }, 'Request URI');
594593

595594
requestWithDefaults(requestOptions, (error, response, body) => {
596-
body = body && _.isArray(body) && body.splice(0, PAGE_SIZE);
595+
body = body && _.isArray(body) && body.splice(0, options.maxResults);
597596
let processedResult = handleRestError(error, entity, response, body);
598597
if (processedResult.error) return done(processedResult);
599598

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "hyas-insight",
3-
"version": "3.1.12",
3+
"version": "3.1.13",
44
"main": "./integration.js",
55
"private": true,
66
"dependencies": {
7-
"async": "^3.2.5",
7+
"async": "^3.2.6",
88
"google-libphonenumber": "^3.2.38",
9-
"postman-request": "^2.88.1-postman.39",
9+
"postman-request": "^2.88.1-postman.40",
1010
"lodash": "^4.17.21"
1111
}
1212
}

0 commit comments

Comments
 (0)